@@ -64,7 +64,7 extern void bsp_uart_init(); | |||
|
64 | 64 | extern void bsp_iic_init(); |
|
65 | 65 | extern void bsp_spi_init(); |
|
66 | 66 | extern void bsp_SD_init(); |
|
67 |
extern |
|
|
67 | extern int bsp_FSMC_init(); | |
|
68 | 68 | |
|
69 | 69 | /* VS1053 */ |
|
70 | 70 | extern void clearXCS(); |
@@ -77,6 +77,12 char bspsdcardpresent(); | |||
|
77 | 77 | void bspsdcardselect(char YESNO); |
|
78 | 78 | char bspsdcardwriteprotected(); |
|
79 | 79 | |
|
80 | ||
|
81 | void bsp_lcd0_write_reg(uint32_t reg,uint32_t data); | |
|
82 | uint32_t bsp_lcd0_read_reg(uint32_t reg); | |
|
83 | void bsp_lcd0_writeGRAM(void *buffer, uint32_t count); | |
|
84 | void bsp_lcd0_readGRAM(void *buffer, uint32_t count); | |
|
85 | ||
|
80 | 86 | #endif |
|
81 | 87 | |
|
82 | 88 |
@@ -33,8 +33,23 uint32_t INTOSC =16000000; | |||
|
33 | 33 | uint32_t RTCOSC =32768; |
|
34 | 34 | uint32_t currentCpuFreq=0; |
|
35 | 35 | extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__]; |
|
36 | LCD_t lcd0; | |
|
37 |
LCD_IF_t lcdIF0 |
|
|
36 | ||
|
37 | LCD_IF_t lcdIF0={ | |
|
38 | .init = &bsp_FSMC_init, | |
|
39 | .writereg = &bsp_lcd0_write_reg, | |
|
40 | .readreg = &bsp_lcd0_read_reg, | |
|
41 | .writeGRAM = &bsp_lcd0_writeGRAM, | |
|
42 | .readGRAM = &bsp_lcd0_readGRAM | |
|
43 | }; | |
|
44 | ||
|
45 | LCD_t lcd0={ | |
|
46 | .interface = &lcdIF0, | |
|
47 | .init = &ili9328init, | |
|
48 | .paint = &ili9328paint, | |
|
49 | .refreshenable = &ili9328refreshenable, | |
|
50 | .width= 240, | |
|
51 | .height = 320 | |
|
52 | }; | |
|
38 | 53 | |
|
39 | 54 | volatile int16_t* lcd0_CMD=(volatile int16_t*) 0x60000000; |
|
40 | 55 | volatile int16_t* lcd0_DATA=(volatile int16_t*)(0x61FFFFF0); |
@@ -103,12 +118,9 void bsp_uart_init() | |||
|
103 | 118 | } |
|
104 | 119 | } |
|
105 | 120 | |
|
106 | void bsp_lcd0_write_reg(uint32_t reg,uint32_t data); | |
|
107 | uint32_t bsp_lcd0_read_reg(uint32_t reg); | |
|
108 | void bsp_lcd0_writeGRAM(void *buffer, uint32_t count); | |
|
109 | void bsp_lcd0_readGRAM(void *buffer, uint32_t count); | |
|
121 | ||
|
110 | 122 | |
|
111 |
|
|
|
123 | int bsp_FSMC_init() | |
|
112 | 124 | { |
|
113 | 125 | #define GPIOGETPORT(gpio) ((GPIO_TypeDef*)(((((uint32_t)gpio) & (uint32_t)0x0000FF00)*(uint32_t)4) + (uint32_t)GPIOA)) |
|
114 | 126 | #define GPIOPORTNUM(gpio) (((uint32_t)(gpio) & (uint32_t)0x0000FF00)>>(uint32_t)8) |
@@ -138,10 +150,10 void bsp_FSMC_init() | |||
|
138 | 150 | /*----------------------- SRAM Bank 3 ----------------------------------------*/ |
|
139 | 151 | /* FSMC_Bank1_NORSRAM4 configuration */ |
|
140 | 152 | //p.FSMC_AddressSetupTime = 5; |
|
141 |
p.FSMC_AddressSetupTime = |
|
|
153 | p.FSMC_AddressSetupTime = 2; | |
|
142 | 154 | p.FSMC_AddressHoldTime = 0; |
|
143 | 155 | //p.FSMC_DataSetupTime = 9; |
|
144 |
p.FSMC_DataSetupTime = |
|
|
156 | p.FSMC_DataSetupTime = 4; | |
|
145 | 157 | p.FSMC_BusTurnAroundDuration = 0; |
|
146 | 158 | p.FSMC_CLKDivision = 0; |
|
147 | 159 | p.FSMC_DataLatency = 0; |
@@ -175,15 +187,9 void bsp_FSMC_init() | |||
|
175 | 187 | |
|
176 | 188 | /* Enable FSMC NOR/SRAM Bank1 */ |
|
177 | 189 | FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM1, ENABLE); |
|
178 | lcdIF0.writereg=&bsp_lcd0_write_reg; | |
|
179 | lcdIF0.readGRAM=&bsp_lcd0_readGRAM; | |
|
180 | lcdIF0.readreg=&bsp_lcd0_read_reg; | |
|
181 | lcdIF0.writeGRAM=&bsp_lcd0_writeGRAM; | |
|
182 | lcd0.interface=&lcdIF0; | |
|
183 | lcd0.init=&ili9328init; | |
|
184 | lcd0.paint=&ili9328paint; | |
|
185 | 190 | gpioset(LCD_RESET); |
|
186 | 191 | lcd0.init(&lcd0); |
|
192 | return 1; | |
|
187 | 193 | } |
|
188 | 194 | |
|
189 | 195 | void bsp_spi_init() |
@@ -233,6 +239,7 void bspsdcardselect(char YESNO) | |||
|
233 | 239 | |
|
234 | 240 | void bsp_lcd0_write_reg(uint32_t reg,uint32_t data) |
|
235 | 241 | { |
|
242 | printf("Write %X @ %d\n\r",data,reg); | |
|
236 | 243 | *lcd0_CMD=(uint16_t)reg; |
|
237 | 244 | *lcd0_DATA=(uint16_t)data; |
|
238 | 245 | } |
@@ -245,12 +252,14 uint32_t bsp_lcd0_read_reg(uint32_t reg) | |||
|
245 | 252 | |
|
246 | 253 | void bsp_lcd0_writeGRAM(void* buffer,uint32_t count) |
|
247 | 254 | { |
|
255 | printf("Write to GRAM %d pixels from 0x%X\t\n\r",count,(int)buffer); | |
|
248 | 256 | *lcd0_CMD=(uint16_t)ILI9328_REGISTER_WRITEDATATOGRAM; |
|
249 | 257 | uint16_t* castedBuff=(uint16_t*)buffer; |
|
250 |
for( |
|
|
258 | for(int i=0;i<(int)count;i++) | |
|
251 | 259 | { |
|
252 | 260 | *lcd0_DATA=castedBuff[i]; |
|
253 | 261 | } |
|
262 | printf("[Done]\n\r"); | |
|
254 | 263 | } |
|
255 | 264 | |
|
256 | 265 | void bsp_lcd0_readGRAM(void* buffer,uint32_t count) |
@@ -258,7 +267,7 void bsp_lcd0_readGRAM(void* buffer,uint | |||
|
258 | 267 | *lcd0_CMD=(uint16_t)ILI9328_REGISTER_WRITEDATATOGRAM; |
|
259 | 268 | uint16_t* castedBuff=(uint16_t*)buffer; |
|
260 | 269 | castedBuff[0]=*lcd0_DATA; |
|
261 |
for( |
|
|
270 | for(int i=0;i<(int)count;i++) | |
|
262 | 271 | { |
|
263 | 272 | castedBuff[i]=*lcd0_DATA; |
|
264 | 273 | } |
@@ -22,39 +22,34 int main() | |||
|
22 | 22 | //ina226open(&ina15VSens,i2c2,INA226_MODE_SHUNT_VOLTAGE_CONTINUOUS|INA226_AVERAGES_16|INA226_BUS_CONV_8244us|INA226_SHUNT_CONV_8244us,1,0,15,1000000); |
|
23 | 23 | *regtest=(int16_t)0; |
|
24 | 24 | printf("LCD ID=%x\n\r",0xFFFF&(*regtest2)); |
|
25 | ||
|
25 | //lcd0.refreshenable(&lcd0,1); | |
|
26 | 26 | while(1) |
|
27 | 27 | { |
|
28 | /* *regtest=(int16_t)ILI9328_REGISTER_ENTRYMODE; | |
|
29 | *regtest2=(int16_t)0x1008;*/ | |
|
30 | ili9328setFrame(&lcd0,0,0,240,320); | |
|
28 | //ili9328setFrame(&lcd0,0,0,240,320); | |
|
29 | //ili9328setGRAMaddress(&lcd0,0,0); | |
|
30 | *regtest=(int16_t)0x20; | |
|
31 | *regtest2=(int16_t)0x0; | |
|
32 | *regtest=(int16_t)0x21; | |
|
33 | *regtest2=(int16_t)0x0; | |
|
31 | 34 | *regtest=(int16_t)0x22; |
|
32 |
for( |
|
|
35 | for(int i=0;i<(320*240);i++) | |
|
33 | 36 | { |
|
34 | 37 | *regtest2=(int16_t)0x001F; |
|
35 | //for(volatile int l=0;l<(1024);l++); | |
|
36 | ||
|
37 | 38 | } |
|
38 | /* *regtest=(int16_t)ILI9328_REGISTER_ENTRYMODE; | |
|
39 | *regtest2=(int16_t)0x1018;*/ | |
|
40 | 39 | for(volatile int i=0;i<(320*240*100);i++); |
|
41 | /* *regtest=(int16_t)ILI9328_REGISTER_ENTRYMODE; | |
|
42 | *regtest2=(int16_t)0x1008;*/ | |
|
43 | //ili9328setGRAMaddress(&lcd0,60,80); | |
|
44 | uint16_t test[80*80]; | |
|
45 | ili9328setFrame(&lcd0,10,10,100,100); | |
|
46 |
*regtest=(int16_t) |
|
|
47 | for(volatile int i=0;i<(100*100);i++) | |
|
48 | { | |
|
49 | *regtest2=(int16_t)(0xF800); | |
|
50 | //test[i]=(int16_t)0xF800; | |
|
51 | //for(volatile int l=0;l<(1024);l++); | |
|
40 | //uint16_t test[100]; | |
|
41 | //ili9328setFrame(&lcd0,10,10,10,10); | |
|
42 | //*regtest=(int16_t)0x22; | |
|
43 | //for(int i=0;i<(10*10);i++) | |
|
44 | //{ | |
|
45 | // *regtest2=(int16_t)(0xF800); | |
|
46 | //test[i]=(int16_t)0xF800; | |
|
47 | //for(volatile int l=0;l<(1024);l++); | |
|
52 | 48 | |
|
53 | } | |
|
49 | //} | |
|
50 | //bsp_lcd0_writeGRAM(test,10*10); | |
|
54 | 51 | //lcd0.paint(&lcd0,test,100,100,80,80); |
|
55 | /**regtest=(int16_t)ILI9328_REGISTER_ENTRYMODE; | |
|
56 | *regtest2=(int16_t)0x1018;*/ | |
|
57 | for(volatile int i=0;i<(320*240*100);i++); | |
|
52 | //for(volatile int i=0;i<(320*240*100);i++); | |
|
58 | 53 | } |
|
59 | 54 | |
|
60 | 55 | if(-1==ina226open(&ina33VSens,i2c2,INA226_MODE_SHUNT_VOLTAGE_CONTINUOUS|INA226_AVERAGES_16|INA226_BUS_CONV_8244us|INA226_SHUNT_CONV_8244us,0,1,15,1000000)) |
@@ -40,6 +40,7 typedef struct LCD_t | |||
|
40 | 40 | LCD_IF_t* interface; |
|
41 | 41 | int (*init)(struct LCD_t* LCD); |
|
42 | 42 | void (*paint)(struct LCD_t* LCD,void* buffer,uint16_t Xpos,uint16_t Ypos,uint16_t Width,uint16_t Height); |
|
43 | void (*refreshenable)(struct LCD_t* LCD,int enable); | |
|
43 | 44 | uint16_t width; |
|
44 | 45 | uint16_t height; |
|
45 | 46 | }LCD_t; |
@@ -27,9 +27,10 | |||
|
27 | 27 | #include <stdint.h> |
|
28 | 28 | |
|
29 | 29 | extern int ili9328init(struct LCD_t* LCD); |
|
30 |
extern void ili9328setFrame(LCD_t* LCD,uint16_t |
|
|
30 | extern void ili9328setFrame(LCD_t* LCD,uint16_t X,uint16_t Y,uint16_t W,uint16_t H); | |
|
31 | 31 | extern void ili9328setGRAMaddress(LCD_t* LCD,uint16_t Haddress,uint16_t Vaddress); |
|
32 | 32 | extern void ili9328paint(LCD_t* LCD,void* buffer,uint16_t Xpos,uint16_t Ypos,uint16_t Width,uint16_t Height); |
|
33 | extern void ili9328refreshenable(struct LCD_t* LCD,int enable); | |
|
33 | 34 | |
|
34 | 35 | #define ILI9328_REGISTER_DRIVERCODEREAD ((uint32_t) 0x0000 ) |
|
35 | 36 | #define ILI9328_REGISTER_DRIVEROUTPUTCONTROL1 ((uint32_t) 0x0001 ) |
@@ -31,12 +31,29 void ili9328setGRAMaddress(LCD_t* LCD,ui | |||
|
31 | 31 | LCD->interface->writereg(ILI9328_REGISTER_VERTICALGRAMADDRESSSET,Vaddress); |
|
32 | 32 | } |
|
33 | 33 | |
|
34 | void ili9328setFrame(LCD_t* LCD,uint16_t HaddressStart,uint16_t VaddressStart,uint16_t HaddressStop,uint16_t VaddressStop) | |
|
34 | void ili9328refreshenable(struct LCD_t* LCD,int enable) | |
|
35 | 35 | { |
|
36 | LCD->interface->writereg(ILI9328_REGISTER_HORIZONTALADDRESSSTARTPOSITION,HaddressStart); | |
|
37 | LCD->interface->writereg(ILI9328_REGISTER_VERTICALADDRESSSTARTPOSITION,VaddressStart); | |
|
38 |
LCD->interface->writereg(ILI9328_REGISTER_ |
|
|
39 | LCD->interface->writereg(ILI9328_REGISTER_VERTICALADDRESSENDPOSITION,VaddressStop); | |
|
36 | if(enable) | |
|
37 | { | |
|
38 | //LCD->interface->writereg(ILI9328_REGISTER_ENTRYMODE,0x1018); | |
|
39 | } | |
|
40 | else | |
|
41 | { | |
|
42 | //LCD->interface->writereg(ILI9328_REGISTER_ENTRYMODE,0x1008); | |
|
43 | ||
|
44 | } | |
|
45 | } | |
|
46 | ||
|
47 | void ili9328setFrame(LCD_t* LCD,uint16_t X,uint16_t Y,uint16_t W,uint16_t H) | |
|
48 | { | |
|
49 | printf("setFrame X=%d Y=%d W=%d H=%d\n\r",(int)X,(int)Y,(int)W,(int)H); | |
|
50 | LCD->interface->writereg(ILI9328_REGISTER_HORIZONTALGRAMADDRESSSET,X); | |
|
51 | LCD->interface->writereg(ILI9328_REGISTER_VERTICALGRAMADDRESSSET,Y); | |
|
52 | LCD->interface->writereg(ILI9328_REGISTER_HORIZONTALADDRESSSTARTPOSITION,X); | |
|
53 | LCD->interface->writereg(ILI9328_REGISTER_HORIZONTALADDRESSSTARTPOSITION,X); | |
|
54 | LCD->interface->writereg(ILI9328_REGISTER_HORIZONTALADDRESSENDPOSITION,W+X); | |
|
55 | LCD->interface->writereg(ILI9328_REGISTER_VERTICALADDRESSSTARTPOSITION,Y); | |
|
56 | LCD->interface->writereg(ILI9328_REGISTER_VERTICALADDRESSENDPOSITION,Y+H); | |
|
40 | 57 | } |
|
41 | 58 | |
|
42 | 59 | void ili9328paint(LCD_t* LCD,void* buffer,uint16_t Xpos,uint16_t Ypos,uint16_t Width,uint16_t Height) |
@@ -44,8 +61,8 void ili9328paint(LCD_t* LCD,void* buffe | |||
|
44 | 61 | if((LCD!=NULL) && (LCD->interface!=NULL) && (LCD->interface->writeGRAM!=NULL) && (LCD->width<(Xpos+Width)) && (LCD->height<(Ypos+Height))) |
|
45 | 62 | { |
|
46 | 63 | printf("paint\n\r"); |
|
47 |
ili9328setFrame(LCD,Xpos,Ypos, |
|
|
48 | ili9328setGRAMaddress(LCD,Xpos,Ypos); | |
|
64 | ili9328setFrame(LCD,Xpos,Ypos,Width,Height); | |
|
65 | //ili9328setGRAMaddress(LCD,Xpos,Ypos); | |
|
49 | 66 | LCD->interface->writeGRAM(buffer,Width*Height); |
|
50 | 67 | } |
|
51 | 68 | } |
@@ -93,7 +110,7 int ili9328init(struct LCD_t* LCD) | |||
|
93 | 110 | // Display On |
|
94 | 111 | LCD->interface->writereg(ILI9328_REGISTER_DISPLAYCONTROL1, 0x0133); // Display Control (R07h) |
|
95 | 112 | _delay_(500000); |
|
96 |
LCD->interface->writereg(ILI9328_REGISTER_ENTRYMODE, 0x10 |
|
|
113 | LCD->interface->writereg(ILI9328_REGISTER_ENTRYMODE, 0x1018); | |
|
97 | 114 | LCD->interface->writereg(ILI9328_REGISTER_DRIVEROUTPUTCONTROL1, 0x0100); |
|
98 | 115 | //ili9328WriteCmd(ILI9328_REGISTER_WRITEDATATOGRAM); |
|
99 | 116 | } |
General Comments 0
You need to be logged in to leave comments.
Login now