@@ -1,99 +1,105 | |||
|
1 | 1 | /*------------------------------------------------------------------------------ |
|
2 | 2 | -- This file is a part of the libuc, microcontroler library |
|
3 | 3 | -- Copyright (C) 2011, Alexis Jeandet |
|
4 | 4 | -- |
|
5 | 5 | -- This program is free software; you can redistribute it and/or modify |
|
6 | 6 | -- it under the terms of the GNU General Public License as published by |
|
7 | 7 | -- the Free Software Foundation; either version 3 of the License, or |
|
8 | 8 | -- (at your option) any later version. |
|
9 | 9 | -- |
|
10 | 10 | -- This program is distributed in the hope that it will be useful, |
|
11 | 11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 | 12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 | 13 | -- GNU General Public License for more details. |
|
14 | 14 | -- |
|
15 | 15 | -- You should have received a copy of the GNU General Public License |
|
16 | 16 | -- along with this program; if not, write to the Free Software |
|
17 | 17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
18 | 18 | ------------------------------------------------------------------------------- |
|
19 | 19 | -- Author : Alexis Jeandet |
|
20 | 20 | -- Mail : alexis.jeandet@gmail.com |
|
21 | 21 | -------------------------------------------------------------------------------*/ |
|
22 | 22 | #ifndef BSP_H |
|
23 | 23 | #define BSP_H |
|
24 | 24 | #include <stm32f4xx.h> |
|
25 | 25 | #include <stm32f4xx_gpio.h> |
|
26 | 26 | #include <stm32f4xx_rcc.h> |
|
27 | 27 | #include <gpio.h> |
|
28 | 28 | #include <ili9328.h> |
|
29 | 29 | #include <genericLCD_Controler.h> |
|
30 | 30 | |
|
31 | 31 | #define __MAX_OPENED_FILES__ 4 |
|
32 | 32 | #define __FS_ROOT_SIZE__ 4 |
|
33 | 33 | /* |
|
34 | 34 | #ifndef PD8 |
|
35 | 35 | #define PD8 |
|
36 | 36 | #endif |
|
37 | 37 | #ifndef PD9 |
|
38 | 38 | #define PD9 |
|
39 | 39 | #endif |
|
40 | 40 | */ |
|
41 | 41 | |
|
42 | 42 | |
|
43 | 43 | #define LED1 PF6 |
|
44 | 44 | #define LED2 PF7 |
|
45 | 45 | #define LED3 PF8 |
|
46 | 46 | |
|
47 | 47 | #define PSU_DISABLE PH2 |
|
48 | 48 | #define PSU_ALERT_5V PF2 |
|
49 | 49 | #define PSU_ALERT_1_5V PF3 |
|
50 | 50 | #define PSU_ALERT_3_3V PF4 |
|
51 | 51 | |
|
52 | 52 | #define LCD_RESET PE2 |
|
53 | 53 | |
|
54 | 54 | extern float VREF0; |
|
55 | 55 | |
|
56 | 56 | extern uint32_t currentCpuFreq; |
|
57 | 57 | extern LCD_t lcd0; |
|
58 | 58 | |
|
59 | 59 | |
|
60 | 60 | extern int bsp_init(); |
|
61 | 61 | |
|
62 | 62 | extern void bsp_GPIO_init(); |
|
63 | 63 | 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(); |
|
71 | 71 | extern void setXCS(); |
|
72 | 72 | extern int vs10XXDREQ(); |
|
73 | 73 | |
|
74 | 74 | /* SD CARD */ |
|
75 | 75 | void bsppowersdcard(char onoff); |
|
76 | 76 | 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 | |
|
83 | 89 | |
|
84 | 90 | |
|
85 | 91 | |
|
86 | 92 | |
|
87 | 93 | |
|
88 | 94 | |
|
89 | 95 | |
|
90 | 96 | |
|
91 | 97 | |
|
92 | 98 | |
|
93 | 99 | |
|
94 | 100 | |
|
95 | 101 | |
|
96 | 102 | |
|
97 | 103 | |
|
98 | 104 | |
|
99 | 105 |
@@ -1,269 +1,278 | |||
|
1 | 1 | /*------------------------------------------------------------------------------ |
|
2 | 2 | -- This file is a part of the libuc, microcontroler library |
|
3 | 3 | -- Copyright (C) 2011, Alexis Jeandet |
|
4 | 4 | -- |
|
5 | 5 | -- This program is free software; you can redistribute it and/or modify |
|
6 | 6 | -- it under the terms of the GNU General Public License as published by |
|
7 | 7 | -- the Free Software Foundation; either version 3 of the License, or |
|
8 | 8 | -- (at your option) any later version. |
|
9 | 9 | -- |
|
10 | 10 | -- This program is distributed in the hope that it will be useful, |
|
11 | 11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 | 12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 | 13 | -- GNU General Public License for more details. |
|
14 | 14 | -- |
|
15 | 15 | -- You should have received a copy of the GNU General Public License |
|
16 | 16 | -- along with this program; if not, write to the Free Software |
|
17 | 17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
18 | 18 | ------------------------------------------------------------------------------- |
|
19 | 19 | -- Author : Alexis Jeandet |
|
20 | 20 | -- Mail : alexis.jeandet@gmail.com |
|
21 | 21 | -------------------------------------------------------------------------------*/ |
|
22 | 22 | #include "bsp.h" |
|
23 | 23 | #include <streamdevices.h> |
|
24 | 24 | #include <malloc.h> |
|
25 | 25 | #include <gpio.h> |
|
26 | 26 | #include <uart.h> |
|
27 | 27 | #include <stdio.h> |
|
28 | 28 | #include <stm32f4xx_gpio.h> |
|
29 | 29 | #include <stm32f4xx_fsmc.h> |
|
30 | 30 | #include <i2c.h> |
|
31 | 31 | uint32_t OSC0 =8000000; |
|
32 | 32 | 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); |
|
41 | 56 | |
|
42 | 57 | float VREF0 =(float)3.3; |
|
43 | 58 | |
|
44 | 59 | int bsp_init() |
|
45 | 60 | { |
|
46 | 61 | int i=0; |
|
47 | 62 | for(i=0;i<32;i++) |
|
48 | 63 | { |
|
49 | 64 | __opnfiles__[i] = NULL; |
|
50 | 65 | } |
|
51 | 66 | bsp_GPIO_init(); |
|
52 | 67 | bsp_uart_init(); |
|
53 | 68 | bsp_iic_init(); |
|
54 | 69 | bsp_FSMC_init(); |
|
55 | 70 | printf("\r================================================================\n\r"); |
|
56 | 71 | printf("================================================================\n\r"); |
|
57 | 72 | printf(BSP); |
|
58 | 73 | printf(" initialised\n\r"); |
|
59 | 74 | printf("================================================================\n\r"); |
|
60 | 75 | return 1; |
|
61 | 76 | } |
|
62 | 77 | |
|
63 | 78 | void bsp_GPIO_init() |
|
64 | 79 | { |
|
65 | 80 | gpio_t gpio1 = gpioopen(LED1); |
|
66 | 81 | gpio_t gpio2 = gpioopen(LED2); |
|
67 | 82 | gpio_t gpio3 = gpioopen(LED3); |
|
68 | 83 | gpio_t gpio4 = gpioopen(PSU_DISABLE); |
|
69 | 84 | gpio_t gpio5 = gpioopen(PSU_ALERT_5V); |
|
70 | 85 | gpio_t gpio6 = gpioopen(PSU_ALERT_1_5V); |
|
71 | 86 | gpio_t gpio7 = gpioopen(PSU_ALERT_3_3V); |
|
72 | 87 | gpiosetspeed(&gpio1,gpiohighspeed); |
|
73 | 88 | gpiosetspeed(&gpio2,gpiohighspeed); |
|
74 | 89 | gpiosetspeed(&gpio3,gpiohighspeed); |
|
75 | 90 | gpiosetspeed(&gpio4,gpiohighspeed); |
|
76 | 91 | gpiosetspeed(&gpio5,gpiohighspeed); |
|
77 | 92 | gpiosetspeed(&gpio6,gpiohighspeed); |
|
78 | 93 | gpiosetspeed(&gpio7,gpiohighspeed); |
|
79 | 94 | gpioclr(PSU_DISABLE); |
|
80 | 95 | gpiosetdir(&gpio1,gpiooutdir); |
|
81 | 96 | gpiosetdir(&gpio3,gpiooutdir); |
|
82 | 97 | gpiosetdir(&gpio2,gpiooutdir); |
|
83 | 98 | gpiosetdir(&gpio4,gpiooutdir); |
|
84 | 99 | gpiosetdir(&gpio5,gpioindir); |
|
85 | 100 | gpiosetdir(&gpio6,gpioindir); |
|
86 | 101 | gpiosetdir(&gpio7,gpioindir); |
|
87 | 102 | gpioclr(PSU_DISABLE); |
|
88 | 103 | } |
|
89 | 104 | |
|
90 | 105 | void bsp_uart_init() |
|
91 | 106 | { |
|
92 | 107 | if(__opnfiles__[1]==NULL) |
|
93 | 108 | { |
|
94 | 109 | //uart_t* uart1 = (uart_t*)malloc(sizeof(uart_t)); |
|
95 | 110 | streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice)); |
|
96 | 111 | uart_t uart = uartopenandconfig(uart1,uartparitynone | uart8bits | uartonestop,115200,PA9,PA10,-1,-1); |
|
97 | 112 | uartmkstreamdev(uart,fd1); |
|
98 | 113 | __opnfiles__[1] = fd1; |
|
99 | 114 | } |
|
100 | 115 | else |
|
101 | 116 | { |
|
102 | 117 | uartopenandconfig(0,uartparitynone | uart8bits | uartonestop,115200,PA9,PA10,-1,-1); |
|
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) |
|
115 | 127 | |
|
116 | 128 | gpio_t gpio1 = gpioopen(LCD_RESET); |
|
117 | 129 | gpiosetspeed(&gpio1,gpiohighspeed); |
|
118 | 130 | gpiosetdir(&gpio1,gpiooutdir); |
|
119 | 131 | gpioclr(LCD_RESET); |
|
120 | 132 | |
|
121 | 133 | gpio_t LCD_DBxList[]={PD14,PD15,PD0,PD1,PE7,PE8,PE9,PE10,PE11,PE12,PE13,PE14,PE15\ |
|
122 | 134 | ,PD8,PD9,PD10,PD4,PD5,PD7,PE4}; |
|
123 | 135 | for(int i=0;i<20;i++) |
|
124 | 136 | { |
|
125 | 137 | gpio_t LCD_DBx = gpioopen(LCD_DBxList[i]); |
|
126 | 138 | LCD_DBx |= gpiohighspeed | gpioaf | gpiopushpulltype | gpionopulltype; |
|
127 | 139 | gpiosetconfig(&LCD_DBx); |
|
128 | 140 | GPIO_PinAFConfig(GPIOGETPORT(LCD_DBx), (uint8_t)(LCD_DBx & 0xF), GPIO_AF_FSMC); |
|
129 | 141 | } |
|
130 | 142 | |
|
131 | 143 | FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure; |
|
132 | 144 | FSMC_NORSRAMTimingInitTypeDef p; |
|
133 | 145 | |
|
134 | 146 | /* Enable FSMC clock */ |
|
135 | 147 | RCC_AHB3PeriphClockCmd(RCC_AHB3Periph_FSMC, ENABLE); |
|
136 | 148 | |
|
137 | 149 | /*-- FSMC Configuration ------------------------------------------------------*/ |
|
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; |
|
148 | 160 | p.FSMC_AccessMode = FSMC_AccessMode_A; |
|
149 | 161 | /* Color LCD configuration ------------------------------------ |
|
150 | 162 | LCD configured as follow: |
|
151 | 163 | - Data/Address MUX = Disable |
|
152 | 164 | - Memory Type = SRAM |
|
153 | 165 | - Data Width = 16bit |
|
154 | 166 | - Write Operation = Enable |
|
155 | 167 | - Extended Mode = Enable |
|
156 | 168 | - Asynchronous Wait = Disable */ |
|
157 | 169 | |
|
158 | 170 | FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM1; |
|
159 | 171 | FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable; |
|
160 | 172 | FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM; |
|
161 | 173 | FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b; |
|
162 | 174 | FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable; |
|
163 | 175 | FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable; |
|
164 | 176 | FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low; |
|
165 | 177 | FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable; |
|
166 | 178 | FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState; |
|
167 | 179 | FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable; |
|
168 | 180 | FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable; |
|
169 | 181 | FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable; |
|
170 | 182 | FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable; |
|
171 | 183 | FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p; |
|
172 | 184 | FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p; |
|
173 | 185 | |
|
174 | 186 | FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure); |
|
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() |
|
190 | 196 | { |
|
191 | 197 | |
|
192 | 198 | } |
|
193 | 199 | |
|
194 | 200 | |
|
195 | 201 | void bsp_iic_init() |
|
196 | 202 | { |
|
197 | 203 | i2copenandconfig(i2c2,0,400000,PF0,PF1); |
|
198 | 204 | } |
|
199 | 205 | |
|
200 | 206 | void bsp_SD_init() |
|
201 | 207 | { |
|
202 | 208 | |
|
203 | 209 | } |
|
204 | 210 | |
|
205 | 211 | void vs10XXclearXCS(){} |
|
206 | 212 | void vs10XXsetXCS(){} |
|
207 | 213 | int vs10XXDREQ() |
|
208 | 214 | { |
|
209 | 215 | return 1; |
|
210 | 216 | } |
|
211 | 217 | |
|
212 | 218 | |
|
213 | 219 | void bsppowersdcard(char onoff) //always ON |
|
214 | 220 | { |
|
215 | 221 | |
|
216 | 222 | } |
|
217 | 223 | |
|
218 | 224 | char bspsdcardpresent() |
|
219 | 225 | { |
|
220 | 226 | return 0; |
|
221 | 227 | } |
|
222 | 228 | |
|
223 | 229 | char bspsdcardwriteprotected() |
|
224 | 230 | { |
|
225 | 231 | return 0; |
|
226 | 232 | } |
|
227 | 233 | |
|
228 | 234 | void bspsdcardselect(char YESNO) |
|
229 | 235 | { |
|
230 | 236 | |
|
231 | 237 | } |
|
232 | 238 | |
|
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 | } |
|
239 | 246 | |
|
240 | 247 | uint32_t bsp_lcd0_read_reg(uint32_t reg) |
|
241 | 248 | { |
|
242 | 249 | *lcd0_CMD=(uint16_t)reg; |
|
243 | 250 | return (uint16_t)*lcd0_DATA; |
|
244 | 251 | } |
|
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) |
|
257 | 266 | { |
|
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 | } |
|
265 | 274 | } |
|
266 | 275 | |
|
267 | 276 | |
|
268 | 277 | |
|
269 | 278 |
@@ -1,93 +1,88 | |||
|
1 | 1 | #include <stdio.h> |
|
2 | 2 | #include <fat32.h> |
|
3 | 3 | #include <gpio.h> |
|
4 | 4 | #include <uart.h> |
|
5 | 5 | #include <stm32f4xx.h> |
|
6 | 6 | #include <bsp.h> |
|
7 | 7 | #include <i2c.h> |
|
8 | 8 | #include <CS43L22.h> |
|
9 | 9 | #include <ina226.h> |
|
10 | 10 | #include <fonts.h> |
|
11 | 11 | |
|
12 | 12 | |
|
13 | 13 | extern streamdevice* __opnfiles__[]; |
|
14 | 14 | |
|
15 | 15 | int main() |
|
16 | 16 | { |
|
17 | 17 | INA226_t ina5VSens,ina33VSens,ina15VSens; |
|
18 | 18 | gpioset(PSU_DISABLE); |
|
19 | 19 | volatile int16_t* regtest=(volatile int16_t*)0x60000000; |
|
20 | 20 | volatile int16_t* regtest2=(volatile int16_t*)(0x61FFFFF0); |
|
21 | 21 | //ina226open(&ina5VSens,i2c2,INA226_MODE_SHUNT_VOLTAGE_CONTINUOUS|INA226_AVERAGES_16|INA226_BUS_CONV_8244us|INA226_SHUNT_CONV_8244us,0,0,15,1000000); |
|
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); | |
|
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); | |
|
50 | 46 |
|
|
51 | 47 |
|
|
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)) |
|
61 | 56 | { |
|
62 | 57 | printf("Can't open 3.3V monitor\n\r"); |
|
63 | 58 | } |
|
64 | 59 | |
|
65 | 60 | int current5V,current33V,current15V; |
|
66 | 61 | printf("\t5V\t3.3V\n\r"); |
|
67 | 62 | while(1) |
|
68 | 63 | { |
|
69 | 64 | for(volatile int i=0;i<1024*1024;i++); |
|
70 | 65 | gpioset(LED1); |
|
71 | 66 | gpioclr(LED2); |
|
72 | 67 | for(volatile int i=0;i<1024*1024;i++); |
|
73 | 68 | gpioclr(LED1); |
|
74 | 69 | gpioset(LED2); |
|
75 | 70 | //current5V = ina226getCurrent(&ina5VSens); |
|
76 | 71 | current33V = ina226getCurrent(&ina33VSens); |
|
77 | 72 | //current15V = ina226getCurrent(&ina15VSens); |
|
78 | 73 | //current = ina226getReg(&Psens1,INA226_Current_Reg); |
|
79 | 74 | //printf("%duA %dmA\t%duA %dmA\n\r",current5V,current5V/1000,current33V,current33V/1000); |
|
80 | 75 | printf("%duA %dmA\n\r",current33V,current33V/1000); |
|
81 | 76 | } |
|
82 | 77 | printf("hello world\n\r"); |
|
83 | 78 | return 0; |
|
84 | 79 | } |
|
85 | 80 | |
|
86 | 81 | |
|
87 | 82 | |
|
88 | 83 | |
|
89 | 84 | |
|
90 | 85 | |
|
91 | 86 | |
|
92 | 87 | |
|
93 | 88 |
@@ -1,53 +1,54 | |||
|
1 | 1 | /*------------------------------------------------------------------------------ |
|
2 | 2 | -- This file is a part of the libuc, microcontroler library |
|
3 | 3 | -- Copyright (C) 2012, Alexis Jeandet |
|
4 | 4 | -- |
|
5 | 5 | -- This program is free software; you can redistribute it and/or modify |
|
6 | 6 | -- it under the terms of the GNU General Public License as published by |
|
7 | 7 | -- the Free Software Foundation; either version 3 of the License, or |
|
8 | 8 | -- (at your option) any later version. |
|
9 | 9 | -- |
|
10 | 10 | -- This program is distributed in the hope that it will be useful, |
|
11 | 11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 | 12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 | 13 | -- GNU General Public License for more details. |
|
14 | 14 | -- |
|
15 | 15 | -- You should have received a copy of the GNU General Public License |
|
16 | 16 | -- along with this program; if not, write to the Free Software |
|
17 | 17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
18 | 18 | ------------------------------------------------------------------------------- |
|
19 | 19 | -- Author : Alexis Jeandet |
|
20 | 20 | -- Mail : alexis.jeandet@gmail.com |
|
21 | 21 | -------------------------------------------------------------------------------*/ |
|
22 | 22 | #ifndef GENERICLCD_CONTROLER_H |
|
23 | 23 | #define GENERICLCD_CONTROLER_H |
|
24 | 24 | |
|
25 | 25 | #include <uhandle.h> |
|
26 | 26 | #include <stdint.h> |
|
27 | 27 | |
|
28 | 28 | |
|
29 | 29 | typedef struct LCD_IF_t |
|
30 | 30 | { |
|
31 | 31 | int (*init)(); |
|
32 | 32 | void (*writereg)(uint32_t reg,uint32_t data); |
|
33 | 33 | uint32_t (*readreg)(uint32_t reg); |
|
34 | 34 | void (*writeGRAM)(void* buffer,uint32_t count); |
|
35 | 35 | void (*readGRAM)(void* buffer,uint32_t count); |
|
36 | 36 | }LCD_IF_t; |
|
37 | 37 | |
|
38 | 38 | typedef struct LCD_t |
|
39 | 39 | { |
|
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; |
|
46 | 47 | |
|
47 | 48 | |
|
48 | 49 | #endif /*GENERICLCD_CONTROLER_H*/ |
|
49 | 50 | |
|
50 | 51 | |
|
51 | 52 | |
|
52 | 53 | |
|
53 | 54 |
@@ -1,91 +1,92 | |||
|
1 | 1 | /*------------------------------------------------------------------------------ |
|
2 | 2 | -- This file is a part of the libuc, microcontroler library |
|
3 | 3 | -- Copyright (C) 2012, Alexis Jeandet |
|
4 | 4 | -- |
|
5 | 5 | -- This program is free software; you can redistribute it and/or modify |
|
6 | 6 | -- it under the terms of the GNU General Public License as published by |
|
7 | 7 | -- the Free Software Foundation; either version 3 of the License, or |
|
8 | 8 | -- (at your option) any later version. |
|
9 | 9 | -- |
|
10 | 10 | -- This program is distributed in the hope that it will be useful, |
|
11 | 11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 | 12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 | 13 | -- GNU General Public License for more details. |
|
14 | 14 | -- |
|
15 | 15 | -- You should have received a copy of the GNU General Public License |
|
16 | 16 | -- along with this program; if not, write to the Free Software |
|
17 | 17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
18 | 18 | ------------------------------------------------------------------------------- |
|
19 | 19 | -- Author : Alexis Jeandet |
|
20 | 20 | -- Mail : alexis.jeandet@gmail.com |
|
21 | 21 | -------------------------------------------------------------------------------*/ |
|
22 | 22 | #ifndef ILI9328_H |
|
23 | 23 | #define ILI9328_H |
|
24 | 24 | |
|
25 | 25 | #include <uhandle.h> |
|
26 | 26 | #include <genericLCD_Controler.h> |
|
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 ) |
|
36 | 37 | #define ILI9328_REGISTER_LCDDRIVINGCONTROL ((uint32_t) 0x0002 ) |
|
37 | 38 | #define ILI9328_REGISTER_ENTRYMODE ((uint32_t) 0x0003 ) |
|
38 | 39 | #define ILI9328_REGISTER_RESIZECONTROL ((uint32_t) 0x0004 ) |
|
39 | 40 | #define ILI9328_REGISTER_DISPLAYCONTROL1 ((uint32_t) 0x0007 ) |
|
40 | 41 | #define ILI9328_REGISTER_DISPLAYCONTROL2 ((uint32_t) 0x0008 ) |
|
41 | 42 | #define ILI9328_REGISTER_DISPLAYCONTROL3 ((uint32_t) 0x0009 ) |
|
42 | 43 | #define ILI9328_REGISTER_DISPLAYCONTROL4 ((uint32_t) 0x000A ) |
|
43 | 44 | #define ILI9328_REGISTER_RGBDISPLAYINTERFACECONTROL1 ((uint32_t) 0x000C ) |
|
44 | 45 | #define ILI9328_REGISTER_FRAMEMAKERPOSITION ((uint32_t) 0x000D ) |
|
45 | 46 | #define ILI9328_REGISTER_RGBDISPLAYINTERFACECONTROL2 ((uint32_t) 0x000F ) |
|
46 | 47 | #define ILI9328_REGISTER_POWERCONTROL1 ((uint32_t) 0x0010 ) |
|
47 | 48 | #define ILI9328_REGISTER_POWERCONTROL2 ((uint32_t) 0x0011 ) |
|
48 | 49 | #define ILI9328_REGISTER_POWERCONTROL3 ((uint32_t) 0x0012 ) |
|
49 | 50 | #define ILI9328_REGISTER_POWERCONTROL4 ((uint32_t) 0x0013 ) |
|
50 | 51 | #define ILI9328_REGISTER_HORIZONTALGRAMADDRESSSET ((uint32_t) 0x0020 ) |
|
51 | 52 | #define ILI9328_REGISTER_VERTICALGRAMADDRESSSET ((uint32_t) 0x0021 ) |
|
52 | 53 | #define ILI9328_REGISTER_WRITEDATATOGRAM ((uint32_t) 0x0022 ) |
|
53 | 54 | #define ILI9328_REGISTER_POWERCONTROL7 ((uint32_t) 0x0029 ) |
|
54 | 55 | #define ILI9328_REGISTER_FRAMERATEANDCOLORCONTROL ((uint32_t) 0x002B ) |
|
55 | 56 | #define ILI9328_REGISTER_GAMMACONTROL1 ((uint32_t) 0x0030 ) |
|
56 | 57 | #define ILI9328_REGISTER_GAMMACONTROL2 ((uint32_t) 0x0031 ) |
|
57 | 58 | #define ILI9328_REGISTER_GAMMACONTROL3 ((uint32_t) 0x0032 ) |
|
58 | 59 | #define ILI9328_REGISTER_GAMMACONTROL4 ((uint32_t) 0x0035 ) |
|
59 | 60 | #define ILI9328_REGISTER_GAMMACONTROL5 ((uint32_t) 0x0036 ) |
|
60 | 61 | #define ILI9328_REGISTER_GAMMACONTROL6 ((uint32_t) 0x0037 ) |
|
61 | 62 | #define ILI9328_REGISTER_GAMMACONTROL7 ((uint32_t) 0x0038 ) |
|
62 | 63 | #define ILI9328_REGISTER_GAMMACONTROL8 ((uint32_t) 0x0039 ) |
|
63 | 64 | #define ILI9328_REGISTER_GAMMACONTROL9 ((uint32_t) 0x003C ) |
|
64 | 65 | #define ILI9328_REGISTER_GAMMACONTROL10 ((uint32_t) 0x003D ) |
|
65 | 66 | #define ILI9328_REGISTER_HORIZONTALADDRESSSTARTPOSITION ((uint32_t) 0x0050 ) |
|
66 | 67 | #define ILI9328_REGISTER_HORIZONTALADDRESSENDPOSITION ((uint32_t) 0x0051 ) |
|
67 | 68 | #define ILI9328_REGISTER_VERTICALADDRESSSTARTPOSITION ((uint32_t) 0x0052 ) |
|
68 | 69 | #define ILI9328_REGISTER_VERTICALADDRESSENDPOSITION ((uint32_t) 0x0053 ) |
|
69 | 70 | #define ILI9328_REGISTER_DRIVEROUTPUTCONTROL2 ((uint32_t) 0x0060 ) |
|
70 | 71 | #define ILI9328_REGISTER_BASEIMAGEDISPLAYCONTROL ((uint32_t) 0x0061 ) |
|
71 | 72 | #define ILI9328_REGISTER_VERTICALSCROLLCONTROL ((uint32_t) 0x006A ) |
|
72 | 73 | #define ILI9328_REGISTER_PARTIALIMAGE1DISPLAYPOSITION ((uint32_t) 0x0080 ) |
|
73 | 74 | #define ILI9328_REGISTER_PARTIALIMAGE1AREASTARTLINE ((uint32_t) 0x0081 ) |
|
74 | 75 | #define ILI9328_REGISTER_PARTIALIMAGE1AREAENDLINE ((uint32_t) 0x0082 ) |
|
75 | 76 | #define ILI9328_REGISTER_PARTIALIMAGE2DISPLAYPOSITION ((uint32_t) 0x0083 ) |
|
76 | 77 | #define ILI9328_REGISTER_PARTIALIMAGE2AREASTARTLINE ((uint32_t) 0x0084 ) |
|
77 | 78 | #define ILI9328_REGISTER_PARTIALIMAGE2AREAENDLINE ((uint32_t) 0x0085 ) |
|
78 | 79 | #define ILI9328_REGISTER_PANELINTERFACECONTROL1 ((uint32_t) 0x0090 ) |
|
79 | 80 | #define ILI9328_REGISTER_PANELINTERFACECONTROL2 ((uint32_t) 0x0092 ) |
|
80 | 81 | #define ILI9328_REGISTER_PANELINTERFACECONTROL4 ((uint32_t) 0x0095 ) |
|
81 | 82 | #define ILI9328_REGISTER_OTPVCMPROGRAMMINGCONTROL ((uint32_t) 0x00A1 ) |
|
82 | 83 | #define ILI9328_REGISTER_OTPVCMSTATUSANDENABLE ((uint32_t) 0x00A2 ) |
|
83 | 84 | #define ILI9328_REGISTER_OTPPROGRAMMINGIDKEY ((uint32_t) 0x00A5 ) |
|
84 | 85 | |
|
85 | 86 | |
|
86 | 87 | #endif |
|
87 | 88 | |
|
88 | 89 | |
|
89 | 90 | |
|
90 | 91 | |
|
91 | 92 |
@@ -1,103 +1,120 | |||
|
1 | 1 | /*------------------------------------------------------------------------------ |
|
2 | 2 | -- This file is a part of the libuc, microcontroler library |
|
3 | 3 | -- Copyright (C) 2012, Alexis Jeandet |
|
4 | 4 | -- |
|
5 | 5 | -- This program is free software; you can redistribute it and/or modify |
|
6 | 6 | -- it under the terms of the GNU General Public License as published by |
|
7 | 7 | -- the Free Software Foundation; either version 3 of the License, or |
|
8 | 8 | -- (at your option) any later version. |
|
9 | 9 | -- |
|
10 | 10 | -- This program is distributed in the hope that it will be useful, |
|
11 | 11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 | 12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 | 13 | -- GNU General Public License for more details. |
|
14 | 14 | -- |
|
15 | 15 | -- You should have received a copy of the GNU General Public License |
|
16 | 16 | -- along with this program; if not, write to the Free Software |
|
17 | 17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
18 | 18 | ------------------------------------------------------------------------------- |
|
19 | 19 | -- Author : Alexis Jeandet |
|
20 | 20 | -- Mail : alexis.jeandet@gmail.com |
|
21 | 21 | -------------------------------------------------------------------------------*/ |
|
22 | 22 | #include <ili9328.h> |
|
23 | 23 | #include <stdio.h> |
|
24 | 24 | #include <stddef.h> |
|
25 | 25 | |
|
26 | 26 | #define _delay_(del) for(volatile int _d_e_l_=0;_d_e_l_<(del);_d_e_l_++); |
|
27 | 27 | |
|
28 | 28 | void ili9328setGRAMaddress(LCD_t* LCD,uint16_t Haddress,uint16_t Vaddress) |
|
29 | 29 | { |
|
30 | 30 | LCD->interface->writereg(ILI9328_REGISTER_HORIZONTALGRAMADDRESSSET,Haddress); |
|
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 | { | |
|
36 | if(enable) | |
|
37 | { | |
|
38 | //LCD->interface->writereg(ILI9328_REGISTER_ENTRYMODE,0x1018); | |
|
39 | } | |
|
40 | else | |
|
35 | 41 | { |
|
36 |
LCD->interface->writereg(ILI9328_REGISTER_ |
|
|
37 | LCD->interface->writereg(ILI9328_REGISTER_VERTICALADDRESSSTARTPOSITION,VaddressStart); | |
|
38 | LCD->interface->writereg(ILI9328_REGISTER_HORIZONTALADDRESSENDPOSITION,HaddressStop); | |
|
39 | LCD->interface->writereg(ILI9328_REGISTER_VERTICALADDRESSENDPOSITION,VaddressStop); | |
|
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) |
|
43 | 60 | { |
|
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 | } |
|
52 | 69 | |
|
53 | 70 | int ili9328init(struct LCD_t* LCD) |
|
54 | 71 | { |
|
55 | 72 | if((LCD!=NULL) && (LCD->interface!=NULL) && (LCD->interface->writereg!=NULL)) |
|
56 | 73 | { |
|
57 | 74 | LCD->interface->writereg(ILI9328_REGISTER_DRIVEROUTPUTCONTROL1, 0x0100); // Driver Output Control Register (R01h) |
|
58 | 75 | LCD->interface->writereg(ILI9328_REGISTER_LCDDRIVINGCONTROL, 0x0700); // LCD Driving Waveform Control (R02h) |
|
59 | 76 | LCD->interface->writereg(ILI9328_REGISTER_ENTRYMODE, 0x1030); // Entry Mode (R03h) |
|
60 | 77 | LCD->interface->writereg(ILI9328_REGISTER_DISPLAYCONTROL2, 0x0302); |
|
61 | 78 | LCD->interface->writereg(ILI9328_REGISTER_DISPLAYCONTROL3, 0x0000); |
|
62 | 79 | LCD->interface->writereg(ILI9328_REGISTER_DISPLAYCONTROL4, 0x0000); // Fmark On |
|
63 | 80 | LCD->interface->writereg(ILI9328_REGISTER_POWERCONTROL1, 0x0000); // Power Control 1 (R10h) |
|
64 | 81 | LCD->interface->writereg(ILI9328_REGISTER_POWERCONTROL2, 0x0007); // Power Control 2 (R11h) |
|
65 | 82 | LCD->interface->writereg(ILI9328_REGISTER_POWERCONTROL3, 0x0000); // Power Control 3 (R12h) |
|
66 | 83 | LCD->interface->writereg(ILI9328_REGISTER_POWERCONTROL4, 0x0000); // Power Control 4 (R13h) |
|
67 | 84 | _delay_(1000000); |
|
68 | 85 | LCD->interface->writereg(ILI9328_REGISTER_POWERCONTROL1, 0x14B0); // Power Control 1 (R10h) |
|
69 | 86 | _delay_(500000); |
|
70 | 87 | LCD->interface->writereg(ILI9328_REGISTER_POWERCONTROL2, 0x0007); // Power Control 2 (R11h) |
|
71 | 88 | _delay_(500000); |
|
72 | 89 | LCD->interface->writereg(ILI9328_REGISTER_POWERCONTROL3, 0x008E); // Power Control 3 (R12h) |
|
73 | 90 | LCD->interface->writereg(ILI9328_REGISTER_POWERCONTROL4, 0x0C00); // Power Control 4 (R13h) |
|
74 | 91 | LCD->interface->writereg(ILI9328_REGISTER_POWERCONTROL7, 0x0015); // NVM read data 2 (R29h) |
|
75 | 92 | _delay_(500000); |
|
76 | 93 | LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL1, 0x0000); // Gamma Control 1 |
|
77 | 94 | LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL2, 0x0107); // Gamma Control 2 |
|
78 | 95 | LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL3, 0x0000); // Gamma Control 3 |
|
79 | 96 | LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL4, 0x0203); // Gamma Control 4 |
|
80 | 97 | LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL5, 0x0402); // Gamma Control 5 |
|
81 | 98 | LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL6, 0x0000); // Gamma Control 6 |
|
82 | 99 | LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL7, 0x0207); // Gamma Control 7 |
|
83 | 100 | LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL8, 0x0000); // Gamma Control 8 |
|
84 | 101 | LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL9, 0x0203); // Gamma Control 9 |
|
85 | 102 | LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL10, 0x0403); // Gamma Control 10 |
|
86 | 103 | LCD->interface->writereg(ILI9328_REGISTER_HORIZONTALADDRESSSTARTPOSITION, 0x0000); // Window Horizontal RAM Address Start (R50h) |
|
87 | 104 | LCD->interface->writereg(ILI9328_REGISTER_HORIZONTALADDRESSENDPOSITION, 240 - 1); // Window Horizontal RAM Address End (R51h) |
|
88 | 105 | LCD->interface->writereg(ILI9328_REGISTER_VERTICALADDRESSSTARTPOSITION, 0X0000); // Window Vertical RAM Address Start (R52h) |
|
89 | 106 | LCD->interface->writereg(ILI9328_REGISTER_VERTICALADDRESSENDPOSITION, 320 - 1); // Window Vertical RAM Address End (R53h) |
|
90 | 107 | LCD->interface->writereg(ILI9328_REGISTER_DRIVEROUTPUTCONTROL2, 0xa700); // Driver Output Control (R60h) |
|
91 | 108 | LCD->interface->writereg(ILI9328_REGISTER_BASEIMAGEDISPLAYCONTROL, 0x0003); // Driver Output Control (R61h) - enable VLE |
|
92 | 109 | LCD->interface->writereg(ILI9328_REGISTER_PANELINTERFACECONTROL1, 0X0010); // Panel Interface Control 1 (R90h) |
|
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 | } |
|
100 | 117 | return 0; |
|
101 | 118 | } |
|
102 | 119 | |
|
103 | 120 |
General Comments 0
You need to be logged in to leave comments.
Login now