SyterKit 0.4.0.x
SyterKit is a bare-metal framework
Loading...
Searching...
No Matches
spi_lcd.c
Go to the documentation of this file.
1/* SPDX-License-Identifier: GPL-2.0+ */
2
3#include <stdbool.h>
4#include <stddef.h>
5#include <stdint.h>
6#include <types.h>
7
8#include <config.h>
9#include <log.h>
10#include <timer.h>
11
12#include <common.h>
13#include <jmp.h>
14#include <mmu.h>
15#include <smalloc.h>
16#include <sstdlib.h>
17#include <string.h>
18
19#include <cli.h>
20#include <cli_shell.h>
21#include <cli_termesc.h>
22
23#include <reg-ncat.h>
24#include <sys-clk.h>
25#include <sys-dram.h>
26#include <sys-i2c.h>
27#include <sys-rtc.h>
28#include <sys-sdcard.h>
29#include <sys-sid.h>
30#include <sys-spi.h>
31
32#include <pmu/axp.h>
33
34#include <fdt_wrapper.h>
35#include <ff.h>
36#include <sys-sdhci.h>
37#include <uart.h>
38
39#define SPI_LCD_COLOR_WHITE 0xFFFF
40#define SPI_LCD_COLOR_BLACK 0x0000
41#define SPI_LCD_COLOR_BLUE 0x001F
42#define SPI_LCD_COLOR_BRED 0XF81F
43#define SPI_LCD_COLOR_GRED 0XFFE0
44#define SPI_LCD_COLOR_GBLUE 0X07FF
45#define SPI_LCD_COLOR_RED 0xF800
46#define SPI_LCD_COLOR_MAGENTA 0xF81F
47#define SPI_LCD_COLOR_GREEN 0x07E0
48#define SPI_LCD_COLOR_CYAN 0x7FFF
49#define SPI_LCD_COLOR_YELLOW 0xFFE0
50
52
55 .id = 0,
56 .clk_rate = 75 * 1000 * 1000,
57 .gpio =
58 {
59 .gpio_cs = {GPIO_PIN(GPIO_PORTL, 10), GPIO_PERIPH_MUX6},
60 .gpio_sck = {GPIO_PIN(GPIO_PORTL, 11), GPIO_PERIPH_MUX6},
61 .gpio_mosi = {GPIO_PIN(GPIO_PORTL, 12), GPIO_PERIPH_MUX6},
62 },
63 .spi_clk =
64 {
65 .spi_clock_cfg_base = SUNXI_R_PRCM_BASE + SUNXI_S_SPI_CLK_REG,
66 .spi_clock_factor_n_offset = SPI_CLK_SEL_FACTOR_N_OFF,
67 .spi_clock_source = SPI_CLK_SEL_PERIPH_300M,
68 },
69 .parent_clk_reg =
70 {
71 .rst_reg_base = SUNXI_R_PRCM_BASE + SUNXI_S_SPI_BGR_REG,
72 .rst_reg_offset = SPI_DEFAULT_CLK_RST_OFFSET(0),
73 .gate_reg_base = SUNXI_R_PRCM_BASE + SUNXI_S_SPI_BGR_REG,
74 .gate_reg_offset = SPI_DEFAULT_CLK_GATE_OFFSET(0),
75 .parent_clk = 300000000,
76 },
77 .dma_handle = &sunxi_dma,
78};
79
81 .pin = GPIO_PIN(GPIO_PORTL, 13),
82 .mux = GPIO_OUTPUT,
83};
84
86 .pin = GPIO_PIN(GPIO_PORTL, 9),
87 .mux = GPIO_OUTPUT,
88};
89
91 .pin = GPIO_PIN(GPIO_PORTL, 8),
92 .mux = GPIO_OUTPUT,
93};
94
98
102
103static void LCD_Write_Bus(uint8_t dat) {
104 uint8_t tx[1]; /* Transmit buffer */
105 tx[0] = dat;
106 /* Perform SPI transfer */
107 if (sunxi_spi_transfer(&sunxi_spi0_lcd, SPI_IO_SINGLE, tx, 1, 0, 0) < 0)
108 printk_error("SPI: SPI Xfer error!\n");
109}
110
111static void LCD_Write_Data_Bus(void *dat, uint32_t len) {
112 if (sunxi_spi_transfer(&sunxi_spi0_lcd, SPI_IO_SINGLE, dat, len, 0, 0) < 0)
113 printk_error("SPI: SPI Xfer error!\n");
114}
115
116static void LCD_WR_DATA(uint16_t dat) {
117 LCD_Write_Bus(dat >> 8);
118 LCD_Write_Bus(dat);
119}
120
121static void LCD_WR_DATA8(uint8_t dat) {
122 LCD_Write_Bus(dat);
123}
124
125static void LCD_WR_REG(uint8_t dat) {
126 LCD_Set_DC(0);
127 LCD_Write_Bus(dat);
128 LCD_Set_DC(1);
129}
130
131static void LCD_Address_Set(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) {
132 LCD_WR_REG(0x2a);
133 LCD_WR_DATA(x1 + 40);
134 LCD_WR_DATA(x2 + 40);
135 LCD_WR_REG(0x2b);
136 LCD_WR_DATA(y1 + 52);
137 LCD_WR_DATA(y2 + 52);
138 LCD_WR_REG(0x2c);
139}
140
141static void LCD_Open_BLK() {
143}
144
145#define LCD_W 240
146#define LCD_H 135
147
148static void LCD_Fill_All(uint16_t color) {
149 uint16_t i, j;
150 LCD_Address_Set(0, 0, LCD_W - 1, LCD_H - 1);
151 uint16_t *video_mem = smalloc(LCD_W * LCD_H);
152
153 for (uint32_t i = 0; i < LCD_W * LCD_H; i++) { video_mem[i] = color; }
154
155 LCD_Write_Data_Bus(video_mem, LCD_W * LCD_H * (sizeof(uint16_t) / sizeof(uint8_t)));
156
157 sfree(video_mem);
158}
159
160static void LCD_Init(void) {
164
165 if (sunxi_spi_init(&sunxi_spi0_lcd) != 0) {
166 printk_error("SPI: init failed\n");
167 }
168
169 LCD_Set_RES(0);
170 mdelay(100);
171 LCD_Set_RES(1);
172 mdelay(100);
173
174 LCD_WR_REG(0x11);
175 mdelay(120);
176 LCD_WR_REG(0x36);
177 LCD_WR_DATA8(0xA0);
178
179 LCD_WR_REG(0x3A);
180 LCD_WR_DATA8(0x05);
181
182 LCD_WR_REG(0xB2);
183 LCD_WR_DATA8(0x0C);
184 LCD_WR_DATA8(0x0C);
185 LCD_WR_DATA8(0x00);
186 LCD_WR_DATA8(0x33);
187 LCD_WR_DATA8(0x33);
188
189 LCD_WR_REG(0xB7);
190 LCD_WR_DATA8(0x35);
191
192 LCD_WR_REG(0xBB);
193 LCD_WR_DATA8(0x19);
194
195 LCD_WR_REG(0xC0);
196 LCD_WR_DATA8(0x2C);
197
198 LCD_WR_REG(0xC2);
199 LCD_WR_DATA8(0x01);
200
201 LCD_WR_REG(0xC3);
202 LCD_WR_DATA8(0x12);
203
204 LCD_WR_REG(0xC4);
205 LCD_WR_DATA8(0x20);
206
207 LCD_WR_REG(0xC6);
208 LCD_WR_DATA8(0x0F);
209
210 LCD_WR_REG(0xD0);
211 LCD_WR_DATA8(0xA4);
212 LCD_WR_DATA8(0xA1);
213
214 LCD_WR_REG(0xE0);
215 LCD_WR_DATA8(0xD0);
216 LCD_WR_DATA8(0x04);
217 LCD_WR_DATA8(0x0D);
218 LCD_WR_DATA8(0x11);
219 LCD_WR_DATA8(0x13);
220 LCD_WR_DATA8(0x2B);
221 LCD_WR_DATA8(0x3F);
222 LCD_WR_DATA8(0x54);
223 LCD_WR_DATA8(0x4C);
224 LCD_WR_DATA8(0x18);
225 LCD_WR_DATA8(0x0D);
226 LCD_WR_DATA8(0x0B);
227 LCD_WR_DATA8(0x1F);
228 LCD_WR_DATA8(0x23);
229
230 LCD_WR_REG(0xE1);
231 LCD_WR_DATA8(0xD0);
232 LCD_WR_DATA8(0x04);
233 LCD_WR_DATA8(0x0C);
234 LCD_WR_DATA8(0x11);
235 LCD_WR_DATA8(0x13);
236 LCD_WR_DATA8(0x2C);
237 LCD_WR_DATA8(0x3F);
238 LCD_WR_DATA8(0x44);
239 LCD_WR_DATA8(0x51);
240 LCD_WR_DATA8(0x2F);
241 LCD_WR_DATA8(0x1F);
242 LCD_WR_DATA8(0x1F);
243 LCD_WR_DATA8(0x20);
244 LCD_WR_DATA8(0x23);
245
246 LCD_WR_REG(0x21);
247
248 LCD_WR_REG(0x29);
249
250 LCD_Fill_All(0x0000);
251}
252
253#define SPLASH_START_X 52
254#define SPLASH_START_Y 43
255#define SPLASH_W 135
256#define SPLASH_H 48
257
258static void LCD_Show_Splash(uint8_t *splash_dest) {
259 uint16_t i, j, k = 0;
261
262 uint16_t *video_mem = smalloc(SPLASH_W * SPLASH_H);
263
264 for (i = 0; i < SPLASH_W; i++) {
265 for (j = 0; j < SPLASH_H; j++) {
266 video_mem[k] = (splash_dest[k * 2] << 8) | splash_dest[k * 2 + 1];
267 k++;
268 }
269 }
270
271 LCD_Write_Data_Bus(video_mem, SPLASH_W * SPLASH_H * (sizeof(uint16_t) / sizeof(uint8_t)));
272
273 sfree(video_mem);
274}
275
276static const unsigned char ascii_1206[][12] = {
277 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*" ",0*/
278 {0x00, 0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00}, /*"!",1*/
279 {0x14, 0x14, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*""",2*/
280 {0x00, 0x00, 0x0A, 0x0A, 0x1F, 0x0A, 0x0A, 0x1F, 0x0A, 0x0A, 0x00, 0x00}, /*"#",3*/
281 {0x00, 0x04, 0x0E, 0x15, 0x05, 0x06, 0x0C, 0x14, 0x15, 0x0E, 0x04, 0x00}, /*"$",4*/
282 {0x00, 0x00, 0x12, 0x15, 0x0D, 0x15, 0x2E, 0x2C, 0x2A, 0x12, 0x00, 0x00}, /*"%",5*/
283 {0x00, 0x00, 0x04, 0x0A, 0x0A, 0x36, 0x15, 0x15, 0x29, 0x16, 0x00, 0x00}, /*"&",6*/
284 {0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"'",7*/
285 {0x10, 0x08, 0x08, 0x04, 0x04, 0x04, 0x04, 0x04, 0x08, 0x08, 0x10, 0x00}, /*"(",8*/
286 {0x02, 0x04, 0x04, 0x08, 0x08, 0x08, 0x08, 0x08, 0x04, 0x04, 0x02, 0x00}, /*")",9*/
287 {0x00, 0x00, 0x00, 0x04, 0x15, 0x0E, 0x0E, 0x15, 0x04, 0x00, 0x00, 0x00}, /*"*",10*/
288 {0x00, 0x00, 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00}, /*"+",11*/
289 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x01, 0x00}, /*",",12*/
290 {0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"-",13*/
291 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00}, /*".",14*/
292 {0x00, 0x20, 0x10, 0x10, 0x08, 0x08, 0x04, 0x04, 0x02, 0x02, 0x01, 0x00}, /*"/",15*/
293 {0x00, 0x00, 0x0E, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x0E, 0x00, 0x00}, /*"0",16*/
294 {0x00, 0x00, 0x04, 0x06, 0x04, 0x04, 0x04, 0x04, 0x04, 0x0E, 0x00, 0x00}, /*"1",17*/
295 {0x00, 0x00, 0x0E, 0x11, 0x11, 0x08, 0x04, 0x02, 0x01, 0x1F, 0x00, 0x00}, /*"2",18*/
296 {0x00, 0x00, 0x0E, 0x11, 0x10, 0x0C, 0x10, 0x10, 0x11, 0x0E, 0x00, 0x00}, /*"3",19*/
297 {0x00, 0x00, 0x08, 0x0C, 0x0C, 0x0A, 0x09, 0x1F, 0x08, 0x1C, 0x00, 0x00}, /*"4",20*/
298 {0x00, 0x00, 0x1F, 0x01, 0x01, 0x0F, 0x11, 0x10, 0x11, 0x0E, 0x00, 0x00}, /*"5",21*/
299 {0x00, 0x00, 0x0C, 0x12, 0x01, 0x0D, 0x13, 0x11, 0x11, 0x0E, 0x00, 0x00}, /*"6",22*/
300 {0x00, 0x00, 0x1E, 0x10, 0x08, 0x08, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00}, /*"7",23*/
301 {0x00, 0x00, 0x0E, 0x11, 0x11, 0x0E, 0x11, 0x11, 0x11, 0x0E, 0x00, 0x00}, /*"8",24*/
302 {0x00, 0x00, 0x0E, 0x11, 0x11, 0x19, 0x16, 0x10, 0x09, 0x06, 0x00, 0x00}, /*"9",25*/
303 {0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00}, /*":",26*/
304 {0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x04, 0x00}, /*";",27*/
305 {0x00, 0x00, 0x10, 0x08, 0x04, 0x02, 0x02, 0x04, 0x08, 0x10, 0x00, 0x00}, /*"<",28*/
306 {0x00, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"=",29*/
307 {0x00, 0x00, 0x02, 0x04, 0x08, 0x10, 0x10, 0x08, 0x04, 0x02, 0x00, 0x00}, /*">",30*/
308 {0x00, 0x00, 0x0E, 0x11, 0x11, 0x08, 0x04, 0x04, 0x00, 0x04, 0x00, 0x00}, /*"?",31*/
309 {0x00, 0x00, 0x1C, 0x22, 0x29, 0x2D, 0x2D, 0x1D, 0x22, 0x1C, 0x00, 0x00}, /*"@",32*/
310 {0x00, 0x00, 0x04, 0x04, 0x0C, 0x0A, 0x0A, 0x1E, 0x12, 0x33, 0x00, 0x00}, /*"A",33*/
311 {0x00, 0x00, 0x0F, 0x12, 0x12, 0x0E, 0x12, 0x12, 0x12, 0x0F, 0x00, 0x00}, /*"B",34*/
312 {0x00, 0x00, 0x1E, 0x11, 0x01, 0x01, 0x01, 0x01, 0x11, 0x0E, 0x00, 0x00}, /*"C",35*/
313 {0x00, 0x00, 0x0F, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x0F, 0x00, 0x00}, /*"D",36*/
314 {0x00, 0x00, 0x1F, 0x12, 0x0A, 0x0E, 0x0A, 0x02, 0x12, 0x1F, 0x00, 0x00}, /*"E",37*/
315 {0x00, 0x00, 0x1F, 0x12, 0x0A, 0x0E, 0x0A, 0x02, 0x02, 0x07, 0x00, 0x00}, /*"F",38*/
316 {0x00, 0x00, 0x1C, 0x12, 0x01, 0x01, 0x39, 0x11, 0x12, 0x0C, 0x00, 0x00}, /*"G",39*/
317 {0x00, 0x00, 0x33, 0x12, 0x12, 0x1E, 0x12, 0x12, 0x12, 0x33, 0x00, 0x00}, /*"H",40*/
318 {0x00, 0x00, 0x1F, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x1F, 0x00, 0x00}, /*"I",41*/
319 {0x00, 0x00, 0x3E, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x09, 0x07}, /*"J",42*/
320 {0x00, 0x00, 0x37, 0x12, 0x0A, 0x06, 0x0A, 0x12, 0x12, 0x37, 0x00, 0x00}, /*"K",43*/
321 {0x00, 0x00, 0x07, 0x02, 0x02, 0x02, 0x02, 0x02, 0x22, 0x3F, 0x00, 0x00}, /*"L",44*/
322 {0x00, 0x00, 0x3B, 0x1B, 0x1B, 0x1B, 0x15, 0x15, 0x15, 0x35, 0x00, 0x00}, /*"M",45*/
323 {0x00, 0x00, 0x3B, 0x12, 0x16, 0x16, 0x1A, 0x1A, 0x12, 0x17, 0x00, 0x00}, /*"N",46*/
324 {0x00, 0x00, 0x0E, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x0E, 0x00, 0x00}, /*"O",47*/
325 {0x00, 0x00, 0x0F, 0x12, 0x12, 0x0E, 0x02, 0x02, 0x02, 0x07, 0x00, 0x00}, /*"P",48*/
326 {0x00, 0x00, 0x0E, 0x11, 0x11, 0x11, 0x11, 0x17, 0x19, 0x0E, 0x18, 0x00}, /*"Q",49*/
327 {0x00, 0x00, 0x0F, 0x12, 0x12, 0x0E, 0x0A, 0x12, 0x12, 0x37, 0x00, 0x00}, /*"R",50*/
328 {0x00, 0x00, 0x1E, 0x11, 0x01, 0x06, 0x08, 0x10, 0x11, 0x0F, 0x00, 0x00}, /*"S",51*/
329 {0x00, 0x00, 0x1F, 0x15, 0x04, 0x04, 0x04, 0x04, 0x04, 0x0E, 0x00, 0x00}, /*"T",52*/
330 {0x00, 0x00, 0x33, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x0C, 0x00, 0x00}, /*"U",53*/
331 {0x00, 0x00, 0x33, 0x12, 0x12, 0x0A, 0x0A, 0x0C, 0x04, 0x04, 0x00, 0x00}, /*"V",54*/
332 {0x00, 0x00, 0x15, 0x15, 0x15, 0x15, 0x0E, 0x0A, 0x0A, 0x0A, 0x00, 0x00}, /*"W",55*/
333 {0x00, 0x00, 0x1B, 0x0A, 0x0A, 0x04, 0x04, 0x0A, 0x0A, 0x1B, 0x00, 0x00}, /*"X",56*/
334 {0x00, 0x00, 0x1B, 0x0A, 0x0A, 0x0A, 0x04, 0x04, 0x04, 0x0E, 0x00, 0x00}, /*"Y",57*/
335 {0x00, 0x00, 0x1F, 0x09, 0x08, 0x04, 0x04, 0x02, 0x12, 0x1F, 0x00, 0x00}, /*"Z",58*/
336 {0x1C, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x1C, 0x00}, /*"[",59*/
337 {0x00, 0x02, 0x02, 0x04, 0x04, 0x04, 0x08, 0x08, 0x08, 0x10, 0x10, 0x00}, /*"\",60*/
338 {0x0E, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x0E, 0x00}, /*"]",61*/
339 {0x04, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"^",62*/
340 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F}, /*"_",63*/
341 {0x02, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"`",64*/
342 {0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x12, 0x1C, 0x12, 0x3C, 0x00, 0x00}, /*"a",65*/
343 {0x00, 0x03, 0x02, 0x02, 0x02, 0x0E, 0x12, 0x12, 0x12, 0x0E, 0x00, 0x00}, /*"b",66*/
344 {0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x12, 0x02, 0x12, 0x0C, 0x00, 0x00}, /*"c",67*/
345 {0x00, 0x18, 0x10, 0x10, 0x10, 0x1C, 0x12, 0x12, 0x12, 0x3C, 0x00, 0x00}, /*"d",68*/
346 {0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x12, 0x1E, 0x02, 0x1C, 0x00, 0x00}, /*"e",69*/
347 {0x00, 0x18, 0x24, 0x04, 0x04, 0x1E, 0x04, 0x04, 0x04, 0x1E, 0x00, 0x00}, /*"f",70*/
348 {0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x12, 0x0C, 0x02, 0x1C, 0x22, 0x1C}, /*"g",71*/
349 {0x00, 0x03, 0x02, 0x02, 0x02, 0x0E, 0x12, 0x12, 0x12, 0x37, 0x00, 0x00}, /*"h",72*/
350 {0x00, 0x04, 0x04, 0x00, 0x00, 0x06, 0x04, 0x04, 0x04, 0x0E, 0x00, 0x00}, /*"i",73*/
351 {0x00, 0x08, 0x08, 0x00, 0x00, 0x0C, 0x08, 0x08, 0x08, 0x08, 0x08, 0x07}, /*"j",74*/
352 {0x00, 0x03, 0x02, 0x02, 0x02, 0x1A, 0x0A, 0x06, 0x0A, 0x13, 0x00, 0x00}, /*"k",75*/
353 {0x00, 0x07, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x1F, 0x00, 0x00}, /*"l",76*/
354 {0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x15, 0x15, 0x15, 0x15, 0x00, 0x00}, /*"m",77*/
355 {0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x12, 0x12, 0x12, 0x37, 0x00, 0x00}, /*"n",78*/
356 {0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x12, 0x12, 0x12, 0x0C, 0x00, 0x00}, /*"o",79*/
357 {0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x12, 0x12, 0x12, 0x0E, 0x02, 0x07}, /*"p",80*/
358 {0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x12, 0x12, 0x12, 0x1C, 0x10, 0x38}, /*"q",81*/
359 {0x00, 0x00, 0x00, 0x00, 0x00, 0x1B, 0x06, 0x02, 0x02, 0x07, 0x00, 0x00}, /*"r",82*/
360 {0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x02, 0x0C, 0x10, 0x1E, 0x00, 0x00}, /*"s",83*/
361 {0x00, 0x00, 0x00, 0x04, 0x04, 0x1E, 0x04, 0x04, 0x04, 0x1C, 0x00, 0x00}, /*"t",84*/
362 {0x00, 0x00, 0x00, 0x00, 0x00, 0x1B, 0x12, 0x12, 0x12, 0x3C, 0x00, 0x00}, /*"u",85*/
363 {0x00, 0x00, 0x00, 0x00, 0x00, 0x1B, 0x0A, 0x0A, 0x04, 0x04, 0x00, 0x00}, /*"v",86*/
364 {0x00, 0x00, 0x00, 0x00, 0x00, 0x15, 0x15, 0x0E, 0x0A, 0x0A, 0x00, 0x00}, /*"w",87*/
365 {0x00, 0x00, 0x00, 0x00, 0x00, 0x1B, 0x0A, 0x04, 0x0A, 0x1B, 0x00, 0x00}, /*"x",88*/
366 {0x00, 0x00, 0x00, 0x00, 0x00, 0x33, 0x12, 0x12, 0x0C, 0x08, 0x04, 0x03}, /*"y",89*/
367 {0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x08, 0x04, 0x04, 0x1E, 0x00, 0x00}, /*"z",90*/
368 {0x18, 0x08, 0x08, 0x08, 0x08, 0x0C, 0x08, 0x08, 0x08, 0x08, 0x18, 0x00}, /*"{",91*/
369 {0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08}, /*"|",92*/
370 {0x06, 0x04, 0x04, 0x04, 0x04, 0x08, 0x04, 0x04, 0x04, 0x04, 0x06, 0x00}, /*"}",93*/
371 {0x16, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*"~",94*/
372};
373
374static void LCD_ShowChar(uint16_t x, uint16_t y, uint8_t num, uint16_t fc, uint16_t bc, uint8_t sizey) {
375 uint8_t temp, sizex, t, m = 0;
376 uint16_t i, TypefaceNum;// Number of bytes for one character
377 uint16_t x0 = x;
378 sizex = sizey / 2;
379 TypefaceNum = (sizex / 8 + ((sizex % 8) ? 1 : 0)) * sizey;
380 num = num - ' '; // Get the offset value
381 LCD_Address_Set(x, y, x + sizex - 1, y + sizey - 1);// Set the cursor position
382 for (i = 0; i < TypefaceNum; i++) {
383 temp = ascii_1206[num][i];// Call 6x12 font
384 for (t = 0; t < 8; t++) {
385 if (temp & (0x01 << t))
386 LCD_WR_DATA(fc);
387 else
388 LCD_WR_DATA(bc);
389 m++;
390 if (m % sizex == 0) {
391 m = 0;
392 break;
393 }
394 }
395 }
396}
397
398
399static void LCD_ShowString(uint16_t x, uint16_t y, const uint8_t *p, uint16_t fc, uint16_t bc, uint8_t sizey) {
400 printk_debug("LCD: Show String: \"%s\"\n", p);
401 while (*p != '\0') {
402 LCD_ShowChar(x, y, *p, fc, bc, sizey);
403 x += sizey / 2;
404 p++;
405 }
406}
void mdelay(uint32_t ms)
Delay execution for a specified number of milliseconds.
Definition timer.c:54
ul val
Definition memtester.c:33
u32_t uint32_t
Definition stdint.h:13
u8_t uint8_t
Definition stdint.h:7
u16_t uint16_t
Definition stdint.h:10
#define SUNXI_R_PRCM_BASE
Definition reg-ncat.h:63
#define SUNXI_S_SPI_CLK_REG
Definition reg-ncat.h:247
#define SUNXI_R_SPI_BASE
Definition reg-ncat.h:123
#define SUNXI_S_SPI_BGR_REG
Definition reg-ncat.h:248
#define printk_debug(fmt,...)
Definition log.h:50
#define printk_error(fmt,...)
Definition log.h:66
void sfree(void *p)
Free the memory block pointed to by the specified pointer.
Definition smalloc.c:105
void * smalloc(uint32_t num_bytes)
Allocate a block of memory from the heap with the specified size.
Definition smalloc.c:22
#define LCD_H
Definition spi_lcd.c:146
static gpio_mux_t lcd_blk_pins
Definition spi_lcd.c:90
static void LCD_Write_Bus(uint8_t dat)
Definition spi_lcd.c:103
static sunxi_spi_t sunxi_spi0_lcd
Definition spi_lcd.c:53
#define SPLASH_START_Y
Definition spi_lcd.c:254
static void LCD_Set_DC(uint8_t val)
Definition spi_lcd.c:95
static void LCD_Address_Set(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2)
Definition spi_lcd.c:131
static const unsigned char ascii_1206[][12]
Definition spi_lcd.c:276
#define SPLASH_W
Definition spi_lcd.c:255
static void LCD_Set_RES(uint8_t val)
Definition spi_lcd.c:99
static void LCD_Show_Splash(uint8_t *splash_dest)
Definition spi_lcd.c:258
static gpio_mux_t lcd_dc_pins
Definition spi_lcd.c:80
static void LCD_WR_REG(uint8_t dat)
Definition spi_lcd.c:125
#define LCD_W
Definition spi_lcd.c:145
static void LCD_WR_DATA8(uint8_t dat)
Definition spi_lcd.c:121
static void LCD_WR_DATA(uint16_t dat)
Definition spi_lcd.c:116
#define SPLASH_START_X
Definition spi_lcd.c:253
static void LCD_Fill_All(uint16_t color)
Definition spi_lcd.c:148
static void LCD_ShowString(uint16_t x, uint16_t y, const uint8_t *p, uint16_t fc, uint16_t bc, uint8_t sizey)
Definition spi_lcd.c:399
sunxi_dma_t sunxi_dma
Definition board.c:45
static void LCD_Write_Data_Bus(void *dat, uint32_t len)
Definition spi_lcd.c:111
#define SPLASH_H
Definition spi_lcd.c:256
static void LCD_ShowChar(uint16_t x, uint16_t y, uint8_t num, uint16_t fc, uint16_t bc, uint8_t sizey)
Definition spi_lcd.c:374
static void LCD_Init(void)
Definition spi_lcd.c:160
static gpio_mux_t lcd_res_pins
Definition spi_lcd.c:85
static void LCD_Open_BLK()
Definition spi_lcd.c:141
Definition sys-gpio.h:68
uint8_t mux
Definition sys-gpio.h:70
gpio_t pin
Definition sys-gpio.h:69
Definition sys-dma.h:100
SPI Device Configuration Structure.
Definition sys-spi.h:92
uint32_t base
Base address of the SPI peripheral.
Definition sys-spi.h:93
void sunxi_gpio_set_value(gpio_t pin, int value)
Set the value of the specified GPIO pin.
Definition sys-gpio-v1.c:107
@ GPIO_PORTL
Definition sys-gpio.h:50
@ GPIO_OUTPUT
Definition sys-gpio.h:21
@ GPIO_PERIPH_MUX6
Definition sys-gpio.h:26
void sunxi_gpio_init(gpio_t pin, int cfg)
Initialize the specified GPIO pin with the given configuration.
Definition sys-gpio-v1.c:84
#define GPIO_PIN(x, y)
Definition sys-gpio.h:66
#define SPI_CLK_SEL_PERIPH_300M
Selects the SPI peripheral clock to 300 MHz.
Definition sys-spi.h:103
#define SPI_CLK_SEL_FACTOR_N_OFF
Offset for the SPI clock select factor is 8.
Definition sys-spi.h:105
int sunxi_spi_transfer(sunxi_spi_t *spi, spi_io_mode_t mode, void *txbuf, uint32_t txlen, void *rxbuf, uint32_t rxlen)
Performs SPI data transfer.
Definition sys-spi.c:958
#define SPI_DEFAULT_CLK_GATE_OFFSET(x)
Returns the default clock gate offset, based on the SPI module number (x).
Definition sys-spi.h:107
#define SPI_DEFAULT_CLK_RST_OFFSET(x)
Returns the default clock reset offset, based on the SPI module number (x).
Definition sys-spi.h:106
int sunxi_spi_init(sunxi_spi_t *spi)
Initializes the SPI interface.
Definition sys-spi.c:893
@ SPI_IO_SINGLE
Single I/O mode, using one data line.
Definition sys-spi.h:31