##// END OF EJS Templates
sync
Jeandet Alexis -
r64:b702edc52366 dev_alexis
parent child
Show More
@@ -1,312 +1,312
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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
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 #include <core.h>
32 32 #include <terminal.h>
33 33
34 34 uint32_t OSC0 =8000000;
35 35 uint32_t INTOSC =16000000;
36 36 uint32_t RTCOSC =32768;
37 37 uint32_t currentCpuFreq=0;
38 38 extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__];
39 39
40 40 LCD_IF_t lcdIF0={
41 41 .init = &bsp_FSMC_init,
42 42 .writereg = &bsp_lcd0_write_reg,
43 43 .readreg = &bsp_lcd0_read_reg,
44 44 .writeGRAM = &bsp_lcd0_writeGRAM,
45 45 .readGRAM = &bsp_lcd0_readGRAM
46 46 };
47 47
48 48 LCD_t lcd0={
49 49 .interface = &lcdIF0,
50 50 .init = &ili9328init,
51 51 .paint = &ili9328paint,
52 52 .paintText = &ili9328paintText,
53 53 .paintFilRect = &ili9328paintFilRect,
54 54 .refreshenable = &ili9328refreshenable,
55 55 .width= 240,
56 56 .height = 320
57 57 };
58 58
59 59 terminal_t terminal0;
60 60
61 61 volatile int16_t* lcd0_CMD=(volatile int16_t*) 0x60000000;
62 62 volatile int16_t* lcd0_DATA=(volatile int16_t*)(0x61FFFFF0);
63 63
64 64 float VREF0 =(float)3.3;
65 65
66 66 int bsp_init()
67 67 {
68 68 int i=0;
69 69 for(i=0;i<32;i++)
70 70 {
71 71 __opnfiles__[i] = NULL;
72 72 }
73 73 bsp_GPIO_init();
74 74 bsp_uart_init();
75 75 bsp_iic_init();
76 76 bsp_FSMC_init();
77 77 bsp_GTerm_init();
78 78 printf("\r=====================\n\r");
79 79 printf( "=====================\n\r");
80 80 printf(BSP);
81 81 printf(" initialised\n\r");
82 82 printf( "=====================\n\r");
83 83 return 1;
84 84 }
85 85
86 86 void bsp_GPIO_init()
87 87 {
88 88 gpio_t gpio1 = gpioopen(LED1);
89 89 gpio_t gpio2 = gpioopen(LED2);
90 90 gpio_t gpio3 = gpioopen(LED3);
91 91 gpio_t gpio4 = gpioopen(PSU_DISABLE);
92 92 gpio_t gpio5 = gpioopen(PSU_ALERT_5V);
93 93 gpio_t gpio6 = gpioopen(PSU_ALERT_1_5V);
94 94 gpio_t gpio7 = gpioopen(PSU_ALERT_3_3V);
95 95 gpiosetspeed(&gpio1,gpiohighspeed);
96 96 gpiosetspeed(&gpio2,gpiohighspeed);
97 97 gpiosetspeed(&gpio3,gpiohighspeed);
98 98 gpiosetspeed(&gpio4,gpiohighspeed);
99 99 gpiosetspeed(&gpio5,gpiohighspeed);
100 100 gpiosetspeed(&gpio6,gpiohighspeed);
101 101 gpiosetspeed(&gpio7,gpiohighspeed);
102 102 gpioclr(PSU_DISABLE);
103 103 gpiosetdir(&gpio1,gpiooutdir);
104 104 gpiosetdir(&gpio3,gpiooutdir);
105 105 gpiosetdir(&gpio2,gpiooutdir);
106 106 gpiosetdir(&gpio4,gpiooutdir);
107 107 gpiosetdir(&gpio5,gpioindir);
108 108 gpiosetdir(&gpio6,gpioindir);
109 109 gpiosetdir(&gpio7,gpioindir);
110 110 gpioclr(PSU_DISABLE);
111 111 }
112 112
113 113 void bsp_uart_init()
114 114 {
115 115 //if(__opnfiles__[1]==NULL)
116 116 //{
117 117 //uart_t* uart1 = (uart_t*)malloc(sizeof(uart_t));
118 118 // streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice));
119 119 // uart_t uart = uartopenandconfig(uart1,uartparitynone | uart8bits | uartonestop,115200,PA9,PA10,-1,-1);
120 120 //uartmkstreamdev(uart,fd1);
121 121 //__opnfiles__[1] = fd1;
122 122 //}
123 123 //else
124 124 //{
125 125 uartopenandconfig(0,uartparitynone | uart8bits | uartonestop,115200,PA9,PA10,-1,-1);
126 126 //}
127 127 }
128 128
129 129
130 130
131 131 int bsp_FSMC_init()
132 132 {
133 133 #define GPIOGETPORT(gpio) ((GPIO_TypeDef*)(((((uint32_t)gpio) & (uint32_t)0x0000FF00)*(uint32_t)4) + (uint32_t)GPIOA))
134 134 #define GPIOPORTNUM(gpio) (((uint32_t)(gpio) & (uint32_t)0x0000FF00)>>(uint32_t)8)
135 135
136 136 gpio_t gpio1 = gpioopen(LCD_RESET);
137 137 gpiosetspeed(&gpio1,gpiohighspeed);
138 138 gpiosetdir(&gpio1,gpiooutdir);
139 139 gpioclr(LCD_RESET);
140 140
141 141 gpio_t LCD_DBxList[]={PD14,PD15,PD0,PD1,PE7,PE8,PE9,PE10,PE11,PE12,PE13,PE14,PE15\
142 142 ,PD8,PD9,PD10,PD4,PD5,PD7,PE4};
143 143 for(int i=0;i<20;i++)
144 144 {
145 145 gpio_t LCD_DBx = gpioopen(LCD_DBxList[i]);
146 146 LCD_DBx |= gpiohighspeed | gpioaf | gpiopushpulltype | gpionopulltype;
147 147 gpiosetconfig(&LCD_DBx);
148 148 GPIO_PinAFConfig(GPIOGETPORT(LCD_DBx), (uint8_t)(LCD_DBx & 0xF), GPIO_AF_FSMC);
149 149 }
150 150
151 151 FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure;
152 152 FSMC_NORSRAMTimingInitTypeDef p;
153 153
154 154 /* Enable FSMC clock */
155 155 RCC_AHB3PeriphClockCmd(RCC_AHB3Periph_FSMC, ENABLE);
156 156
157 157 /*-- FSMC Configuration ------------------------------------------------------*/
158 158 /*----------------------- SRAM Bank 3 ----------------------------------------*/
159 159 /* FSMC_Bank1_NORSRAM4 configuration */
160 160 //p.FSMC_AddressSetupTime = 5;
161 161 p.FSMC_AddressSetupTime = 1;
162 162 p.FSMC_AddressHoldTime = 0;
163 163 //p.FSMC_DataSetupTime = 9;
164 164 p.FSMC_DataSetupTime = getCpuFreq()/14545450 ;// 11;
165 165 p.FSMC_BusTurnAroundDuration = 0;
166 166 p.FSMC_CLKDivision = 0;
167 167 p.FSMC_DataLatency = 0;
168 168 p.FSMC_AccessMode = FSMC_AccessMode_A;
169 169 /* Color LCD configuration ------------------------------------
170 170 LCD configured as follow:
171 171 - Data/Address MUX = Disable
172 172 - Memory Type = SRAM
173 173 - Data Width = 16bit
174 174 - Write Operation = Enable
175 175 - Extended Mode = Enable
176 176 - Asynchronous Wait = Disable */
177 177
178 178 FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM1;
179 179 FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;
180 180 FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM;
181 181 FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;
182 182 FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable;
183 183 FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable;
184 184 FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;
185 185 FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable;
186 186 FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;
187 187 FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable;
188 188 FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable;
189 189 FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable;
190 190 FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;
191 191 FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p;
192 192 FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p;
193 193
194 194 FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure);
195 195
196 196 /* Enable FSMC NOR/SRAM Bank1 */
197 197 FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM1, ENABLE);
198 198 gpioset(LCD_RESET);
199 199 lcd0.init(&lcd0);
200 200 return 1;
201 201 }
202 202
203 203 void bsp_spi_init()
204 204 {
205 205
206 206 }
207 207
208 208
209 209 void bsp_iic_init()
210 210 {
211 211 i2copenandconfig(i2c2,0,10000,PF0,PF1);
212 212 }
213 213
214 214 void bsp_SD_init()
215 215 {
216 216
217 217 }
218 218
219 219 void vs10XXclearXCS(){}
220 220 void vs10XXsetXCS(){}
221 221 int vs10XXDREQ()
222 222 {
223 223 return 1;
224 224 }
225 225
226 226
227 227 void bsppowersdcard(char onoff) //always ON
228 228 {
229 229
230 230 }
231 231
232 232 char bspsdcardpresent()
233 233 {
234 234 return 0;
235 235 }
236 236
237 237 char bspsdcardwriteprotected()
238 238 {
239 239 return 0;
240 240 }
241 241
242 242 void bspsdcardselect(char YESNO)
243 243 {
244 244
245 245 }
246 246
247 247
248 248 void bsp_lcd0_write_reg(uint32_t reg,uint32_t data)
249 249 {
250 250 *lcd0_CMD=(uint16_t)reg;
251 251 *lcd0_DATA=(uint16_t)data;
252 252 }
253 253
254 254 uint32_t bsp_lcd0_read_reg(uint32_t reg)
255 255 {
256 256 *lcd0_CMD=(uint16_t)reg;
257 257 return (uint16_t)*lcd0_DATA;
258 258 }
259 259
260 260 void bsp_lcd0_writeGRAM(void* buffer,uint32_t count)
261 261 {
262 262 *lcd0_CMD=(uint16_t)ILI9328_REGISTER_WRITEDATATOGRAM;
263 263 uint16_t* castedBuff=(uint16_t*)buffer;
264 264 for(int i=0;i<(int)count;i++)
265 265 {
266 266 *lcd0_DATA=castedBuff[i];
267 267 }
268 268 }
269 269
270 270 void bsp_lcd0_readGRAM(void* buffer,uint32_t count)
271 271 {
272 272 *lcd0_CMD=(uint16_t)ILI9328_REGISTER_WRITEDATATOGRAM;
273 273 uint16_t* castedBuff=(uint16_t*)buffer;
274 274 castedBuff[0]=*lcd0_DATA;
275 275 for(int i=0;i<(int)count;i++)
276 276 {
277 277 castedBuff[i]=*lcd0_DATA;
278 278 }
279 279 }
280 280
281 281
282 282 void bsp_GTerm_init()
283 283 {
284 284 if(__opnfiles__[1]==NULL)
285 285 {
286 286 //uart_t* uart1 = (uart_t*)malloc(sizeof(uart_t));
287 287 streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice));
288 288 terminal_init(&terminal0 ,&lcd0,&ComicSansMS_8,fd1);
289 289 __opnfiles__[1] = fd1;
290 290 }
291 291 else
292 292 {
293 293
294 294 }
295 295 }
296 296
297 297
298 298
299 299
300 300
301 301
302 302
303 303
304 304
305 305
306 306
307 307
308 308
309 309
310 310
311 311
312 312
@@ -1,106 +1,106
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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
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 67 extern void bsp_GTerm_init();
68 68 extern int bsp_FSMC_init();
69 69
70 70 /* VS1053 */
71 71 extern void clearXCS();
72 72 extern void setXCS();
73 73 extern int vs10XXDREQ();
74 74
75 75 /* SD CARD */
76 76 void bsppowersdcard(char onoff);
77 77 char bspsdcardpresent();
78 78 void bspsdcardselect(char YESNO);
79 79 char bspsdcardwriteprotected();
80 80
81 81
82 82 void bsp_lcd0_write_reg(uint32_t reg,uint32_t data);
83 83 uint32_t bsp_lcd0_read_reg(uint32_t reg);
84 84 void bsp_lcd0_writeGRAM(void *buffer, uint32_t count);
85 85 void bsp_lcd0_readGRAM(void *buffer, uint32_t count);
86 86
87 87 #endif
88 88
89 89
90 90
91 91
92 92
93 93
94 94
95 95
96 96
97 97
98 98
99 99
100 100
101 101
102 102
103 103
104 104
105 105
106 106
@@ -1,126 +1,126
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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
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 uint32_t OSC0 =8000000;
29 29 uint32_t INTOSC =16000000;
30 30 uint32_t RTCOSC =32768;
31 31 uint32_t currentCpuFreq=0;
32 32 extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__];
33 33
34 34 float VREF0 =(float)3.3;
35 35
36 36 int bsp_init()
37 37 {
38 38 int i=0;
39 39 for(i=0;i<32;i++)
40 40 {
41 41 __opnfiles__[i] = NULL;
42 42 }
43 43 bsp_GPIO_init();
44 44 bsp_uart_init();
45 45 printf("\r================================================================\n\r");
46 46 printf("================================================================\n\r");
47 47 printf(BSP);
48 48 printf(" initialised\n\r");
49 49 printf("================================================================\n\r");
50 50 return 1;
51 51 }
52 52
53 53 void bsp_GPIO_init()
54 54 {
55 55 gpio_t gpio1 = gpioopen(PC6);//gpioopen(LED1); //PD9 D=> 0x0300 9 => 0x0009
56 56 gpio_t gpio2 = gpioopen(PC7);//gpioopen(LED2);
57 57 gpiosetspeed(&gpio1,gpiohighspeed);
58 58 gpiosetspeed(&gpio2,gpiohighspeed);
59 59 gpiosetdir(&gpio1,gpiooutdir);
60 60 gpiosetdir(&gpio2,gpiooutdir);
61 61 }
62 62
63 63 void bsp_uart_init()
64 64 {
65 65 if(__opnfiles__[1]==NULL)
66 66 {
67 67 //uart_t* uart1 = (uart_t*)malloc(sizeof(uart_t));
68 68 streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice));
69 69 uart_t uart = uartopenandconfig(uart3,uartparitynone | uart8bits | uartonestop,115200,LED2,LED1,-1,-1);
70 70 uartmkstreamdev(uart,fd1);
71 71 __opnfiles__[1] = fd1;
72 72 }
73 73 else
74 74 {
75 75 uartopenandconfig(uart3,uartparitynone | uart8bits | uartonestop,115200,LED2,LED1,-1,-1);
76 76 }
77 77 }
78 78
79 79 void bsp_spi_init()
80 80 {
81 81
82 82 }
83 83
84 84
85 85 void bsp_iic_init()
86 86 {
87 87
88 88 }
89 89
90 90 void bsp_SD_init()
91 91 {
92 92
93 93 }
94 94
95 95 void vs10XXclearXCS(){}
96 96 void vs10XXsetXCS(){}
97 97 int vs10XXDREQ()
98 98 {
99 99 return 1;
100 100 }
101 101
102 102
103 103 void bsppowersdcard(char onoff) //always ON
104 104 {
105 105
106 106 }
107 107
108 108 char bspsdcardpresent()
109 109 {
110 110 return 0;
111 111 }
112 112
113 113 char bspsdcardwriteprotected()
114 114 {
115 115 return 0;
116 116 }
117 117
118 118 void bspsdcardselect(char YESNO)
119 119 {
120 120
121 121 }
122 122
123 123
124 124
125 125
126 126
@@ -1,86 +1,86
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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
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
29 29
30 30 #define __MAX_OPENED_FILES__ 32
31 31 #define __FS_ROOT_SIZE__ 32
32 32
33 33 #define LED1 PD8
34 34 #define LED2 PD9
35 35
36 36 #define LED3ON GPIOB->BSRRH = GPIO_Pin_15
37 37 #define LED2ON GPIOD->BSRRH = GPIO_Pin_8
38 38 #define LED1ON GPIOD->BSRRH = GPIO_Pin_9
39 39
40 40 #define LED3OFF GPIOB->BSRRL = GPIO_Pin_15
41 41 #define LED2OFF GPIOD->BSRRL = GPIO_Pin_8
42 42 #define LED1OFF GPIOD->BSRRL = GPIO_Pin_9
43 43
44 44 extern float VREF0;
45 45
46 46 extern uint32_t currentCpuFreq;
47 47
48 48 extern int bsp_init();
49 49
50 50 extern void bsp_GPIO_init();
51 51 extern void bsp_uart_init();
52 52 extern void bsp_iic_init();
53 53 extern void bsp_spi_init();
54 54 extern void bsp_SD_init();
55 55
56 56 /* VS1053 */
57 57 extern void clearXCS();
58 58 extern void setXCS();
59 59 extern int vs10XXDREQ();
60 60
61 61 /* SD CARD */
62 62 void bsppowersdcard(char onoff);
63 63 char bspsdcardpresent();
64 64 void bspsdcardselect(char YESNO);
65 65 char bspsdcardwriteprotected();
66 66
67 67 #endif
68 68
69 69
70 70
71 71
72 72
73 73
74 74
75 75
76 76
77 77
78 78
79 79
80 80
81 81
82 82
83 83
84 84
85 85
86 86
@@ -1,143 +1,143
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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
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 <spi.h>
28 28 #include <stdio.h>
29 29 #include <core.h>
30 30 uint32_t OSC0 =8000000;
31 31 uint32_t INTOSC =16000000;
32 32 uint32_t RTCOSC =32768;
33 33 uint32_t currentCpuFreq=0;
34 34 extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__];
35 35
36 36 float VREF0 =(float)3.3;
37 37
38 38 int bsp_init()
39 39 {
40 40 int i=0;
41 41 for(i=0;i<32;i++)
42 42 {
43 43 __opnfiles__[i] = NULL;
44 44 }
45 45 bsp_GPIO_init();
46 46 bsp_uart_init();
47 47 bsp_spi_init();
48 48 printf("\r================================================================\n\r");
49 49 printf("================================================================\n\r");
50 50 printf(BSP);
51 51 printf(" initialised\n\r");
52 52 printf("================================================================\n\r");
53 53 return 1;
54 54 }
55 55
56 56 void bsp_GPIO_init()
57 57 {
58 58 gpio_t GPIOList[]={LED1,LED2,LED3,ADC_MODE0,ADC_MODE1,ADC_FSYNC
59 59 ,ADC_SYNC,ADC_CLKDIV};
60 60 gpio_t GPIOx;
61 61 for(int i=0;i<8;i++)
62 62 {
63 63 GPIOx = gpioopen(GPIOList[i]);
64 64 gpiosetspeed(&GPIOx,gpiohighspeed);
65 65 gpiosetdir(&GPIOx,gpiooutdir);
66 66 gpiosetouttype(&GPIOx,gpiopushpulltype);
67 67 }
68 68 gpioset(ADC_CLKDIV);
69 69 gpioset(ADC_MODE0);
70 70 gpioset(ADC_MODE1);
71 71 gpioclr(ADC_SYNC);
72 72 gpioclr(ADC_FSYNC);
73 73 delay_100us(10);
74 74 gpioset(ADC_SYNC);
75 75
76 76 }
77 77
78 78 void bsp_uart_init()
79 79 {
80 80 if(__opnfiles__[1]==NULL)
81 81 {
82 82 //uart_t* uart1 = (uart_t*)malloc(sizeof(uart_t));
83 83 streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice));
84 84 //uart_t uart = uartopenandconfig(uart1,uartparitynone | uart8bits | uartonestop,230400,PA9,PA10,-1,-1);
85 85 uart_t uart = uartopenandconfig(uart1,uartparitynone | uart8bits | uartonestop,115200,PA9,PA10,-1,-1);
86 86 uartmkstreamdev(uart,fd1);
87 87 __opnfiles__[1] = fd1;
88 88 }
89 89 else
90 90 {
91 91 // uartopenandconfig(uart1,uartparitynone | uart8bits | uartonestop,230400,PA9,PA10,-1,-1);
92 92 uartopenandconfig(uart1,uartparitynone | uart8bits | uartonestop,115200,PA9,PA10,-1,-1);
93 93 }
94 94 }
95 95
96 96 void bsp_spi_init()
97 97 {
98 98 spiopenandconfig(spi1,spi8bits | spimaster |spiclkinhlow | spiclkfirstedge | spimsbfirst,4000000,DAC_DIN,ADC_DOUT1,ADC_SCLK,-1);
99 99 }
100 100
101 101
102 102 void bsp_iic_init()
103 103 {
104 104
105 105 }
106 106
107 107 void bsp_SD_init()
108 108 {
109 109
110 110 }
111 111
112 112 void vs10XXclearXCS(){}
113 113 void vs10XXsetXCS(){}
114 114 int vs10XXDREQ()
115 115 {
116 116 return 1;
117 117 }
118 118
119 119
120 120 void bsppowersdcard(char onoff) //always ON
121 121 {
122 122
123 123 }
124 124
125 125 char bspsdcardpresent()
126 126 {
127 127 return 0;
128 128 }
129 129
130 130 char bspsdcardwriteprotected()
131 131 {
132 132 return 0;
133 133 }
134 134
135 135 void bspsdcardselect(char YESNO)
136 136 {
137 137
138 138 }
139 139
140 140
141 141
142 142
143 143
@@ -1,92 +1,92
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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
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
29 29
30 30 #define __MAX_OPENED_FILES__ 32
31 31 #define __FS_ROOT_SIZE__ 32
32 32
33 33 #define LED1 PD9
34 34 #define LED2 PD8
35 35 #define LED3 PB15
36 36
37 37 #define DAC_CS PA1
38 38 #define DAC_DIN PA7
39 39
40 40 #define ADC_MODE0 PA2
41 41 #define ADC_MODE1 PA3
42 42 #define ADC_FSYNC PA4
43 43 #define ADC_SCLK PA5
44 44 #define ADC_DOUT1 PA6
45 45
46 46 #define ADC_SYNC PB10
47 47 #define ADC_CLKDIV PB11
48 48
49 49
50 50 extern float VREF0;
51 51
52 52 extern uint32_t currentCpuFreq;
53 53
54 54 extern int bsp_init();
55 55
56 56 extern void bsp_GPIO_init();
57 57 extern void bsp_uart_init();
58 58 extern void bsp_iic_init();
59 59 extern void bsp_spi_init();
60 60 extern void bsp_SD_init();
61 61
62 62 /* VS1053 */
63 63 extern void clearXCS();
64 64 extern void setXCS();
65 65 extern int vs10XXDREQ();
66 66
67 67 /* SD CARD */
68 68 void bsppowersdcard(char onoff);
69 69 char bspsdcardpresent();
70 70 void bspsdcardselect(char YESNO);
71 71 char bspsdcardwriteprotected();
72 72
73 73 #endif
74 74
75 75
76 76
77 77
78 78
79 79
80 80
81 81
82 82
83 83
84 84
85 85
86 86
87 87
88 88
89 89
90 90
91 91
92 92
@@ -1,523 +1,524
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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
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 #include <core.h>
32 32 #include <terminal.h>
33 33
34 34 uint32_t OSC0 =8000000;
35 35 uint32_t INTOSC =16000000;
36 36 uint32_t RTCOSC =32768;
37 37 uint32_t currentCpuFreq=0;
38 38 extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__];
39 39
40 40 LCD_IF_t lcdIF0={
41 41 .init = &bsp_FSMC_init,
42 42 .writereg = &bsp_lcd0_write_reg,
43 43 .readreg = &bsp_lcd0_read_reg,
44 44 .writeGRAM = &bsp_lcd0_writeGRAM,
45 45 .readGRAM = &bsp_lcd0_readGRAM
46 46 };
47 47
48 48 LCD_t lcd0={
49 49 .interface = &lcdIF0,
50 50 .init = &ili9328init,
51 51 .paint = &ili9328paint,
52 52 .paintText = &ili9328paintText,
53 53 .paintFilRect = &ili9328paintFilRect,
54 54 .refreshenable = &ili9328refreshenable,
55 55 .width= 240,
56 56 .height = 320
57 57 };
58 58
59 59 terminal_t terminal0;
60 60
61 61 volatile uint8_t* lcd0_CMD=(volatile uint8_t*) 0x60000000;
62 62 volatile uint8_t* lcd0_DATA=(volatile uint8_t*)(0x61FFFFF0);
63 63
64 64 float VREF0 =(float)3.3;
65 65 volatile vs10XXDev audioCodec0;
66 66
67 67 sdcardDev sdcard2;
68 68 blkdevice sdcard2blkdev;
69 69 dikpartition sdcard2Part1;
70 70 FAT32fs sdcard2FAT32part1;
71 71 dikpartition sdcard2Part2;
72 72 FAT32fs sdcard2FAT32part2;
73 73 dikpartition sdcard2Part3;
74 74 FAT32fs sdcard2FAT32part3;
75 75 dikpartition sdcard2Part4;
76 76 FAT32fs sdcard2FAT32part4;
77 77
78 78 int bsp_init()
79 79 {
80 80 int i=0;
81 81 for(i=0;i<__MAX_OPENED_FILES__;i++)
82 82 {
83 83 __opnfiles__[i] = NULL;
84 84 }
85 85 bsp_GPIO_init();
86 86 bsp_uart_init();
87 87 bsp_iic_init();
88 88 bsp_FSMC_init();
89 89 bsp_GTerm_init();
90 90 bsp_spi_init();
91 91 bsp_SD_init();
92 92 bsp_Audio_init();
93 93 printf("\r=====================\n\r");
94 94 printf( "=====================\n\r");
95 95 printf(BSP);
96 96 printf(" initialised\n\r");
97 97 printf( "=====================\n\r");
98 98 return 1;
99 99 }
100 100
101 101 void bsp_GPIO_init()
102 102 {
103 103 gpio_t GPIO_Out_init_List[]={LED1,LED2,LCD_RESET,LCD_BACKL,VS1053xCS,VS1053xDCS,VS1053xRESET,SDCARD2CS};
104 104 for(int i=0;i<8;i++)
105 105 {
106 106 gpio_t GPIO_init = gpioopen(GPIO_Out_init_List[i]);
107 107 GPIO_init |= gpiohighspeed | gpiooutdir | gpiopushpulltype;
108 108 gpiosetconfig(&GPIO_init);
109 109 }
110 110 gpio_t GPIO_In_init_List[]={VS1053DREQ,SDCARD2CD,BP3};
111 111 for(int i=0;i<3;i++)
112 112 {
113 113 gpio_t GPIO_init = gpioopen(GPIO_In_init_List[i]);
114 114 GPIO_init |= gpiohighspeed | gpioindir;
115 115 gpiosetconfig(&GPIO_init);
116 116 }
117 117 gpioclr(VS1053xRESET);
118 118 gpioset(VS1053xCS);
119 119 gpioset(VS1053xDCS);
120 120 gpioset(SDCARD2CS);
121 121 gpioclr(LCD_RESET);
122 122 gpioclr(LCD_BACKL);
123 123 }
124 124
125 125 void bsp_uart_init()
126 126 {
127 127 // if(__opnfiles__[1]==NULL)
128 128 // {
129 129 // //uart_t* uart1 = (uart_t*)malloc(sizeof(uart_t));
130 130 // streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice));
131 131 // uart_t uart = uartopenandconfig(uart3,uartparitynone | uart8bits | uartonestop,115200,PD8,PD9,-1,-1);
132 132 // uartmkstreamdev(uart,fd1);
133 133 // __opnfiles__[1] = fd1;
134 134 // }
135 135 // else
136 136 // {
137 137 // uartopenandconfig(uart3,uartparitynone | uart8bits | uartonestop,115200,PD8,PD9,-1,-1);
138 138 // }
139 139 }
140 140
141 141 /*
142 142 D0 PD14 D1 PD15 D2 PD0 D3 PD1 D4 PE7
143 143 D5 PE8 D6 PE9 D7 PE10
144 144 A20 PE4 = RS FSMC_NE1 PD7 CS FSMC_NWE PD5 W/S
145 145 FSMC_NOE PD4 RD
146 146 */
147 147
148 148 int bsp_FSMC_init()
149 149 {
150 150 #define GPIOGETPORT(gpio) ((GPIO_TypeDef*)(((((uint32_t)gpio) & (uint32_t)0x0000FF00)*(uint32_t)4) + (uint32_t)GPIOA))
151 151 #define GPIOPORTNUM(gpio) (((uint32_t)(gpio) & (uint32_t)0x0000FF00)>>(uint32_t)8)
152 152
153 153 gpio_t LCD_DBxList[]={PD14,PD15,PD0,PD1,PE7,PE8,PE9,PE10\
154 154 ,PD4,PD5,PD7,PE4};
155 155 for(int i=0;i<12;i++)
156 156 {
157 157 gpio_t LCD_DBx = gpioopen(LCD_DBxList[i]);
158 158 LCD_DBx |= gpiohighspeed | gpioaf | gpiopushpulltype | gpionopulltype;
159 159 gpiosetconfig(&LCD_DBx);
160 160 GPIO_PinAFConfig(GPIOGETPORT(LCD_DBx), (uint8_t)(LCD_DBx & 0xF), GPIO_AF_FSMC);
161 161 }
162 162
163 163 FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure;
164 164 FSMC_NORSRAMTimingInitTypeDef p;
165 165
166 166 /* Enable FSMC clock */
167 167 RCC_AHB3PeriphClockCmd(RCC_AHB3Periph_FSMC, ENABLE);
168 168
169 169 /*-- FSMC Configuration ------------------------------------------------------*/
170 170 /*----------------------- SRAM Bank 3 ----------------------------------------*/
171 171 /* FSMC_Bank1_NORSRAM4 configuration */
172 172 //p.FSMC_AddressSetupTime = 5;
173 173 //p.FSMC_AddressSetupTime = 1;
174 174 p.FSMC_AddressSetupTime = 3;
175 175 p.FSMC_AddressHoldTime = 3;
176 176 //p.FSMC_DataSetupTime = 9;
177 177 //ili9328 -> data setup time > 10ns
178 178 p.FSMC_DataSetupTime = 1;
179 179 if(getCpuFreq()>100*1000*1000)
180 180 p.FSMC_DataSetupTime = 2;// 11;
181 181 p.FSMC_BusTurnAroundDuration = 0;
182 182 p.FSMC_CLKDivision = 0;
183 183 p.FSMC_DataLatency = 0;
184 184 //ili9328 -> data hold time > 15ns
185 185 if(getCpuFreq()>66*1000*1000)
186 186 p.FSMC_DataLatency = 1;
187 187 p.FSMC_AccessMode = FSMC_AccessMode_A;
188 188
189 189 FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM1;
190 190 FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;
191 191 FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM;
192 192 FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_8b;
193 193 FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable;
194 194 FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable;
195 195 FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;
196 196 FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable;
197 197 FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;
198 198 FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable;
199 199 FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable;
200 200 FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable;
201 201 FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;
202 202 FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p;
203 203 FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p;
204 204
205 205 FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure);
206 206
207 207 FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM1, ENABLE);
208 208 gpioset(LCD_RESET);
209 209 gpioclr(LCD_RESET);
210 210 delay_100us(500);
211 211 gpioset(LCD_RESET);
212 212 delay_100us(500);
213 213 lcd0.init(&lcd0);
214 214 gpioset(LCD_BACKL);
215 215 return 1;
216 216 }
217 217
218 218 void bsp_spi_init()
219 219 {
220 220 gpio_t VSSPI_DBxList[]={VS1053SCK,VS1053MOSI,VS1053MISO};
221 221 for(int i=0;i<3;i++)
222 222 {
223 223 gpio_t SPI_DBx = gpioopen(VSSPI_DBxList[i]);
224 224 SPI_DBx |= gpiohighspeed | gpioaf | gpiopushpulltype | gpionopulltype;
225 225 gpiosetconfig(&SPI_DBx);
226 226 GPIO_PinAFConfig(GPIOGETPORT(SPI_DBx), (uint8_t)(SPI_DBx & 0xF), GPIO_AF_SPI1);
227 227 }
228 228 spiopenandconfig(VS1053SPI,spi8bits|spimaster|spimsbfirst,2*1000*1000,VS1053MOSI,VS1053MISO,VS1053SCK,-1);
229 229
230 230 gpio_t SDSPI_DBxList[]={SDCARD2SCK,SDCARD2MOSI,SDCARD2MISO};
231 231 for(int i=0;i<3;i++)
232 232 {
233 233 gpio_t SPI_DBx = gpioopen(SDSPI_DBxList[i]);
234 234 SPI_DBx |= gpiohighspeed | gpioaf | gpiopushpulltype | gpionopulltype;
235 235 gpiosetconfig(&SPI_DBx);
236 236 GPIO_PinAFConfig(GPIOGETPORT(SPI_DBx), (uint8_t)(SPI_DBx & 0xF), GPIO_AF_SPI3);
237 237 }
238 238 spiopenandconfig(SDCARD2SPI,spi8bits|spimaster|spimsbfirst,400*1000,SDCARD2MOSI,SDCARD2MISO,SDCARD2SCK,-1);
239 239
240 240 }
241 241
242 242
243 243 void bsp_iic_init()
244 244 {
245 245 // i2copenandconfig(i2c2,0,10000,PF0,PF1);
246 246 }
247 247
248 248
249 249 void bsp_Audio_init()
250 250 {
251 251 vs10XXopen(&audioCodec0,VS1053SPI,vs1052setXCS,vs1052setRST,vs1052setXDCS,vs10XXDREQ);
252 252 if(audioCodec0.VERSION!=UNKNOWN)
253 253 {
254 254 printf("detected Audio codec ");
255 255 switch (audioCodec0.VERSION) {
256 256 case VS1001:
257 257 printf("VS1001\n");
258 258 break;
259 259 case VS1011:
260 260 printf("VS1011\n");
261 261 break;
262 262 case VS1002:
263 263 printf("VS1002\n");
264 264 break;
265 265 case VS1003:
266 266 printf("VS1003\n");
267 267 break;
268 268 case VS1053:
269 269 printf("VS1053\n");
270 270 break;
271 271 case VS1033:
272 272 printf("VS1033\n");
273 273 break;
274 274 case VS1103:
275 275 printf("VS1103\n");
276 276 break;
277 277 default:
278 278 printf("Unknown device\n");
279 279 break;
280 280 }
281 281 }
282 282 }
283 283
284 284 void bsp_SD_init()
285 285 {
286 286 if(bspsdcardpresent())
287 287 {
288 288 sdcardspimake(&sdcard2,(UHANDLE)SDCARD2SPI,spigetnc,spiputnc,spisetspeed,spigetspeed);
289 289 sdcardspimakeblkdev(&sdcard2blkdev,&sdcard2,bspsdcardselect,bsppowersdcard,bspsdcardpresent,bspsdcardwriteprotected);
290 290 if(sdcard2blkdev.initialize(&sdcard2blkdev)!=STA_NOINIT)
291 291 {
292 292 if(mbropen(&sdcard2blkdev,&sdcard2Part1,1)==MBRnoErr)
293 293 {
294 294 if(FATnoErr!=fat32open(&sdcard2FAT32part1,&sdcard2Part1))
295 295 printf("Can't open fat32 partition 1\n");
296 296 }
297 297 else
298 298 {
299 299 printf("Can't open or read MBR\n");
300 300 }
301
301 delay_100us(10000);
302 302 if(mbropen(&sdcard2blkdev,&sdcard2Part2,2)==MBRnoErr)
303 303 {
304 304 if(FATnoErr!=fat32open(&sdcard2FAT32part2,&sdcard2Part2))
305 305 printf("Can't open fat32 partition 2\n");
306 306 }
307 307 else
308 308 {
309 309 printf("Can't open or read MBR\n");
310 310 }
311
311 delay_100us(10000);
312 312 if(mbropen(&sdcard2blkdev,&sdcard2Part3,3)==MBRnoErr)
313 313 {
314 314 if(FATnoErr!=fat32open(&sdcard2FAT32part3,&sdcard2Part3))
315 315 printf("Can't open fat32 partition 3\n");
316 316 }
317 317 else
318 318 {
319 319 printf("Can't open or read MBR\n");
320 320 }
321
321 delay_100us(10000);
322 322 if(mbropen(&sdcard2blkdev,&sdcard2Part4,4)==MBRnoErr)
323 323 {
324 324 if(FATnoErr!=fat32open(&sdcard2FAT32part4,&sdcard2Part4))
325 325 printf("Can't open fat32 partition 4\n");
326 326 }
327 327 else
328 328 {
329 329 printf("Can't open or read MBR\n");
330 330 }
331 331 }
332 332 else
333 333 {
334 334 printf("Can't initialize SDCARD\n");
335 335 }
336 336 }
337 delay_100us(20000);
337 338 }
338 339
339 340 void vs1052setXCS(char val)
340 341 {
341 342 gpiosetval(VS1053xCS,(int)val);
342 343 }
343 344
344 345 void vs1052setXDCS(char val)
345 346 {
346 347 //gpiosetval(LED1,(int)val);
347 348 gpiosetval(VS1053xDCS,(int)val);
348 349 }
349 350
350 351 void vs1052setRST(char val)
351 352 {
352 353 if(val)
353 354 gpioset(VS1053xRESET);
354 355 else
355 356 gpioclr(VS1053xRESET);
356 357 }
357 358
358 359 int vs10XXDREQ()
359 360 {
360 361 return gpiogetval(VS1053DREQ);
361 362 }
362 363
363 364
364 365 void bsppowersdcard(char onoff) //always ON
365 366 {
366 367
367 368 }
368 369
369 370 char bspsdcardpresent()
370 371 {
371 372 return gpiogetval(SDCARD2CD);
372 373 }
373 374
374 375 char bspsdcardwriteprotected()
375 376 {
376 377 return 0;
377 378 }
378 379
379 380 void bspsdcardselect(char YESNO)
380 381 {
381 382 // gpiosetval(LED1,(int)YESNO);
382 383 if(YESNO)
383 384 gpioclr(SDCARD2CS);
384 385 else
385 386 gpioset(SDCARD2CS);
386 387 }
387 388
388 389
389 390 void bsp_lcd0_write_reg(uint32_t reg,uint32_t data)
390 391 {
391 392 uint8_t* pt8 = (uint8_t*)(void*)&reg;
392 393 #if __BYTE_ORDER__==__ORDER_BIG_ENDIAN__
393 394 *lcd0_CMD=pt8[3];
394 395 *lcd0_CMD=pt8[2];
395 396 pt8 = (uint8_t*)(void*)&data;
396 397 *lcd0_DATA=pt8[3];
397 398 *lcd0_DATA=pt8[2];
398 399 #else
399 400 *lcd0_CMD=pt8[1];
400 401 *lcd0_CMD=pt8[0];
401 402 pt8 = (uint8_t*)(void*)&data;
402 403 *lcd0_DATA=pt8[1];
403 404 *lcd0_DATA=pt8[0];
404 405 #endif
405 406
406 407 }
407 408
408 409 uint32_t bsp_lcd0_read_reg(uint32_t reg)
409 410 {
410 411 uint8_t* pt8 = (uint8_t*)(void*)&reg;
411 412 uint32_t DATA=0;
412 413 #if __BYTE_ORDER__==__ORDER_BIG_ENDIAN__
413 414 *lcd0_CMD=pt8[3];
414 415 *lcd0_CMD=pt8[2];
415 416 pt8 = (uint8_t*)(void*)&DATA;
416 417 pt8[3]=*lcd0_DATA;
417 418 pt8[2]=*lcd0_DATA;
418 419 #else
419 420
420 421 *lcd0_CMD=pt8[1];
421 422 *lcd0_CMD=pt8[0];
422 423 pt8 = (uint8_t*)(void*)&DATA;
423 424 pt8[1]=*lcd0_DATA;
424 425 pt8[0]=*lcd0_DATA;
425 426 #endif
426 427
427 428 return DATA;
428 429 }
429 430
430 431 void bsp_lcd0_writeGRAM(void* buffer,uint32_t count)
431 432 {
432 433 uint32_t reg =ILI9328_REGISTER_WRITEDATATOGRAM;
433 434 uint8_t* pt8 = (uint8_t*)(void*)&reg;
434 435 #if __BYTE_ORDER__==__ORDER_BIG_ENDIAN__
435 436 *lcd0_CMD=pt8[3];
436 437 *lcd0_CMD=pt8[2];
437 438 pt8 = (uint8_t*)(void*)buffer;
438 439 for(int i=0;i<(int)count;i++)
439 440 {
440 441 *lcd0_DATA=pt8[(2*i) +1];
441 442 *lcd0_DATA=pt8[2*i];
442 443 }
443 444 #else
444 445
445 446 *lcd0_CMD=pt8[1];
446 447 *lcd0_CMD=pt8[0];
447 448 pt8 = (uint8_t*)(void*)buffer;
448 449 for(int i=0;i<(int)count;i++)
449 450 {
450 451
451 452 *lcd0_DATA=pt8[(2*i) +1];
452 453 *lcd0_DATA=pt8[2*i];
453 454 }
454 455 #endif
455 456 }
456 457
457 458 void bsp_lcd0_readGRAM(void* buffer,uint32_t count)
458 459 {
459 460 // uint32_t reg =ILI9328_REGISTER_WRITEDATATOGRAM;
460 461 // int8_t* pt8 = (int8_t*)(void*)&reg;
461 462 #if __BYTE_ORDER__==__ORDER_BIG_ENDIAN__
462 463 *lcd0_CMD=pt8[3];
463 464 *lcd0_CMD=pt8[2];
464 465 pt8 = (uint8_t*)(void*)buffer;
465 466 for(int i=0;i<(int)count;i++)
466 467 {
467 468 pt8[(2*i) +1]=*lcd0_DATA;
468 469 __asm__("nop");
469 470 __asm__("nop");
470 471 __asm__("nop");
471 472 __asm__("nop");
472 473 __asm__("nop");
473 474 pt8[2*i]=*lcd0_DATA;
474 475 }
475 476 #else
476 477 // lcd0_CMD=pt8[1];
477 478 // lcd0_CMD=pt8[0];
478 479 // pt8 = (int8_t*)(void*)buffer;
479 480 // for(int i=0;i<(int)count;i++)
480 481 // {
481 482 // pt8[(2*i) +1]=*lcd0_DATA;
482 483 // __asm__("nop");
483 484 // __asm__("nop");
484 485 // __asm__("nop");
485 486 // __asm__("nop");
486 487 // __asm__("nop");
487 488 // pt8[2*i]=*lcd0_DATA;
488 489 //pt8[(2*i) +1]=(uint8_t)0;
489 490 //pt8[(2*i)]=(uint8_t)0;
490 491 // }
491 492 #endif
492 493 }
493 494
494 495 void bsp_GTerm_init()
495 496 {
496 497 if(__opnfiles__[1]==NULL)
497 498 {
498 499 streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice));
499 terminal_init(&terminal0 ,&lcd0,&ComicSansMS_18,fd1);
500 terminal_init(&terminal0 ,&lcd0,&ComicSansMS_8,fd1);
500 501 __opnfiles__[1] = fd1;
501 502 }
502 503 else
503 504 {
504 505
505 506 }
506 507 }
507 508
508 509
509 510
510 511
511 512
512 513
513 514
514 515
515 516
516 517
517 518
518 519
519 520
520 521
521 522
522 523
523 524
@@ -1,133 +1,133
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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
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 <spi.h>
29 29 #include <ili9328.h>
30 30 #include <genericLCD_Controler.h>
31 31 #include <sdcard-spi.h>
32 32 #include <sdcard.h>
33 33 #include <mbr.h>
34 34 #include <VS10XX.h>
35 35 #include <fat32.h>
36 36
37 37 #define __MAX_OPENED_FILES__ 4
38 38 #define __FS_ROOT_SIZE__ 4
39 39
40 40
41 41 #define LED1 PC15
42 42 #define LED2 PC14
43 43
44 44 #define BP3 PA0
45 45
46 46 #define LCD_RESET PD10
47 47 #define LCD_BACKL PE11
48 48
49 49 #define VS1053SPI spi1
50 50 #define VS1053xCS PA3
51 51 #define VS1053xRESET PA2
52 52 #define VS1053xDCS PA4
53 53 #define VS1053DREQ PA1
54 54 #define VS1053MISO PA6
55 55 #define VS1053MOSI PA7
56 56 #define VS1053SCK PA5
57 57
58 58
59 59
60 60 #define SDCARD2SPI spi3
61 61 #define SDCARD2CS PB8
62 62 #define SDCARD2CD PB9
63 63 #define SDCARD2MISO PB4
64 64 #define SDCARD2MOSI PB5
65 65 #define SDCARD2SCK PB3
66 66
67 67 extern float VREF0;
68 68
69 69 extern uint32_t currentCpuFreq;
70 70 extern LCD_t lcd0;
71 71
72 72 extern volatile vs10XXDev audioCodec0;
73 73
74 74 extern sdcardDev sdcard2;
75 75 extern blkdevice sdcard2blkdev;
76 76 extern dikpartition sdcard2Part1;
77 77 extern FAT32fs sdcard2FAT32part1;
78 78 extern dikpartition sdcard2Part2;
79 79 extern FAT32fs sdcard2FAT32part2;
80 80 extern dikpartition sdcard2Part3;
81 81 extern FAT32fs sdcard2FAT32part3;
82 82 extern dikpartition sdcard2Part4;
83 83 extern FAT32fs sdcard2FAT32part4;
84 84
85 85 extern int bsp_init();
86 86
87 87 extern void bsp_GPIO_init();
88 88 extern void bsp_uart_init();
89 89 extern void bsp_iic_init();
90 90 extern void bsp_spi_init();
91 91 extern void bsp_SD_init();
92 92 extern void bsp_Audio_init();
93 93 extern void bsp_GTerm_init();
94 94 extern int bsp_FSMC_init();
95 95
96 96 /* VS1053 */
97 97 extern void vs1052setXCS(char val);
98 98 extern void vs1052setXDCS(char val);
99 99 extern void vs1052setRST(char val);
100 100 extern int vs10XXDREQ();
101 101
102 102 /* SD CARD */
103 103 void bsppowersdcard(char onoff);
104 104 char bspsdcardpresent();
105 105 void bspsdcardselect(char YESNO);
106 106 char bspsdcardwriteprotected();
107 107
108 108
109 109 void bsp_lcd0_write_reg(uint32_t reg,uint32_t data);
110 110 uint32_t bsp_lcd0_read_reg(uint32_t reg);
111 111 void bsp_lcd0_writeGRAM(void *buffer, uint32_t count);
112 112 void bsp_lcd0_readGRAM(void *buffer, uint32_t count);
113 113
114 114 #endif
115 115
116 116
117 117
118 118
119 119
120 120
121 121
122 122
123 123
124 124
125 125
126 126
127 127
128 128
129 129
130 130
131 131
132 132
133 133
@@ -1,282 +1,283
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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
21 21 -------------------------------------------------------------------------------*/
22 22 #include "bsp.h"
23 23 #include <streamdevices.h>
24 24 #include <malloc.h>
25 25 #include <stdio.h>
26 26
27 27
28 28 uint32_t OSC0 =8000000;
29 29 uint32_t INTOSC =16000000;
30 30 uint32_t RTCOSC =32768;
31 31 uint32_t currentCpuFreq=0;
32 32 extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__];
33 33
34 34
35 35 LCD_IF_t lcdIF0={
36 36 .init = &SDLCD_init,
37 37 .writereg = &SDLCD_writereg,
38 38 .readreg = &SDLCD_readreg,
39 .writeGRAM = &SDLCD_writeGRAM,
40 .readGRAM = &SDLCD_readGRAM
39 .writeGRAM = &SDLCD_writeGRAM_16bpp,
40 .readGRAM = &SDLCD_readGRAM_16bpp
41 41 };
42 42
43 43 LCD_t lcd0={
44 44 .interface = &lcdIF0,
45 45 .init = &ili9328init,
46 46 .paint = &ili9328paint,
47 47 .paintText = &ili9328paintText,
48 48 .paintFilRect = &ili9328paintFilRect,
49 49 .refreshenable = &ili9328refreshenable,
50 50 .width= 240,
51 51 .height = 320
52 52 };
53 53
54 54 terminal_t terminal0;
55 55
56 56 volatile int8_t* lcd0_CMD=(volatile int8_t*) 0x60000000;
57 57 volatile int8_t* lcd0_DATA=(volatile int8_t*)(0x61FFFFF0);
58 58
59 59 float VREF0 =(float)3.3;
60 60 volatile vs10XXDev audioCodec0;
61 61
62 62 sdcardDev sdcard2;
63 63 blkdevice sdcard2blkdev;
64 64 dikpartition sdcard2Part1;
65 65 FAT32fs sdcard2FAT32part1;
66 66 dikpartition sdcard2Part2;
67 67 FAT32fs sdcard2FAT32part2;
68 68 dikpartition sdcard2Part3;
69 69 FAT32fs sdcard2FAT32part3;
70 70 dikpartition sdcard2Part4;
71 71 FAT32fs sdcard2FAT32part4;
72 72
73 73 int bsp_init()
74 74 {
75 75 int i=0;
76 76 for(i=0;i<__MAX_OPENED_FILES__;i++)
77 77 {
78 78 __opnfiles__[i] = NULL;
79 79 }
80 80 bsp_GPIO_init();
81 81 bsp_uart_init();
82 82 bsp_iic_init();
83 83 bsp_FSMC_init();
84 84 bsp_GTerm_init();
85 85 bsp_spi_init();
86 86 bsp_SD_init();
87 87 bsp_Audio_init();
88 88 printf("\r=====================\n\r");
89 89 printf( "=====================\n\r");
90 90 printf(BSP);
91 91 printf(" initialised\n\r");
92 92 printf( "=====================\n\r");
93 93 return 1;
94 94 }
95 95
96 96 void bsp_GPIO_init()
97 97 {
98 98
99 99 }
100 100
101 101 void bsp_uart_init()
102 102 {
103 103
104 104 }
105 105
106 106 /*
107 107 D0 PD14 D1 PD15 D2 PD0 D3 PD1 D4 PE7
108 108 D5 PE8 D6 PE9 D7 PE10
109 109 A20 PE4 = RS FSMC_NE1 PD7 CS FSMC_NWE PD5 W/S
110 110 FSMC_NOE PD4 RD
111 111 */
112 112
113 113 int bsp_FSMC_init()
114 114 {
115 115
116 116 return 1;
117 117 }
118 118
119 119 void bsp_spi_init()
120 120 {
121 121
122 122 }
123 123
124 124
125 125 void bsp_iic_init()
126 126 {
127 127
128 128 }
129 129
130 130
131 131 void bsp_Audio_init()
132 132 {
133 133
134 134 }
135 135
136 136 void bsp_SD_init()
137 137 {
138 138
139 139 }
140 140
141 141 void vs1052setXCS(char val)
142 142 {
143 143 }
144 144
145 145 void vs1052setXDCS(char val)
146 146 {
147 147 }
148 148
149 149 void vs1052setRST(char val)
150 150 {
151 151 }
152 152
153 153 int vs10XXDREQ()
154 154 {
155 155 return 1;
156 156 }
157 157
158 158
159 159 void bsppowersdcard(char onoff) //always ON
160 160 {
161 161
162 162 }
163 163
164 164 char bspsdcardpresent()
165 165 {
166 166 return 1;
167 167 }
168 168
169 169 char bspsdcardwriteprotected()
170 170 {
171 171 return 0;
172 172 }
173 173
174 174 void bspsdcardselect(char YESNO)
175 175 {
176 176
177 177 }
178 178
179 179
180 180 void bsp_lcd0_write_reg(uint32_t reg,uint32_t data)
181 181 {
182 182
183 183 }
184 184
185 185 uint32_t bsp_lcd0_read_reg(uint32_t reg)
186 186 {
187 187 return 0;
188 188 }
189 189
190 190 void bsp_lcd0_writeGRAM(void* buffer,uint32_t count)
191 191 {
192 192
193 193 }
194 194
195 195 void bsp_lcd0_readGRAM(void* buffer,uint32_t count)
196 196 {
197 197
198 198 }
199 199
200 200 void bsp_GTerm_init()
201 201 {
202 202 SDLCD_mkscreen(240,320,16,LCDILI9328);
203 203
204 204 if(__opnfiles__[1]==NULL)
205 205 {
206 206 streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice));
207 207 terminal_init(&terminal0 ,&lcd0,&ComicSansMS_18,fd1);
208 lcd0.paintFilRect(&lcd0,0,0,240,320,0,0,0x0f0f);
208 209 __opnfiles__[1] = fd1;
209 210 }
210 211 else
211 212 {
212 213
213 214 }
214 215 }
215 216
216 217
217 218
218 219
219 220
220 221
221 222
222 223 void putpixel(SDL_Surface *surface, int x, int y, Uint32 pixel)
223 224 {
224 225 int bpp = surface->format->BytesPerPixel;
225 226 /* Here p is the address to the pixel we want to set */
226 227 Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;
227 228 switch(bpp) {
228 229 case 1:
229 230 *p = pixel;
230 231 break;
231 232 case 2:
232 233 *(Uint16 *)p = pixel;
233 234 break;
234 235 case 3:
235 236 if(SDL_BYTEORDER == SDL_BIG_ENDIAN) {
236 237 p[0] = (pixel >> 16) & 0xff;
237 238 p[1] = (pixel >> 8) & 0xff;
238 239 p[2] = pixel & 0xff;
239 240 } else {
240 241 p[0] = pixel & 0xff;
241 242 p[1] = (pixel >> 8) & 0xff;
242 243 p[2] = (pixel >> 16) & 0xff;
243 244 }
244 245 break;
245 246 case 4:
246 247 *(Uint32 *)p = pixel;
247 248 break;
248 249 }
249 250 }
250 251
251 252 Uint32 getpixel(SDL_Surface *surface, int x, int y)
252 253 {
253 254 int bpp = surface->format->BytesPerPixel;
254 255 /* Here p is the address to the pixel we want to retrieve */
255 256 Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;
256 257 switch(bpp) {
257 258 case 1:
258 259 return *p;
259 260 case 2:
260 261 return *(Uint16 *)p;
261 262 case 3:
262 263 if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
263 264 return p[0] << 16 | p[1] << 8 | p[2];
264 265 else
265 266 return p[0] | p[1] << 8 | p[2] << 16;
266 267 case 4:
267 268 return *(Uint32 *)p;
268 269 default:
269 270 return 0;
270 271 }
271 272 /* shouldn’t happen, but avoids warnings */
272 273 }
273 274
274 275
275 276
276 277
277 278
278 279
279 280
280 281
281 282
282 283
@@ -1,139 +1,139
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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
21 21 -------------------------------------------------------------------------------*/
22 22 #ifndef BSP_H
23 23 #define BSP_H
24 24 #include <gpio.h>
25 25 #include <spi.h>
26 26 #include <ili9328.h>
27 27 #include <genericLCD_Controler.h>
28 28 #include <sdcard-spi.h>
29 29 #include <terminal.h>
30 30 #include <sdcard.h>
31 31 #include <mbr.h>
32 32 #include <VS10XX.h>
33 33 #include <fat32.h>
34 34 #include <SDL.h>
35 35 #include <stdint.h>
36 36 #include <SDLCD.h>
37 37
38 38
39 39 #define __MAX_OPENED_FILES__ 4
40 40 #define __FS_ROOT_SIZE__ 4
41 41
42 42
43 43 #define LED1 PC15
44 44 #define LED2 PC14
45 45
46 46 #define BP3 PA0
47 47
48 48 #define LCD_RESET PD10
49 49 #define LCD_BACKL PE11
50 50
51 51 #define VS1053SPI spi1
52 52 #define VS1053xCS PA3
53 53 #define VS1053xRESET PA2
54 54 #define VS1053xDCS PA4
55 55 #define VS1053DREQ PA1
56 56 #define VS1053MISO PA6
57 57 #define VS1053MOSI PA7
58 58 #define VS1053SCK PA5
59 59
60 60
61 61
62 62 #define SDCARD2SPI spi3
63 63 #define SDCARD2CS PB8
64 64 #define SDCARD2CD PB9
65 65 #define SDCARD2MISO PB4
66 66 #define SDCARD2MOSI PB5
67 67 #define SDCARD2SCK PB3
68 68
69 69 extern float VREF0;
70 70
71 71 extern uint32_t currentCpuFreq;
72 72 extern LCD_t lcd0;
73 73
74 74 extern volatile vs10XXDev audioCodec0;
75 75
76 76 extern sdcardDev sdcard2;
77 77 extern blkdevice sdcard2blkdev;
78 78 extern dikpartition sdcard2Part1;
79 79 extern FAT32fs sdcard2FAT32part1;
80 80 extern dikpartition sdcard2Part2;
81 81 extern FAT32fs sdcard2FAT32part2;
82 82 extern dikpartition sdcard2Part3;
83 83 extern FAT32fs sdcard2FAT32part3;
84 84 extern dikpartition sdcard2Part4;
85 85 extern FAT32fs sdcard2FAT32part4;
86 86
87 87 extern int bsp_init();
88 88
89 89 extern void bsp_GPIO_init();
90 90 extern void bsp_uart_init();
91 91 extern void bsp_iic_init();
92 92 extern void bsp_spi_init();
93 93 extern void bsp_SD_init();
94 94 extern void bsp_Audio_init();
95 95 extern void bsp_GTerm_init();
96 96 extern int bsp_FSMC_init();
97 97
98 98 /* VS1053 */
99 99 extern void vs1052setXCS(char val);
100 100 extern void vs1052setXDCS(char val);
101 101 extern void vs1052setRST(char val);
102 102 extern int vs10XXDREQ();
103 103
104 104 /* SD CARD */
105 105 void bsppowersdcard(char onoff);
106 106 char bspsdcardpresent();
107 107 void bspsdcardselect(char YESNO);
108 108 char bspsdcardwriteprotected();
109 109
110 110
111 111 void bsp_lcd0_write_reg(uint32_t reg,uint32_t data);
112 112 uint32_t bsp_lcd0_read_reg(uint32_t reg);
113 113 void bsp_lcd0_writeGRAM(void *buffer, uint32_t count);
114 114 void bsp_lcd0_readGRAM(void *buffer, uint32_t count);
115 115
116 116
117 117 extern void putpixel(SDL_Surface *surface, int x, int y, Uint32 pixel);
118 118 extern Uint32 getpixel(SDL_Surface *surface, int x, int y);
119 119
120 120 #endif
121 121
122 122
123 123
124 124
125 125
126 126
127 127
128 128
129 129
130 130
131 131
132 132
133 133
134 134
135 135
136 136
137 137
138 138
139 139
@@ -1,140 +1,140
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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
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 <i2c.h>
29 29
30 30 uint32_t OSC0 =8000000;
31 31 uint32_t INTOSC =16000000;
32 32 uint32_t RTCOSC =32768;
33 33 uint32_t currentCpuFreq=0;
34 34 extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__];
35 35
36 36 float VREF0 =(float)3.3;
37 37
38 38 int bsp_init()
39 39 {
40 40 int i=0;
41 41 for(i=0;i<32;i++)
42 42 {
43 43 __opnfiles__[i] = NULL;
44 44 }
45 45 bsp_GPIO_init();
46 46 bsp_uart_init();
47 47 bsp_iic_init();
48 48 printf("\r================================================================\n\r");
49 49 printf("================================================================\n\r");
50 50 printf(BSP);
51 51 printf(" initialised\n\r");
52 52 printf("================================================================\n\r");
53 53 return 1;
54 54 }
55 55
56 56 void bsp_GPIO_init()
57 57 {
58 58 gpio_t gpio1 = gpioopen(PD12);//gpioopen(LED1); //PD9 D=> 0x0300 9 => 0x0009
59 59 gpio_t gpio2 = gpioopen(PD13);//gpioopen(LED2);
60 60 gpio_t gpio3 = gpioopen(PD14);//gpioopen(LED2);
61 61 gpio_t gpio4 = gpioopen(PD15);//gpioopen(LED2);
62 62 gpio_t dacRst=gpioopen(PD4);
63 63 gpiosetspeed(&gpio1,gpiohighspeed);
64 64 gpiosetspeed(&gpio2,gpiohighspeed);
65 65 gpiosetspeed(&gpio3,gpiohighspeed);
66 66 gpiosetspeed(&gpio4,gpiohighspeed);
67 67 gpiosetspeed(&dacRst,gpiohighspeed);
68 68 gpiosetdir(&gpio1,gpiooutdir);
69 69 gpiosetdir(&gpio3,gpiooutdir);
70 70 gpiosetdir(&gpio2,gpiooutdir);
71 71 gpiosetdir(&gpio4,gpiooutdir);
72 72 gpiosetdir(&dacRst,gpiooutdir);
73 73 gpioset(dacRst);
74 74 }
75 75
76 76 void bsp_uart_init()
77 77 {
78 78 if(__opnfiles__[1]==NULL)
79 79 {
80 80 //uart_t* uart1 = (uart_t*)malloc(sizeof(uart_t));
81 81 streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice));
82 82 uart_t uart = uartopenandconfig(uart3,uartparitynone | uart8bits | uartonestop,115200,PB10,PB11,-1,-1);
83 83 uartmkstreamdev(uart,fd1);
84 84 __opnfiles__[1] = fd1;
85 85 }
86 86 else
87 87 {
88 88 uartopenandconfig(uart3,uartparitynone | uart8bits | uartonestop,115200,PB10,PB11,-1,-1);
89 89 }
90 90 }
91 91
92 92 void bsp_spi_init()
93 93 {
94 94
95 95 }
96 96
97 97
98 98 void bsp_iic_init()
99 99 {
100 100 i2copenandconfig(i2c1,0,400000,PB9,PB6);
101 101 i2copenandconfig(i2c3,0,400000,PC9,PA8);
102 102 }
103 103
104 104 void bsp_SD_init()
105 105 {
106 106
107 107 }
108 108
109 109 void vs10XXclearXCS(){}
110 110 void vs10XXsetXCS(){}
111 111 int vs10XXDREQ()
112 112 {
113 113 return 1;
114 114 }
115 115
116 116
117 117 void bsppowersdcard(char onoff) //always ON
118 118 {
119 119
120 120 }
121 121
122 122 char bspsdcardpresent()
123 123 {
124 124 return 0;
125 125 }
126 126
127 127 char bspsdcardwriteprotected()
128 128 {
129 129 return 0;
130 130 }
131 131
132 132 void bspsdcardselect(char YESNO)
133 133 {
134 134
135 135 }
136 136
137 137
138 138
139 139
140 140
@@ -1,87 +1,87
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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
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
29 29 #define __MAX_OPENED_FILES__ 32
30 30 #define __FS_ROOT_SIZE__ 32
31 31 /*
32 32 #ifndef PD8
33 33 #define PD8
34 34 #endif
35 35 #ifndef PD9
36 36 #define PD9
37 37 #endif
38 38 */
39 39
40 40 #define LED1 PD12
41 41 #define LED2 PD13
42 42 #define LED3 PD14
43 43 #define LED4 PD15
44 44
45 45 extern float VREF0;
46 46
47 47 extern uint32_t currentCpuFreq;
48 48
49 49 extern int bsp_init();
50 50
51 51 extern void bsp_GPIO_init();
52 52 extern void bsp_uart_init();
53 53 extern void bsp_iic_init();
54 54 extern void bsp_spi_init();
55 55 extern void bsp_SD_init();
56 56
57 57 /* VS1053 */
58 58 extern void clearXCS();
59 59 extern void setXCS();
60 60 extern int vs10XXDREQ();
61 61
62 62 /* SD CARD */
63 63 void bsppowersdcard(char onoff);
64 64 char bspsdcardpresent();
65 65 void bspsdcardselect(char YESNO);
66 66 char bspsdcardwriteprotected();
67 67
68 68 #endif
69 69
70 70
71 71
72 72
73 73
74 74
75 75
76 76
77 77
78 78
79 79
80 80
81 81
82 82
83 83
84 84
85 85
86 86
87 87
@@ -1,311 +1,311
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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
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 <stm32f4xx_gpio.h>
31 31 #include <stm32f4xx_rcc.h>
32 32 #include <core.h>
33 33
34 34 uint32_t OSC0 =8000000;
35 35 uint32_t INTOSC =16000000;
36 36 uint32_t RTCOSC =32768;
37 37 uint32_t currentCpuFreq=0;
38 38 extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__];
39 39
40 40 float VREF0 =(float)3.3;
41 41
42 42 LCD_IF_t lcdIF0={
43 43 .init = &bsp_FSMC_init,
44 44 .writereg = &bsp_lcd0_write_reg,
45 45 .readreg = &bsp_lcd0_read_reg,
46 46 .writeGRAM = &bsp_lcd0_writeGRAM,
47 47 .readGRAM = &bsp_lcd0_readGRAM
48 48 };
49 49
50 50 LCD_t lcd0={
51 51 .interface = &lcdIF0,
52 52 .init = &ssd2119init,
53 53 .paint = &ssd2119paint,
54 54 .paintText = &ssd2119paintText,
55 55 .paintFilRect = &ssd2119paintFilRect,
56 56 .refreshenable = &ssd2119refreshenable,
57 57 .width= 320,
58 58 .height = 240
59 59 };
60 60
61 61
62 62 volatile int16_t* lcd0_CMD=(volatile int16_t*) 0x60000000;
63 63 volatile int16_t* lcd0_DATA=(volatile int16_t*)(0x60FFFFF0);
64 64
65 65 int bsp_init()
66 66 {
67 67 int i=0;
68 68 for(i=0;i<32;i++)
69 69 {
70 70 __opnfiles__[i] = NULL;
71 71 }
72 72 bsp_GPIO_init();
73 73 bsp_uart_init();
74 74 bsp_FSMC_init();
75 75 printf("\r================================================================\n\r");
76 76 printf("================================================================\n\r");
77 77 printf(BSP);
78 78 printf(" initialised\n\r");
79 79 printf("================================================================\n\r");
80 80 return 1;
81 81 }
82 82
83 83 void bsp_GPIO_init()
84 84 {
85 85 gpio_t gpio1 = gpioopen(PD12);//gpioopen(LED1); //PD9 D=> 0x0300 9 => 0x0009
86 86 // gpio_t gpio2 = gpioopen(PD13);//gpioopen(LED2);
87 87 gpio_t gpio3 = gpioopen(PD14);//gpioopen(LED2);
88 88 // gpio_t gpio4 = gpioopen(PD15);//gpioopen(LED2);
89 89 gpiosetspeed(&gpio1,gpiohighspeed);
90 90 //gpiosetspeed(&gpio2,gpiohighspeed);
91 91 gpiosetspeed(&gpio3,gpiohighspeed);
92 92 //gpiosetspeed(&gpio4,gpiohighspeed);
93 93 gpiosetdir(&gpio1,gpiooutdir);
94 94 gpiosetdir(&gpio3,gpiooutdir);
95 95 // gpiosetdir(&gpio2,gpiooutdir);
96 96 //gpiosetdir(&gpio4,gpiooutdir);
97 97 }
98 98
99 99 void bsp_uart_init()
100 100 {
101 101 if(__opnfiles__[1]==NULL)
102 102 {
103 103 //uart_t* uart1 = (uart_t*)malloc(sizeof(uart_t));
104 104 streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice));
105 105 uart_t uart = uartopenandconfig(uart6,uartparitynone | uart8bits | uartonestop,9600,PC6,PC7,-1,-1);
106 106 uartmkstreamdev(uart,fd1);
107 107 __opnfiles__[1] = fd1; //stdo
108 108 __opnfiles__[0] = fd1; //stdi
109 109 }
110 110 else
111 111 {
112 112 uartopenandconfig(uart6,uartparitynone | uart8bits | uartonestop,9600,PC6,PC7,-1,-1);
113 113 }
114 114 }
115 115
116 116
117 117 /*
118 118 D0 PD14 D1 PD15 D2 PD0 D3 PD1 D4 PE7
119 119 D5 PE8 D6 PE9 D7 PE10 D8 PE11 D9 PE12
120 120 D10 PE13 D11 PE14 D12 PE15 D13 PD8 D14 PD9
121 121 D15 PD10
122 122 A0 PF0 = RS FSMC_NE3 PG10 CS FSMC_NWE PD5 W/S
123 123 FSMC_NOE PD4 RD
124 124 */
125 125 /*-- GPIOs Configuration -----------------------------------------------------*/
126 126 /*
127 127 +-------------------+--------------------+------------------+------------------+
128 128 + SRAM pins assignment +
129 129 +-------------------+--------------------+------------------+------------------+
130 130 | PD0 <-> FSMC_D2 | PE0 <-> FSMC_NBL0 | PF0 <-> FSMC_A0 | PG0 <-> FSMC_A10 |
131 131 | PD1 <-> FSMC_D3 | PE1 <-> FSMC_NBL1 | PF1 <-> FSMC_A1 | PG1 <-> FSMC_A11 |
132 132 | PD4 <-> FSMC_NOE | PE3 <-> FSMC_A19 | PF2 <-> FSMC_A2 | PG2 <-> FSMC_A12 |
133 133 | PD5 <-> FSMC_NWE | PE4 <-> FSMC_A20 | PF3 <-> FSMC_A3 | PG3 <-> FSMC_A13 |
134 134 | PD8 <-> FSMC_D13 | PE7 <-> FSMC_D4 | PF4 <-> FSMC_A4 | PG4 <-> FSMC_A14 |
135 135 | PD9 <-> FSMC_D14 | PE8 <-> FSMC_D5 | PF5 <-> FSMC_A5 | PG5 <-> FSMC_A15 |
136 136 | PD10 <-> FSMC_D15 | PE9 <-> FSMC_D6 | PF12 <-> FSMC_A6 | PG9 <-> FSMC_NE2 |
137 137 | PD11 <-> FSMC_A16 | PE10 <-> FSMC_D7 | PF13 <-> FSMC_A7 |------------------+
138 138 | PD12 <-> FSMC_A17 | PE11 <-> FSMC_D8 | PF14 <-> FSMC_A8 |
139 139 | PD13 <-> FSMC_A18 | PE12 <-> FSMC_D9 | PF15 <-> FSMC_A9 |
140 140 | PD14 <-> FSMC_D0 | PE13 <-> FSMC_D10 |------------------+
141 141 | PD15 <-> FSMC_D1 | PE14 <-> FSMC_D11 |
142 142 | | PE15 <-> FSMC_D12 |
143 143 +-------------------+--------------------+
144 144 */
145 145 int bsp_FSMC_init()
146 146 {
147 147 #define GPIOGETPORT(gpio) ((GPIO_TypeDef*)(((((uint32_t)gpio) & (uint32_t)0x0000FF00)*(uint32_t)4) + (uint32_t)GPIOA))
148 148 #define GPIOPORTNUM(gpio) (((uint32_t)(gpio) & (uint32_t)0x0000FF00)>>(uint32_t)8)
149 149
150 150 gpio_t gpio1 = gpioopen(LCD_RESET);
151 151 gpiosetspeed(&gpio1,gpiohighspeed);
152 152 gpiosetdir(&gpio1,gpiooutdir);
153 153 gpioclr(LCD_RESET);
154 154 gpio1 = gpioopen(LCD_CS);
155 155 gpiosetspeed(&gpio1,gpiohighspeed);
156 156 gpiosetdir(&gpio1,gpiooutdir);
157 157 gpioset(LCD_CS);
158 158 gpio_t LCD_DBxList[]={
159 159 PD0 ,PD1 ,PD4 ,PD5 ,PD8 ,PD9 ,PD10,PD14,PD15,
160 160 PE3 ,PE7 ,PE8 ,PE9 ,PE10,PE11,PE12,PE13,PE14,
161 161 PE15 };
162 162
163 163 for(int i=0;i<19;i++)
164 164 {
165 165 gpio_t LCD_DBx = gpioopen(LCD_DBxList[i]);
166 166 LCD_DBx |= gpiohighspeed | gpioaf | gpiopushpulltype | gpionopulltype;
167 167 gpiosetconfig(&LCD_DBx);
168 168 GPIO_PinAFConfig(GPIOGETPORT(LCD_DBx), (uint8_t)(LCD_DBx & 0xF), GPIO_AF_FSMC);
169 169 }
170 170
171 171 FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure;
172 172 FSMC_NORSRAMTimingInitTypeDef p;
173 173
174 174 /* Enable FSMC clock */
175 175 RCC_AHB3PeriphClockCmd(RCC_AHB3Periph_FSMC, ENABLE);
176 176
177 177 /*-- FSMC Configuration ------------------------------------------------------*/
178 178 /*----------------------- SRAM Bank 3 ----------------------------------------*/
179 179 /* FSMC_Bank1_NORSRAM3 configuration */
180 180 p.FSMC_AddressSetupTime = 1;
181 181 p.FSMC_AddressHoldTime = 0;
182 182 p.FSMC_DataSetupTime = getCpuFreq()/14545450 ;// 11;
183 183 p.FSMC_BusTurnAroundDuration = 0;
184 184 p.FSMC_CLKDivision = 0;
185 185 p.FSMC_DataLatency = 0;
186 186 p.FSMC_AccessMode = FSMC_AccessMode_A;
187 187 /* Color LCD configuration ------------------------------------
188 188 LCD configured as follow:
189 189 - Data/Address MUX = Disable
190 190 - Memory Type = SRAM
191 191 - Data Width = 16bit
192 192 - Write Operation = Enable
193 193 - Extended Mode = Enable
194 194 - Asynchronous Wait = Disable */
195 195
196 196 FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM3;
197 197 FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;
198 198 FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM;
199 199 FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;
200 200 FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable;
201 201 FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable;
202 202 FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;
203 203 FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable;
204 204 FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;
205 205 FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable;
206 206 FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable;
207 207 FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable;
208 208 FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;
209 209 FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p;
210 210 FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p;
211 211
212 212 FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure);
213 213
214 214 /* Enable FSMC NOR/SRAM Bank1 */
215 215 FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM3, ENABLE);
216 216 gpioset(LCD_RESET);
217 217 gpioclr(LCD_CS);
218 218 lcd0.init(&lcd0);
219 219 return 1;
220 220 }
221 221
222 222 void bsp_spi_init()
223 223 {
224 224
225 225 }
226 226
227 227
228 228 void bsp_iic_init()
229 229 {
230 230
231 231 }
232 232
233 233 void bsp_SD_init()
234 234 {
235 235
236 236 }
237 237
238 238
239 239 void vs10XXclearXCS(){}
240 240 void vs10XXsetXCS(){}
241 241 int vs10XXDREQ()
242 242 {
243 243 return 1;
244 244 }
245 245
246 246
247 247 void bsppowersdcard(char onoff) //always ON
248 248 {
249 249
250 250 }
251 251
252 252 char bspsdcardpresent()
253 253 {
254 254 return 0;
255 255 }
256 256
257 257 char bspsdcardwriteprotected()
258 258 {
259 259 return 0;
260 260 }
261 261
262 262 void bspsdcardselect(char YESNO)
263 263 {
264 264
265 265 }
266 266
267 267
268 268
269 269 void bsp_lcd0_write_reg(uint32_t reg,uint32_t data)
270 270 {
271 271 gpioclr(LCD_CS);
272 272 *lcd0_CMD=(uint16_t)reg;
273 273 *lcd0_DATA=(uint16_t)data;
274 274 gpioset(LCD_CS);
275 275 }
276 276
277 277 uint32_t bsp_lcd0_read_reg(uint32_t reg)
278 278 {
279 279 gpioclr(LCD_CS);
280 280 *lcd0_CMD=(uint16_t)reg;
281 281 uint32_t data=(uint16_t)*lcd0_DATA;
282 282 gpioset(LCD_CS);
283 283 return data;
284 284 }
285 285
286 286 void bsp_lcd0_writeGRAM(void* buffer,uint32_t count)
287 287 {
288 288 gpioclr(LCD_CS);
289 289 *lcd0_CMD=(uint16_t)ILI9328_REGISTER_WRITEDATATOGRAM;
290 290 uint16_t* castedBuff=(uint16_t*)buffer;
291 291 for(int i=0;i<(int)count;i++)
292 292 {
293 293 *lcd0_DATA=castedBuff[i];
294 294 }
295 295 gpioset(LCD_CS);
296 296 }
297 297
298 298 void bsp_lcd0_readGRAM(void* buffer,uint32_t count)
299 299 {
300 300 gpioclr(LCD_CS);
301 301 *lcd0_CMD=(uint16_t)ILI9328_REGISTER_WRITEDATATOGRAM;
302 302 uint16_t* castedBuff=(uint16_t*)buffer;
303 303 castedBuff[0]=*lcd0_DATA;
304 304 for(int i=0;i<(int)count;i++)
305 305 {
306 306 castedBuff[i]=*lcd0_DATA;
307 307 }
308 308 gpioset(LCD_CS);
309 309 }
310 310
311 311
@@ -1,108 +1,108
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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
21 21 -------------------------------------------------------------------------------*/
22 22 #ifndef BSP_H
23 23 #define BSP_H
24 24 #include <stm32f4xx.h>
25 25 #include <gpio.h>
26 26 #include <ili9328.h>
27 27 #include <ssd2119.h>
28 28 #include <genericLCD_Controler.h>
29 29 /*
30 30 #ifndef PD12
31 31 #define PD12
32 32 #endif
33 33 #ifndef PD13
34 34 #define PD13
35 35 #endif
36 36 */
37 37 #define __MAX_OPENED_FILES__ 32
38 38 #define __FS_ROOT_SIZE__ 32
39 39
40 40 #define LED1 PD12
41 41 #define LED2 PD13
42 42 #define LCD_RESET PD3
43 43 #define LCD_CS PD7
44 44 #define LCD_BACKL PD13
45 45
46 46 #define GREENLEDON (GPIOD->BSRRL = 1<<12)
47 47 #define ORANGELEDON (GPIOD->BSRRL = 1<<13)
48 48 #define REDLEDON (GPIOD->BSRRL = 1<<14)
49 49 #define BLUELEDON (GPIOD->BSRRL = 1<<15)
50 50
51 51 #define GREENLEDOFF (GPIOD->BSRRH = 1<<12)
52 52 #define ORANGELEDOFF (GPIOD->BSRRH = 1<<13)
53 53 #define REDLEDOFF (GPIOD->BSRRH = 1<<14)
54 54 #define BLUELEDOFF (GPIOD->BSRRH = 1<<15)
55 55
56 56 extern float VREF0;
57 57
58 58 extern uint32_t OSC0;
59 59 extern uint32_t currentCpuFreq;
60 60
61 61
62 62
63 63 extern int bsp_init();
64 64
65 65 extern void bsp_GPIO_init();
66 66 extern void bsp_uart_init();
67 67 extern void bsp_iic_init();
68 68 extern void bsp_spi_init();
69 69 extern void bsp_SD_init();
70 70 extern int bsp_FSMC_init();
71 71
72 72 /* VS1053 */
73 73 extern void clearXCS();
74 74 extern void setXCS();
75 75 extern int vs10XXDREQ();
76 76
77 77 /* SD CARD */
78 78 void bsppowersdcard(char onoff);
79 79 char bspsdcardpresent();
80 80 void bspsdcardselect(char YESNO);
81 81 char bspsdcardwriteprotected();
82 82
83 83
84 84 void bsp_lcd0_write_reg(uint32_t reg,uint32_t data);
85 85 uint32_t bsp_lcd0_read_reg(uint32_t reg);
86 86 void bsp_lcd0_writeGRAM(void *buffer, uint32_t count);
87 87 void bsp_lcd0_readGRAM(void *buffer, uint32_t count);
88 88
89 89 #endif
90 90
91 91
92 92
93 93
94 94
95 95
96 96
97 97
98 98
99 99
100 100
101 101
102 102
103 103
104 104
105 105
106 106
107 107
108 108
@@ -1,134 +1,134
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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
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 uint32_t OSC0 =8000000;
29 29 uint32_t INTOSC =16000000;
30 30 uint32_t RTCOSC =32768;
31 31 uint32_t currentCpuFreq=0;
32 32 extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__];
33 33
34 34 float VREF0 =(float)3.3;
35 35
36 36 int bsp_init()
37 37 {
38 38 int i=0;
39 39 for(i=0;i<32;i++)
40 40 {
41 41 __opnfiles__[i] = NULL;
42 42 }
43 43 bsp_GPIO_init();
44 44 bsp_uart_init();
45 45 printf("\r================================================================\n\r");
46 46 printf("================================================================\n\r");
47 47 printf(BSP);
48 48 printf(" initialised\n\r");
49 49 printf("================================================================\n\r");
50 50 return 1;
51 51 }
52 52
53 53 void bsp_GPIO_init()
54 54 {
55 55 gpio_t gpio1 = gpioopen(PD12);//gpioopen(LED1); //PD9 D=> 0x0300 9 => 0x0009
56 56 gpio_t gpio2 = gpioopen(PD13);//gpioopen(LED2);
57 57 gpio_t gpio3 = gpioopen(PD14);//gpioopen(LED2);
58 58 gpio_t gpio4 = gpioopen(PD15);//gpioopen(LED2);
59 59 gpiosetspeed(&gpio1,gpiohighspeed);
60 60 gpiosetspeed(&gpio2,gpiohighspeed);
61 61 gpiosetspeed(&gpio3,gpiohighspeed);
62 62 gpiosetspeed(&gpio4,gpiohighspeed);
63 63 gpiosetdir(&gpio1,gpiooutdir);
64 64 gpiosetdir(&gpio3,gpiooutdir);
65 65 gpiosetdir(&gpio2,gpiooutdir);
66 66 gpiosetdir(&gpio4,gpiooutdir);
67 67 }
68 68
69 69 void bsp_uart_init()
70 70 {
71 71 if(__opnfiles__[1]==NULL)
72 72 {
73 73 //uart_t* uart1 = (uart_t*)malloc(sizeof(uart_t));
74 74 streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice));
75 75 uart_t uart = uartopenandconfig(uart3,uartparitynone | uart8bits | uartonestop,19200,PB10,PB11,-1,-1);
76 76 uartmkstreamdev(uart,fd1);
77 77 __opnfiles__[1] = fd1; //stdo
78 78 __opnfiles__[0] = fd1; //stdi
79 79 }
80 80 else
81 81 {
82 82 uartopenandconfig(2,uartparitynone | uart8bits | uartonestop,115200,PB10,PB11,-1,-1);
83 83 }
84 84 }
85 85
86 86 void bsp_spi_init()
87 87 {
88 88
89 89 }
90 90
91 91
92 92 void bsp_iic_init()
93 93 {
94 94
95 95 }
96 96
97 97 void bsp_SD_init()
98 98 {
99 99
100 100 }
101 101
102 102
103 103 void vs10XXclearXCS(){}
104 104 void vs10XXsetXCS(){}
105 105 int vs10XXDREQ()
106 106 {
107 107 return 1;
108 108 }
109 109
110 110
111 111 void bsppowersdcard(char onoff) //always ON
112 112 {
113 113
114 114 }
115 115
116 116 char bspsdcardpresent()
117 117 {
118 118 return 0;
119 119 }
120 120
121 121 char bspsdcardwriteprotected()
122 122 {
123 123 return 0;
124 124 }
125 125
126 126 void bspsdcardselect(char YESNO)
127 127 {
128 128
129 129 }
130 130
131 131
132 132
133 133
134 134
@@ -1,95 +1,95
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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
21 21 -------------------------------------------------------------------------------*/
22 22 #ifndef BSP_H
23 23 #define BSP_H
24 24 #include <stm32f4xx.h>
25 25 #include <gpio.h>
26 26 /*
27 27 #ifndef PD12
28 28 #define PD12
29 29 #endif
30 30 #ifndef PD13
31 31 #define PD13
32 32 #endif
33 33 */
34 34 #define __MAX_OPENED_FILES__ 32
35 35 #define __FS_ROOT_SIZE__ 32
36 36
37 37 #define LED1 PD12
38 38 #define LED2 PD13
39 39
40 40 #define GREENLEDON (GPIOD->BSRRL = 1<<12)
41 41 #define ORANGELEDON (GPIOD->BSRRL = 1<<13)
42 42 #define REDLEDON (GPIOD->BSRRL = 1<<14)
43 43 #define BLUELEDON (GPIOD->BSRRL = 1<<15)
44 44
45 45 #define GREENLEDOFF (GPIOD->BSRRH = 1<<12)
46 46 #define ORANGELEDOFF (GPIOD->BSRRH = 1<<13)
47 47 #define REDLEDOFF (GPIOD->BSRRH = 1<<14)
48 48 #define BLUELEDOFF (GPIOD->BSRRH = 1<<15)
49 49
50 50 extern float VREF0;
51 51
52 52 extern uint32_t OSC0;
53 53 extern uint32_t currentCpuFreq;
54 54
55 55
56 56
57 57 extern int bsp_init();
58 58
59 59 extern void bsp_GPIO_init();
60 60 extern void bsp_uart_init();
61 61 extern void bsp_iic_init();
62 62 extern void bsp_spi_init();
63 63 extern void bsp_SD_init();
64 64
65 65 /* VS1053 */
66 66 extern void clearXCS();
67 67 extern void setXCS();
68 68 extern int vs10XXDREQ();
69 69
70 70 /* SD CARD */
71 71 void bsppowersdcard(char onoff);
72 72 char bspsdcardpresent();
73 73 void bspsdcardselect(char YESNO);
74 74 char bspsdcardwriteprotected();
75 75
76 76 #endif
77 77
78 78
79 79
80 80
81 81
82 82
83 83
84 84
85 85
86 86
87 87
88 88
89 89
90 90
91 91
92 92
93 93
94 94
95 95
@@ -1,345 +1,345
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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
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 #include <core.h>
32 32 #include <terminal.h>
33 33 uint32_t OSC0 =8000000;
34 34 uint32_t INTOSC =16000000;
35 35 uint32_t RTCOSC =32768;
36 36 uint32_t currentCpuFreq=0;
37 37 extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__];
38 38
39 39 LCD_IF_t lcdIF0={
40 40 .init = &bsp_FSMC_init,
41 41 .writereg = &bsp_lcd0_write_reg,
42 42 .readreg = &bsp_lcd0_read_reg,
43 43 .writeGRAM = &bsp_lcd0_writeGRAM,
44 44 .readGRAM = &bsp_lcd0_readGRAM
45 45 };
46 46
47 47 LCD_t lcd0={
48 48 .interface = &lcdIF0,
49 49 .init = &ili9328init,
50 50 .paint = &ili9328paint,
51 51 .paintText = &ili9328paintText,
52 52 .paintFilRect = &ili9328paintFilRect,
53 53 .refreshenable = &ili9328refreshenable,
54 54 .width= 240,
55 55 .height = 320
56 56 };
57 57
58 58 terminal_t terminal0;
59 59
60 60
61 61 volatile int16_t* lcd0_CMD=(volatile int16_t*) (0x60000000 | 0x08000000);
62 62 volatile int16_t* lcd0_DATA=((volatile int16_t*)(0x60000000 | 0x08000002));
63 63
64 64 float VREF0 =(float)3.3;
65 65
66 66 int bsp_init()
67 67 {
68 68 int i=0;
69 69 for(i=0;i<32;i++)
70 70 {
71 71 __opnfiles__[i] = NULL;
72 72 }
73 73 bsp_GPIO_init();
74 74 bsp_uart_init();
75 75 bsp_iic_init();
76 76 bsp_FSMC_init();
77 77 bsp_GTerm_init();
78 78 printf("\r=====================\n\r");
79 79 printf( "=====================\n\r");
80 80 printf(BSP);
81 81 printf(" initialised\n\r");
82 82 printf( "=====================\n\r");
83 83 return 1;
84 84 }
85 85
86 86 void bsp_GPIO_init()
87 87 {
88 88 gpio_t gpio1 = gpioopen(LED1);
89 89 gpio_t gpio2 = gpioopen(LED2);
90 90 gpio_t gpio3 = gpioopen(LED3);
91 91 gpiosetspeed(&gpio1,gpiohighspeed);
92 92 gpiosetspeed(&gpio2,gpiohighspeed);
93 93 gpiosetspeed(&gpio3,gpiohighspeed);
94 94 gpiosetdir(&gpio1,gpiooutdir);
95 95 gpiosetdir(&gpio2,gpiooutdir);
96 96 gpiosetdir(&gpio3,gpiooutdir);
97 97 }
98 98
99 99 void bsp_uart_init()
100 100 {
101 101 //if(__opnfiles__[1]==NULL)
102 102 //{
103 103 //uart_t* uart1 = (uart_t*)malloc(sizeof(uart_t));
104 104 // streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice));
105 105 // uart_t uart = uartopenandconfig(uart1,uartparitynone | uart8bits | uartonestop,115200,PA9,PA10,-1,-1);
106 106 //uartmkstreamdev(uart,fd1);
107 107 //__opnfiles__[1] = fd1;
108 108 //}
109 109 //else
110 110 //{
111 111 uartopenandconfig(0,uartparitynone | uart8bits | uartonestop,115200,PA9,PA10,-1,-1);
112 112 //}
113 113 }
114 114
115 115 /*
116 116 D0 PD14 D1 PD15 D2 PD0 D3 PD1 D4 PE7
117 117 D5 PE8 D6 PE9 D7 PE10 D8 PE11 D9 PE12
118 118 D10 PE13 D11 PE14 D12 PE15 D13 PD8 D14 PD9
119 119 D15 PD10
120 120 A0 PF0 = RS FSMC_NE3 PG10 CS FSMC_NWE PD5 W/S
121 121 FSMC_NOE PD4 RD
122 122 */
123 123 /*-- GPIOs Configuration -----------------------------------------------------*/
124 124 /*
125 125 +-------------------+--------------------+------------------+------------------+
126 126 + SRAM pins assignment +
127 127 +-------------------+--------------------+------------------+------------------+
128 128 | PD0 <-> FSMC_D2 | PE0 <-> FSMC_NBL0 | PF0 <-> FSMC_A0 | PG0 <-> FSMC_A10 |
129 129 | PD1 <-> FSMC_D3 | PE1 <-> FSMC_NBL1 | PF1 <-> FSMC_A1 | PG1 <-> FSMC_A11 |
130 130 | PD4 <-> FSMC_NOE | PE3 <-> FSMC_A19 | PF2 <-> FSMC_A2 | PG2 <-> FSMC_A12 |
131 131 | PD5 <-> FSMC_NWE | PE4 <-> FSMC_A20 | PF3 <-> FSMC_A3 | PG3 <-> FSMC_A13 |
132 132 | PD8 <-> FSMC_D13 | PE7 <-> FSMC_D4 | PF4 <-> FSMC_A4 | PG4 <-> FSMC_A14 |
133 133 | PD9 <-> FSMC_D14 | PE8 <-> FSMC_D5 | PF5 <-> FSMC_A5 | PG5 <-> FSMC_A15 |
134 134 | PD10 <-> FSMC_D15 | PE9 <-> FSMC_D6 | PF12 <-> FSMC_A6 | PG9 <-> FSMC_NE2 |
135 135 | PD11 <-> FSMC_A16 | PE10 <-> FSMC_D7 | PF13 <-> FSMC_A7 |------------------+
136 136 | PD12 <-> FSMC_A17 | PE11 <-> FSMC_D8 | PF14 <-> FSMC_A8 |
137 137 | PD13 <-> FSMC_A18 | PE12 <-> FSMC_D9 | PF15 <-> FSMC_A9 |
138 138 | PD14 <-> FSMC_D0 | PE13 <-> FSMC_D10 |------------------+
139 139 | PD15 <-> FSMC_D1 | PE14 <-> FSMC_D11 |
140 140 | | PE15 <-> FSMC_D12 |
141 141 +-------------------+--------------------+
142 142 */
143 143 int bsp_FSMC_init()
144 144 {
145 145 #define GPIOGETPORT(gpio) ((GPIO_TypeDef*)(((((uint32_t)gpio) & (uint32_t)0x0000FF00)*(uint32_t)4) + (uint32_t)GPIOA))
146 146 #define GPIOPORTNUM(gpio) (((uint32_t)(gpio) & (uint32_t)0x0000FF00)>>(uint32_t)8)
147 147
148 148 gpio_t LCD_DBxList[]={
149 149 PD0 ,PD1 ,PD4 ,PD5 ,PD8 ,PD9 ,PD10,PD11,PD12,PD13,PD14,PD15,
150 150 PE0 ,PE1 ,PE3 ,PE4 ,PE7 ,PE8 ,PE9 ,PE10,PE11,PE12,PE13,PE14,
151 151 PE15,PF0 ,PF1 ,PF2 ,PF3 ,PF4 ,PF5 ,PF12,PF13,PF14,PF15,PG0 ,
152 152 PG1 ,PG2 ,PG3 ,PG4 ,PG5 ,PG9 ,PG10
153 153 };
154 154
155 155 for(int i=0;i<43;i++)
156 156 {
157 157 gpio_t LCD_DBx = gpioopen(LCD_DBxList[i]);
158 158 LCD_DBx |= gpiohighspeed | gpioaf | gpiopushpulltype | gpionopulltype;
159 159 gpiosetconfig(&LCD_DBx);
160 160 GPIO_PinAFConfig(GPIOGETPORT(LCD_DBx), (uint8_t)(LCD_DBx & 0xF), GPIO_AF_FSMC);
161 161 }
162 162
163 163 FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure;
164 164 FSMC_NORSRAMTimingInitTypeDef p;
165 165
166 166 /* Enable FSMC clock */
167 167 RCC_AHB3PeriphClockCmd(RCC_AHB3Periph_FSMC, ENABLE);
168 168
169 169 /*-- FSMC Configuration ------------------------------------------------------*/
170 170 /*----------------------- SRAM Bank 3 ----------------------------------------*/
171 171 /* FSMC_Bank1_NORSRAM3 configuration */
172 172 p.FSMC_AddressSetupTime = 1;
173 173 p.FSMC_AddressHoldTime = 0;
174 174 p.FSMC_DataSetupTime = getCpuFreq()/14545450 ;// 11;
175 175 p.FSMC_BusTurnAroundDuration = 0;
176 176 p.FSMC_CLKDivision = 0;
177 177 p.FSMC_DataLatency = 0;
178 178 p.FSMC_AccessMode = FSMC_AccessMode_A;
179 179 /* Color LCD configuration ------------------------------------
180 180 LCD configured as follow:
181 181 - Data/Address MUX = Disable
182 182 - Memory Type = SRAM
183 183 - Data Width = 16bit
184 184 - Write Operation = Enable
185 185 - Extended Mode = Enable
186 186 - Asynchronous Wait = Disable */
187 187
188 188 FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM3;
189 189 FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;
190 190 FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM;
191 191 FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;
192 192 FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable;
193 193 FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable;
194 194 FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;
195 195 FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable;
196 196 FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;
197 197 FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable;
198 198 FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable;
199 199 FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable;
200 200 FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;
201 201 FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p;
202 202 FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p;
203 203
204 204 FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure);
205 205
206 206 /* Enable FSMC NOR/SRAM Bank1 */
207 207 FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM3, ENABLE);
208 208
209 209
210 210 p.FSMC_AddressSetupTime = getCpuFreq()/50000000;
211 211 p.FSMC_AddressHoldTime = 0;
212 212 p.FSMC_DataSetupTime = getCpuFreq()/25000000;
213 213 p.FSMC_BusTurnAroundDuration = 1;
214 214 p.FSMC_CLKDivision = 0;
215 215 p.FSMC_DataLatency = 0;
216 216 p.FSMC_AccessMode = FSMC_AccessMode_A;
217 217
218 218 FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM2;
219 219 FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;
220 220 FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_PSRAM;
221 221 FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;
222 222 FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable;
223 223 FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable;
224 224 FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;
225 225 FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable;
226 226 FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;
227 227 FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable;
228 228 FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable;
229 229 FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable;
230 230 FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;
231 231 FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p;
232 232 FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p;
233 233
234 234 FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure);
235 235
236 236 /*!< Enable FSMC Bank1_SRAM2 Bank */
237 237 FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM2, ENABLE);
238 238 lcd0.init(&lcd0);
239 239 return 1;
240 240 }
241 241
242 242 void bsp_spi_init()
243 243 {
244 244
245 245 }
246 246
247 247
248 248 void bsp_iic_init()
249 249 {
250 250 i2copenandconfig(i2c1,0,10000,PB9,PB6);
251 251 }
252 252
253 253 void bsp_SD_init()
254 254 {
255 255 gpio_t SDIO_DBxList[]={PC8 ,PC9 ,PC10 ,PC11 ,PC12,PD2};
256 256 for(int i=0;i<6;i++)
257 257 {
258 258 gpio_t SDIO_DBx = gpioopen(SDIO_DBxList[i]);
259 259 SDIO_DBx |= gpiohighspeed | gpioaf | gpiopushpulltype | gpionopulltype;
260 260 gpiosetconfig(&SDIO_DBx);
261 261 GPIO_PinAFConfig(GPIOGETPORT(SDIO_DBx), (uint8_t)(SDIO_DBx & 0xF), GPIO_AF_SDIO);
262 262 }
263 263 }
264 264
265 265 void vs10XXclearXCS(){}
266 266 void vs10XXsetXCS(){}
267 267 int vs10XXDREQ()
268 268 {
269 269 return 1;
270 270 }
271 271
272 272
273 273 void bsppowersdcard(char onoff) //always ON
274 274 {
275 275
276 276 }
277 277
278 278 char bspsdcardpresent()
279 279 {
280 280 return 0;
281 281 }
282 282
283 283 char bspsdcardwriteprotected()
284 284 {
285 285 return 0;
286 286 }
287 287
288 288 void bspsdcardselect(char YESNO)
289 289 {
290 290
291 291 }
292 292
293 293
294 294 void bsp_lcd0_write_reg(uint32_t reg,uint32_t data)
295 295 {
296 296 *lcd0_CMD=(uint16_t)reg;
297 297 *lcd0_DATA=(uint16_t)data;
298 298 }
299 299
300 300 uint32_t bsp_lcd0_read_reg(uint32_t reg)
301 301 {
302 302 *lcd0_CMD=(uint16_t)reg;
303 303 return (uint16_t)*lcd0_DATA;
304 304 }
305 305
306 306 void bsp_lcd0_writeGRAM(void* buffer,uint32_t count)
307 307 {
308 308 *lcd0_CMD=(uint16_t)ILI9328_REGISTER_WRITEDATATOGRAM;
309 309 uint16_t* castedBuff=(uint16_t*)buffer;
310 310 for(int i=0;i<(int)count;i++)
311 311 {
312 312 *lcd0_DATA=castedBuff[i];
313 313 }
314 314 }
315 315
316 316 void bsp_lcd0_readGRAM(void* buffer,uint32_t count)
317 317 {
318 318 *lcd0_CMD=(uint16_t)ILI9328_REGISTER_WRITEDATATOGRAM;
319 319 uint16_t* castedBuff=(uint16_t*)buffer;
320 320 castedBuff[0]=*lcd0_DATA;
321 321 for(int i=0;i<(int)count;i++)
322 322 {
323 323 castedBuff[i]=*lcd0_DATA;
324 324 }
325 325 }
326 326
327 327 void bsp_GTerm_init()
328 328 {
329 329 if(__opnfiles__[1]==NULL)
330 330 {
331 331 //uart_t* uart1 = (uart_t*)malloc(sizeof(uart_t));
332 332 streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice));
333 333
334 334 ili9328paintFilRect(&lcd0,0,0,240,320,0x7FFF,5,0);
335 335 terminal_init(&terminal0,&lcd0,&ComicSansMS_8,fd1);
336 336 __opnfiles__[1] = fd1;
337 337 }
338 338 else
339 339 {
340 340
341 341 }
342 342 }
343 343
344 344
345 345
@@ -1,94 +1,94
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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
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
35 35
36 36 #define LED1 PG6
37 37 #define LED2 PG8
38 38 #define LED3 PI9
39 39 #define LED4 PC7
40 40
41 41
42 42 extern float VREF0;
43 43
44 44 extern uint32_t currentCpuFreq;
45 45 extern LCD_t lcd0;
46 46
47 47
48 48 extern int bsp_init();
49 49
50 50 extern void bsp_GPIO_init();
51 51 extern void bsp_uart_init();
52 52 extern void bsp_iic_init();
53 53 extern void bsp_spi_init();
54 54 extern void bsp_SD_init();
55 55 extern void bsp_GTerm_init();
56 56 extern int bsp_FSMC_init();
57 57
58 58 /* VS1053 */
59 59 extern void clearXCS();
60 60 extern void setXCS();
61 61 extern int vs10XXDREQ();
62 62
63 63 /* SD CARD */
64 64 void bsppowersdcard(char onoff);
65 65 char bspsdcardpresent();
66 66 void bspsdcardselect(char YESNO);
67 67 char bspsdcardwriteprotected();
68 68
69 69
70 70 void bsp_lcd0_write_reg(uint32_t reg,uint32_t data);
71 71 uint32_t bsp_lcd0_read_reg(uint32_t reg);
72 72 void bsp_lcd0_writeGRAM(void *buffer, uint32_t count);
73 73 void bsp_lcd0_readGRAM(void *buffer, uint32_t count);
74 74
75 75 #endif
76 76
77 77
78 78
79 79
80 80
81 81
82 82
83 83
84 84
85 85
86 86
87 87
88 88
89 89
90 90
91 91
92 92
93 93
94 94
@@ -1,14 +1,14
1 1 TEMPLATE = app
2 2 CONFIG += cpu
3 3
4 4
5 5 UCMODEL=stm32f4
6 6 BSP = OPLAYER
7 7
8 DEFINES += CPUFREQ=180000000
8 DEFINES += CPUFREQ=10000000
9 9
10 10
11 11 SOURCES += \
12 12 main.c \
13 13 test_lcd.c
14 14
@@ -1,206 +1,207
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 <core.h>
8 8 #include <VS10XX.h>
9 9 #include <bsp.h>
10 10 #include <spi.h>
11 11 #include <sdcard.h>
12 12 #include <sdcard-spi.h>
13 13 #include <fat32.h>
14 14 #include <ucdirent.h>
15 15 #include <string.h>
16 16 #include <terminal.h>
17 17 #include <ili9328.h>
18 18
19 19
20 20 extern streamdevice* __opnfiles__[];
21 21 extern void test_Block_Move(LCD_t* LCD,int x,int y,int w,int h,int color);
22 22 char buffer[512];
23 23
24 24 void randBoxesDemo()
25 25 {
26 26 int16_t x,y,w,h,t,r;
27 27 x=rand()%240;
28 28 y=rand()%320;
29 29 w=rand()%(240-x);
30 30 if(x>y)
31 31 r=(rand()%(y))%(320-y);
32 32 else
33 33 r=(rand()%(x))%(240-x);
34 34 h=rand()%(320-y);
35 35 t=rand()%(10);
36 36 ili9328paintFilRect(&lcd0,x,y,w,h,rand(),t,rand());
37 37 //ili9328paintFilCirc(&lcd0,x,y,r,rand(),t,rand());
38 38 //delay_100us(10);
39 39 //for(volatile int i=0;i<(1024*2);i++);
40 40 }
41 41
42 42 void randTextDemo()
43 43 {
44 44 int16_t x,y,w,h,t,r;
45 45 char buf[2];
46 46 buf[1]='\0';
47 47 x=rand()%240;
48 48 y=rand()%320;
49 49 if(x>y)
50 50 r=(rand()%(y))%(320-y);
51 51 else
52 52 r=(rand()%(x))%(240-x);
53 53 h=rand()%(320-y);
54 54 buf[0]=rand()%(255);
55 55 //ili9328paintFilRect(&lcd0,x,y,w,h,rand(),t,rand());
56 56 ili9328paintText(&lcd0,buf,x,y,&ComicSansMS_18,rand());
57 57 //ili9328paintFilCirc(&lcd0,x,y,r,rand(),t,rand());
58 58 delay_100us(5000);
59 59 //for(volatile int i=0;i<(1024*2);i++);
60 60 }
61 61
62 62 void tryToplay2()
63 63 {
64 64
65 65 extern blkdevice sdcard2blkdev;
66 66 int i=0,l=0;
67 67
68 68 spisetspeed(audioCodec0.SPIdev,4000000);
69 69 printf("Streaming File\n");
70 70
71 71 //printf("New LBA=0x%X\n",nextLba);
72 72
73 73 while(sdcard2blkdev.read(&sdcard2blkdev,buffer,l++,1)==RES_OK)
74 74 {
75 75
76 76 for(i=0;i<512;i+=32)
77 77 {
78 78 vs10XXstream32bytes(&audioCodec0,buffer+i);
79 79 }
80 80 }
81 81 }
82 82
83 83 void playFile(ucdirent* file,FAT32fs* part)
84 84 {
85 85 extern volatile vs10XXDev audioCodec0;
86 86 char direntName[]=" \n";
87 87 uint32_t fileLba,nextLba;
88 88 int i=0;
89 89 fat32getdirentname(file,direntName);
90 90 gpioset(LCD_BACKL);
91 91 //printf("%s\n",direntName);
92 92 nextLba=fat32getdirentlba(file);
93 93 //printf("Streaming File\n");
94 94 gpioclr(LCD_BACKL);
95 95 do
96 96 {
97 97 fileLba = nextLba;
98 98 if(sdcard2FAT32part1.part->phy->read(part->part->phy,buffer,fileLba,1)==RES_OK)
99 99 {
100 100 for(i=0;i<512;i+=32)
101 101 {
102 102 vs10XXstream32bytes(&audioCodec0,buffer+i);
103 103 }
104 104 }
105 105 }while ((fat32nextsectorlba(part,fileLba,&nextLba)==DIRENT_noErr) && (!gpiogetval(BP3)));
106 106 vs10XXsoftReset(&audioCodec0);
107 107 while (gpiogetval(BP3))delay_100us(1000);
108 108 }
109 109
110 110 void playAllparts()
111 111 {
112 112 extern FAT32fs sdcard2FAT32part1,sdcard2FAT32part2,sdcard2FAT32part3,sdcard2FAT32part4;
113 113 ucdirent root;
114 114 if(DIRENT_noErr==fat32mkdirent(&sdcard2FAT32part1,&root))
115 115 {
116 116 printf("Reading on SDCARD2 part1\n");
117 117 if(DIRENT_noErr==fat32getrootfirstent(&root))
118 118 {
119 119 do{
120 120 playFile(&root,&sdcard2FAT32part1);
121 121 }while (DIRENT_noErr==fat32nextdirent(&root));
122 122 }
123 123 }
124 124 gpioset(LED2);
125 125 if(DIRENT_noErr==fat32mkdirent(&sdcard2FAT32part2,&root))
126 126 {
127 127 printf("Reading on SDCARD2 part2\n");
128 128 if(DIRENT_noErr==fat32getrootfirstent(&root))
129 129 {
130 130 do{
131 131 playFile(&root,&sdcard2FAT32part2);
132 132 }while (DIRENT_noErr==fat32nextdirent(&root));
133 133 }
134 134 }
135 135 }
136 136
137 137 int main()
138 138 {
139 delay_100us(30000);
139 140 int i=0;
140 141 int color=0;
141 142 for(i=0;i<240;i++)
142 143 {
143 144 if(i>(240/3))
144 145 {
145 146 color= (i<<5) + 0x1F;
146 147 }
147 148 else
148 149 {
149 150 color = i;
150 151 }
151 152 if(i>(2*240/3))
152 153 {
153 154 color= (i<<10) + 0x3FF;
154 155 }
155 156 lcd0.paintFilRect(&lcd0,i,0,1,100,0,0,color);
156 157 }
157 158 while(1)printf("test ");
158 159 // for(i=0;i<240;i++)
159 160 // {
160 161 // if(i>(240/3))
161 162 // {
162 163 // color= (i<<5) + 0x1F;
163 164 // }
164 165 // else
165 166 // {
166 167 // color = i;
167 168 // }
168 169 // if(i>(2*240/3))
169 170 // {
170 171 // color= (i<<10) + 0x3FF;
171 172 // }
172 173 // lcd0.paintFilRect(&lcd0,i,220,1,100,0,0,color);
173 174 // }
174 175 for(i=0;i<240;i++)
175 176 {
176 177 ili9328setFrame(&lcd0,i,0,1,100);
177 178 lcd0.interface->readGRAM(buffer,100);
178 179 lcd0.paint(&lcd0,buffer,i,200,1,100);
179 180 }
180 181 while(1);
181 182 }
182 183
183 184 int main2()
184 185 {
185 186 extern terminal_t terminal0;
186 187 extern volatile vs10XXDev audioCodec0;
187 188 lcd0.paintText(&lcd0,"hello",20,50,&ComicSansMS_18 ,0xF0F0);
188 189 while (1)
189 190 randTextDemo();
190 191 printf("Volume=0x%x\n",vs10XXcmdread(&audioCodec0,VSVOL));
191 192 vs10XXcmdwrite(&audioCodec0,VSCLOCKF,0x2000);
192 193 delay_100us(1000);
193 194 vs10XXcmdwrite(&audioCodec0,VSVOL,0x2020);
194 195 printf("VSCLOCKF=0x%x\n",vs10XXcmdread(&audioCodec0,VSCLOCKF));
195 196 printf("VSMODE=0x%x\n",vs10XXcmdread(&audioCodec0,VSMODE));
196 197 //terminal_clear(&terminal0);
197 198 gpioclr(LCD_BACKL);
198 199 playAllparts();
199 200 return 0;
200 201 }
201 202
202 203
203 204
204 205
205 206
206 207
@@ -1,55 +1,56
1 1 #include <stdio.h>
2 2 #include <fat32.h>
3 3 #include <gpio.h>
4 4 #include <uart.h>
5 5 #include <bsp.h>
6 6 #include <core.h>
7 7 #include <bsp.h>
8 8 #include <spi.h>
9 9 #include <fat32.h>
10 10 #include <ucdirent.h>
11 11 #include <string.h>
12 12 #include <unistd.h>
13 13 #include <terminal.h>
14 14 #include <stdarg.h>
15 15 #include <malloc.h>
16 16
17 17 extern streamdevice* __opnfiles__[];
18 18 extern void test_Block_Move(LCD_t* LCD,int x,int y,int w,int h,int color);
19 19 char buffer[512];
20 20
21 21 void streamdevicePrint(streamdevice* dev, const char* format,...)
22 22 {
23 23 char** str_buffer;
24 24 int i;
25 25 va_list ap;
26 26 va_start(ap,format);
27 27 vasprintf(str_buffer,format,ap);
28 28 va_end(ap);
29 29 i=strlen(*str_buffer);
30 30 dev->ops->write(dev,(void*)*str_buffer,1,i);
31 31 free(*str_buffer);
32 32 }
33 33
34 34 void lcd_print()
35 35 {
36 36 lcd0.paintFilRect(&lcd0,10,10,100,100,0,0,0x0F0F);
37 37 // __opnfiles__[1]->ops->write(__opnfiles__[1],(void*)"hello",1,5);
38 38 }
39 39
40 40 int libuc2_main_task()
41 41 {
42 42 char in[255];
43 43 lcd_print();
44 44 printf("hello world\n");
45 streamdevicePrint(__opnfiles__[1],"test Hello %d %f \n ",1234567,8.96);
45 streamdevicePrint(__opnfiles__[1],"test Hello %d %f \n",1234567,8.96);
46 lcd0.paintText(&lcd0,"A",10,100,&ComicSansMS_18,0x0);
46 47 // while (scanf("%c",in))
47 48 // {
48 sleep(3);
49 sleep(5);
49 50 // }
50 51 }
51 52
52 53
53 54
54 55
55 56
@@ -1,56 +1,56
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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
21 21 -------------------------------------------------------------------------------*/
22 22 #include <CS43L22.h>
23 23 #include <stdio.h>
24 24 #include <stddef.h>
25 25 #include <spi.h>
26 26
27 27 int cs43l22open(CS43L22_t* dev,i2c_t i2cdev, uint8_t A0)
28 28 {
29 29 if(dev != NULL)
30 30 {
31 31 dev->i2cdev=i2cdev;
32 32 dev->devAddress = CS43L22_I2C_ADDRESS | (A0 & 1);
33 33 return 1;
34 34 }
35 35 return -1;
36 36 }
37 37
38 38 uint8_t cs43l22getID(CS43L22_t* dev)
39 39 {
40 40 if(dev != NULL)
41 41 {
42 42 char DATA[]={CS43L22_MAP_ID};
43 43 i2cwrite(dev->i2cdev,dev->devAddress,DATA,1);
44 44 i2cread(dev->i2cdev,dev->devAddress,DATA,1);
45 45 return DATA[0];
46 46 }
47 47 return -1;
48 48 }
49 49
50 50
51 51
52 52
53 53
54 54
55 55
56 56
@@ -1,132 +1,132
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 #-- Mail : alexis.jeandet@gmail.com
20 #-- Mail : alexis.jeandet@member.fsf.org
21 21 #-------------------------------------------------------------------------------*/
22 22 #include <spi.h>
23 23 #include <VS10XX.h>
24 24 #include <core.h>
25 25 #include <stdio.h>
26 26 //#include <bsp.h>
27 27
28 28 void vs10XXopen(vs10XXDev *codec, spi_t dev, void (*setxCS)(char), void (*setxRST)(char), void (*setxDCS)(char), int (*getDREQ)())
29 29 {
30 30 codec->SPIdev = dev;
31 31 codec->setxCS = setxCS;
32 32 codec->setxDCS = setxDCS;
33 33 codec->setxRST = setxRST;
34 34 codec->getDREQ = getDREQ;
35 35 codec->setxDCS(1);
36 36 codec->setxCS(1);
37 37 codec->setxRST(0);
38 38 delay_100us(2);
39 39 codec->setxRST(1);
40 40 int status;
41 41 do{
42 42 status= vs10XXcmdread(codec,VSSTATUS);
43 43 }while (status==0xc);
44 44 printf("Status=0x%x\n",status);
45 45 status = (status>>4) & 0xF;
46 46 switch (status) {
47 47 case 0:
48 48 codec->VERSION = VS1001;
49 49 break;
50 50 case 1:
51 51 codec->VERSION = VS1011;
52 52 break;
53 53 case 2:
54 54 codec->VERSION = VS1002;
55 55 break;
56 56 case 3:
57 57 codec->VERSION = VS1003;
58 58 break;
59 59 case 4:
60 60 codec->VERSION = VS1053;
61 61 break;
62 62 case 5:
63 63 codec->VERSION = VS1033;
64 64 break;
65 65 case 7:
66 66 codec->VERSION = VS1103;
67 67 break;
68 68 default:
69 69 codec->VERSION = UNKNOWN;
70 70 break;
71 71 }
72 72 }
73 73
74 74 void vs10XXsoftreset(vs10XXDev* dev)
75 75 {
76 76 vs10XXcmdwrite(dev,VSMODE,(1<<2));
77 77 }
78 78
79 79 void vs10XXsetCansel(vs10XXDev* dev)
80 80 {
81 81 int mode=vs10XXcmdread(dev,VSMODE);
82 82 vs10XXcmdwrite(dev,VSMODE,mode|8);
83 83 }
84 84
85 85 void vs10XXsoftReset(vs10XXDev* dev)
86 86 {
87 87 int mode=vs10XXcmdread(dev,VSMODE);
88 88 vs10XXcmdwrite(dev,VSMODE,mode|4);
89 89 }
90 90
91 91 int vs10XXcanselAccepted(vs10XXDev* dev)
92 92 {
93 93 int mode=vs10XXcmdread(dev,VSMODE);
94 94 return ((mode & 8)!=8);
95 95 }
96 96
97 97 int vs10XXcmdread(vs10XXDev* dev,char address)
98 98 {
99 99 int result;
100 100 while(!dev->getDREQ());
101 101 dev->setxCS(0);
102 102 spiputw(dev->SPIdev,3);
103 103 spiputw(dev->SPIdev,address);
104 104 result = (0xFF00 & (spigetw(dev->SPIdev)<<8)) + (0xFF & spigetw(dev->SPIdev));
105 105 dev->setxCS(1);
106 106 return result;
107 107 }
108 108
109 109
110 110 void vs10XXcmdwrite(vs10XXDev* dev,char address,int value)
111 111 {
112 112 while(!dev->getDREQ());
113 113 dev->setxCS(0);
114 114 spiputw(dev->SPIdev,2<<8);
115 115 spiputw(dev->SPIdev,address);
116 116 spiputw(dev->SPIdev,value>>8);
117 117 spiputw(dev->SPIdev,value);
118 118 dev->setxCS(1);
119 119 }
120 120
121 121
122 122 void vs10XXstream32bytes(vs10XXDev* dev,char* buffer)
123 123 {
124 124 while(!dev->getDREQ());
125 125 dev->setxCS(1);
126 126 dev->setxDCS(0);
127 127 spiputnc(dev->SPIdev,buffer,32);
128 128 dev->setxDCS(1);
129 129
130 130 }
131 131
132 132
@@ -1,103 +1,103
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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
21 21 -------------------------------------------------------------------------------*/
22 22 #include <24LC0X.h>
23 23 #include <i2c.h>
24 24 #include <core.h>
25 25 /*
26 26 struct 24LC0X_str
27 27 {
28 28 i2cDev iicdev;
29 29 unsigned char devAddress;
30 30 unsigned char size;
31 31 };
32 32 */
33 33
34 34
35 35 void eeprom24lc0xopen(eeprom24lc0xDev* dev, i2c_t iicdev, unsigned char A0_A1_A2_val, unsigned int size)
36 36 {
37 37 dev->iicdev = iicdev;
38 38 dev->devAddress = 0x50 | (A0_A1_A2_val & 0x7);
39 39 if(size == 2048) dev->size = 2;
40 40 if(size == 1024) dev->size = 1;
41 41 }
42 42
43 43 void eeprom24lc0xpagewrite(eeprom24lc0xDev* dev,unsigned char address,unsigned char* page)
44 44 {
45 45 int cmdcnt=1,datacnt=8;
46 46 //i2cwrite(dev.iicdev,address,page)
47 47 //i2cwrite2(dev.iicdev,dev.devAddress,&address,&cmdcnt,page,&datacnt);
48 48 }
49 49
50 50
51 51 void eeprom24lc0xpageread(eeprom24lc0xDev* dev,unsigned char address,unsigned char* page)
52 52 {
53 53 int cmdcnt=1,datacnt=8;
54 54 /*i2cwrite(dev.iicdev,dev.devAddress,&address,&cmdcnt);
55 55 i2cread(dev.iicdev,dev.devAddress,page,&datacnt);*/
56 56 }
57 57
58 58 void eeprom24lc0xbytewrite(eeprom24lc0xDev* dev,unsigned char address,unsigned char data)
59 59 {
60 60 int cmdcnt=1,datacnt=1;
61 61 //i2cwrite2(dev.iicdev,dev.devAddress,&address,&cmdcnt,&data,&datacnt);
62 62 }
63 63
64 64
65 65 unsigned char eeprom24lc0xbyteread(eeprom24lc0xDev* dev,unsigned char address)
66 66 {
67 67 int cmdcnt=1,datacnt=1;
68 68 unsigned char data = 0;
69 69 /* i2cwrite(dev.iicdev,dev.devAddress,&address,&cmdcnt);
70 70 i2cread(dev.iicdev,dev.devAddress,&data,&datacnt);*/
71 71 return data;
72 72 }
73 73
74 74
75 75 void eeprom24lc0xreadn(eeprom24lc0xDev* dev,unsigned char address,unsigned char* data, unsigned int count)
76 76 {
77 77 int cmdcnt=1,datacnt=count;
78 78 /* i2cwrite(dev.iicdev,dev.devAddress,&address,&cmdcnt);
79 79 i2cread(dev.iicdev,dev.devAddress,data,&datacnt);*/
80 80
81 81 }
82 82
83 83 void eeprom24lc0xwriten(eeprom24lc0xDev* dev,unsigned char address,unsigned char* data, unsigned int count)
84 84 {
85 85 int cmdcnt=1,datacnt=8;
86 86 while(count >8)
87 87 {
88 88 cmdcnt=1;datacnt=8;
89 89 // while(i2noerr!=i2cwrite2(dev.iicdev,dev.devAddress,&address,&cmdcnt,data,&datacnt)){cmdcnt=1;datacnt=8;}
90 90 count-=8;
91 91 address+=8;
92 92 data+=8;
93 93 }
94 94 cmdcnt=1;datacnt=count;
95 95 // while(i2noerr!=i2cwrite2(dev.iicdev,dev.devAddress,&address,&cmdcnt,data,&datacnt)){cmdcnt=1;datacnt=count;}
96 96 }
97 97
98 98
99 99
100 100
101 101
102 102
103 103
@@ -1,136 +1,136
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the libuc, microcontroler library
3 3 -- Copyright (C) 2013, 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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
21 21 -------------------------------------------------------------------------------*/
22 22 #include <N25Q128.h>
23 23 #include <core.h>
24 24 #include <stdio.h>
25 25
26 26
27 27
28 28 void eepromN25Q128open(eepromN25Q128Dev *dev, spi_t spidev, void (*select)(int), void (*writeprotect)(int), void (*holdreset)(int))
29 29 {
30 30 dev->spidev = spidev;
31 31 dev->holdreset = holdreset;
32 32 dev->select = select;
33 33 dev->writeprotect = writeprotect;
34 34 }
35 35
36 36 void eepromN25Q128pagewrite(eepromN25Q128Dev* dev,uint32_t address,unsigned char* page)
37 37 {
38 38 int cmdcnt=1,datacnt=8;
39 39 }
40 40
41 41
42 42 void eepromN25Q128pageread(eepromN25Q128Dev* dev,uint32_t address,unsigned char* page)
43 43 {
44 44 int cmdcnt=1,datacnt=8;
45 45 }
46 46
47 47 void eepromN25Q128bytewrite(eepromN25Q128Dev* dev,uint32_t address,unsigned char data)
48 48 {
49 49 int cmdcnt=1,datacnt=1;
50 50 }
51 51
52 52
53 53 unsigned char eepromN25Q128byteread(eepromN25Q128Dev* dev,uint32_t address)
54 54 {
55 55 int cmdcnt=1,datacnt=1;
56 56 unsigned char data = 0;
57 57 return data;
58 58 }
59 59
60 60
61 61 void eepromN25Q128readn(eepromN25Q128Dev* dev,uint32_t address,unsigned char* data, unsigned int count)
62 62 {
63 63
64 64 char baddress[3];
65 65 baddress[0]=(char)0xFF&((address)>>16);
66 66 baddress[1]=(char)0xFF&((address)>>8);
67 67 baddress[2]=(char)0xFF&((address));
68 68 printf("about to read %d bytes\n\r",count);
69 69 if(dev->select!=NULL)dev->select(0);
70 70 spiputw(dev->spidev,N25Q128_READ);
71 71 spiputnc(dev->spidev,baddress,3);
72 72 spigetnc(dev->spidev,data,count);
73 73 if(dev->select!=NULL)dev->select(1);
74 74
75 75 }
76 76
77 77 void eepromN25Q128writen(eepromN25Q128Dev* dev,uint32_t address,unsigned char* data, unsigned int count)
78 78 {
79 79 char baddress[3];
80 80 if(dev->select!=NULL)dev->select(0);
81 81 for(int i=0;i<(count/N25Q128_PAGE_SZ);i++)
82 82 {
83 83 printf("about to send %d bytes\n\r",N25Q128_PAGE_SZ);
84 84 int index =i*N25Q128_PAGE_SZ;
85 85 baddress[0]=(char)0xFF&((address+index)>>16);
86 86 baddress[1]=(char)0xFF&((address+index)>>8);
87 87 baddress[2]=(char)0xFF&((address+index));
88 88 if(dev->select!=NULL)dev->select(0);
89 89 spiputw(dev->spidev,N25Q128_PP);
90 90 spiputnc(dev->spidev,baddress,3);
91 91 spiputnc(dev->spidev,data+(index),count);
92 92 if(dev->select!=NULL)
93 93 {
94 94 dev->select(1);
95 95 }
96 96 else {
97 97 while (!spitransactionfinished(dev->spidev));
98 98 }
99 99 }
100 100 int mod = count%N25Q128_PAGE_SZ;
101 101 if(mod)
102 102 {
103 103 baddress[0]=(char)0xFF&((address+(count-mod))>>16);
104 104 baddress[1]=(char)0xFF&((address+(count-mod))>>8);
105 105 baddress[2]=(char)0xFF&((address+(count-mod)));
106 106 printf("about to send %d bytes\n\r",mod);
107 107 if(dev->select!=NULL)dev->select(0);
108 108 spiputw(dev->spidev,N25Q128_PP);
109 109 spiputnc(dev->spidev,baddress,3);
110 110 spiputnc(dev->spidev,data+(count-mod),mod);
111 111 if(dev->select!=NULL)
112 112 {
113 113 dev->select(1);
114 114 }
115 115 else {
116 116 while (!spitransactionfinished(dev->spidev));
117 117 }
118 118
119 119 }
120 120
121 121 }
122 122
123 123
124 124 void eepromN25Q128enablewrite(eepromN25Q128Dev *dev)
125 125 {
126 126 if(dev->select!=NULL)dev->select(0);
127 127 spiputw(dev->spidev,N25Q128_WREN);
128 128 if(dev->select!=NULL)dev->select(1);
129 129
130 130 }
131 131
132 132
133 133
134 134
135 135
136 136
@@ -1,383 +1,383
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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
21 21 -------------------------------------------------------------------------------*/
22 22 #define FAT32_PRIVATE
23 23 #include <fat32.h>
24 24 #include <stdio.h>
25 25 #include <stdint.h>
26 26 #include <hexviewer.h>
27 27
28 28 char fat32buff[512]__attribute__ ((aligned (4)));
29 29 uint32_t lastSecAddrs=-1;
30 30 FAT32fs* lastFATFS=0;
31 31
32 32 int fat32open(FAT32fs* fs,dikpartition* part)
33 33 {
34 34 fs->valide = 0;
35 35 if(part->valide==0)return FATBadpart;
36 36 char sector[512];
37 37 fs->part = part;
38 38 if(!isFat32(fs->part->TypeCode))return FATBadpart;
39 39 if(fs->part->phy->read(fs->part->phy,sector,fs->part->LBABegin,1)!=RES_OK)return FATReadErr;
40 40 fs->BPB_BytsPerSec = fat32Ui8_2_Ui16(sector,BPB_BytsPerSecoff);
41 41 fs->BPB_RsvdSecCnt = fat32Ui8_2_Ui16(sector,BPB_RsvdSecCntoff);
42 42 fs->BPB_FATSz32 = fat32Ui8_2_Ui32(sector,BPB_FATSz32off);
43 43 fs->BPB_RootClus = fat32Ui8_2_Ui32(sector,BPB_RootClusoff);
44 44 fs->BPB_SecPerClus = sector[BPB_SecPerClusoff];
45 45 fs->BPB_NumFATs = sector[BPB_NumFATsoff];
46 46 fs->fat_begin_lba = (unsigned int)fs->part->LBABegin + (unsigned int)(unsigned short)fs->BPB_RsvdSecCnt;
47 47 fs->cluster_begin_lba = (unsigned int)fs->fat_begin_lba + ((unsigned int)fs->BPB_NumFATs * (unsigned int)fs->BPB_FATSz32 );
48 48 fs->valide=1;
49 49 return FATnoErr;
50 50 }
51 51
52 52
53 53 int fat32mkdirent(FAT32fs* fs,ucdirent* dirent)
54 54 {
55 55 if((fs==0) || (fs->valide==0)) return DIRENT_BabArg;
56 56 if(dirent==0) return DIRENT_BabArg;
57 57 dirent->fs = (UHANDLE)fs;
58 58 dirent->getrootfirstent = &fat32getrootfirstent;
59 59 dirent->nextdirent = &fat32nextdirent;
60 60 return DIRENT_noErr;
61 61 }
62 62
63 63
64 64 int fat32getrootfirstent(ucdirent* entry)
65 65 {
66 66 if(entry==0) return DIRENT_BabArg;
67 67 entry->CurrentSec = ((FAT32fs*)entry->fs)->cluster_begin_lba;
68 68 entry->Currententry = 0;
69 69 return fat32nextdirent(entry);
70 70 }
71 71
72 72
73 73 int fat32getVolName(FAT32fs* fs,char* Name)
74 74 {
75 75 if((fs==0) || (fs->valide==0)) return DIRENT_BabArg;
76 76 if(Name==0) return DIRENT_BabArg;
77 77 int i=0;
78 78 ucdirent entry;
79 79 if(DIRENT_noErr==fat32mkdirent(fs,&entry))
80 80 {
81 81 entry.CurrentSec = ((FAT32fs*)entry.fs)->cluster_begin_lba;
82 82 entry.Currententry = -1;
83 83 if(DIRENT_noErr!=fat32nextdirent(&entry))return DIRENT_ReadErr;
84 84 for(i=0;i<16;i++)
85 85 {
86 86 Name[i] = entry.DIR_Name[i];
87 87 }
88 88 return DIRENT_noErr;
89 89 }
90 90 return DIRENT_ReadErr;
91 91 }
92 92
93 93
94 94 int fat32enterdirent(ucdirent* currententry,ucdirent* firstentry)
95 95 {
96 96 if(firstentry==0) return DIRENT_BabArg;
97 97 if(currententry==0) return DIRENT_BabArg;
98 98 fat32mkdirent(((FAT32fs*)currententry->fs),firstentry);
99 99 firstentry->CurrentSec = fat32getdirentlba(currententry);
100 100 firstentry->Currententry = -1;
101 101 return fat32nextdirent(firstentry);
102 102 }
103 103
104 104
105 105 int fat32nextdirent(ucdirent* entry)
106 106 {
107 107 uint32_t n=0,res=DIRENT_noErr,k,j;
108 108 k=(0xFF&((signed char)entry->Currententry)+1)*32; /*Restart at last dir entry*/
109 109 j=entry->CurrentSec;// /*Restart at last sector*/
110 110 do
111 111 {
112 112 //printf("reading new secotr\n",k);
113 113 fat32sectorreadout(((FAT32fs*)entry->fs),j);
114 114 //printf("done\n",k);
115 115 /*512 Bytes per sector and 32 bytes per entry*/
116 116 for(k=k;k<(512);k+=32)
117 117 {
118 118 if((fat32buff[DIR_Nameoff+k]!=(char)0xE5)) /*0xE5 = free entry*/
119 119 {
120 120 //printf("Fount dir entry = %d, 0x%X\n",0xff & ((int)fat32buff[DIR_Nameoff+k]),0xff & ((int)fat32buff[DIR_Attroff+k]));
121 121 if(fat32buff[DIR_Nameoff+k]==(char)0)
122 122 {
123 123 //printf("end of directory reached\n",k);
124 124 return DIRENT_EndOfDir; /*0x00 = end of dir*/
125 125 }
126 126 else
127 127 {
128 128 uint8_t attribute=fat32buff[DIR_Attroff + k];
129 129 if( (attribute==ATTR_DIRECTORY)
130 130 ||(attribute==ATTR_ARCHIVE)
131 131 ||(attribute==ATTR_READ_ONLY)
132 132 ||(attribute==ATTR_READ_ONLY))
133 133 {
134 134 for(n=0;n<16;n++)entry->DIR_Name[n] = '\0';
135 135 for(n=0;n<11;n++)entry->DIR_Name[n] = fat32buff[n+DIR_Nameoff + k];
136 136 entry->DIR_Attr = attribute;
137 137 entry->DIR_CrtTimeTenth = (uint8_t)fat32buff[DIR_CrtTimeTenthoff + k];
138 138 entry->DIR_CrtTime = fat32extract16b(fat32buff,(DIR_CrtTimeoff + k));
139 139 entry->DIR_CrtDate = fat32extract16b(fat32buff,(DIR_CrtDateoff + k));
140 140 entry->DIR_LstAccDate = fat32extract16b(fat32buff,(DIR_LstAccDateoff + k));
141 141 entry->DIR_FstClusHI = fat32extract16b(fat32buff, (DIR_FstClusHIoff + k));
142 142 entry->DIR_WrtTime = fat32extract16b(fat32buff,(DIR_WrtTimeoff + k));
143 143 entry->DIR_FstClustLO = fat32extract16b(fat32buff, (DIR_FstClusLOoff + k));
144 144 entry->DIR_FileSize = fat32extract32b(fat32buff,(DIR_FileSizeoff + k));
145 145 entry->CurrentSec = j;
146 146 entry->Currententry = (uint8_t)(0xFF&(k>>5));
147 147 return DIRENT_noErr;
148 148 }
149 149 }
150 150 }
151 151 }
152 152 //printf("asking for next sector\n");
153 153 //printf("current = 0x%X\n",j);
154 154 j=fat32nextsectorlba(((FAT32fs*)entry->fs),j,&k);
155 155 //printf("got it 0x%x\n",k);
156 156 if(j!=DIRENT_noErr)
157 157 {
158 158 if(j==DIRENT_LastSect) return DIRENT_EndOfDir; /*Not clean but can avoid some bugs*/
159 159 return j;
160 160 }
161 161 j=k;
162 162 k=0;
163 163 }while(res==DIRENT_noErr);
164 164 return res;
165 165 }
166 166
167 167
168 168 int fat32getdirentname(ucdirent* entry,char* nameBuffer)
169 169 {
170 170 uint32_t j;
171 171 int k,n,i;
172 172 int res=DIRENT_noErr;
173 173 char longName=0;
174 174 k=(((signed char)entry->Currententry))*32;
175 175 j=entry->CurrentSec;
176 176 fat32sectorreadout(((FAT32fs*)entry->fs),j);
177 177 longName |= fat32buff[DIR_Nameoff + 6 + k]=='~';
178 178 if(k>=32)
179 179 {
180 180 longName |= ((fat32buff[DIR_Nameoff + k-32]&0x40)==0x40)&((fat32buff[DIR_Nameoff + k-32 +11])==ATTR_LONGNAME);
181 181 }
182 182 else
183 183 {
184 184 uint32_t j_old=j;
185 185 if(fat32prevsectorlba((FAT32fs*)entry->fs, j,&j)!=DIRENT_noErr)return DIRENT_ReadErr;
186 186 fat32sectorreadout(((FAT32fs*)entry->fs),j);
187 187 k=512;
188 188 longName |= ((fat32buff[DIR_Nameoff + k-32]&0x40)==0x40)&((fat32buff[DIR_Nameoff + k-32 +11])==ATTR_LONGNAME);
189 189 if(!longName)
190 190 {
191 191 k=0;
192 192 j=j_old;
193 193 fat32sectorreadout(((FAT32fs*)entry->fs),j);
194 194 k=0;
195 195 }
196 196 }
197 197 if(longName) //long Name? or lower case name
198 198 {
199 199 i=0;
200 200 do{
201 201 if(k==0)
202 202 {
203 203 //get previous sector
204 204 if(fat32prevsectorlba2((FAT32fs*)entry->fs,entry, j,&j)!=DIRENT_noErr)return DIRENT_ReadErr;
205 205 fat32sectorreadout(((FAT32fs*)entry->fs),j);
206 206 k=512-32;
207 207 for(n=0;n<5;n++)nameBuffer[i++] = fat32buff[((n<<1)|1) + k];
208 208 for(n=14;n<26;n+=2)nameBuffer[i++] = fat32buff[n + k];
209 209 for(n=28;n<32;n+=2)nameBuffer[i++] = fat32buff[n + k];
210 210 }
211 211 else
212 212 {
213 213 k-=32;
214 214 for(n=0;n<5;n++)nameBuffer[i++] = fat32buff[((n<<1)|1) + k];
215 215 for(n=14;n<26;n+=2)nameBuffer[i++] = fat32buff[n + k];
216 216 for(n=28;n<32;n+=2)nameBuffer[i++] = fat32buff[n + k];
217 217 }
218 218 }while((fat32buff[k]&0x40)!=0x40);
219 219 nameBuffer[i]='\0';
220 220 }
221 221 else
222 222 {
223 223 i=0;
224 224 for(n=0;n<8;n++)
225 225 {
226 226 nameBuffer[i] = 0x20 | fat32buff[n+DIR_Nameoff + k];
227 227 if(nameBuffer[i]!=0x20)i++;
228 228 }
229 229 if((((fat32buff[DIR_Nameoff + k +11])&ATTR_DIRECTORY)!=ATTR_DIRECTORY)&&(fat32buff[8+DIR_Nameoff + k]!=0x20))
230 230 nameBuffer[i++]='.';
231 231 for(n=8;n<11;n++)
232 232 {
233 233 nameBuffer[i] = 0x20 | fat32buff[n+DIR_Nameoff + k];
234 234 if(nameBuffer[i]!=0x20)i++;
235 235 }
236 236
237 237 nameBuffer[i]='\0';
238 238 }
239 239 return res;
240 240 }
241 241
242 242
243 243 uint32_t fat32getdirentlba(ucdirent* entry)
244 244 {
245 245 uint32_t clusterNum = (uint32_t)((uint16_t)entry->DIR_FstClustLO) + ((uint32_t)((uint16_t)entry->DIR_FstClusHI) <<16);
246 246 uint32_t lba=clusterlba(((FAT32fs*)entry->fs),clusterNum);
247 247 return lba;
248 248 }
249 249
250 250
251 251 int fat32nextsectorlba(FAT32fs* fs,uint32_t lastsector_lba,uint32_t *nextsector_lba)
252 252 {
253 253
254 254 if(((lastsector_lba + 1 - fs->cluster_begin_lba) & ((uint32_t)(fs->BPB_SecPerClus)-1))!=0) /*Is it the last sector of the cluster?*/
255 255 {
256 256 *nextsector_lba = lastsector_lba+1; /*if not just increment lba*/
257 257 return DIRENT_noErr;
258 258 }
259 259
260 260 uint32_t clusternum=fat32sectorlbatoclusternum(fs,lastsector_lba); /*Get cluster Number from sector number*/
261 261 uint32_t fatsec=fat32clusterinfatsect(fs,clusternum); /*Get FAT sector number*/
262 262 fat32sectorreadout(fs,fatsec);
263 263 int i= fat32clusterinfatoff(clusternum);
264 264 *nextsector_lba=fat32Ui8_2_Ui32(fat32buff,i);
265 265 if(*nextsector_lba==0xFFFFFFF7)
266 266 {
267 267 return DIRENT_BadSect;
268 268 }
269 269 if((uint32_t)(*nextsector_lba)>=(uint32_t)0xFFFFFFF6)
270 270 {
271 271 return DIRENT_LastSect;
272 272 }
273 273 *nextsector_lba = clusterlba(fs,*nextsector_lba);
274 274 return DIRENT_noErr;
275 275 }
276 276
277 277
278 278 int fat32prevsectorlba(FAT32fs* fs,uint32_t lastsector_lba,uint32_t *nextsector_lba)
279 279 {
280 280 uint32_t i=0,fatsec=0;
281 281 if(((lastsector_lba - 1 - fs->cluster_begin_lba) & (fs->BPB_SecPerClus-1))!=0) /*Is it the first sector of the cluster?*/
282 282 {
283 283 *nextsector_lba = lastsector_lba-1; /*if not just decrement lba*/
284 284 return DIRENT_noErr;
285 285 }
286 286
287 287 uint32_t clusternum = fat32sectorlbatoclusternum(fs,lastsector_lba); /*Get cluster Number from sector number*/
288 288 fatsec=fat32clusterinfatsect(fs,clusternum); /*Get FAT sector number*/
289 289 while(fatsec>=fs->fat_begin_lba)
290 290 {
291 291 fat32sectorreadout(fs,fatsec);
292 292 fatsec--;
293 293 for(i=508;i>2;i-=4)
294 294 {
295 295 *nextsector_lba = fat32Ui8_2_Ui32(fat32buff,i);
296 296 if (*nextsector_lba ==clusternum)
297 297 {
298 298 *nextsector_lba = clusterlba(fs,*nextsector_lba);
299 299 return DIRENT_noErr;
300 300 }
301 301 }
302 302 }
303 303
304 304 clusternum=fat32sectorlbatoclusternum(fs,lastsector_lba); /*Get cluster Number from sector number*/
305 305 fatsec=fat32clusterinfatsect(fs,clusternum); /*Get FAT sector number*/
306 306 do
307 307 {
308 308
309 309 fat32sectorreadout(fs,fatsec);
310 310 fatsec++;
311 311 for(i=0;i<512;i+=4)
312 312 {
313 313 *nextsector_lba = fat32Ui8_2_Ui32(fat32buff,i);
314 314 if (*nextsector_lba ==clusternum)
315 315 {
316 316 *nextsector_lba = clusterlba(fs,*nextsector_lba);
317 317 return DIRENT_noErr;
318 318 }
319 319
320 320 }
321 321 }while(fatsec<=(fs->fat_begin_lba+fs->BPB_FATSz32));
322 322 return DIRENT_ReadErr;
323 323 }
324 324
325 325
326 326 int fat32prevsectorlba2(FAT32fs* fs,ucdirent* entry,uint32_t lastsector_lba,uint32_t *nextsector_lba)
327 327 {
328 328 uint32_t i=0,fatsec=0;
329 329 if(((lastsector_lba - 1 - fs->cluster_begin_lba) & (fs->BPB_SecPerClus-1))!=0) /*Is it the first sector of the cluster?*/
330 330 {
331 331 *nextsector_lba = lastsector_lba-1; /*if not just decrement lba*/
332 332 return DIRENT_noErr;
333 333 }
334 334
335 335 uint32_t clusternum = fat32sectorlbatoclusternum(fs,lastsector_lba); /*Get cluster Number from sector number*/
336 336 uint32_t currentClusternum = fat32sectorlbatoclusternum(fs,(fat32getdirentlba(entry)));
337 337 fatsec=fat32clusterinfatsect(fs,currentClusternum); /*Get FAT sector number*/
338 338 *nextsector_lba = fat32getdirentlba(entry);
339 339 while(fatsec<=(fs->fat_begin_lba+fs->BPB_FATSz32))
340 340 {
341 341 uint32_t currentClusternum = fat32sectorlbatoclusternum(fs,(*nextsector_lba));
342 342 fatsec=fat32clusterinfatsect(fs,currentClusternum); /*Get FAT sector number*/
343 343 fat32sectorreadout(fs,fatsec);
344 344 i= fat32clusterinfatoff(currentClusternum);
345 345 if(i==clusternum)
346 346 {
347 347 return DIRENT_noErr;
348 348 }
349 349 *nextsector_lba=fat32Ui8_2_Ui32(fat32buff,i);
350 350 if(*nextsector_lba==0xFFFFFFF7)
351 351 {
352 352 return DIRENT_BadSect;
353 353 }
354 354 if((uint32_t)(*nextsector_lba)>=(uint32_t)0xFFFFFFF6)
355 355 {
356 356 return DIRENT_LastSect;
357 357 }
358 358 }
359 359 return DIRENT_ReadErr;
360 360 }
361 361
362 362
363 363
364 364
365 365
366 366
367 367
368 368
369 369
370 370
371 371
372 372
373 373
374 374
375 375
376 376
377 377
378 378
379 379
380 380
381 381
382 382
383 383
@@ -1,86 +1,86
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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
21 21 -------------------------------------------------------------------------------*/
22 22 #include <mbr.h>
23 23 #include <stdio.h>
24 24
25 25
26 26 int mbropen(blkdevice* phy,dikpartition* part,char partNum)
27 27 {
28 28 printf("enter MBR open function\n");
29 29 char mbr[512];
30 30 if((part==0) || (phy ==0) || (partNum>4) || (partNum==0) ) return MBRBabArg;
31 31 part->phy = phy;
32 32 if(phy->read(phy,mbr,0,1)!=RES_OK)
33 33 {
34 34 printf("can't read MBR!\n");
35 35 printf("%x %x %x %x %x %x %x %x\n",mbr[0],mbr[1],mbr[2],mbr[3],mbr[4],mbr[5],mbr[6],mbr[7]);
36 36 part->valide = 0;
37 37 return MBRReadErr;
38 38 }
39 39 if(((mbr[510]) == (char)0x55) && ((mbr[511]) == (char)0xAA))
40 40 {
41 41 part->TypeCode = mbr[(512-82+TypeCodeoffset)+partNum*16];
42 42 part->LBABegin = (unsigned int)mbr[(512-82+LBABeginoffset)+partNum*16] + ((unsigned int)mbr[(512-82+LBABeginoffset+1)+partNum*16]<<8)+ ((unsigned int)mbr[(512-82+LBABeginoffset+2)+partNum*16]<<16)+ ((unsigned int)mbr[(512-82+LBABeginoffset+3)+partNum*16]<<24);
43 43 part->NumOfSec = (unsigned int)mbr[(512-82+NumOfSecoffset)+partNum*16] + ((unsigned int)mbr[(512-82+NumOfSecoffset+1)+partNum*16]<<8)+ ((unsigned int)mbr[(512-82+NumOfSecoffset+2)+partNum*16]<<16)+ ((unsigned int)mbr[(512-82+NumOfSecoffset+3)+partNum*16]<<24);
44 44 printf("MBR Ok\n");
45 45 part->valide = 1;
46 46 return MBRnoErr;
47 47 }
48 48 printf("Bad MBR MBR[510]=0x%.2X MBR[511]=0x%.2X!\n",0xff&mbr[510],0xff&mbr[511]);
49 49 part->valide = 0;
50 50 return MBRBadMbr;
51 51
52 52 }
53 53
54 54
55 55
56 56
57 57
58 58
59 59
60 60
61 61
62 62
63 63
64 64
65 65
66 66
67 67
68 68
69 69
70 70
71 71
72 72
73 73
74 74
75 75
76 76
77 77
78 78
79 79
80 80
81 81
82 82
83 83
84 84
85 85
86 86
@@ -1,511 +1,511
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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
21 21 -------------------------------------------------------------------------------*/
22 22 #include <sdcard.h>
23 23 #include <sdcard-spi.h>
24 24 #include <stdio.h>
25 25 #include <core.h>
26 26
27 27 int sdcardselect (blkdeviceptr _this);
28 28 void sdcarddeselect (blkdeviceptr _this);
29 29 int sdcardwait_ready (sdcardDev* sdcard);
30 30 int sdcardxmit_datablock (sdcardDev* sdcard,const char *buff,char token);
31 31 int sdcardrcvr_datablock (sdcardDev* sdcard,char *buff,uint32_t btr);
32 32 char sdcardsend_cmd (blkdeviceptr _this,char cmd,uint32_t arg);
33 33
34 34 DSTATUS sdcarddisk_status (blkdeviceptr _this);
35 35 DSTATUS sdcarddisk_initialize (blkdeviceptr _this);
36 36 DRESULT sdcarddisk_read (blkdeviceptr _this,char *buff,uint32_t sector,char count);
37 37 DRESULT sdcarddisk_write (blkdeviceptr _this,const char *buff,uint32_t sector,char count);
38 38 DRESULT sdcarddisk_ioctl (blkdeviceptr _this,char ctrl,void *buff);
39 39
40 40 static volatile
41 41 unsigned int Timer1, Timer2; /* 1kHz decrement timer stopped at zero (disk_timerproc()) */
42 42
43 43 void sdcarddeselect (blkdeviceptr _this)
44 44 {
45 45 char d;
46 46 _this->select(0);
47 47 ((sdcardDev*)_this->phy)->rcvr_mmc(((sdcardDev*)_this->phy)->phy,&d, 1); /* Dummy clock (force DO hi-z for multiple slave SPI) */
48 48 }
49 49
50 50 int sdcardselect (blkdeviceptr _this) /* 1:OK, 0:Timeout */
51 51 {
52 52 char d;
53 53 _this->select(1);
54 54 ((sdcardDev*)_this->phy)->rcvr_mmc(((sdcardDev*)_this->phy)->phy,&d, 1); /* Dummy clock (force DO enabled) */
55 55
56 56 if (sdcardwait_ready(((sdcardDev*)_this->phy))) return 1; /* OK */
57 57 _this->select(0);
58 58 return 0; /* Timeout */
59 59 }
60 60
61 61 int sdcardwait_ready (sdcardDev* sdcard) /* 1:OK, 0:Timeout */
62 62 {
63 63 char d=0;
64 64 unsigned int tmr;
65 65 volatile unsigned int i=0;
66 66
67 67 for (tmr = 500; tmr>0; tmr--) { /* Wait for ready in timeout of 500ms */
68 68 sdcard->rcvr_mmc(sdcard->phy,&d, 1);
69 69 if (d == 0xFF) break;
70 70 delay_100us(10);
71 71 }
72 72
73 73 return tmr != 0;
74 74 }
75 75
76 76 int sdcardrcvr_datablock (sdcardDev* sdcard,char *buff,uint32_t btr)
77 77 {
78 78 char d[2];
79 79 unsigned int tmr;
80 80 volatile unsigned int i=0;
81 81 for (tmr = 100; tmr; tmr--) { /* Wait for data packet in timeout of 100ms */
82 82 sdcard->rcvr_mmc(sdcard->phy,d, 1);
83 83 if (d[0] != 0xFF) break;
84 84 delay_100us(10);
85 85 }
86 86 if (d[0] != 0xFE) return 0; /* If not valid data token, return with error */
87 87
88 88 sdcard->rcvr_mmc(sdcard->phy,buff, btr); /* Receive the data block into buffer */
89 89 sdcard->rcvr_mmc(sdcard->phy,d, 2); /* Discard CRC */
90 90
91 91 return 1; /* Return with success */
92 92 }
93 93
94 94
95 95 int sdcardxmit_datablock (sdcardDev* sdcard,const char *buff,char token)
96 96 {
97 97 char d[2];
98 98
99 99
100 100 if (!sdcardwait_ready(sdcard)) return 0;
101 101
102 102 d[0] = token;
103 103 sdcard->xmit_mmc(sdcard->phy,d, 1); /* Xmit a token */
104 104 if (token != 0xFD) { /* Is it data token? */
105 105 sdcard->xmit_mmc(sdcard->phy,buff, 512); /* Xmit the 512 byte data block to MMC */
106 106 sdcard->rcvr_mmc(sdcard->phy,d, 2); /* Xmit dummy CRC (0xFF,0xFF) */
107 107 sdcard->rcvr_mmc(sdcard->phy,d, 1); /* Receive data response */
108 108 if ((d[0] & 0x1F) != 0x05) /* If not accepted, return with error */
109 109 return 0;
110 110 }
111 111
112 112 return 1;
113 113 }
114 114
115 115
116 116 char sdcardsend_cmd (blkdeviceptr _this,char cmd,uint32_t arg)
117 117 {
118 118 char n, d, buf[6];
119 119
120 120
121 121 if (cmd & 0x80) { /* ACMD<n> is the command sequense of CMD55-CMD<n> */
122 122 cmd &= 0x7F;
123 123 n = sdcardsend_cmd(_this,CMD55, 0);
124 124 if (n > 1) return n;
125 125 }
126 126 /* Select the card and wait for ready */
127 127 sdcarddeselect(_this);
128 128 if (!sdcardselect(_this)) {printf("Can't select SDCARD\n");return 0xFF;}
129 129 /* Send a command packet */
130 130 buf[0] = 0x40 | cmd; /* Start + Command index */
131 131 buf[1] = (char)(arg >> 24); /* Argument[31..24] */
132 132 buf[2] = (char)(arg >> 16); /* Argument[23..16] */
133 133 buf[3] = (char)(arg >> 8); /* Argument[15..8] */
134 134 buf[4] = (char)arg; /* Argument[7..0] */
135 135 n = 0x01; /* Dummy CRC + Stop */
136 136 if (cmd == CMD0) n = 0x95; /* (valid CRC for CMD0(0)) */
137 137 if (cmd == CMD8) n = 0x87; /* (valid CRC for CMD8(0x1AA)) */
138 138 if (cmd == CMD55) n = 0x63;
139 139 buf[5] = n;
140 140 ((sdcardDev*)_this->phy)->xmit_mmc(((sdcardDev*)_this->phy)->phy,buf, 6);
141 141 /* Receive command response */
142 142 if (cmd == CMD12)
143 143 {
144 144 ((sdcardDev*)_this->phy)->rcvr_mmc(((sdcardDev*)_this->phy)->phy,&d, 1);
145 145 } /* Skip a stuff byte when stop reading */
146 146 n = 100; /* Wait for a valid response in timeout of 100 attempts */
147 147 do
148 148 {
149 149 ((sdcardDev*)_this->phy)->rcvr_mmc(((sdcardDev*)_this->phy)->phy,&d, 1);
150 150 delay_100us(10);
151 151 //libucprintf("resp=%d\n\r",d);
152 152 }while ((d & 0x80) && --n);
153 153
154 154 return d; /* Return with the response value */
155 155 }
156 156
157 157
158 158
159 159
160 160 DSTATUS sdcarddisk_status (blkdeviceptr _this)
161 161 {
162 162 DSTATUS s = ((sdcardDev*)_this->phy)->Stat;
163 163 char ocr[4];
164 164
165 165
166 166 if ((_this==0) || !_this->detect()) {
167 167 s = STA_NODISK | STA_NOINIT;
168 168 } else {
169 169 s &= ~STA_NODISK;
170 170 if (_this->writeprotected()) /* Check card write protection */
171 171 s |= STA_PROTECT;
172 172 else
173 173 s &= ~STA_PROTECT;
174 174 if (!(s & STA_NOINIT)) {
175 175 if (sdcardsend_cmd(_this,CMD58, 0)) /* Check if the card is kept initialized */
176 176 s |= STA_NOINIT;
177 177 ((sdcardDev*)_this->phy)->rcvr_mmc(((sdcardDev*)_this->phy)->phy,ocr, 4);
178 178 _this->select(0);
179 179 }
180 180 }
181 181 ((sdcardDev*)_this->phy)->Stat = s;
182 182
183 183 return s;
184 184 }
185 185
186 186
187 187
188 188
189 189 DSTATUS sdcarddisk_initialize (blkdeviceptr _this)
190 190 {
191 191 char cmd, ty, ocr[4],ocr2[4];
192 192 int n;
193 193 const char dummy=0xff;
194 194 uint32_t speed = 1000000;
195 195
196 196 ((sdcardDev*)_this->phy)->setspeed(((sdcardDev*)_this->phy)->phy,350000);
197 197 if (_this==0) return STA_NOINIT; /* Supports only drive 0 */
198 198 /* Is card existing in the soket? */
199 199 if (((sdcardDev*)_this->phy)->Stat & STA_NODISK)
200 200 {
201 201 printf("No SDCARD\n");
202 202 return ((sdcardDev*)_this->phy)->Stat;
203 203 }
204 204 printf("SDCARD Detected\n");
205 205 for (n = 100; n; n--) ((sdcardDev*)_this->phy)->xmit_mmc(((sdcardDev*)_this->phy)->phy,&dummy, 1); /* Send 80 dummy clocks */
206 206
207 207 ty = 0;
208 208 if (sdcardsend_cmd(_this,CMD0, 0) == 1) { /* Put the card SPI/Idle state */
209 209 printf("SDCARD in Idle mode\n");
210 210 Timer1 = 1000; /* Initialization timeout = 1 sec */
211 211 if (sdcardsend_cmd(_this,CMD8, 0x1AA) == 1) { /* SDv2? */
212 212 printf("SDCARD V2\n");
213 213 ((sdcardDev*)_this->phy)->rcvr_mmc(((sdcardDev*)_this->phy)->phy,ocr, 4);
214 214 //for (n = 0; n < 4; n++) ocr[n] = xchg_spi(0xFF); /* Get 32 bit return value of R7 resp */
215 215 if (ocr[2] == 0x01 && ocr[3] == 0xAA) { /* Is the card supports vcc of 2.7-3.6V? */
216 216 printf("The card supports vcc of 2.7-3.6V\n");
217 217 while (Timer1 && sdcardsend_cmd(_this,ACMD41, 1UL << 30)) ; /* Wait for end of initialization with ACMD41(HCS) */
218 218 if (Timer1 && sdcardsend_cmd(_this,CMD58, 0) == 0) { /* Check CCS bit in the OCR */
219 219 //for (n = 0; n < 4; n++) ocr[n] = xchg_spi(0xFF);
220 220 printf("Check CCS bit in the OCR:\n");
221 221 ((sdcardDev*)_this->phy)->rcvr_mmc(((sdcardDev*)_this->phy)->phy,ocr, 4);
222 222 printf("OCR[0]=0x%X\n",ocr[0]);
223 223 ty = (ocr[0] & 0x40) ? CT_SD2 | CT_BLOCK : CT_SD2; /* Card id SDv2 */
224 224 }
225 225 }
226 226 } else { /* Not SDv2 card */
227 227 if (sdcardsend_cmd(_this,ACMD41, 0) <= 1) { /* SDv1 or MMC? */
228 228 ty = CT_SD1; cmd = ACMD41; /* SDv1 (ACMD41(0)) */
229 229 } else {
230 230 ty = CT_MMC; cmd = CMD1; /* MMCv3 (CMD1(0)) */
231 231 }
232 232 while (Timer1 && sdcardsend_cmd(_this,cmd, 0)) ; /* Wait for end of initialization */
233 233 if (!Timer1 || sdcardsend_cmd(_this,CMD16, 512) != 0) /* Set block length: 512 */
234 234 ty = 0;
235 235 }
236 236 }
237 237 ((sdcardDev*)_this->phy)->CardType = ty; /* Card type */
238 238 printf("CardType=0x%X\n",ty);
239 239
240 240 if (ty) { /* OK */
241 241 ((sdcardDev*)_this->phy)->Stat &= ~STA_NOINIT; /* Clear STA_NOINIT flag */
242 242 sdcardsend_cmd(_this,CMD58, 0);
243 243 ((sdcardDev*)_this->phy)->rcvr_mmc(((sdcardDev*)_this->phy)->phy,ocr, 4);
244 244 do
245 245 {
246 246 speed+=1000000;
247 247 ((sdcardDev*)_this->phy)->setspeed(((sdcardDev*)_this->phy)->phy,speed);
248 248 sdcardsend_cmd(_this,CMD58, 0);
249 249 ((sdcardDev*)_this->phy)->rcvr_mmc(((sdcardDev*)_this->phy)->phy,ocr2, 4);
250 250 for(n=0;n<4;n++)
251 251 {
252 252 if(ocr[n]!=ocr2[n])
253 253 {
254 254 n=0;
255 255 break;
256 256 }
257 257 }
258 258 if((speed>(50*1000*1000)) || (speed >= getCpuFreq()))
259 259 {
260 260 break;
261 261 }
262 262 }while(n);
263 263 if(!n)
264 264 {
265 265 speed-=1000000;
266 266 ((sdcardDev*)_this->phy)->setspeed(((sdcardDev*)_this->phy)->phy,speed);
267 267 }
268 268 printf("SDCARD speed = %dMHz\n",speed/1000000);
269 269
270 270 } else { /* Failed */
271 271 //power_off();
272 272 ((sdcardDev*)_this->phy)->Stat = STA_NOINIT;
273 273 }
274 274 sdcarddeselect (_this);
275 275 return ((sdcardDev*)_this->phy)->Stat;
276 276 }
277 277
278 278
279 279
280 280
281 281
282 282
283 283
284 284
285 285
286 286
287 287 DRESULT sdcarddisk_read (blkdeviceptr _this,char *buff,uint32_t sector,char count)
288 288 {
289 289 DSTATUS s;
290 290
291 291
292 292 s = sdcarddisk_status(_this);
293 293 if (s & STA_NOINIT) return RES_NOTRDY;
294 294 if (!count) return RES_PARERR;
295 295 if (!(((sdcardDev*)_this->phy)->CardType & CT_BLOCK)) sector *= 512; /* Convert LBA to byte address if needed */
296 296
297 297 if (count == 1) { /* Single block read */
298 298 if ((sdcardsend_cmd(_this,CMD17, sector) == 0) && sdcardrcvr_datablock((sdcardDev*)(_this->phy),buff, 512))
299 299 count = 0;
300 300 }
301 301 else { /* Multiple block read */
302 302 if (sdcardsend_cmd(_this,CMD18, sector) == 0) { /* READ_MULTIPLE_BLOCK */
303 303 do {
304 304 if (!sdcardrcvr_datablock (((sdcardDev*)_this->phy),buff, 512)) break;
305 305 buff += 512;
306 306 } while (--count);
307 307 sdcardsend_cmd(_this,CMD12, 0); /* STOP_TRANSMISSION */
308 308 }
309 309 }
310 310 sdcarddeselect (_this);
311 311
312 312 return count ? RES_ERROR : RES_OK;
313 313 }
314 314
315 315
316 316
317 317
318 318
319 319 DRESULT sdcarddisk_write (blkdeviceptr _this,const char *buff,uint32_t sector,char count)
320 320 {
321 321 DSTATUS s;
322 322
323 323
324 324 s = sdcarddisk_status(_this);
325 325 if (s & STA_NOINIT) return RES_NOTRDY;
326 326 if (s & STA_PROTECT) return RES_WRPRT;
327 327 if (!count) return RES_PARERR;
328 328 if (!(((sdcardDev*)_this->phy)->CardType & CT_BLOCK)) sector *= 512; /* Convert LBA to byte address if needed */
329 329
330 330 if (count == 1) { /* Single block write */
331 331 if ((sdcardsend_cmd(_this,CMD24, sector) == 0) /* WRITE_BLOCK */
332 332 && sdcardxmit_datablock (((sdcardDev*)_this->phy),buff, 0xFE))
333 333 count = 0;
334 334 }
335 335 else { /* Multiple block write */
336 336 if (((sdcardDev*)_this->phy)->CardType & CT_SDC) sdcardsend_cmd(_this,ACMD23, count);
337 337 if (sdcardsend_cmd(_this,CMD25, sector) == 0) { /* WRITE_MULTIPLE_BLOCK */
338 338 do {
339 339 if (!sdcardxmit_datablock (((sdcardDev*)_this->phy),buff, 0xFC)) break;
340 340 buff += 512;
341 341 } while (--count);
342 342 if (!sdcardxmit_datablock (((sdcardDev*)_this->phy),0, 0xFD)) /* STOP_TRAN token */
343 343 count = 1;
344 344 }
345 345 }
346 346 sdcarddeselect (_this);
347 347
348 348 return count ? RES_ERROR : RES_OK;
349 349 }
350 350
351 351
352 352 DRESULT sdcarddisk_ioctl (blkdeviceptr _this,char ctrl,void *buff)
353 353 {
354 354 DRESULT res;
355 355 const char dummy=0xff;
356 356 char n, csd[16], *ptr = buff;
357 357 uint16_t csize;
358 358 uint32_t *dp, st, ed;
359 359
360 360
361 361 if (_this==0) return RES_PARERR; /* Check parameter */
362 362 if (((sdcardDev*)_this->phy)->Stat & STA_NOINIT) return RES_NOTRDY; /* Check if drive is ready */
363 363
364 364 res = RES_ERROR;
365 365
366 366 switch (ctrl) {
367 367 case CTRL_SYNC : /* Wait for end of internal write process of the drive */
368 368 if (sdcardselect (_this)) {
369 369 sdcarddeselect (_this);
370 370 res = RES_OK;
371 371 }
372 372 break;
373 373
374 374 case GET_SECTOR_COUNT : /* Get drive capacity in unit of sector (DWORD) */
375 375 if ((sdcardsend_cmd(_this,CMD9, 0) == 0) && sdcardrcvr_datablock (((sdcardDev*)_this->phy),csd, 16)) {
376 376 if ((csd[0] >> 6) == 1) { /* SDC ver 2.00 */
377 377 csize = csd[9] + ((uint16_t)csd[8] << 8) + 1;
378 378 *(uint32_t*)buff = (uint32_t)csize << 10;
379 379 } else { /* SDC ver 1.XX or MMC ver 3 */
380 380 n = (csd[5] & 15) + ((csd[10] & 128) >> 7) + ((csd[9] & 3) << 1) + 2;
381 381 csize = (csd[8] >> 6) + ((uint16_t)csd[7] << 2) + ((uint16_t)(csd[6] & 3) << 10) + 1;
382 382 *(uint32_t*)buff = (uint32_t)csize << (n - 9);
383 383 }
384 384 res = RES_OK;
385 385 }
386 386 break;
387 387
388 388 case GET_SECTOR_SIZE : /* Get sector size in unit of byte (WORD) */
389 389 *(uint16_t*)buff = 512;
390 390 res = RES_OK;
391 391 break;
392 392
393 393 case GET_BLOCK_SIZE : /* Get erase block size in unit of sector (DWORD) */
394 394 if (((sdcardDev*)_this->phy)->CardType & CT_SD2) { /* SDC ver 2.00 */
395 395 if (sdcardsend_cmd(_this,ACMD13, 0) == 0) { /* Read SD status */
396 396 ((sdcardDev*)_this->phy)->xmit_mmc(((sdcardDev*)_this->phy)->phy,&dummy, 1);
397 397 if (sdcardrcvr_datablock (((sdcardDev*)_this->phy),csd, 16)) { /* Read partial block */
398 398 for (n = 64 - 16; n; n--) ((sdcardDev*)_this->phy)->xmit_mmc(((sdcardDev*)_this->phy)->phy,&dummy, 1); /* Purge trailing data */
399 399 *(uint32_t*)buff = 16UL << (csd[10] >> 4);
400 400 res = RES_OK;
401 401 ((sdcardDev*)_this->phy)->xmit_mmc(((sdcardDev*)_this->phy)->phy,&dummy, 1);
402 402 }
403 403 }
404 404 } else { /* SDC ver 1.XX or MMC */
405 405 if ((sdcardsend_cmd(_this,CMD9, 0) == 0) && sdcardrcvr_datablock (((sdcardDev*)_this->phy),csd, 16)) { /* Read CSD */
406 406 if (((sdcardDev*)_this->phy)->CardType & CT_SD1) { /* SDC ver 1.XX */
407 407 *(uint32_t*)buff = (((csd[10] & 63) << 1) + ((uint16_t)(csd[11] & 128) >> 7) + 1) << ((csd[13] >> 6) - 1);
408 408 } else { /* MMC */
409 409 *(uint32_t*)buff = ((uint16_t)((csd[10] & 124) >> 2) + 1) * (((csd[11] & 3) << 3) + ((csd[11] & 224) >> 5) + 1);
410 410 }
411 411 res = RES_OK;
412 412 }
413 413 }
414 414 break;
415 415
416 416 case CTRL_ERASE_SECTOR : /* Erase a block of sectors (used when _USE_ERASE == 1) */
417 417 if (!(((sdcardDev*)_this->phy)->CardType & CT_SDC)) break; /* Check if the card is SDC */
418 418 if (sdcarddisk_ioctl(_this, MMC_GET_CSD, csd)) break; /* Get CSD */
419 419 if (!(csd[0] >> 6) && !(csd[10] & 0x40)) break; /* Check if sector erase can be applied to the card */
420 420 dp = buff; st = dp[0]; ed = dp[1]; /* Load sector block */
421 421 if (!(((sdcardDev*)_this->phy)->CardType & CT_BLOCK)) {
422 422 st *= 512; ed *= 512;
423 423 }
424 424 if (sdcardsend_cmd(_this,CMD32, st) == 0 && sdcardsend_cmd(_this,CMD33, ed) == 0 && sdcardsend_cmd(_this,CMD38, 0) == 0 && sdcardwait_ready(((sdcardDev*)_this->phy))) /* Erase sector block */
425 425 res = RES_OK; /* FatFs does not check result of this command */
426 426 break;
427 427
428 428 /* Following command are not used by FatFs module */
429 429
430 430 case MMC_GET_TYPE : /* Get MMC/SDC type (BYTE) */
431 431 *ptr = ((sdcardDev*)_this->phy)->CardType;
432 432 res = RES_OK;
433 433 break;
434 434
435 435 case MMC_GET_CSD : /* Read CSD (16 bytes) */
436 436 if (sdcardsend_cmd(_this,CMD9, 0) == 0 /* READ_CSD */
437 437 && sdcardrcvr_datablock (((sdcardDev*)_this->phy),ptr, 16))
438 438 res = RES_OK;
439 439 break;
440 440
441 441 case MMC_GET_CID : /* Read CID (16 bytes) */
442 442 if (sdcardsend_cmd(_this,CMD10, 0) == 0 /* READ_CID */
443 443 && sdcardrcvr_datablock (((sdcardDev*)_this->phy),ptr, 16))
444 444 res = RES_OK;
445 445 break;
446 446
447 447 case MMC_GET_OCR : /* Read OCR (4 bytes) */
448 448 if (sdcardsend_cmd(_this,CMD58, 0) == 0) { /* READ_OCR */
449 449 //for (n = 4; n; n--) *ptr++ =
450 450 ((sdcardDev*)_this->phy)->rcvr_mmc(((sdcardDev*)_this->phy)->phy,ptr, 4);
451 451 res = RES_OK;
452 452 }
453 453 break;
454 454
455 455 case MMC_GET_SDSTAT : /* Read SD status (64 bytes) */
456 456 if (sdcardsend_cmd(_this,ACMD13, 0) == 0) { /* SD_STATUS */
457 457 ((sdcardDev*)_this->phy)->xmit_mmc(((sdcardDev*)_this->phy)->phy,&dummy, 1);
458 458 if (sdcardrcvr_datablock (((sdcardDev*)_this->phy),ptr, 64))
459 459 res = RES_OK;
460 460 }
461 461 break;
462 462
463 463 default:
464 464 res = RES_PARERR;
465 465 }
466 466
467 467 sdcarddeselect (_this);
468 468
469 469 return res;
470 470 }
471 471
472 472
473 473
474 474 void sdcardspimake(sdcardDev* sdcard,UHANDLE phy,void (*rcvr_mmc) (UHANDLE,char *,uint32_t),void (*xmit_mmc) (UHANDLE,const char *,uint32_t ),void (*setspeed) (UHANDLE phy,uint32_t speed),uint32_t (*getspeed) (UHANDLE phy))
475 475 {
476 476 sdcard->phy = phy;
477 477 sdcard->rcvr_mmc = rcvr_mmc;
478 478 sdcard->xmit_mmc = xmit_mmc;
479 479 sdcard->setspeed = setspeed;
480 480 sdcard->getspeed = getspeed;
481 481 }
482 482
483 483 void sdcardspimakeblkdev(blkdevice* dev,sdcardDev* sdcard, blkdevselect_t select,blkdevpower_t power,blkdevdetect_t detect,blkdevwriteprotected_t writeprotected)
484 484 {
485 485 dev->phy=sdcard;
486 486 dev->select=select;
487 487 dev->power = power;
488 488 dev->detect = detect;
489 489 dev->writeprotected = writeprotected;
490 490 dev->write = sdcarddisk_write;
491 491 dev->read = sdcarddisk_read;
492 492 dev->ioctl = sdcarddisk_ioctl;
493 493 dev->initialize = sdcarddisk_initialize;
494 494 dev->status = sdcarddisk_status;
495 495 }
496 496
497 497
498 498
499 499
500 500
501 501
502 502
503 503
504 504
505 505
506 506
507 507
508 508
509 509
510 510
511 511
@@ -1,422 +1,422
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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
21 21 -------------------------------------------------------------------------------*/
22 22 #include <ili9328.h>
23 23 #include <stdio.h>
24 24 #include <stddef.h>
25 25 #include <core.h>
26 26 #include <math.h>
27 27
28 28 #ifdef __OPTIMIZED_MATH
29 29 #include <optimised_math.h>
30 30 #endif
31 31
32 32
33 33 #define ilipaintLine(LCD,X,Y,W,buffer,buffsize) \
34 34 for(int l=0;l<1;l++)\
35 35 {\
36 36 ili9328setFrame(LCD,X,Y,W,1);\
37 37 int rem=(W)%buffsize;\
38 38 if(rem)LCD->interface->writeGRAM(buffer,rem);\
39 39 for(int i=rem;i<(W);i+=buffsize)\
40 40 {\
41 41 LCD->interface->writeGRAM(buffer,buffsize);\
42 42 }\
43 43 }
44 44
45 45 #define ilipaintHLineWithCont(LCD,X,Y,W,ContSz,bufferInt,buffIntsize,bufferCont,buffContsize) \
46 46 for(int l=0;l<1;l++)\
47 47 {\
48 48 ili9328setFrame(LCD,X,Y,W,1);\
49 49 int rem=(ContSz)%buffContsize;\
50 50 if(rem)LCD->interface->writeGRAM(bufferCont,rem);\
51 51 for(int i=rem;i<(ContSz);i+=buffContsize)\
52 52 {\
53 53 LCD->interface->writeGRAM(bufferCont,buffContsize);\
54 54 }\
55 55 if((2*ContSz)<W) \
56 56 {\
57 57 rem=(W-(2*ContSz))%buffIntsize;\
58 58 if(rem)LCD->interface->writeGRAM(bufferInt,rem);\
59 59 for(int i=rem;i<(W-(2*ContSz));i+=buffIntsize)\
60 60 {\
61 61 LCD->interface->writeGRAM(bufferInt,buffIntsize);\
62 62 }\
63 63 }\
64 64 rem=(ContSz)%buffContsize;\
65 65 if(rem)LCD->interface->writeGRAM(bufferCont,rem);\
66 66 for(int i=rem;i<(ContSz);i+=buffContsize)\
67 67 {\
68 68 LCD->interface->writeGRAM(bufferCont,buffContsize);\
69 69 }\
70 70 }\
71 71
72 72
73 73 #define ilipaintVLineWithCont(LCD,X,Y,H,ContSz,bufferInt,buffIntsize,bufferCont,buffContsize) \
74 74 for(int l=0;l<1;l++)\
75 75 {\
76 76 ili9328setFrame(LCD,X,Y,1,H);\
77 77 int rem=(ContSz)%buffContsize;\
78 78 if(rem)LCD->interface->writeGRAM(bufferCont,rem);\
79 79 for(int i=rem;i<(ContSz);i+=buffContsize)\
80 80 {\
81 81 LCD->interface->writeGRAM(bufferCont,buffContsize);\
82 82 }\
83 83 if((2*ContSz)<H) \
84 84 {\
85 85 rem=(H-(2*ContSz))%buffIntsize;\
86 86 if(rem)LCD->interface->writeGRAM(bufferInt,rem);\
87 87 for(int i=rem;i<(H-(2*ContSz));i+=buffIntsize)\
88 88 {\
89 89 LCD->interface->writeGRAM(bufferInt,buffIntsize);\
90 90 }\
91 91 }\
92 92 rem=(ContSz)%buffContsize;\
93 93 if(rem)LCD->interface->writeGRAM(bufferCont,rem);\
94 94 for(int i=rem;i<(ContSz);i+=buffContsize)\
95 95 {\
96 96 LCD->interface->writeGRAM(bufferCont,buffContsize);\
97 97 }\
98 98 }\
99 99
100 100
101 101 #define ilipaintHalfTopVLineWithCont(LCD,X,Y,H,ContSz,bufferInt,buffIntsize,bufferCont,buffContsize) \
102 102 for(int l=0;l<1;l++)\
103 103 {\
104 104 ili9328setFrame(LCD,X,Y,1,H);\
105 105 int rem=(ContSz)%buffContsize;\
106 106 if(rem)LCD->interface->writeGRAM(bufferCont,rem);\
107 107 for(int i=rem;i<(ContSz);i+=buffContsize)\
108 108 {\
109 109 LCD->interface->writeGRAM(bufferCont,buffContsize);\
110 110 }\
111 111 if(ContSz<H) \
112 112 {\
113 113 rem=(H-ContSz)%buffIntsize;\
114 114 if(rem)LCD->interface->writeGRAM(bufferInt,rem);\
115 115 for(int i=rem;i<(H-ContSz);i+=buffIntsize)\
116 116 {\
117 117 LCD->interface->writeGRAM(bufferInt,buffIntsize);\
118 118 }\
119 119 }\
120 120 }\
121 121
122 122
123 123 #define ilipaintHalfBottomVLineWithCont(LCD,X,Y,H,ContSz,bufferInt,buffIntsize,bufferCont,buffContsize) \
124 124 for(int l=0;l<1;l++)\
125 125 {\
126 126 ili9328setFrame(LCD,X,Y,1,H);\
127 127 int rem;\
128 128 if(ContSz<H) \
129 129 {\
130 130 rem=(H-ContSz)%buffIntsize;\
131 131 if(rem)LCD->interface->writeGRAM(bufferInt,rem);\
132 132 for(int i=rem;i<(H-ContSz);i+=buffIntsize)\
133 133 {\
134 134 LCD->interface->writeGRAM(bufferInt,buffIntsize);\
135 135 }\
136 136 }\
137 137 rem=(ContSz)%buffContsize;\
138 138 if(rem)LCD->interface->writeGRAM(bufferCont,rem);\
139 139 for(int i=rem;i<(ContSz);i+=buffContsize)\
140 140 {\
141 141 LCD->interface->writeGRAM(bufferCont,buffContsize);\
142 142 }\
143 143 }\
144 144
145 145
146 146 void ili9328setGRAMaddress(LCD_t* LCD,uint16_t Haddress,uint16_t Vaddress)
147 147 {
148 148 LCD->interface->writereg(ILI9328_REGISTER_HORIZONTALGRAMADDRESSSET,Haddress);
149 149 LCD->interface->writereg(ILI9328_REGISTER_VERTICALGRAMADDRESSSET,Vaddress);
150 150 }
151 151
152 152 void ili9328refreshenable(struct LCD_t* LCD,int enable)
153 153 {
154 154 if(enable)
155 155 {
156 156 //LCD->interface->writereg(ILI9328_REGISTER_ENTRYMODE,0x1018);
157 157 }
158 158 else
159 159 {
160 160 //LCD->interface->writereg(ILI9328_REGISTER_ENTRYMODE,0x1008);
161 161
162 162 }
163 163 }
164 164
165 165 void ili9328setFrame(LCD_t* LCD,uint16_t X,uint16_t Y,uint16_t W,uint16_t H)
166 166 {
167 167 LCD->interface->writereg(ILI9328_REGISTER_HORIZONTALGRAMADDRESSSET,(uint32_t)X);
168 168 LCD->interface->writereg(ILI9328_REGISTER_VERTICALGRAMADDRESSSET,(uint32_t)Y);
169 169 LCD->interface->writereg(ILI9328_REGISTER_HORIZONTALADDRESSSTARTPOSITION,(uint32_t)X);
170 170 LCD->interface->writereg(ILI9328_REGISTER_HORIZONTALADDRESSENDPOSITION,(uint32_t)(W+X-1));
171 171 LCD->interface->writereg(ILI9328_REGISTER_VERTICALADDRESSSTARTPOSITION,(uint32_t)Y);
172 172 LCD->interface->writereg(ILI9328_REGISTER_VERTICALADDRESSENDPOSITION,(uint32_t)(Y+H-1));
173 173 }
174 174
175 175 void ili9328paint(LCD_t* LCD,void* buffer,uint16_t Xpos,uint16_t Ypos,uint16_t Width,uint16_t Height)
176 176 {
177 177 if((LCD!=NULL) && (LCD->interface!=NULL) && (LCD->interface->writeGRAM!=NULL) && (LCD->width>(Xpos+Width)) && (LCD->height>(Ypos+Height)))
178 178 {
179 179 ili9328setFrame(LCD,Xpos,Ypos,Width,Height);
180 180 LCD->interface->writeGRAM(buffer,Width*Height);
181 181 }
182 182 }
183 183
184 184 void ili9328paintFilCirc(LCD_t* LCD,uint16_t Xpos,uint16_t Ypos,uint16_t r,uint32_t contColor,uint16_t contSz,uint32_t fillColor)
185 185 {
186 186 //Based on the mid point circle algorithm from Wikipedia
187 187 //http://en.wikipedia.org/wiki/Midpoint_circle_algorithm
188 188 uint16_t innerbuffer[16];
189 189 uint16_t outterbuffer[16];
190 190 for(int i=0;i<16;i++)innerbuffer[i]=fillColor;
191 191 for(int i=0;i<16;i++)outterbuffer[i]=contColor;
192 192 if(contSz<r)
193 193 {
194 194 int error = -r,error_int = -r+contSz;
195 195 int x = r,x_int=r-contSz;
196 196 int y = 0,y_int=0;
197 197 while (x >= y)
198 198 {
199 199 ilipaintHLineWithCont(LCD,(Xpos-x),(Ypos+y),(2*x),(x-x_int),innerbuffer,16,outterbuffer,16);
200 200 ilipaintHLineWithCont(LCD,(Xpos-x),(Ypos-y),(2*x),(x-x_int),innerbuffer,16,outterbuffer,16);
201 201 ilipaintHalfTopVLineWithCont(LCD,(Xpos+y),(Ypos-x),(x),(x-x_int),innerbuffer,16,outterbuffer,16);
202 202 ilipaintHalfTopVLineWithCont(LCD,(Xpos-y),(Ypos-x),(x),(x-x_int),innerbuffer,16,outterbuffer,16);
203 203 ilipaintHalfBottomVLineWithCont(LCD,(Xpos-y),(Ypos),(x),(x-x_int),innerbuffer,16,outterbuffer,16);
204 204 ilipaintHalfBottomVLineWithCont(LCD,(Xpos+y),(Ypos),(x),(x-x_int),innerbuffer,16,outterbuffer,16);
205 205 error += y;
206 206 ++y;
207 207 error += y;
208 208 error_int += y_int;
209 209 ++y_int;
210 210 error_int += y_int;
211 211 if(error >= 0)
212 212 {
213 213 error -= x;
214 214 --x;
215 215 error -= x;
216 216 }
217 217 if(error_int >= 0)
218 218 {
219 219 error_int -= x_int;
220 220 --x_int;
221 221 error_int -= x_int;
222 222 }
223 223 }
224 224
225 225
226 226
227 227 }
228 228
229 229 }
230 230
231 231 void ili9328paintFilCirc_old(LCD_t* LCD,uint16_t Xpos,uint16_t Ypos,uint16_t r,uint32_t contColor,uint16_t contSz,uint32_t fillColor)
232 232 {
233 233 if(contSz<r)
234 234 {
235 235 uint16_t innerbuffer[16];
236 236 uint16_t outterbuffer[16];
237 237 int32_t rr=(r*r),rr2=((r-contSz)*(r-contSz)),contSz2,Val1,Val2,X1,W,rem;
238 238 for(int i=0;i<16;i++)innerbuffer[i]=fillColor;
239 239 for(int i=0;i<16;i++)outterbuffer[i]=contColor;
240 240 /* Y = b +/- sqrt[r^2 - (x - a)^2] */
241 241 for(int32_t line=-r;line<r;line++)
242 242 {
243 243 #ifdef __OPTIMIZED_MATH
244 244 Val1 = (uint32_t)optimised_sqrt((float32_t)(rr - (line*line)) );
245 245 Val2 = (uint32_t)optimised_sqrt((float32_t)(rr2 - (line*line)) );
246 246 #else
247 247 Val1 = sqrt( (double)(rr - ((line)*(line))) );
248 248 Val2 = sqrt( (double)(rr2 - ((line)*(line))) );
249 249 #endif
250 250 X1=Xpos - Val1;
251 251 contSz2= Val1-Val2;
252 252 ili9328setFrame(LCD,X1,line+Ypos,2*Val1,1);
253 253 rem=(contSz2)%16;
254 254 if(rem)LCD->interface->writeGRAM(outterbuffer,rem);
255 255 for(int i=rem;i<(contSz2);i+=16)
256 256 {
257 257 LCD->interface->writeGRAM(outterbuffer,16);
258 258 }
259 259
260 260 W=2*Val1;
261 261 if(W>(2*contSz2))
262 262 {
263 263 W-=2*contSz2;
264 264 rem=(W)%16;
265 265 if(rem)LCD->interface->writeGRAM(innerbuffer,rem);
266 266 for(int i=rem;i<(W);i+=16)
267 267 {
268 268 LCD->interface->writeGRAM(innerbuffer,16);
269 269 }
270 270 }
271 271
272 272 rem=(contSz2)%16;
273 273 if(rem)LCD->interface->writeGRAM(outterbuffer,rem);
274 274 for(int i=rem;i<(contSz2);i+=16)
275 275 {
276 276 LCD->interface->writeGRAM(outterbuffer,16);
277 277 }
278 278 }
279 279 }
280 280 }
281 281
282 282
283 283
284 284
285 285 void ili9328paintFilRect(LCD_t* LCD,uint16_t Xpos,uint16_t Ypos,uint16_t w,uint16_t h,uint32_t contColor,uint16_t contSz,uint32_t fillColor)
286 286 {
287 287 ili9328setFrame(LCD,Xpos,Ypos,w,h);
288 288 uint16_t tmp[32];
289 289 for(int i=0;i<32;i++)tmp[i]=fillColor;
290 290 for(int i=0;i<(h*w);i+=32)
291 291 {
292 292 LCD->interface->writeGRAM(tmp,32);
293 293 }
294 294 int rem=(w*h)%32;
295 295 if(rem)LCD->interface->writeGRAM(tmp,rem);
296 296 if(contSz)
297 297 {
298 298 ili9328setFrame(LCD,Xpos,Ypos,w,contSz);
299 299 for(int i=0;i<32;i++)tmp[i]=contColor;
300 300 rem=(w*contSz)%32;
301 301 if(rem)LCD->interface->writeGRAM(tmp,rem);
302 302 for(int i=rem;i<(w*contSz);i+=32)
303 303 {
304 304 LCD->interface->writeGRAM(tmp,32);
305 305 }
306 306
307 307 ili9328setFrame(LCD,Xpos,Ypos+h-contSz,w,contSz);
308 308 rem=(w*contSz)%32;
309 309 if(rem)LCD->interface->writeGRAM(tmp,rem);
310 310 for(int i=rem;i<(w*contSz);i+=32)
311 311 {
312 312 LCD->interface->writeGRAM(tmp,32);
313 313 }
314 314
315 315 ili9328setFrame(LCD,Xpos,Ypos,contSz,h);
316 316 rem=(h*contSz)%32;
317 317 if(rem)LCD->interface->writeGRAM(tmp,rem);
318 318 for(int i=rem;i<(h*contSz);i+=32)
319 319 {
320 320 LCD->interface->writeGRAM(tmp,32);
321 321 }
322 322
323 323 ili9328setFrame(LCD,Xpos+w-contSz,Ypos,contSz,h);
324 324 rem=(h*contSz)%32;
325 325 if(rem)LCD->interface->writeGRAM(tmp,rem);
326 326 for(int i=rem;i<(h*contSz);i+=32)
327 327 {
328 328 LCD->interface->writeGRAM(tmp,32);
329 329 }
330 330 }
331 331 }
332 332
333 333 void ili9328paintText(LCD_t* LCD,char* buffer,uint16_t Xpos,uint16_t Ypos,sFONT* font,uint32_t color)
334 334 {
335 335 int w=font->Width,h=font->Height,bpl=font->bytesPerLine,pix=0,tableoffset=0;
336 336 uint16_t tmp[w];
337 337 uint16_t linenum=0,charnum=0;
338 338 uint8_t line=0;
339 339 while(*buffer!='\0')
340 340 {
341 341 if(*buffer<32)*buffer=32;
342 342 if(*buffer>127)*buffer=32;
343 343 ili9328setFrame(LCD,Xpos+(charnum*w),Ypos-h,w,1);
344 344 LCD->interface->readGRAM(tmp,w);
345 345 for(int i=0;i<(h*w);i++)
346 346 {
347 347 if( ((i%w)==0) ) //read current line to apply text pixmap
348 348 {
349 349 if(linenum++>0)
350 350 {
351 351 ili9328setFrame(LCD,Xpos+(charnum*w),Ypos + linenum -h,w,1);
352 352 LCD->interface->writeGRAM(tmp,w);
353 353 ili9328setFrame(LCD,Xpos+(charnum*w),Ypos + linenum + 1-h,w,1);
354 354 LCD->interface->readGRAM(tmp,w);
355 355 pix=0;
356 356 }
357 357 }
358 358 if((pix%8) == 0)
359 359 {
360 360 line=font->table[(((*buffer)-32)*h*bpl)+tableoffset++];
361 361 }
362 362 tmp[pix]=0;
363 363 if((line & (uint8_t)0x01)==(uint8_t)1)tmp[pix]=(uint16_t)color;
364 364 pix++;
365 365 line>>=1;
366 366 }
367 367 linenum=0;
368 368 tableoffset=0;
369 369 charnum++;
370 370 buffer++;
371 371 }
372 372 }
373 373
374 374 int ili9328init(struct LCD_t* LCD)
375 375 {
376 376 if((LCD!=NULL) && (LCD->interface!=NULL) && (LCD->interface->writereg!=NULL))
377 377 {
378 378 LCD->interface->writereg(ILI9328_REGISTER_DRIVEROUTPUTCONTROL1, 0x0100); // Driver Output Control Register (R01h)
379 379 LCD->interface->writereg(ILI9328_REGISTER_LCDDRIVINGCONTROL, 0x0700); // LCD Driving Waveform Control (R02h)
380 380 LCD->interface->writereg(ILI9328_REGISTER_ENTRYMODE, 0x1030); // Entry Mode (R03h)
381 381 LCD->interface->writereg(ILI9328_REGISTER_DISPLAYCONTROL2, 0x0302);
382 382 LCD->interface->writereg(ILI9328_REGISTER_DISPLAYCONTROL3, 0x0000);
383 383 LCD->interface->writereg(ILI9328_REGISTER_DISPLAYCONTROL4, 0x0000); // Fmark On
384 384 LCD->interface->writereg(ILI9328_REGISTER_POWERCONTROL1, 0x0000); // Power Control 1 (R10h)
385 385 LCD->interface->writereg(ILI9328_REGISTER_POWERCONTROL2, 0x0007); // Power Control 2 (R11h)
386 386 LCD->interface->writereg(ILI9328_REGISTER_POWERCONTROL3, 0x0000); // Power Control 3 (R12h)
387 387 LCD->interface->writereg(ILI9328_REGISTER_POWERCONTROL4, 0x0000); // Power Control 4 (R13h)
388 388 delay_100us(1000);
389 389 LCD->interface->writereg(ILI9328_REGISTER_POWERCONTROL1, 0x14B0); // Power Control 1 (R10h)
390 390 delay_100us(500);
391 391 LCD->interface->writereg(ILI9328_REGISTER_POWERCONTROL2, 0x0007); // Power Control 2 (R11h)
392 392 delay_100us(500);
393 393 LCD->interface->writereg(ILI9328_REGISTER_POWERCONTROL3, 0x008E); // Power Control 3 (R12h)
394 394 LCD->interface->writereg(ILI9328_REGISTER_POWERCONTROL4, 0x0C00); // Power Control 4 (R13h)
395 395 LCD->interface->writereg(ILI9328_REGISTER_POWERCONTROL7, 0x0015); // NVM read data 2 (R29h)
396 396 delay_100us(500);
397 397 LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL1, 0x0000); // Gamma Control 1
398 398 LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL2, 0x0107); // Gamma Control 2
399 399 LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL3, 0x0000); // Gamma Control 3
400 400 LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL4, 0x0203); // Gamma Control 4
401 401 LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL5, 0x0402); // Gamma Control 5
402 402 LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL6, 0x0000); // Gamma Control 6
403 403 LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL7, 0x0207); // Gamma Control 7
404 404 LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL8, 0x0000); // Gamma Control 8
405 405 LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL9, 0x0203); // Gamma Control 9
406 406 LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL10, 0x0403); // Gamma Control 10
407 407 LCD->interface->writereg(ILI9328_REGISTER_HORIZONTALADDRESSSTARTPOSITION, 0x0000); // Window Horizontal RAM Address Start (R50h)
408 408 LCD->interface->writereg(ILI9328_REGISTER_HORIZONTALADDRESSENDPOSITION, LCD->width - 1); // Window Horizontal RAM Address End (R51h)
409 409 LCD->interface->writereg(ILI9328_REGISTER_VERTICALADDRESSSTARTPOSITION, 0X0000); // Window Vertical RAM Address Start (R52h)
410 410 LCD->interface->writereg(ILI9328_REGISTER_VERTICALADDRESSENDPOSITION, LCD->height - 1); // Window Vertical RAM Address End (R53h)
411 411 LCD->interface->writereg(ILI9328_REGISTER_DRIVEROUTPUTCONTROL2, 0xa700); // Driver Output Control (R60h)
412 412 LCD->interface->writereg(ILI9328_REGISTER_BASEIMAGEDISPLAYCONTROL, 0x0003); // Driver Output Control (R61h) - enable VLE
413 413 LCD->interface->writereg(ILI9328_REGISTER_PANELINTERFACECONTROL1, 0X0010); // Panel Interface Control 1 (R90h)
414 414 // Display On
415 415 LCD->interface->writereg(ILI9328_REGISTER_DISPLAYCONTROL1, 0x0133); // Display Control (R07h)
416 416 delay_100us(500);
417 417 LCD->paintFilRect(LCD,0,0,LCD->width,LCD->height,0,0,0xFFFF);
418 418 }
419 419 return 0;
420 420 }
421 421
422 422
@@ -1,416 +1,416
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the libuc, microcontroler library
3 3 -- Copyright (C) 2013, 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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
21 21 -------------------------------------------------------------------------------*/
22 22 #include <ssd2119.h>
23 23 #include <stdio.h>
24 24 #include <stddef.h>
25 25 #include <core.h>
26 26 #include <math.h>
27 27
28 28 #ifdef __OPTIMIZED_MATH
29 29 #include <optimised_math.h>
30 30 #endif
31 31
32 32 #define _delay_(del) for(volatile int _d_e_l_=0;_d_e_l_<(del);_d_e_l_++);
33 33
34 34 #define ilipaintLine(LCD,X,Y,W,buffer,buffsize) \
35 35 for(int l=0;l<1;l++)\
36 36 {\
37 37 ssd2119setFrame(LCD,X,Y,W,1);\
38 38 int rem=(W)%buffsize;\
39 39 if(rem)LCD->interface->writeGRAM(buffer,rem);\
40 40 for(int i=rem;i<(W);i+=buffsize)\
41 41 {\
42 42 LCD->interface->writeGRAM(buffer,buffsize);\
43 43 }\
44 44 }
45 45
46 46 #define ilipaintHLineWithCont(LCD,X,Y,W,ContSz,bufferInt,buffIntsize,bufferCont,buffContsize) \
47 47 for(int l=0;l<1;l++)\
48 48 {\
49 49 ssd2119setFrame(LCD,X,Y,W,1);\
50 50 int rem=(ContSz)%buffContsize;\
51 51 if(rem)LCD->interface->writeGRAM(bufferCont,rem);\
52 52 for(int i=rem;i<(ContSz);i+=buffContsize)\
53 53 {\
54 54 LCD->interface->writeGRAM(bufferCont,buffContsize);\
55 55 }\
56 56 if((2*ContSz)<W) \
57 57 {\
58 58 rem=(W-(2*ContSz))%buffIntsize;\
59 59 if(rem)LCD->interface->writeGRAM(bufferInt,rem);\
60 60 for(int i=rem;i<(W-(2*ContSz));i+=buffIntsize)\
61 61 {\
62 62 LCD->interface->writeGRAM(bufferInt,buffIntsize);\
63 63 }\
64 64 }\
65 65 rem=(ContSz)%buffContsize;\
66 66 if(rem)LCD->interface->writeGRAM(bufferCont,rem);\
67 67 for(int i=rem;i<(ContSz);i+=buffContsize)\
68 68 {\
69 69 LCD->interface->writeGRAM(bufferCont,buffContsize);\
70 70 }\
71 71 }\
72 72
73 73
74 74 #define ilipaintVLineWithCont(LCD,X,Y,H,ContSz,bufferInt,buffIntsize,bufferCont,buffContsize) \
75 75 for(int l=0;l<1;l++)\
76 76 {\
77 77 ssd2119setFrame(LCD,X,Y,1,H);\
78 78 int rem=(ContSz)%buffContsize;\
79 79 if(rem)LCD->interface->writeGRAM(bufferCont,rem);\
80 80 for(int i=rem;i<(ContSz);i+=buffContsize)\
81 81 {\
82 82 LCD->interface->writeGRAM(bufferCont,buffContsize);\
83 83 }\
84 84 if((2*ContSz)<H) \
85 85 {\
86 86 rem=(H-(2*ContSz))%buffIntsize;\
87 87 if(rem)LCD->interface->writeGRAM(bufferInt,rem);\
88 88 for(int i=rem;i<(H-(2*ContSz));i+=buffIntsize)\
89 89 {\
90 90 LCD->interface->writeGRAM(bufferInt,buffIntsize);\
91 91 }\
92 92 }\
93 93 rem=(ContSz)%buffContsize;\
94 94 if(rem)LCD->interface->writeGRAM(bufferCont,rem);\
95 95 for(int i=rem;i<(ContSz);i+=buffContsize)\
96 96 {\
97 97 LCD->interface->writeGRAM(bufferCont,buffContsize);\
98 98 }\
99 99 }\
100 100
101 101
102 102 #define ilipaintHalfTopVLineWithCont(LCD,X,Y,H,ContSz,bufferInt,buffIntsize,bufferCont,buffContsize) \
103 103 for(int l=0;l<1;l++)\
104 104 {\
105 105 ssd2119setFrame(LCD,X,Y,1,H);\
106 106 int rem=(ContSz)%buffContsize;\
107 107 if(rem)LCD->interface->writeGRAM(bufferCont,rem);\
108 108 for(int i=rem;i<(ContSz);i+=buffContsize)\
109 109 {\
110 110 LCD->interface->writeGRAM(bufferCont,buffContsize);\
111 111 }\
112 112 if(ContSz<H) \
113 113 {\
114 114 rem=(H-ContSz)%buffIntsize;\
115 115 if(rem)LCD->interface->writeGRAM(bufferInt,rem);\
116 116 for(int i=rem;i<(H-ContSz);i+=buffIntsize)\
117 117 {\
118 118 LCD->interface->writeGRAM(bufferInt,buffIntsize);\
119 119 }\
120 120 }\
121 121 }\
122 122
123 123
124 124 #define ilipaintHalfBottomVLineWithCont(LCD,X,Y,H,ContSz,bufferInt,buffIntsize,bufferCont,buffContsize) \
125 125 for(int l=0;l<1;l++)\
126 126 {\
127 127 ssd2119setFrame(LCD,X,Y,1,H);\
128 128 int rem;\
129 129 if(ContSz<H) \
130 130 {\
131 131 rem=(H-ContSz)%buffIntsize;\
132 132 if(rem)LCD->interface->writeGRAM(bufferInt,rem);\
133 133 for(int i=rem;i<(H-ContSz);i+=buffIntsize)\
134 134 {\
135 135 LCD->interface->writeGRAM(bufferInt,buffIntsize);\
136 136 }\
137 137 }\
138 138 rem=(ContSz)%buffContsize;\
139 139 if(rem)LCD->interface->writeGRAM(bufferCont,rem);\
140 140 for(int i=rem;i<(ContSz);i+=buffContsize)\
141 141 {\
142 142 LCD->interface->writeGRAM(bufferCont,buffContsize);\
143 143 }\
144 144 }\
145 145
146 146
147 147 void ssd2119setGRAMaddress(LCD_t* LCD,uint16_t Haddress,uint16_t Vaddress)
148 148 {
149 149 LCD->interface->writereg(SSD2119_REGISTER_X_RAM_ADDR,Haddress);
150 150 LCD->interface->writereg(SSD2119_REGISTER_Y_RAM_ADDR,Vaddress);
151 151 }
152 152
153 153 void ssd2119refreshenable(struct LCD_t* LCD,int enable)
154 154 {
155 155 if(enable)
156 156 {
157 157 //LCD->interface->writereg(ssd2119_REGISTER_ENTRYMODE,0x1018);
158 158 }
159 159 else
160 160 {
161 161 //LCD->interface->writereg(ssd2119_REGISTER_ENTRYMODE,0x1008);
162 162
163 163 }
164 164 }
165 165
166 166 void ssd2119setFrame(LCD_t* LCD,uint16_t X,uint16_t Y,uint16_t W,uint16_t H)
167 167 {
168 168 LCD->interface->writereg(SSD2119_REGISTER_X_RAM_ADDR,(uint32_t)X);
169 169 LCD->interface->writereg(SSD2119_REGISTER_Y_RAM_ADDR,(uint32_t)Y);
170 170 LCD->interface->writereg(SSD2119_REGISTER_H_RAM_START,(uint32_t)X);
171 171 LCD->interface->writereg(SSD2119_REGISTER_H_RAM_END,(uint32_t)(W+X-1));
172 172 LCD->interface->writereg(SSD2119_REGISTER_V_RAM_POS,(((uint32_t)(Y+H-1))<<8) + (uint32_t)Y);
173 173 }
174 174
175 175 void ssd2119paint(LCD_t* LCD,void* buffer,uint16_t Xpos,uint16_t Ypos,uint16_t Width,uint16_t Height)
176 176 {
177 177 if((LCD!=NULL) && (LCD->interface!=NULL) && (LCD->interface->writeGRAM!=NULL) && (LCD->width>(Xpos+Width)) && (LCD->height>(Ypos+Height)))
178 178 {
179 179 ssd2119setFrame(LCD,Xpos,Ypos,Width,Height);
180 180 LCD->interface->writeGRAM(buffer,Width*Height);
181 181 }
182 182 }
183 183
184 184 void ssd2119paintFilCirc(LCD_t* LCD,uint16_t Xpos,uint16_t Ypos,uint16_t r,uint32_t contColor,uint16_t contSz,uint32_t fillColor)
185 185 {
186 186 //Based on the mid point circle algorithm from Wikipedia
187 187 //http://en.wikipedia.org/wiki/Midpoint_circle_algorithm
188 188 uint16_t innerbuffer[16];
189 189 uint16_t outterbuffer[16];
190 190 for(int i=0;i<16;i++)innerbuffer[i]=fillColor;
191 191 for(int i=0;i<16;i++)outterbuffer[i]=contColor;
192 192 if(contSz<r)
193 193 {
194 194 int error = -r,error_int = -r+contSz;
195 195 int x = r,x_int=r-contSz;
196 196 int y = 0,y_int=0;
197 197 while (x >= y)
198 198 {
199 199 ilipaintHLineWithCont(LCD,(Xpos-x),(Ypos+y),(2*x),(x-x_int),innerbuffer,16,outterbuffer,16);
200 200 ilipaintHLineWithCont(LCD,(Xpos-x),(Ypos-y),(2*x),(x-x_int),innerbuffer,16,outterbuffer,16);
201 201 ilipaintHalfTopVLineWithCont(LCD,(Xpos+y),(Ypos-x),(x),(x-x_int),innerbuffer,16,outterbuffer,16);
202 202 ilipaintHalfTopVLineWithCont(LCD,(Xpos-y),(Ypos-x),(x),(x-x_int),innerbuffer,16,outterbuffer,16);
203 203 ilipaintHalfBottomVLineWithCont(LCD,(Xpos-y),(Ypos),(x),(x-x_int),innerbuffer,16,outterbuffer,16);
204 204 ilipaintHalfBottomVLineWithCont(LCD,(Xpos+y),(Ypos),(x),(x-x_int),innerbuffer,16,outterbuffer,16);
205 205 error += y;
206 206 ++y;
207 207 error += y;
208 208 error_int += y_int;
209 209 ++y_int;
210 210 error_int += y_int;
211 211 if(error >= 0)
212 212 {
213 213 error -= x;
214 214 --x;
215 215 error -= x;
216 216 }
217 217 if(error_int >= 0)
218 218 {
219 219 error_int -= x_int;
220 220 --x_int;
221 221 error_int -= x_int;
222 222 }
223 223 }
224 224
225 225
226 226
227 227 }
228 228
229 229 }
230 230
231 231 void ssd2119paintFilCirc_old(LCD_t* LCD,uint16_t Xpos,uint16_t Ypos,uint16_t r,uint32_t contColor,uint16_t contSz,uint32_t fillColor)
232 232 {
233 233 if(contSz<r)
234 234 {
235 235 uint16_t innerbuffer[16];
236 236 uint16_t outterbuffer[16];
237 237 int32_t rr=(r*r),rr2=((r-contSz)*(r-contSz)),contSz2,Val1,Val2,X1,W,rem;
238 238 for(int i=0;i<16;i++)innerbuffer[i]=fillColor;
239 239 for(int i=0;i<16;i++)outterbuffer[i]=contColor;
240 240 /* Y = b +/- sqrt[r^2 - (x - a)^2] */
241 241 for(int32_t line=-r;line<r;line++)
242 242 {
243 243 #ifdef __OPTIMIZED_MATH
244 244 Val1 = (uint32_t)optimised_sqrt((float32_t)(rr - (line*line)) );
245 245 Val2 = (uint32_t)optimised_sqrt((float32_t)(rr2 - (line*line)) );
246 246 #else
247 247 Val1 = sqrt( (double)(rr - ((line)*(line))) );
248 248 Val2 = sqrt( (double)(rr2 - ((line)*(line))) );
249 249 #endif
250 250 X1=Xpos - Val1;
251 251 contSz2= Val1-Val2;
252 252 ssd2119setFrame(LCD,X1,line+Ypos,2*Val1,1);
253 253 rem=(contSz2)%16;
254 254 if(rem)LCD->interface->writeGRAM(outterbuffer,rem);
255 255 for(int i=rem;i<(contSz2);i+=16)
256 256 {
257 257 LCD->interface->writeGRAM(outterbuffer,16);
258 258 }
259 259
260 260 W=2*Val1;
261 261 if(W>(2*contSz2))
262 262 {
263 263 W-=2*contSz2;
264 264 rem=(W)%16;
265 265 if(rem)LCD->interface->writeGRAM(innerbuffer,rem);
266 266 for(int i=rem;i<(W);i+=16)
267 267 {
268 268 LCD->interface->writeGRAM(innerbuffer,16);
269 269 }
270 270 }
271 271
272 272 rem=(contSz2)%16;
273 273 if(rem)LCD->interface->writeGRAM(outterbuffer,rem);
274 274 for(int i=rem;i<(contSz2);i+=16)
275 275 {
276 276 LCD->interface->writeGRAM(outterbuffer,16);
277 277 }
278 278 }
279 279 }
280 280 }
281 281
282 282
283 283
284 284
285 285 void ssd2119paintFilRect(LCD_t* LCD,uint16_t Xpos,uint16_t Ypos,uint16_t w,uint16_t h,uint32_t contColor,uint16_t contSz,uint32_t fillColor)
286 286 {
287 287 ssd2119setFrame(LCD,Xpos,Ypos,w,h);
288 288 uint16_t tmp[32];
289 289 for(int i=0;i<32;i++)tmp[i]=fillColor;
290 290 for(int i=0;i<(h*w);i+=32)
291 291 {
292 292 LCD->interface->writeGRAM(tmp,32);
293 293 }
294 294 int rem=(w*h)%32;
295 295 if(rem)LCD->interface->writeGRAM(tmp,rem);
296 296 if(contSz)
297 297 {
298 298 ssd2119setFrame(LCD,Xpos,Ypos,w,contSz);
299 299 for(int i=0;i<32;i++)tmp[i]=contColor;
300 300 rem=(w*contSz)%32;
301 301 if(rem)LCD->interface->writeGRAM(tmp,rem);
302 302 for(int i=rem;i<(w*contSz);i+=32)
303 303 {
304 304 LCD->interface->writeGRAM(tmp,32);
305 305 }
306 306
307 307 ssd2119setFrame(LCD,Xpos,Ypos+h-contSz,w,contSz);
308 308 rem=(w*contSz)%32;
309 309 if(rem)LCD->interface->writeGRAM(tmp,rem);
310 310 for(int i=rem;i<(w*contSz);i+=32)
311 311 {
312 312 LCD->interface->writeGRAM(tmp,32);
313 313 }
314 314
315 315 ssd2119setFrame(LCD,Xpos,Ypos,contSz,h);
316 316 rem=(h*contSz)%32;
317 317 if(rem)LCD->interface->writeGRAM(tmp,rem);
318 318 for(int i=rem;i<(h*contSz);i+=32)
319 319 {
320 320 LCD->interface->writeGRAM(tmp,32);
321 321 }
322 322
323 323 ssd2119setFrame(LCD,Xpos+w-contSz,Ypos,contSz,h);
324 324 rem=(h*contSz)%32;
325 325 if(rem)LCD->interface->writeGRAM(tmp,rem);
326 326 for(int i=rem;i<(h*contSz);i+=32)
327 327 {
328 328 LCD->interface->writeGRAM(tmp,32);
329 329 }
330 330 }
331 331 }
332 332
333 333 void ssd2119paintText(LCD_t* LCD,char* buffer,uint16_t Xpos,uint16_t Ypos,sFONT* font,uint32_t color)
334 334 {
335 335 int w=font->Width,h=font->Height,bpl=font->bytesPerLine,pix=0,tableoffset=0;
336 336 uint16_t tmp[w];
337 337 uint16_t linenum=0,charnum=0;
338 338 uint8_t line=0;
339 339 while(*buffer!='\0')
340 340 {
341 341 ssd2119setFrame(LCD,Xpos+(charnum*w),Ypos-h,w,1);
342 342 LCD->interface->readGRAM(tmp,w);
343 343 for(int i=0;i<(h*w);i++)
344 344 {
345 345 if( ((i%w)==0) ) //read current line to apply text pixmap
346 346 {
347 347 if(linenum++>0)
348 348 {
349 349 ssd2119setFrame(LCD,Xpos+(charnum*(w-10)),Ypos + linenum -h,w,1); // TODO remove -10 and generate good fonts!
350 350 LCD->interface->writeGRAM(tmp,w);
351 351 ssd2119setFrame(LCD,Xpos+(charnum*(w-10)),Ypos + linenum + 1-h,w,1);
352 352 LCD->interface->readGRAM(tmp,w);
353 353 pix=0;
354 354 }
355 355 }
356 356 if((pix%8) == 0)
357 357 {
358 358 line=font->table[(((*buffer)-32)*h*bpl)+tableoffset++];
359 359 }
360 360 if((line & (uint8_t)0x01)==(uint8_t)1)tmp[pix]=(uint16_t)color;
361 361 pix++;
362 362 line>>=1;
363 363 }
364 364 linenum=0;
365 365 tableoffset=0;
366 366 charnum++;
367 367 buffer++;
368 368 }
369 369 }
370 370
371 371
372 372 int ssd2119init(struct LCD_t* LCD)
373 373 {
374 374 if((LCD!=NULL) && (LCD->interface!=NULL) && (LCD->interface->writereg!=NULL))
375 375 {
376 376 LCD->interface->writereg(0x28,0x0006); // VCOM OTP - Page 55-56 of SSD2119 datasheet
377 377 LCD->interface->writereg(0x00,0x0001); // start Oscillator - Page 36 of SSD2119 datasheet
378 378 LCD->interface->writereg(0x10,0x0000); // Sleep mode - Page 49 of SSD2119 datasheet
379 379 LCD->interface->writereg(0x01,0x72ef); // Driver Output Control - Page 36-39 of SSD2119 datasheet
380 380 LCD->interface->writereg(0x02,0x0600); // LCD Driving Waveform Control - Page 40-42 of SSD2119 datasheet
381 381 LCD->interface->writereg(0x03,0x6a38); // Power Control 1 - Page 43-44 of SSD2119 datasheet
382 382 LCD->interface->writereg(0x11,0x6870); // Entry Mode - Page 50-52 of SSD2119 datasheet
383 383
384 384 // RAM WRITE DATA MASK
385 385 LCD->interface->writereg(0x0f,0x0000); // Gate Scan Position - Page 49 of SSD2119 datasheet
386 386 // RAM WRITE DATA MASK
387 387 LCD->interface->writereg(0x0b,0x5308); // Frame Cycle Control - Page 45 of SSD2119 datasheet
388 388 LCD->interface->writereg(0x0c,0x0003); // Power Control 2 - Page 47 of SSD2119 datasheet
389 389 LCD->interface->writereg(0x0d,0x000a); // Power Control 3 - Page 48 of SSD2119 datasheet
390 390 LCD->interface->writereg(0x0e,0x2e00); // Power Control 4 - Page 48 of SSD2119 datasheet
391 391 LCD->interface->writereg(0x1e,0x00be); // Power Control 5 - Page 53 of SSD2119 datasheet
392 392 LCD->interface->writereg(0x25,0x8000); // Frame Frequency Control - Page 53 of SSD2119 datasheet
393 393 LCD->interface->writereg(0x26,0x7800); // Analog setting - Page 54 of SSD2119 datasheet
394 394 LCD->interface->writereg(0x4e,0x0000); // Ram Address Set - Page 58 of SSD2119 datasheet
395 395 LCD->interface->writereg(0x4f,0x0000); // Ram Address Set - Page 58 of SSD2119 datasheet
396 396 LCD->interface->writereg(0x12,0x08d9); // Sleep mode - Page 49 of SSD2119 datasheet
397 397
398 398 // -----------------Adjust the Gamma Curve----//
399 399 LCD->interface->writereg(0x30,0x0000); //0007
400 400 LCD->interface->writereg(0x31,0x0104); //0203
401 401 LCD->interface->writereg(0x32,0x0100); //0001
402 402 LCD->interface->writereg(0x33,0x0305); //0007
403 403 LCD->interface->writereg(0x34,0x0505); //0007
404 404 LCD->interface->writereg(0x35,0x0305); //0407
405 405 LCD->interface->writereg(0x36,0x0707); //0407
406 406 LCD->interface->writereg(0x37,0x0300); //0607
407 407 LCD->interface->writereg(0x3a,0x1200); //0106
408 408 LCD->interface->writereg(0x3b,0x0800);
409 409 LCD->interface->writereg(0x07,0x0033); // Display Control - Page 45 of SSD2119 datasheet
410 410 }
411 411 return 0;
412 412 }
413 413
414 414
415 415
416 416
@@ -1,1977 +1,1977
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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
21 21 -------------------------------------------------------------------------------*/
22 22 #include <fonts.h>
23 23
24 24 const uint8_t ComicSansMS_18_TBL[] = {
25 25 /* Character Data - Index: 32 */
26 26 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
27 27
28 28 /* Character Data - Index: 33 */
29 29 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
30 30
31 31 /* Character Data - Index: 34 */
32 32 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x24,0x00,0x24,0x00,0x24,0x00,0x24,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
33 33
34 34 /* Character Data - Index: 35 */
35 35 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x02,0x20,0x02,0x20,0x02,0xFC,0x07,0x10,0x01,0x08,0x01,0xFE,0x03,0x88,0x00,0x44,0x00,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
36 36
37 37 /* Character Data - Index: 36 */
38 38 0x00,0x00,0x00,0x00,0x10,0x00,0x10,0x00,0xF8,0x00,0x14,0x00,0x14,0x00,0x14,0x00,0x38,0x00,0x50,0x00,0x90,0x00,0x90,0x00,0x50,0x00,0x3C,0x00,0x10,0x00,0x10,0x00,0x00,0x00,0x00,0x00,
39 39
40 40 /* Character Data - Index: 37 */
41 41 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x01,0xA4,0x00,0xA4,0x00,0xD8,0x00,0x40,0x00,0x40,0x00,0x20,0x03,0xA0,0x04,0x90,0x04,0x10,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
42 42
43 43 /* Character Data - Index: 38 */
44 44 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x00,0xA0,0x00,0xA0,0x00,0x60,0x00,0x70,0x00,0x48,0x01,0x44,0x01,0x84,0x00,0xC4,0x01,0x78,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
45 45
46 46 /* Character Data - Index: 39 */
47 47 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
48 48
49 49 /* Character Data - Index: 40 */
50 50 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x10,0x00,0x08,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x08,0x00,0x10,0x00,0x20,0x00,0x00,0x00,
51 51
52 52 /* Character Data - Index: 41 */
53 53 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x08,0x00,0x08,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x08,0x00,0x08,0x00,0x04,0x00,0x00,0x00,
54 54
55 55 /* Character Data - Index: 42 */
56 56 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x7E,0x00,0x18,0x00,0x24,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
57 57
58 58 /* Character Data - Index: 43 */
59 59 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x08,0x00,0x3E,0x00,0x08,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
60 60
61 61 /* Character Data - Index: 44 */
62 62 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x0C,0x00,0x04,0x00,0x00,0x00,0x00,0x00,
63 63
64 64 /* Character Data - Index: 45 */
65 65 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
66 66
67 67 /* Character Data - Index: 46 */
68 68 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
69 69
70 70 /* Character Data - Index: 47 */
71 71 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x10,0x00,0x18,0x00,0x08,0x00,0x04,0x00,0x04,0x00,0x02,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
72 72
73 73 /* Character Data - Index: 48 */
74 74 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x48,0x00,0x84,0x00,0x84,0x00,0x84,0x00,0x84,0x00,0x84,0x00,0x84,0x00,0x48,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
75 75
76 76 /* Character Data - Index: 49 */
77 77 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x0C,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
78 78
79 79 /* Character Data - Index: 50 */
80 80 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x00,0x84,0x00,0x80,0x00,0x80,0x00,0x40,0x00,0x30,0x00,0x08,0x00,0x04,0x00,0x04,0x00,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
81 81
82 82 /* Character Data - Index: 51 */
83 83 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x44,0x00,0x40,0x00,0x40,0x00,0x38,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x44,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
84 84
85 85 /* Character Data - Index: 52 */
86 86 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x60,0x00,0x50,0x00,0x48,0x00,0x44,0x00,0x42,0x00,0xFE,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
87 87
88 88 /* Character Data - Index: 53 */
89 89 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x00,0x04,0x00,0x04,0x00,0x74,0x00,0x8C,0x00,0x84,0x00,0x80,0x00,0x80,0x00,0x44,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
90 90
91 91 /* Character Data - Index: 54 */
92 92 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x10,0x00,0x08,0x00,0x08,0x00,0x7C,0x00,0x84,0x00,0x84,0x00,0x84,0x00,0x84,0x00,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
93 93
94 94 /* Character Data - Index: 55 */
95 95 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x00,0x40,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x10,0x00,0x10,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
96 96
97 97 /* Character Data - Index: 56 */
98 98 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x00,0x84,0x00,0x84,0x00,0x84,0x00,0x78,0x00,0x84,0x00,0x84,0x00,0x84,0x00,0x84,0x00,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
99 99
100 100 /* Character Data - Index: 57 */
101 101 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x00,0x84,0x00,0x84,0x00,0x84,0x00,0x84,0x00,0x84,0x00,0x78,0x00,0x40,0x00,0x30,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
102 102
103 103 /* Character Data - Index: 58 */
104 104 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
105 105
106 106 /* Character Data - Index: 59 */
107 107 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x06,0x00,0x02,0x00,0x00,0x00,0x00,0x00,
108 108
109 109 /* Character Data - Index: 60 */
110 110 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x08,0x00,0x04,0x00,0x06,0x00,0x08,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
111 111
112 112 /* Character Data - Index: 61 */
113 113 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x00,0x00,0x00,0x00,0x00,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
114 114
115 115 /* Character Data - Index: 62 */
116 116 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x04,0x00,0x08,0x00,0x18,0x00,0x04,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
117 117
118 118 /* Character Data - Index: 63 */
119 119 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x00,0x60,0x00,0x40,0x00,0x40,0x00,0x20,0x00,0x10,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
120 120
121 121 /* Character Data - Index: 64 */
122 122 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x00,0x0C,0x03,0x64,0x06,0x32,0x04,0xCA,0x04,0xCA,0x04,0x72,0x03,0x02,0x00,0x04,0x00,0x08,0x02,0xF0,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
123 123
124 124 /* Character Data - Index: 65 */
125 125 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0xA0,0x00,0x90,0x00,0x90,0x00,0xF8,0x00,0x08,0x01,0x04,0x01,0x04,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
126 126
127 127 /* Character Data - Index: 66 */
128 128 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x00,0x44,0x00,0x44,0x00,0x44,0x00,0x24,0x00,0x7C,0x00,0x84,0x00,0x84,0x00,0x44,0x00,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
129 129
130 130 /* Character Data - Index: 67 */
131 131 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x00,0x88,0x00,0x04,0x00,0x04,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x82,0x00,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
132 132
133 133 /* Character Data - Index: 68 */
134 134 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x34,0x00,0x44,0x00,0x84,0x00,0x04,0x01,0x04,0x01,0x04,0x01,0x04,0x01,0x84,0x00,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
135 135
136 136 /* Character Data - Index: 69 */
137 137 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0xFC,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
138 138
139 139 /* Character Data - Index: 70 */
140 140 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x7C,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
141 141
142 142 /* Character Data - Index: 71 */
143 143 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x88,0x00,0x04,0x00,0x04,0x00,0x02,0x00,0xF2,0x01,0x02,0x01,0x82,0x00,0x42,0x00,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
144 144
145 145 /* Character Data - Index: 72 */
146 146 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x02,0x04,0x02,0x04,0x02,0x04,0x02,0x04,0x02,0xFC,0x03,0x04,0x02,0x04,0x02,0x04,0x02,0x04,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
147 147
148 148 /* Character Data - Index: 73 */
149 149 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
150 150
151 151 /* Character Data - Index: 74 */
152 152 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x01,0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x44,0x00,0x44,0x00,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
153 153
154 154 /* Character Data - Index: 75 */
155 155 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x84,0x00,0x44,0x00,0x24,0x00,0x14,0x00,0x0C,0x00,0x0C,0x00,0x14,0x00,0x24,0x00,0x44,0x00,0x84,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
156 156
157 157 /* Character Data - Index: 76 */
158 158 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
159 159
160 160 /* Character Data - Index: 77 */
161 161 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x01,0x10,0x01,0x10,0x01,0x90,0x01,0xA8,0x02,0xA8,0x02,0xA8,0x02,0xA4,0x02,0x44,0x04,0x44,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
162 162
163 163 /* Character Data - Index: 78 */
164 164 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x06,0x02,0x0A,0x02,0x0A,0x02,0x12,0x02,0x22,0x02,0x42,0x02,0x82,0x02,0x02,0x03,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
165 165
166 166 /* Character Data - Index: 79 */
167 167 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x00,0x08,0x01,0x04,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x01,0x84,0x00,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
168 168
169 169 /* Character Data - Index: 80 */
170 170 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x00,0x44,0x00,0x44,0x00,0x44,0x00,0x44,0x00,0x3C,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
171 171
172 172 /* Character Data - Index: 81 */
173 173 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x01,0x08,0x03,0x04,0x02,0x02,0x04,0x02,0x04,0x02,0x04,0x42,0x04,0xC4,0x04,0x8C,0x03,0xF0,0x03,0x00,0x06,0x00,0x0C,0x00,0x00,0x00,0x00,
174 174
175 175 /* Character Data - Index: 82 */
176 176 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x00,0x44,0x00,0x84,0x00,0x84,0x00,0x84,0x00,0x44,0x00,0x3C,0x00,0x24,0x00,0x44,0x00,0x84,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
177 177
178 178 /* Character Data - Index: 83 */
179 179 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x01,0x08,0x00,0x04,0x00,0x04,0x00,0xF8,0x00,0x00,0x01,0x00,0x01,0x00,0x01,0x82,0x00,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
180 180
181 181 /* Character Data - Index: 84 */
182 182 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x01,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
183 183
184 184 /* Character Data - Index: 85 */
185 185 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x02,0x04,0x02,0x04,0x02,0x04,0x02,0x04,0x02,0x04,0x02,0x04,0x02,0x04,0x02,0x08,0x01,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
186 186
187 187 /* Character Data - Index: 86 */
188 188 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x01,0x02,0x01,0x82,0x00,0x84,0x00,0x44,0x00,0x44,0x00,0x28,0x00,0x28,0x00,0x10,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
189 189
190 190 /* Character Data - Index: 87 */
191 191 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x84,0x10,0x84,0x10,0x84,0x08,0x48,0x09,0x48,0x09,0x28,0x05,0x28,0x05,0x28,0x05,0x10,0x02,0x10,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
192 192
193 193 /* Character Data - Index: 88 */
194 194 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x04,0x01,0x88,0x00,0x50,0x00,0x20,0x00,0x20,0x00,0x50,0x00,0x88,0x00,0x04,0x01,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
195 195
196 196 /* Character Data - Index: 89 */
197 197 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x01,0x84,0x00,0x88,0x00,0x48,0x00,0x50,0x00,0x30,0x00,0x20,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
198 198
199 199 /* Character Data - Index: 90 */
200 200 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x01,0x80,0x00,0x40,0x00,0x20,0x00,0x10,0x00,0x10,0x00,0x08,0x00,0x04,0x00,0x02,0x00,0xFE,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
201 201
202 202 /* Character Data - Index: 91 */
203 203 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x1C,0x00,0x00,0x00,
204 204
205 205 /* Character Data - Index: 92 */
206 206 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x02,0x00,0x04,0x00,0x04,0x00,0x08,0x00,0x08,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x20,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
207 207
208 208 /* Character Data - Index: 93 */
209 209 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x1C,0x00,0x00,0x00,
210 210
211 211 /* Character Data - Index: 94 */
212 212 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x1C,0x00,0x22,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
213 213
214 214 /* Character Data - Index: 95 */
215 215 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x01,0x00,0x00,0x00,0x00,
216 216
217 217 /* Character Data - Index: 96 */
218 218 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x04,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
219 219
220 220 /* Character Data - Index: 97 */
221 221 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x48,0x00,0x44,0x00,0x44,0x00,0x44,0x00,0x44,0x00,0xB8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
222 222
223 223 /* Character Data - Index: 98 */
224 224 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x34,0x00,0x4C,0x00,0x84,0x00,0x84,0x00,0x84,0x00,0x44,0x00,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
225 225
226 226 /* Character Data - Index: 99 */
227 227 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x48,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x44,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
228 228
229 229 /* Character Data - Index: 100 */
230 230 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0xF0,0x00,0x88,0x00,0x84,0x00,0x84,0x00,0x84,0x00,0x84,0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
231 231
232 232 /* Character Data - Index: 101 */
233 233 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x48,0x00,0x44,0x00,0x34,0x00,0x0C,0x00,0x44,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
234 234
235 235 /* Character Data - Index: 102 */
236 236 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x00,0x10,0x00,0x10,0x00,0x7C,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
237 237
238 238 /* Character Data - Index: 103 */
239 239 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x48,0x00,0x44,0x00,0x44,0x00,0x44,0x00,0x64,0x00,0x58,0x00,0x40,0x00,0x40,0x00,0x20,0x00,0x1C,0x00,
240 240
241 241 /* Character Data - Index: 104 */
242 242 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x34,0x00,0x4C,0x00,0x44,0x00,0x44,0x00,0x44,0x00,0x44,0x00,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
243 243
244 244 /* Character Data - Index: 105 */
245 245 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
246 246
247 247 /* Character Data - Index: 106 */
248 248 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x09,0x00,0x06,0x00,
249 249
250 250 /* Character Data - Index: 107 */
251 251 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x44,0x00,0x24,0x00,0x14,0x00,0x1C,0x00,0x24,0x00,0x24,0x00,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
252 252
253 253 /* Character Data - Index: 108 */
254 254 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
255 255
256 256 /* Character Data - Index: 109 */
257 257 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xB4,0x00,0x6C,0x01,0x24,0x01,0x24,0x01,0x24,0x01,0x24,0x01,0x24,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
258 258
259 259 /* Character Data - Index: 110 */
260 260 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x34,0x00,0x4C,0x00,0x44,0x00,0x44,0x00,0x44,0x00,0x44,0x00,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
261 261
262 262 /* Character Data - Index: 111 */
263 263 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x44,0x00,0x44,0x00,0x44,0x00,0x44,0x00,0x44,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
264 264
265 265 /* Character Data - Index: 112 */
266 266 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x00,0x44,0x00,0x44,0x00,0x44,0x00,0x44,0x00,0x44,0x00,0x3C,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,
267 267
268 268 /* Character Data - Index: 113 */
269 269 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x48,0x00,0x44,0x00,0x44,0x00,0x44,0x00,0x44,0x00,0x78,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x00,
270 270
271 271 /* Character Data - Index: 114 */
272 272 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x34,0x00,0x2C,0x00,0x24,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
273 273
274 274 /* Character Data - Index: 115 */
275 275 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x24,0x00,0x04,0x00,0x18,0x00,0x20,0x00,0x20,0x00,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
276 276
277 277 /* Character Data - Index: 116 */
278 278 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x08,0x00,0x3E,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
279 279
280 280 /* Character Data - Index: 117 */
281 281 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x44,0x00,0x44,0x00,0x44,0x00,0x44,0x00,0x44,0x00,0x44,0x00,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
282 282
283 283 /* Character Data - Index: 118 */
284 284 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x44,0x00,0x44,0x00,0x28,0x00,0x28,0x00,0x28,0x00,0x10,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
285 285
286 286 /* Character Data - Index: 119 */
287 287 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x22,0x02,0x22,0x02,0x54,0x01,0x54,0x01,0x54,0x01,0xC8,0x00,0x88,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
288 288
289 289 /* Character Data - Index: 120 */
290 290 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x82,0x00,0x44,0x00,0x38,0x00,0x10,0x00,0x28,0x00,0x44,0x00,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
291 291
292 292 /* Character Data - Index: 121 */
293 293 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x42,0x00,0x42,0x00,0x24,0x00,0x24,0x00,0x18,0x00,0x18,0x00,0x10,0x00,0x08,0x00,0x08,0x00,0x04,0x00,0x04,0x00,
294 294
295 295 /* Character Data - Index: 122 */
296 296 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x00,0x20,0x00,0x20,0x00,0x10,0x00,0x08,0x00,0x08,0x00,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
297 297
298 298 /* Character Data - Index: 123 */
299 299 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x06,0x00,0x06,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x18,0x00,0x00,0x00,
300 300
301 301 /* Character Data - Index: 124 */
302 302 0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x00,0x00,0x00,0x00,
303 303
304 304 /* Character Data - Index: 125 */
305 305 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x18,0x00,0x18,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x06,0x00,0x00,0x00,
306 306
307 307 /* Character Data - Index: 126 */
308 308 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x8C,0x00,0xD6,0x00,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
309 309
310 310 /* Character Data - Index: 127 */
311 311 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
312 312 };
313 313
314 314 const uint8_t ComicSansMS_24_TBL[] = {
315 315
316 316 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
317 317
318 318 /* Character Data - Index: 33 */
319 319 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
320 320
321 321 /* Character Data - Index: 34 */
322 322 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xCC,0x00,0x00,0xCC,0x00,0x00,0xCC,0x00,0x00,0xCC,0x00,0x00,0xCC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
323 323
324 324 /* Character Data - Index: 35 */
325 325 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x18,0x00,0xC0,0x18,0x00,0xC0,0x18,0x00,0xFC,0x7F,0x00,0xFC,0x7F,0x00,0x60,0x0C,0x00,0x60,0x0C,0x00,0x30,0x06,0x00,0xFE,0x3F,0x00,0xFE,0x3F,0x00,0x30,0x06,0x00,0x18,0x03,0x00,0x18,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
326 326
327 327 /* Character Data - Index: 36 */
328 328 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x00,0x00,0xC0,0x00,0x00,0xE0,0x03,0x00,0xF8,0x07,0x00,0xDC,0x00,0x00,0xCC,0x00,0x00,0xCC,0x00,0x00,0xFC,0x03,0x00,0xF0,0x07,0x00,0xC0,0x0E,0x00,0xC0,0x0C,0x00,0xC0,0x0C,0x00,0xCC,0x0E,0x00,0xFC,0x07,0x00,0xF8,0x03,0x00,0xC0,0x00,0x00,0xC0,0x00,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
329 329
330 330 /* Character Data - Index: 37 */
331 331 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x3C,0x06,0x00,0x7E,0x03,0x00,0x66,0x03,0x00,0xFE,0x03,0x00,0xBC,0x01,0x00,0x80,0x01,0x00,0xC0,0x00,0x00,0xC0,0x00,0x00,0xE0,0x1E,0x00,0x60,0x3F,0x00,0x60,0x33,0x00,0x30,0x3F,0x00,0x30,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
332 332
333 333 /* Character Data - Index: 38 */
334 334 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x00,0x00,0xF0,0x01,0x00,0xB0,0x01,0x00,0xB0,0x01,0x00,0xF0,0x00,0x00,0x70,0x04,0x00,0xDC,0x04,0x00,0xCC,0x04,0x00,0x86,0x07,0x00,0x06,0x07,0x00,0x0E,0x07,0x00,0xFC,0x07,0x00,0xF8,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
335 335
336 336 /* Character Data - Index: 39 */
337 337 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
338 338
339 339 /* Character Data - Index: 40 */
340 340 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x70,0x00,0x00,0x30,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x08,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x38,0x00,0x00,0x70,0x00,0x00,0x60,0x00,0x00,0x00,0x00,0x00,
341 341
342 342 /* Character Data - Index: 41 */
343 343 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x0E,0x00,0x00,0x0C,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x10,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x1C,0x00,0x00,0x0E,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x00,
344 344
345 345 /* Character Data - Index: 42 */
346 346 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x10,0x00,0x00,0xFE,0x01,0x00,0xFC,0x00,0x00,0x78,0x00,0x00,0x6C,0x00,0x00,0x84,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
347 347
348 348 /* Character Data - Index: 43 */
349 349 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0xFE,0x01,0x00,0xFE,0x01,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
350 350
351 351 /* Character Data - Index: 44 */
352 352 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
353 353
354 354 /* Character Data - Index: 45 */
355 355 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x00,0x00,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
356 356
357 357 /* Character Data - Index: 46 */
358 358 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
359 359
360 360 /* Character Data - Index: 47 */
361 361 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x80,0x01,0x00,0x80,0x01,0x00,0xC0,0x00,0x00,0xC0,0x00,0x00,0xC0,0x00,0x00,0x60,0x00,0x00,0x60,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
362 362
363 363 /* Character Data - Index: 48 */
364 364 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x00,0x00,0xF8,0x01,0x00,0x8C,0x01,0x00,0x0E,0x03,0x00,0x06,0x03,0x00,0x06,0x03,0x00,0x06,0x03,0x00,0x06,0x03,0x00,0x06,0x03,0x00,0x8E,0x03,0x00,0x8C,0x01,0x00,0xFC,0x01,0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
365 365
366 366 /* Character Data - Index: 49 */
367 367 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x38,0x00,0x00,0x3C,0x00,0x00,0x34,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0xFC,0x00,0x00,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
368 368
369 369 /* Character Data - Index: 50 */
370 370 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x00,0x00,0xF8,0x03,0x00,0x9C,0x03,0x00,0x0C,0x03,0x00,0x00,0x03,0x00,0x80,0x01,0x00,0xC0,0x00,0x00,0x70,0x00,0x00,0x18,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0xFC,0x03,0x00,0xFC,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
371 371
372 372 /* Character Data - Index: 51 */
373 373 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x00,0x00,0xFC,0x01,0x00,0x0C,0x03,0x00,0x00,0x03,0x00,0x80,0x03,0x00,0xF0,0x01,0x00,0xF0,0x00,0x00,0x80,0x03,0x00,0x00,0x03,0x00,0x04,0x03,0x00,0x8C,0x03,0x00,0xF8,0x01,0x00,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
374 374
375 375 /* Character Data - Index: 52 */
376 376 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x01,0x00,0xC0,0x01,0x00,0xE0,0x01,0x00,0xA0,0x01,0x00,0x90,0x01,0x00,0x98,0x01,0x00,0x8C,0x01,0x00,0xFE,0x07,0x00,0xFE,0x07,0x00,0x80,0x01,0x00,0x80,0x01,0x00,0x80,0x01,0x00,0x80,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
377 377
378 378 /* Character Data - Index: 53 */
379 379 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x03,0x00,0xFC,0x03,0x00,0x0C,0x00,0x00,0xFC,0x00,0x00,0xFC,0x01,0x00,0x8C,0x03,0x00,0x0C,0x03,0x00,0x00,0x03,0x00,0x00,0x03,0x00,0x00,0x03,0x00,0x8C,0x01,0x00,0xFC,0x01,0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
380 380
381 381 /* Character Data - Index: 54 */
382 382 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x00,0x00,0xE0,0x00,0x00,0x70,0x00,0x00,0x38,0x00,0x00,0x18,0x00,0x00,0xFC,0x00,0x00,0xFC,0x01,0x00,0x0C,0x03,0x00,0x0C,0x03,0x00,0x0C,0x03,0x00,0x9C,0x03,0x00,0xF8,0x01,0x00,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
383 383
384 384 /* Character Data - Index: 55 */
385 385 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x07,0x00,0xFE,0x07,0x00,0x00,0x03,0x00,0x80,0x01,0x00,0xC0,0x00,0x00,0xC0,0x00,0x00,0x60,0x00,0x00,0x60,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x10,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
386 386
387 387 /* Character Data - Index: 56 */
388 388 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x00,0x00,0xFC,0x03,0x00,0x0E,0x03,0x00,0x06,0x03,0x00,0x8E,0x03,0x00,0xFE,0x01,0x00,0xFC,0x01,0x00,0x8E,0x03,0x00,0x06,0x03,0x00,0x06,0x03,0x00,0x8E,0x03,0x00,0xFC,0x01,0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
389 389
390 390 /* Character Data - Index: 57 */
391 391 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x00,0x00,0xFC,0x01,0x00,0x8E,0x03,0x00,0x06,0x03,0x00,0x06,0x03,0x00,0x06,0x03,0x00,0x8E,0x03,0x00,0xFC,0x03,0x00,0xF8,0x01,0x00,0x80,0x01,0x00,0xC0,0x00,0x00,0xE0,0x00,0x00,0x3C,0x00,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
392 392
393 393 /* Character Data - Index: 58 */
394 394 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
395 395
396 396 /* Character Data - Index: 59 */
397 397 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
398 398
399 399 /* Character Data - Index: 60 */
400 400 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x38,0x00,0x00,0x1C,0x00,0x00,0x06,0x00,0x00,0x0C,0x00,0x00,0x18,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
401 401
402 402 /* Character Data - Index: 61 */
403 403 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x00,0x00,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x00,0x00,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
404 404
405 405 /* Character Data - Index: 62 */
406 406 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x00,0x1C,0x00,0x00,0x30,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0x38,0x00,0x00,0x1C,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
407 407
408 408 /* Character Data - Index: 63 */
409 409 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x00,0xFC,0x01,0x00,0x8C,0x03,0x00,0x00,0x03,0x00,0x00,0x03,0x00,0x00,0x03,0x00,0x80,0x01,0x00,0xE0,0x00,0x00,0x30,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
410 410
411 411 /* Character Data - Index: 64 */
412 412 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x0F,0x00,0xE0,0x3F,0x00,0x70,0x78,0x00,0x18,0x60,0x00,0x98,0xC3,0x00,0xCC,0xC1,0x00,0x6C,0xC6,0x00,0x6C,0xC6,0x00,0xEC,0x7F,0x00,0xCC,0x3D,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x70,0x18,0x00,0xE0,0x1F,0x00,0xC0,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
413 413
414 414 /* Character Data - Index: 65 */
415 415 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x03,0x00,0x80,0x03,0x00,0xC0,0x06,0x00,0xC0,0x06,0x00,0x60,0x06,0x00,0x60,0x07,0x00,0xF0,0x07,0x00,0x78,0x06,0x00,0x18,0x0E,0x00,0x18,0x0C,0x00,0x0C,0x0C,0x00,0x0C,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
416 416
417 417 /* Character Data - Index: 66 */
418 418 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x00,0x00,0xFC,0x01,0x00,0x8C,0x03,0x00,0x0C,0x03,0x00,0x0C,0x03,0x00,0x8C,0x03,0x00,0xFC,0x01,0x00,0xFC,0x03,0x00,0x0C,0x07,0x00,0x0C,0x06,0x00,0x8C,0x07,0x00,0xFC,0x03,0x00,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
419 419
420 420 /* Character Data - Index: 67 */
421 421 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x03,0x00,0xF0,0x03,0x00,0x38,0x03,0x00,0x18,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x06,0x00,0x00,0x06,0x00,0x00,0x06,0x00,0x00,0x06,0x03,0x00,0x8E,0x03,0x00,0xFC,0x01,0x00,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
422 422
423 423 /* Character Data - Index: 68 */
424 424 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x00,0x7C,0x00,0x00,0xEC,0x01,0x00,0x8C,0x03,0x00,0x0C,0x06,0x00,0x0C,0x0E,0x00,0x0C,0x0C,0x00,0x0C,0x0C,0x00,0x0C,0x0C,0x00,0x0C,0x0E,0x00,0x0C,0x07,0x00,0xFC,0x03,0x00,0xF8,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
425 425
426 426 /* Character Data - Index: 69 */
427 427 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x07,0x00,0xFC,0x07,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0xFC,0x03,0x00,0xFC,0x03,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0xFC,0x03,0x00,0xF8,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
428 428
429 429 /* Character Data - Index: 70 */
430 430 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x03,0x00,0xFC,0x07,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0xFC,0x03,0x00,0xFC,0x03,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
431 431
432 432 /* Character Data - Index: 71 */
433 433 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x01,0x00,0xF0,0x07,0x00,0x38,0x06,0x00,0x18,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0xF6,0x0F,0x00,0xF6,0x0F,0x00,0x06,0x0C,0x00,0x06,0x06,0x00,0x0E,0x07,0x00,0xFC,0x03,0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
434 434
435 435 /* Character Data - Index: 72 */
436 436 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x18,0x00,0x0C,0x18,0x00,0x0C,0x18,0x00,0x0C,0x18,0x00,0x0C,0x18,0x00,0x0C,0x18,0x00,0x8C,0x1F,0x00,0xFC,0x1F,0x00,0x7C,0x18,0x00,0x0C,0x18,0x00,0x0C,0x18,0x00,0x0C,0x18,0x00,0x0C,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
437 437
438 438 /* Character Data - Index: 73 */
439 439 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x01,0x00,0xFE,0x01,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0xFE,0x01,0x00,0xFE,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
440 440
441 441 /* Character Data - Index: 74 */
442 442 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x0F,0x00,0xF0,0x0F,0x00,0x80,0x01,0x00,0x80,0x01,0x00,0x80,0x01,0x00,0x80,0x01,0x00,0x80,0x01,0x00,0x80,0x01,0x00,0x86,0x01,0x00,0x86,0x01,0x00,0xCE,0x01,0x00,0xFC,0x01,0x00,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
443 443
444 444 /* Character Data - Index: 75 */
445 445 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x04,0x00,0x0C,0x06,0x00,0x0C,0x03,0x00,0x8C,0x01,0x00,0xEC,0x00,0x00,0x7C,0x00,0x00,0x3C,0x00,0x00,0x3C,0x00,0x00,0x6C,0x00,0x00,0xEC,0x00,0x00,0xCC,0x01,0x00,0x8C,0x07,0x00,0x0C,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
446 446
447 447 /* Character Data - Index: 76 */
448 448 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0xFC,0x01,0x00,0xFC,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
449 449
450 450 /* Character Data - Index: 77 */
451 451 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x08,0x00,0x70,0x1C,0x00,0x70,0x1C,0x00,0x70,0x1C,0x00,0x70,0x14,0x00,0xD8,0x34,0x00,0xD8,0x36,0x00,0xD8,0x36,0x00,0xD8,0x36,0x00,0xCC,0x36,0x00,0x8C,0x33,0x00,0x8C,0x63,0x00,0x8C,0x63,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
452 452
453 453 /* Character Data - Index: 78 */
454 454 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x10,0x00,0x1C,0x30,0x00,0x1C,0x30,0x00,0x3C,0x30,0x00,0x6C,0x30,0x00,0xCC,0x30,0x00,0x8C,0x31,0x00,0x8C,0x31,0x00,0x0C,0x33,0x00,0x0C,0x36,0x00,0x0C,0x3C,0x00,0x0C,0x38,0x00,0x0C,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
455 455
456 456 /* Character Data - Index: 79 */
457 457 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x07,0x00,0xE0,0x1F,0x00,0x70,0x38,0x00,0x38,0x30,0x00,0x18,0x30,0x00,0x0C,0x30,0x00,0x0C,0x30,0x00,0x0C,0x30,0x00,0x0C,0x18,0x00,0x1C,0x18,0x00,0x38,0x0C,0x00,0xF0,0x07,0x00,0xE0,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
458 458
459 459 /* Character Data - Index: 80 */
460 460 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x00,0x00,0xFC,0x00,0x00,0xCC,0x01,0x00,0x8C,0x01,0x00,0x8C,0x01,0x00,0xCC,0x01,0x00,0xFC,0x00,0x00,0x7C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
461 461
462 462 /* Character Data - Index: 81 */
463 463 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x0F,0x00,0xE0,0x1F,0x00,0x70,0x38,0x00,0x18,0x30,0x00,0x1C,0x70,0x00,0x0C,0x60,0x00,0x0C,0x60,0x00,0x0C,0x60,0x00,0x0C,0x61,0x00,0x18,0x63,0x00,0x38,0x36,0x00,0xF0,0x3F,0x00,0xC0,0x1B,0x00,0x00,0x30,0x00,0x00,0x70,0x00,0x00,0x60,0x00,0x00,0x40,0x00,0x00,0x00,0x00,
464 464
465 465 /* Character Data - Index: 82 */
466 466 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x00,0x00,0xFC,0x00,0x00,0xCC,0x01,0x00,0x8C,0x03,0x00,0x0C,0x03,0x00,0x0C,0x03,0x00,0x8C,0x03,0x00,0xFC,0x01,0x00,0x7C,0x00,0x00,0xEC,0x00,0x00,0x8C,0x03,0x00,0x0C,0x07,0x00,0x0C,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
467 467
468 468 /* Character Data - Index: 83 */
469 469 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x03,0x00,0xF0,0x07,0x00,0x30,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0xF8,0x03,0x00,0xF0,0x07,0x00,0x00,0x0E,0x00,0x00,0x0C,0x00,0x0C,0x0C,0x00,0x1C,0x0E,0x00,0xF8,0x07,0x00,0xF0,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
470 470
471 471 /* Character Data - Index: 84 */
472 472 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x0F,0x00,0xFE,0x0F,0x00,0x60,0x00,0x00,0x60,0x00,0x00,0x60,0x00,0x00,0x60,0x00,0x00,0x60,0x00,0x00,0x60,0x00,0x00,0x60,0x00,0x00,0x60,0x00,0x00,0x60,0x00,0x00,0x60,0x00,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
473 473
474 474 /* Character Data - Index: 85 */
475 475 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x18,0x00,0x0C,0x18,0x00,0x0C,0x18,0x00,0x0C,0x18,0x00,0x0C,0x18,0x00,0x0C,0x18,0x00,0x0C,0x18,0x00,0x0C,0x18,0x00,0x0C,0x0C,0x00,0x1C,0x0C,0x00,0x38,0x0E,0x00,0xF8,0x07,0x00,0xE0,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
476 476
477 477 /* Character Data - Index: 86 */
478 478 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x0C,0x00,0x0C,0x0C,0x00,0x0C,0x06,0x00,0x18,0x06,0x00,0x18,0x06,0x00,0x18,0x03,0x00,0x18,0x03,0x00,0x30,0x03,0x00,0xB0,0x01,0x00,0xB0,0x01,0x00,0xB0,0x01,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
479 479
480 480 /* Character Data - Index: 87 */
481 481 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x0C,0x02,0x0C,0x0E,0x03,0x1C,0x0E,0x03,0x18,0x0E,0x03,0x18,0x1B,0x03,0x18,0x9B,0x01,0x30,0x9B,0x01,0xB0,0x99,0x01,0xB0,0xD9,0x00,0xA0,0xD9,0x00,0xE0,0xD8,0x00,0xE0,0x78,0x00,0xE0,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
482 482
483 483 /* Character Data - Index: 88 */
484 484 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x18,0x00,0x1C,0x18,0x00,0x38,0x0C,0x00,0x70,0x06,0x00,0x60,0x07,0x00,0xC0,0x03,0x00,0x80,0x01,0x00,0xC0,0x03,0x00,0x60,0x03,0x00,0x30,0x06,0x00,0x18,0x0C,0x00,0x1C,0x1C,0x00,0x0C,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
485 485
486 486 /* Character Data - Index: 89 */
487 487 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x06,0x00,0x06,0x06,0x00,0x0C,0x03,0x00,0x18,0x03,0x00,0x98,0x01,0x00,0xB0,0x01,0x00,0xB0,0x01,0x00,0xE0,0x00,0x00,0xC0,0x00,0x00,0x60,0x00,0x00,0x60,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
488 488
489 489 /* Character Data - Index: 90 */
490 490 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x1F,0x00,0xFC,0x1F,0x00,0x00,0x0E,0x00,0x00,0x03,0x00,0x80,0x01,0x00,0xC0,0x01,0x00,0xC0,0x00,0x00,0x60,0x00,0x00,0x30,0x00,0x00,0x18,0x00,0x00,0x0C,0x00,0x00,0xFC,0x1F,0x00,0xFC,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
491 491
492 492 /* Character Data - Index: 91 */
493 493 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x00,0x00,0xF8,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0xF8,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,0x00,
494 494
495 495 /* Character Data - Index: 92 */
496 496 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x60,0x00,0x00,0x60,0x00,0x00,0x40,0x00,0x00,0xC0,0x00,0x00,0xC0,0x00,0x00,0x80,0x01,0x00,0x80,0x01,0x00,0x80,0x01,0x00,0x00,0x03,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
497 497
498 498 /* Character Data - Index: 93 */
499 499 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x00,0x00,0x3E,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x3E,0x00,0x00,0x3E,0x00,0x00,0x00,0x00,0x00,
500 500
501 501 /* Character Data - Index: 94 */
502 502 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0xE0,0x00,0x00,0x30,0x01,0x00,0x18,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
503 503
504 504 /* Character Data - Index: 95 */
505 505 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
506 506
507 507 /* Character Data - Index: 96 */
508 508 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x00,0x18,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
509 509
510 510 /* Character Data - Index: 97 */
511 511 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x01,0x00,0xF8,0x01,0x00,0x98,0x01,0x00,0x8C,0x01,0x00,0x8C,0x01,0x00,0x8C,0x01,0x00,0x8C,0x01,0x00,0xF8,0x03,0x00,0x70,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
512 512
513 513 /* Character Data - Index: 98 */
514 514 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0xEC,0x00,0x00,0xFC,0x01,0x00,0x9C,0x03,0x00,0x0C,0x03,0x00,0x0C,0x03,0x00,0x0C,0x03,0x00,0x8C,0x03,0x00,0xFC,0x01,0x00,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
515 515
516 516 /* Character Data - Index: 99 */
517 517 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x00,0x00,0xF8,0x01,0x00,0x98,0x01,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x9C,0x01,0x00,0xF8,0x01,0x00,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
518 518
519 519 /* Character Data - Index: 100 */
520 520 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x03,0x00,0x00,0x03,0x00,0x00,0x03,0x00,0x00,0x03,0x00,0xF0,0x03,0x00,0xF8,0x03,0x00,0x1C,0x03,0x00,0x0C,0x03,0x00,0x0C,0x03,0x00,0x0C,0x03,0x00,0x9C,0x03,0x00,0xF8,0x03,0x00,0xF0,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
521 521
522 522 /* Character Data - Index: 101 */
523 523 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x01,0x00,0xF8,0x03,0x00,0x18,0x03,0x00,0xCC,0x03,0x00,0xFC,0x00,0x00,0x3C,0x00,0x00,0x1C,0x02,0x00,0xF8,0x03,0x00,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
524 524
525 525 /* Character Data - Index: 102 */
526 526 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x01,0x00,0xE0,0x01,0x00,0x70,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0xFC,0x01,0x00,0xFC,0x01,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
527 527
528 528 /* Character Data - Index: 103 */
529 529 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x00,0x00,0xF8,0x01,0x00,0x98,0x01,0x00,0x8C,0x01,0x00,0x8C,0x01,0x00,0x8C,0x01,0x00,0xCC,0x01,0x00,0xF8,0x01,0x00,0xB8,0x01,0x00,0x80,0x01,0x00,0x80,0x01,0x00,0xC0,0x00,0x00,0xFC,0x00,0x00,0x7C,0x00,0x00,
530 530
531 531 /* Character Data - Index: 104 */
532 532 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0xEC,0x00,0x00,0xFC,0x01,0x00,0x9C,0x01,0x00,0x8C,0x01,0x00,0x8C,0x01,0x00,0x8C,0x01,0x00,0x8C,0x01,0x00,0x8C,0x01,0x00,0x8C,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
533 533
534 534 /* Character Data - Index: 105 */
535 535 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
536 536
537 537 /* Character Data - Index: 106 */
538 538 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x33,0x00,0x00,0x33,0x00,0x00,0x3E,0x00,0x00,0x1C,0x00,0x00,
539 539
540 540 /* Character Data - Index: 107 */
541 541 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x03,0x00,0x8C,0x01,0x00,0xCC,0x00,0x00,0x6C,0x00,0x00,0x7C,0x00,0x00,0xDC,0x00,0x00,0x8C,0x01,0x00,0x0C,0x03,0x00,0x0C,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
542 542
543 543 /* Character Data - Index: 108 */
544 544 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
545 545
546 546 /* Character Data - Index: 109 */
547 547 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xCC,0x0E,0x00,0xEC,0x1F,0x00,0xBC,0x1B,0x00,0x9C,0x19,0x00,0x8C,0x19,0x00,0x8C,0x19,0x00,0x8C,0x19,0x00,0x8C,0x19,0x00,0x8C,0x19,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
548 548
549 549 /* Character Data - Index: 110 */
550 550 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xEC,0x00,0x00,0xFC,0x01,0x00,0x9C,0x01,0x00,0x8C,0x01,0x00,0x8C,0x01,0x00,0x8C,0x01,0x00,0x8C,0x01,0x00,0x8C,0x01,0x00,0x8C,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
551 551
552 552 /* Character Data - Index: 111 */
553 553 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x00,0x00,0xF8,0x01,0x00,0x98,0x03,0x00,0x0C,0x03,0x00,0x0C,0x03,0x00,0x0C,0x03,0x00,0x9C,0x03,0x00,0xF8,0x01,0x00,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
554 554
555 555 /* Character Data - Index: 112 */
556 556 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x00,0xEC,0x00,0x00,0xFC,0x00,0x00,0x9C,0x01,0x00,0x8C,0x01,0x00,0x8C,0x01,0x00,0x8C,0x01,0x00,0xCC,0x01,0x00,0xFC,0x00,0x00,0x7C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,
557 557
558 558 /* Character Data - Index: 113 */
559 559 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x01,0x00,0xF8,0x01,0x00,0x98,0x01,0x00,0x8C,0x01,0x00,0x8C,0x01,0x00,0x8C,0x01,0x00,0x8C,0x01,0x00,0xF8,0x01,0x00,0xF0,0x01,0x00,0x80,0x01,0x00,0x80,0x01,0x00,0x80,0x01,0x00,0x80,0x01,0x00,0x80,0x01,0x00,
560 560
561 561 /* Character Data - Index: 114 */
562 562 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xEC,0x00,0x00,0xFC,0x00,0x00,0xDC,0x00,0x00,0xCC,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
563 563
564 564 /* Character Data - Index: 115 */
565 565 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x00,0x00,0xF8,0x00,0x00,0xDC,0x00,0x00,0x0C,0x00,0x00,0x7C,0x00,0x00,0xF0,0x00,0x00,0xC0,0x00,0x00,0xFC,0x00,0x00,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
566 566
567 567 /* Character Data - Index: 116 */
568 568 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0xFC,0x00,0x00,0xFC,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
569 569
570 570 /* Character Data - Index: 117 */
571 571 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x8C,0x01,0x00,0x8C,0x01,0x00,0x8C,0x01,0x00,0x8C,0x01,0x00,0x8C,0x01,0x00,0x8C,0x01,0x00,0x8C,0x01,0x00,0xFC,0x01,0x00,0xF8,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
572 572
573 573 /* Character Data - Index: 118 */
574 574 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x86,0x01,0x00,0x86,0x01,0x00,0x8C,0x00,0x00,0xCC,0x00,0x00,0xCC,0x00,0x00,0x78,0x00,0x00,0x78,0x00,0x00,0x38,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
575 575
576 576 /* Character Data - Index: 119 */
577 577 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x8C,0x19,0x00,0x8C,0x19,0x00,0xCC,0x19,0x00,0xCC,0x0D,0x00,0xD8,0x0D,0x00,0x58,0x0D,0x00,0x78,0x0D,0x00,0x38,0x07,0x00,0x30,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
578 578
579 579 /* Character Data - Index: 120 */
580 580 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x03,0x00,0x8E,0x03,0x00,0xDC,0x01,0x00,0xF8,0x00,0x00,0x70,0x00,0x00,0xF8,0x00,0x00,0xDC,0x01,0x00,0x8E,0x03,0x00,0x06,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
581 581
582 582 /* Character Data - Index: 121 */
583 583 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x03,0x00,0x06,0x03,0x00,0x8C,0x01,0x00,0x8C,0x01,0x00,0xD8,0x00,0x00,0xD8,0x00,0x00,0x70,0x00,0x00,0x70,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x10,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x08,0x00,0x00,
584 584
585 585 /* Character Data - Index: 122 */
586 586 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x03,0x00,0xFC,0x03,0x00,0xC0,0x01,0x00,0xC0,0x00,0x00,0xE0,0x00,0x00,0x70,0x00,0x00,0x38,0x00,0x00,0xFC,0x03,0x00,0xFC,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
587 587
588 588 /* Character Data - Index: 123 */
589 589 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x00,0x78,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0E,0x00,0x00,0x06,0x00,0x00,0x0E,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x1C,0x00,0x00,0x78,0x00,0x00,0x70,0x00,0x00,0x00,0x00,0x00,
590 590
591 591 /* Character Data - Index: 124 */
592 592 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
593 593
594 594 /* Character Data - Index: 125 */
595 595 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0E,0x00,0x00,0x1E,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x38,0x00,0x00,0x70,0x00,0x00,0x38,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x18,0x00,0x00,0x0E,0x00,0x00,0x0E,0x00,0x00,0x00,0x00,0x00,
596 596
597 597 /* Character Data - Index: 126 */
598 598 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x78,0x04,0x00,0xC8,0x06,0x00,0xCC,0x07,0x00,0x84,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
599 599
600 600 /* Character Data - Index: 127 */
601 601 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
602 602
603 603 };
604 604
605 605
606 606 /* Character bitmaps for Comic Sans MS 8pt */
607 607 const uint8_t comicSansMS_8ptBitmaps[] =
608 608 {
609 609 // @0 ' ' (11 pixels wide)
610 610 0x00, 0x00, //
611 611 0x00, 0x00, //
612 612 0x00, 0x00, //
613 613 0x00, 0x00, //
614 614 0x00, 0x00, //
615 615 0x00, 0x00, //
616 616 0x00, 0x00, //
617 617 0x00, 0x00, //
618 618 0x00, 0x00, //
619 619 0x00, 0x00, //
620 620 0x00, 0x00, //
621 621 0x00, 0x00, //
622 622
623 623 // @24 '!' (11 pixels wide)
624 624 0x20, 0x00, // #
625 625 0x20, 0x00, // #
626 626 0x20, 0x00, // #
627 627 0x20, 0x00, // #
628 628 0x20, 0x00, // #
629 629 0x20, 0x00, // #
630 630 0x20, 0x00, // #
631 631 0x00, 0x00, //
632 632 0x20, 0x00, // #
633 633 0x00, 0x00, //
634 634 0x00, 0x00, //
635 635 0x00, 0x00, //
636 636
637 637 // @48 '"' (11 pixels wide)
638 638 0x00, 0x00, //
639 639 0x50, 0x00, // # #
640 640 0x50, 0x00, // # #
641 641 0x50, 0x00, // # #
642 642 0x00, 0x00, //
643 643 0x00, 0x00, //
644 644 0x00, 0x00, //
645 645 0x00, 0x00, //
646 646 0x00, 0x00, //
647 647 0x00, 0x00, //
648 648 0x00, 0x00, //
649 649 0x00, 0x00, //
650 650
651 651 // @72 '#' (11 pixels wide)
652 652 0x00, 0x00, //
653 653 0x10, 0x01, // # #
654 654 0x10, 0x01, // # #
655 655 0xFC, 0x03, // ########
656 656 0x88, 0x00, // # #
657 657 0x88, 0x00, // # #
658 658 0xFE, 0x01, // ########
659 659 0x44, 0x00, // # #
660 660 0x44, 0x00, // # #
661 661 0x00, 0x00, //
662 662 0x00, 0x00, //
663 663 0x00, 0x00, //
664 664
665 665 // @96 '$' (11 pixels wide)
666 666 0x20, 0x00, // #
667 667 0xF0, 0x00, // ####
668 668 0x28, 0x00, // # #
669 669 0x28, 0x00, // # #
670 670 0x70, 0x00, // ###
671 671 0xA0, 0x00, // # #
672 672 0xA0, 0x00, // # #
673 673 0xA0, 0x00, // # #
674 674 0x78, 0x00, // ####
675 675 0x20, 0x00, // #
676 676 0x20, 0x00, // #
677 677 0x00, 0x00, //
678 678
679 679 // @120 '%' (11 pixels wide)
680 680 0x80, 0x00, // #
681 681 0xCC, 0x00, // ## ##
682 682 0x52, 0x00, // # # #
683 683 0x72, 0x00, // # ###
684 684 0x2C, 0x00, // ## #
685 685 0xB0, 0x01, // ## ##
686 686 0x50, 0x02, // # # #
687 687 0x58, 0x02, // ## # #
688 688 0x88, 0x01, // # ##
689 689 0x00, 0x00, //
690 690 0x00, 0x00, //
691 691 0x00, 0x00, //
692 692
693 693 // @144 '&' (11 pixels wide)
694 694 0x00, 0x00, //
695 695 0x60, 0x00, // ##
696 696 0x50, 0x00, // # #
697 697 0x30, 0x00, // ##
698 698 0xB8, 0x00, // ### #
699 699 0xAC, 0x00, // ## # #
700 700 0xC4, 0x00, // # ##
701 701 0x44, 0x00, // # #
702 702 0xB8, 0x00, // ### #
703 703 0x00, 0x00, //
704 704 0x00, 0x00, //
705 705 0x00, 0x00, //
706 706
707 707 // @168 ''' (11 pixels wide)
708 708 0x00, 0x00, //
709 709 0x20, 0x00, // #
710 710 0x20, 0x00, // #
711 711 0x20, 0x00, // #
712 712 0x00, 0x00, //
713 713 0x00, 0x00, //
714 714 0x00, 0x00, //
715 715 0x00, 0x00, //
716 716 0x00, 0x00, //
717 717 0x00, 0x00, //
718 718 0x00, 0x00, //
719 719 0x00, 0x00, //
720 720
721 721 // @192 '(' (11 pixels wide)
722 722 0x40, 0x00, // #
723 723 0x20, 0x00, // #
724 724 0x20, 0x00, // #
725 725 0x10, 0x00, // #
726 726 0x10, 0x00, // #
727 727 0x10, 0x00, // #
728 728 0x10, 0x00, // #
729 729 0x10, 0x00, // #
730 730 0x10, 0x00, // #
731 731 0x20, 0x00, // #
732 732 0x40, 0x00, // #
733 733 0x00, 0x00, //
734 734
735 735 // @216 ')' (11 pixels wide)
736 736 0x08, 0x00, // #
737 737 0x10, 0x00, // #
738 738 0x10, 0x00, // #
739 739 0x20, 0x00, // #
740 740 0x20, 0x00, // #
741 741 0x20, 0x00, // #
742 742 0x20, 0x00, // #
743 743 0x20, 0x00, // #
744 744 0x20, 0x00, // #
745 745 0x10, 0x00, // #
746 746 0x08, 0x00, // #
747 747 0x00, 0x00, //
748 748
749 749 // @240 '*' (11 pixels wide)
750 750 0x00, 0x00, //
751 751 0x10, 0x00, // #
752 752 0x7C, 0x00, // #####
753 753 0x38, 0x00, // ###
754 754 0x2C, 0x00, // ## #
755 755 0x00, 0x00, //
756 756 0x00, 0x00, //
757 757 0x00, 0x00, //
758 758 0x00, 0x00, //
759 759 0x00, 0x00, //
760 760 0x00, 0x00, //
761 761 0x00, 0x00, //
762 762
763 763 // @264 '+' (11 pixels wide)
764 764 0x00, 0x00, //
765 765 0x00, 0x00, //
766 766 0x00, 0x00, //
767 767 0x20, 0x00, // #
768 768 0x20, 0x00, // #
769 769 0xF8, 0x00, // #####
770 770 0x20, 0x00, // #
771 771 0x20, 0x00, // #
772 772 0x00, 0x00, //
773 773 0x00, 0x00, //
774 774 0x00, 0x00, //
775 775 0x00, 0x00, //
776 776
777 777 // @288 ',' (11 pixels wide)
778 778 0x00, 0x00, //
779 779 0x00, 0x00, //
780 780 0x00, 0x00, //
781 781 0x00, 0x00, //
782 782 0x00, 0x00, //
783 783 0x00, 0x00, //
784 784 0x00, 0x00, //
785 785 0x00, 0x00, //
786 786 0x20, 0x00, // #
787 787 0x10, 0x00, // #
788 788 0x00, 0x00, //
789 789 0x00, 0x00, //
790 790
791 791 // @312 '-' (11 pixels wide)
792 792 0x00, 0x00, //
793 793 0x00, 0x00, //
794 794 0x00, 0x00, //
795 795 0x00, 0x00, //
796 796 0x00, 0x00, //
797 797 0x00, 0x00, //
798 798 0x70, 0x00, // ###
799 799 0x00, 0x00, //
800 800 0x00, 0x00, //
801 801 0x00, 0x00, //
802 802 0x00, 0x00, //
803 803 0x00, 0x00, //
804 804
805 805 // @336 '.' (11 pixels wide)
806 806 0x00, 0x00, //
807 807 0x00, 0x00, //
808 808 0x00, 0x00, //
809 809 0x00, 0x00, //
810 810 0x00, 0x00, //
811 811 0x00, 0x00, //
812 812 0x00, 0x00, //
813 813 0x00, 0x00, //
814 814 0x20, 0x00, // #
815 815 0x00, 0x00, //
816 816 0x00, 0x00, //
817 817 0x00, 0x00, //
818 818
819 819 // @360 '/' (11 pixels wide)
820 820 0x80, 0x00, // #
821 821 0x40, 0x00, // #
822 822 0x40, 0x00, // #
823 823 0x40, 0x00, // #
824 824 0x20, 0x00, // #
825 825 0x10, 0x00, // #
826 826 0x10, 0x00, // #
827 827 0x08, 0x00, // #
828 828 0x08, 0x00, // #
829 829 0x00, 0x00, //
830 830 0x00, 0x00, //
831 831 0x00, 0x00, //
832 832
833 833 // @384 '0' (11 pixels wide)
834 834 0x00, 0x00, //
835 835 0x70, 0x00, // ###
836 836 0x88, 0x00, // # #
837 837 0x88, 0x00, // # #
838 838 0x88, 0x00, // # #
839 839 0x88, 0x00, // # #
840 840 0x88, 0x00, // # #
841 841 0x88, 0x00, // # #
842 842 0x70, 0x00, // ###
843 843 0x00, 0x00, //
844 844 0x00, 0x00, //
845 845 0x00, 0x00, //
846 846
847 847 // @408 '1' (11 pixels wide)
848 848 0x00, 0x00, //
849 849 0x20, 0x00, // #
850 850 0x30, 0x00, // ##
851 851 0x20, 0x00, // #
852 852 0x20, 0x00, // #
853 853 0x20, 0x00, // #
854 854 0x20, 0x00, // #
855 855 0x20, 0x00, // #
856 856 0x70, 0x00, // ###
857 857 0x00, 0x00, //
858 858 0x00, 0x00, //
859 859 0x00, 0x00, //
860 860
861 861 // @432 '2' (11 pixels wide)
862 862 0x00, 0x00, //
863 863 0x70, 0x00, // ###
864 864 0x88, 0x00, // # #
865 865 0x80, 0x00, // #
866 866 0x40, 0x00, // #
867 867 0x20, 0x00, // #
868 868 0x10, 0x00, // #
869 869 0x08, 0x00, // #
870 870 0xF8, 0x00, // #####
871 871 0x00, 0x00, //
872 872 0x00, 0x00, //
873 873 0x00, 0x00, //
874 874
875 875 // @456 '3' (11 pixels wide)
876 876 0x00, 0x00, //
877 877 0x70, 0x00, // ###
878 878 0x88, 0x00, // # #
879 879 0x80, 0x00, // #
880 880 0x70, 0x00, // ###
881 881 0x80, 0x00, // #
882 882 0x80, 0x00, // #
883 883 0x88, 0x00, // # #
884 884 0x70, 0x00, // ###
885 885 0x00, 0x00, //
886 886 0x00, 0x00, //
887 887 0x00, 0x00, //
888 888
889 889 // @480 '4' (11 pixels wide)
890 890 0x00, 0x00, //
891 891 0x40, 0x00, // #
892 892 0x60, 0x00, // ##
893 893 0x50, 0x00, // # #
894 894 0x50, 0x00, // # #
895 895 0x48, 0x00, // # #
896 896 0xFC, 0x00, // ######
897 897 0x40, 0x00, // #
898 898 0x40, 0x00, // #
899 899 0x00, 0x00, //
900 900 0x00, 0x00, //
901 901 0x00, 0x00, //
902 902
903 903 // @504 '5' (11 pixels wide)
904 904 0x00, 0x00, //
905 905 0xF8, 0x00, // #####
906 906 0x08, 0x00, // #
907 907 0x78, 0x00, // ####
908 908 0x88, 0x00, // # #
909 909 0x80, 0x00, // #
910 910 0x80, 0x00, // #
911 911 0x88, 0x00, // # #
912 912 0x70, 0x00, // ###
913 913 0x00, 0x00, //
914 914 0x00, 0x00, //
915 915 0x00, 0x00, //
916 916
917 917 // @528 '6' (11 pixels wide)
918 918 0x00, 0x00, //
919 919 0x40, 0x00, // #
920 920 0x20, 0x00, // #
921 921 0x10, 0x00, // #
922 922 0x78, 0x00, // ####
923 923 0x88, 0x00, // # #
924 924 0x88, 0x00, // # #
925 925 0x88, 0x00, // # #
926 926 0x70, 0x00, // ###
927 927 0x00, 0x00, //
928 928 0x00, 0x00, //
929 929 0x00, 0x00, //
930 930
931 931 // @552 '7' (11 pixels wide)
932 932 0x00, 0x00, //
933 933 0xFC, 0x00, // ######
934 934 0x40, 0x00, // #
935 935 0x20, 0x00, // #
936 936 0x20, 0x00, // #
937 937 0x10, 0x00, // #
938 938 0x10, 0x00, // #
939 939 0x10, 0x00, // #
940 940 0x08, 0x00, // #
941 941 0x00, 0x00, //
942 942 0x00, 0x00, //
943 943 0x00, 0x00, //
944 944
945 945 // @576 '8' (11 pixels wide)
946 946 0x00, 0x00, //
947 947 0x70, 0x00, // ###
948 948 0x88, 0x00, // # #
949 949 0x88, 0x00, // # #
950 950 0x70, 0x00, // ###
951 951 0x88, 0x00, // # #
952 952 0x88, 0x00, // # #
953 953 0x88, 0x00, // # #
954 954 0x70, 0x00, // ###
955 955 0x00, 0x00, //
956 956 0x00, 0x00, //
957 957 0x00, 0x00, //
958 958
959 959 // @600 '9' (11 pixels wide)
960 960 0x00, 0x00, //
961 961 0x70, 0x00, // ###
962 962 0x88, 0x00, // # #
963 963 0x88, 0x00, // # #
964 964 0x88, 0x00, // # #
965 965 0xF0, 0x00, // ####
966 966 0x40, 0x00, // #
967 967 0x20, 0x00, // #
968 968 0x18, 0x00, // ##
969 969 0x00, 0x00, //
970 970 0x00, 0x00, //
971 971 0x00, 0x00, //
972 972
973 973 // @624 ':' (11 pixels wide)
974 974 0x00, 0x00, //
975 975 0x00, 0x00, //
976 976 0x00, 0x00, //
977 977 0x20, 0x00, // #
978 978 0x00, 0x00, //
979 979 0x00, 0x00, //
980 980 0x00, 0x00, //
981 981 0x20, 0x00, // #
982 982 0x00, 0x00, //
983 983 0x00, 0x00, //
984 984 0x00, 0x00, //
985 985 0x00, 0x00, //
986 986
987 987 // @648 ';' (11 pixels wide)
988 988 0x00, 0x00, //
989 989 0x00, 0x00, //
990 990 0x00, 0x00, //
991 991 0x20, 0x00, // #
992 992 0x00, 0x00, //
993 993 0x00, 0x00, //
994 994 0x00, 0x00, //
995 995 0x00, 0x00, //
996 996 0x20, 0x00, // #
997 997 0x10, 0x00, // #
998 998 0x00, 0x00, //
999 999 0x00, 0x00, //
1000 1000
1001 1001 // @672 '<' (11 pixels wide)
1002 1002 0x00, 0x00, //
1003 1003 0x00, 0x00, //
1004 1004 0x00, 0x00, //
1005 1005 0x20, 0x00, // #
1006 1006 0x10, 0x00, // #
1007 1007 0x08, 0x00, // #
1008 1008 0x10, 0x00, // #
1009 1009 0x20, 0x00, // #
1010 1010 0x00, 0x00, //
1011 1011 0x00, 0x00, //
1012 1012 0x00, 0x00, //
1013 1013 0x00, 0x00, //
1014 1014
1015 1015 // @696 '=' (11 pixels wide)
1016 1016 0x00, 0x00, //
1017 1017 0x00, 0x00, //
1018 1018 0x00, 0x00, //
1019 1019 0xF0, 0x00, // ####
1020 1020 0x00, 0x00, //
1021 1021 0x00, 0x00, //
1022 1022 0xF0, 0x00, // ####
1023 1023 0x00, 0x00, //
1024 1024 0x00, 0x00, //
1025 1025 0x00, 0x00, //
1026 1026 0x00, 0x00, //
1027 1027 0x00, 0x00, //
1028 1028
1029 1029 // @720 '>' (11 pixels wide)
1030 1030 0x00, 0x00, //
1031 1031 0x00, 0x00, //
1032 1032 0x00, 0x00, //
1033 1033 0x08, 0x00, // #
1034 1034 0x10, 0x00, // #
1035 1035 0x20, 0x00, // #
1036 1036 0x10, 0x00, // #
1037 1037 0x08, 0x00, // #
1038 1038 0x00, 0x00, //
1039 1039 0x00, 0x00, //
1040 1040 0x00, 0x00, //
1041 1041 0x00, 0x00, //
1042 1042
1043 1043 // @744 '?' (11 pixels wide)
1044 1044 0x00, 0x00, //
1045 1045 0x78, 0x00, // ####
1046 1046 0x80, 0x00, // #
1047 1047 0x80, 0x00, // #
1048 1048 0x40, 0x00, // #
1049 1049 0x20, 0x00, // #
1050 1050 0x10, 0x00, // #
1051 1051 0x00, 0x00, //
1052 1052 0x10, 0x00, // #
1053 1053 0x00, 0x00, //
1054 1054 0x00, 0x00, //
1055 1055 0x00, 0x00, //
1056 1056
1057 1057 // @768 '@' (11 pixels wide)
1058 1058 0xF8, 0x00, // #####
1059 1059 0x04, 0x01, // # #
1060 1060 0x72, 0x02, // # ### #
1061 1061 0xDA, 0x02, // # ## ## #
1062 1062 0xCA, 0x02, // # # ## #
1063 1063 0xB2, 0x01, // # ## ##
1064 1064 0x02, 0x00, // #
1065 1065 0x04, 0x01, // # #
1066 1066 0xF8, 0x00, // #####
1067 1067 0x00, 0x00, //
1068 1068 0x00, 0x00, //
1069 1069 0x00, 0x00, //
1070 1070
1071 1071 // @792 'A' (11 pixels wide)
1072 1072 0x00, 0x00, //
1073 1073 0x20, 0x00, // #
1074 1074 0x20, 0x00, // #
1075 1075 0x50, 0x00, // # #
1076 1076 0x48, 0x00, // # #
1077 1077 0x78, 0x00, // ####
1078 1078 0x44, 0x00, // # #
1079 1079 0x84, 0x00, // # #
1080 1080 0x82, 0x00, // # #
1081 1081 0x00, 0x00, //
1082 1082 0x00, 0x00, //
1083 1083 0x00, 0x00, //
1084 1084
1085 1085 // @816 'B' (11 pixels wide)
1086 1086 0x00, 0x00, //
1087 1087 0x78, 0x00, // ####
1088 1088 0x88, 0x00, // # #
1089 1089 0x88, 0x00, // # #
1090 1090 0x48, 0x00, // # #
1091 1091 0x78, 0x00, // ####
1092 1092 0x88, 0x00, // # #
1093 1093 0x88, 0x00, // # #
1094 1094 0x78, 0x00, // ####
1095 1095 0x00, 0x00, //
1096 1096 0x00, 0x00, //
1097 1097 0x00, 0x00, //
1098 1098
1099 1099 // @840 'C' (11 pixels wide)
1100 1100 0x00, 0x00, //
1101 1101 0xE0, 0x00, // ###
1102 1102 0x90, 0x00, // # #
1103 1103 0x08, 0x00, // #
1104 1104 0x04, 0x00, // #
1105 1105 0x04, 0x00, // #
1106 1106 0x04, 0x00, // #
1107 1107 0x84, 0x00, // # #
1108 1108 0x78, 0x00, // ####
1109 1109 0x00, 0x00, //
1110 1110 0x00, 0x00, //
1111 1111 0x00, 0x00, //
1112 1112
1113 1113 // @864 'D' (11 pixels wide)
1114 1114 0x00, 0x00, //
1115 1115 0x0C, 0x00, // ##
1116 1116 0x34, 0x00, // # ##
1117 1117 0x44, 0x00, // # #
1118 1118 0x84, 0x00, // # #
1119 1119 0x84, 0x00, // # #
1120 1120 0x84, 0x00, // # #
1121 1121 0x44, 0x00, // # #
1122 1122 0x3C, 0x00, // ####
1123 1123 0x00, 0x00, //
1124 1124 0x00, 0x00, //
1125 1125 0x00, 0x00, //
1126 1126
1127 1127 // @888 'E' (11 pixels wide)
1128 1128 0x00, 0x00, //
1129 1129 0xF8, 0x00, // #####
1130 1130 0x08, 0x00, // #
1131 1131 0x08, 0x00, // #
1132 1132 0xF8, 0x00, // #####
1133 1133 0x08, 0x00, // #
1134 1134 0x08, 0x00, // #
1135 1135 0x08, 0x00, // #
1136 1136 0xF8, 0x00, // #####
1137 1137 0x00, 0x00, //
1138 1138 0x00, 0x00, //
1139 1139 0x00, 0x00, //
1140 1140
1141 1141 // @912 'F' (11 pixels wide)
1142 1142 0x00, 0x00, //
1143 1143 0xF0, 0x01, // #####
1144 1144 0x10, 0x00, // #
1145 1145 0x10, 0x00, // #
1146 1146 0xF0, 0x00, // ####
1147 1147 0x10, 0x00, // #
1148 1148 0x10, 0x00, // #
1149 1149 0x10, 0x00, // #
1150 1150 0x10, 0x00, // #
1151 1151 0x00, 0x00, //
1152 1152 0x00, 0x00, //
1153 1153 0x00, 0x00, //
1154 1154
1155 1155 // @936 'G' (11 pixels wide)
1156 1156 0x00, 0x00, //
1157 1157 0xE0, 0x00, // ###
1158 1158 0x10, 0x01, // # #
1159 1159 0x08, 0x00, // #
1160 1160 0x04, 0x00, // #
1161 1161 0xF4, 0x01, // # #####
1162 1162 0x04, 0x01, // # #
1163 1163 0x84, 0x00, // # #
1164 1164 0x78, 0x00, // ####
1165 1165 0x00, 0x00, //
1166 1166 0x00, 0x00, //
1167 1167 0x00, 0x00, //
1168 1168
1169 1169 // @960 'H' (11 pixels wide)
1170 1170 0x00, 0x00, //
1171 1171 0x08, 0x01, // # #
1172 1172 0x08, 0x01, // # #
1173 1173 0x08, 0x01, // # #
1174 1174 0xF8, 0x01, // ######
1175 1175 0x08, 0x01, // # #
1176 1176 0x08, 0x01, // # #
1177 1177 0x08, 0x01, // # #
1178 1178 0x08, 0x01, // # #
1179 1179 0x00, 0x00, //
1180 1180 0x00, 0x00, //
1181 1181 0x00, 0x00, //
1182 1182
1183 1183 // @984 'I' (11 pixels wide)
1184 1184 0x00, 0x00, //
1185 1185 0x7C, 0x00, // #####
1186 1186 0x10, 0x00, // #
1187 1187 0x10, 0x00, // #
1188 1188 0x10, 0x00, // #
1189 1189 0x10, 0x00, // #
1190 1190 0x10, 0x00, // #
1191 1191 0x10, 0x00, // #
1192 1192 0x7C, 0x00, // #####
1193 1193 0x00, 0x00, //
1194 1194 0x00, 0x00, //
1195 1195 0x00, 0x00, //
1196 1196
1197 1197 // @1008 'J' (11 pixels wide)
1198 1198 0x00, 0x00, //
1199 1199 0xF0, 0x01, // #####
1200 1200 0x40, 0x00, // #
1201 1201 0x40, 0x00, // #
1202 1202 0x40, 0x00, // #
1203 1203 0x40, 0x00, // #
1204 1204 0x44, 0x00, // # #
1205 1205 0x44, 0x00, // # #
1206 1206 0x78, 0x00, // ####
1207 1207 0x00, 0x00, //
1208 1208 0x00, 0x00, //
1209 1209 0x00, 0x00, //
1210 1210
1211 1211 // @1032 'K' (11 pixels wide)
1212 1212 0x00, 0x00, //
1213 1213 0x88, 0x00, // # #
1214 1214 0x48, 0x00, // # #
1215 1215 0x28, 0x00, // # #
1216 1216 0x18, 0x00, // ##
1217 1217 0x18, 0x00, // ##
1218 1218 0x28, 0x00, // # #
1219 1219 0x48, 0x00, // # #
1220 1220 0x88, 0x00, // # #
1221 1221 0x00, 0x00, //
1222 1222 0x00, 0x00, //
1223 1223 0x00, 0x00, //
1224 1224
1225 1225 // @1056 'L' (11 pixels wide)
1226 1226 0x00, 0x00, //
1227 1227 0x08, 0x00, // #
1228 1228 0x08, 0x00, // #
1229 1229 0x08, 0x00, // #
1230 1230 0x08, 0x00, // #
1231 1231 0x08, 0x00, // #
1232 1232 0x08, 0x00, // #
1233 1233 0x08, 0x00, // #
1234 1234 0x78, 0x00, // ####
1235 1235 0x00, 0x00, //
1236 1236 0x00, 0x00, //
1237 1237 0x00, 0x00, //
1238 1238
1239 1239 // @1080 'M' (11 pixels wide)
1240 1240 0x00, 0x00, //
1241 1241 0x44, 0x00, // # #
1242 1242 0x44, 0x00, // # #
1243 1243 0x44, 0x00, // # #
1244 1244 0xAA, 0x00, // # # # #
1245 1245 0xAA, 0x00, // # # # #
1246 1246 0xAA, 0x00, // # # # #
1247 1247 0x11, 0x01, // # # #
1248 1248 0x11, 0x01, // # # #
1249 1249 0x00, 0x00, //
1250 1250 0x00, 0x00, //
1251 1251 0x00, 0x00, //
1252 1252
1253 1253 // @1104 'N' (11 pixels wide)
1254 1254 0x00, 0x00, //
1255 1255 0x04, 0x01, // # #
1256 1256 0x0C, 0x01, // ## #
1257 1257 0x14, 0x01, // # # #
1258 1258 0x14, 0x01, // # # #
1259 1259 0x24, 0x01, // # # #
1260 1260 0x44, 0x01, // # # #
1261 1261 0x84, 0x01, // # ##
1262 1262 0x04, 0x01, // # #
1263 1263 0x00, 0x00, //
1264 1264 0x00, 0x00, //
1265 1265 0x00, 0x00, //
1266 1266
1267 1267 // @1128 'O' (11 pixels wide)
1268 1268 0x00, 0x00, //
1269 1269 0xF0, 0x00, // ####
1270 1270 0x08, 0x01, // # #
1271 1271 0x04, 0x01, // # #
1272 1272 0x04, 0x01, // # #
1273 1273 0x04, 0x01, // # #
1274 1274 0x04, 0x01, // # #
1275 1275 0x84, 0x00, // # #
1276 1276 0x78, 0x00, // ####
1277 1277 0x00, 0x00, //
1278 1278 0x00, 0x00, //
1279 1279 0x00, 0x00, //
1280 1280
1281 1281 // @1152 'P' (11 pixels wide)
1282 1282 0x00, 0x00, //
1283 1283 0x70, 0x00, // ###
1284 1284 0x90, 0x00, // # #
1285 1285 0x90, 0x00, // # #
1286 1286 0x90, 0x00, // # #
1287 1287 0x90, 0x00, // # #
1288 1288 0x70, 0x00, // ###
1289 1289 0x10, 0x00, // #
1290 1290 0x10, 0x00, // #
1291 1291 0x00, 0x00, //
1292 1292 0x00, 0x00, //
1293 1293 0x00, 0x00, //
1294 1294
1295 1295 // @1176 'Q' (11 pixels wide)
1296 1296 0x00, 0x00, //
1297 1297 0xF0, 0x00, // ####
1298 1298 0x08, 0x01, // # #
1299 1299 0x04, 0x02, // # #
1300 1300 0x04, 0x02, // # #
1301 1301 0x04, 0x02, // # #
1302 1302 0x24, 0x02, // # # #
1303 1303 0x48, 0x01, // # # #
1304 1304 0xF0, 0x01, // #####
1305 1305 0x00, 0x03, // ##
1306 1306 0x00, 0x02, // #
1307 1307 0x00, 0x00, //
1308 1308
1309 1309 // @1200 'R' (11 pixels wide)
1310 1310 0x00, 0x00, //
1311 1311 0x38, 0x00, // ###
1312 1312 0x48, 0x00, // # #
1313 1313 0x48, 0x00, // # #
1314 1314 0x48, 0x00, // # #
1315 1315 0x38, 0x00, // ###
1316 1316 0x28, 0x00, // # #
1317 1317 0x48, 0x00, // # #
1318 1318 0x88, 0x00, // # #
1319 1319 0x00, 0x00, //
1320 1320 0x00, 0x00, //
1321 1321 0x00, 0x00, //
1322 1322
1323 1323 // @1224 'S' (11 pixels wide)
1324 1324 0x00, 0x00, //
1325 1325 0xE0, 0x01, // ####
1326 1326 0x10, 0x00, // #
1327 1327 0x10, 0x00, // #
1328 1328 0xE0, 0x00, // ###
1329 1329 0x00, 0x01, // #
1330 1330 0x00, 0x01, // #
1331 1331 0x08, 0x01, // # #
1332 1332 0xF0, 0x00, // ####
1333 1333 0x00, 0x00, //
1334 1334 0x00, 0x00, //
1335 1335 0x00, 0x00, //
1336 1336
1337 1337 // @1248 'T' (11 pixels wide)
1338 1338 0x00, 0x00, //
1339 1339 0xFC, 0x01, // #######
1340 1340 0x20, 0x00, // #
1341 1341 0x20, 0x00, // #
1342 1342 0x20, 0x00, // #
1343 1343 0x20, 0x00, // #
1344 1344 0x20, 0x00, // #
1345 1345 0x20, 0x00, // #
1346 1346 0x20, 0x00, // #
1347 1347 0x00, 0x00, //
1348 1348 0x00, 0x00, //
1349 1349 0x00, 0x00, //
1350 1350
1351 1351 // @1272 'U' (11 pixels wide)
1352 1352 0x00, 0x00, //
1353 1353 0x84, 0x00, // # #
1354 1354 0x84, 0x00, // # #
1355 1355 0x84, 0x00, // # #
1356 1356 0x84, 0x00, // # #
1357 1357 0x84, 0x00, // # #
1358 1358 0x84, 0x00, // # #
1359 1359 0x84, 0x00, // # #
1360 1360 0x78, 0x00, // ####
1361 1361 0x00, 0x00, //
1362 1362 0x00, 0x00, //
1363 1363 0x00, 0x00, //
1364 1364
1365 1365 // @1296 'V' (11 pixels wide)
1366 1366 0x00, 0x00, //
1367 1367 0x88, 0x00, // # #
1368 1368 0x88, 0x00, // # #
1369 1369 0x88, 0x00, // # #
1370 1370 0x50, 0x00, // # #
1371 1371 0x50, 0x00, // # #
1372 1372 0x50, 0x00, // # #
1373 1373 0x50, 0x00, // # #
1374 1374 0x20, 0x00, // #
1375 1375 0x00, 0x00, //
1376 1376 0x00, 0x00, //
1377 1377 0x00, 0x00, //
1378 1378
1379 1379 // @1320 'W' (11 pixels wide)
1380 1380 0x00, 0x00, //
1381 1381 0x21, 0x04, // # # #
1382 1382 0x21, 0x04, // # # #
1383 1383 0x52, 0x02, // # # # #
1384 1384 0x52, 0x02, // # # # #
1385 1385 0x4A, 0x01, // # # # #
1386 1386 0x4A, 0x01, // # # # #
1387 1387 0x44, 0x01, // # # #
1388 1388 0x84, 0x00, // # #
1389 1389 0x00, 0x00, //
1390 1390 0x00, 0x00, //
1391 1391 0x00, 0x00, //
1392 1392
1393 1393 // @1344 'X' (11 pixels wide)
1394 1394 0x00, 0x00, //
1395 1395 0x82, 0x00, // # #
1396 1396 0x44, 0x00, // # #
1397 1397 0x28, 0x00, // # #
1398 1398 0x10, 0x00, // #
1399 1399 0x10, 0x00, // #
1400 1400 0x28, 0x00, // # #
1401 1401 0x44, 0x00, // # #
1402 1402 0x82, 0x00, // # #
1403 1403 0x00, 0x00, //
1404 1404 0x00, 0x00, //
1405 1405 0x00, 0x00, //
1406 1406
1407 1407 // @1368 'Y' (11 pixels wide)
1408 1408 0x00, 0x00, //
1409 1409 0x84, 0x00, // # #
1410 1410 0x48, 0x00, // # #
1411 1411 0x48, 0x00, // # #
1412 1412 0x50, 0x00, // # #
1413 1413 0x30, 0x00, // ##
1414 1414 0x20, 0x00, // #
1415 1415 0x10, 0x00, // #
1416 1416 0x10, 0x00, // #
1417 1417 0x00, 0x00, //
1418 1418 0x00, 0x00, //
1419 1419 0x00, 0x00, //
1420 1420
1421 1421 // @1392 'Z' (11 pixels wide)
1422 1422 0x00, 0x00, //
1423 1423 0xFC, 0x01, // #######
1424 1424 0x80, 0x00, // #
1425 1425 0x40, 0x00, // #
1426 1426 0x20, 0x00, // #
1427 1427 0x10, 0x00, // #
1428 1428 0x08, 0x00, // #
1429 1429 0x04, 0x00, // #
1430 1430 0xFC, 0x01, // #######
1431 1431 0x00, 0x00, //
1432 1432 0x00, 0x00, //
1433 1433 0x00, 0x00, //
1434 1434
1435 1435 // @1416 '[' (11 pixels wide)
1436 1436 0x70, 0x00, // ###
1437 1437 0x10, 0x00, // #
1438 1438 0x10, 0x00, // #
1439 1439 0x10, 0x00, // #
1440 1440 0x10, 0x00, // #
1441 1441 0x10, 0x00, // #
1442 1442 0x10, 0x00, // #
1443 1443 0x10, 0x00, // #
1444 1444 0x10, 0x00, // #
1445 1445 0x10, 0x00, // #
1446 1446 0x70, 0x00, // ###
1447 1447 0x00, 0x00, //
1448 1448
1449 1449 // @1440 '\' (11 pixels wide)
1450 1450 0x00, 0x00, //
1451 1451 0x08, 0x00, // #
1452 1452 0x08, 0x00, // #
1453 1453 0x10, 0x00, // #
1454 1454 0x10, 0x00, // #
1455 1455 0x20, 0x00, // #
1456 1456 0x20, 0x00, // #
1457 1457 0x20, 0x00, // #
1458 1458 0x40, 0x00, // #
1459 1459 0x40, 0x00, // #
1460 1460 0x00, 0x00, //
1461 1461 0x00, 0x00, //
1462 1462
1463 1463 // @1464 ']' (11 pixels wide)
1464 1464 0x38, 0x00, // ###
1465 1465 0x20, 0x00, // #
1466 1466 0x20, 0x00, // #
1467 1467 0x20, 0x00, // #
1468 1468 0x20, 0x00, // #
1469 1469 0x20, 0x00, // #
1470 1470 0x20, 0x00, // #
1471 1471 0x20, 0x00, // #
1472 1472 0x20, 0x00, // #
1473 1473 0x20, 0x00, // #
1474 1474 0x38, 0x00, // ###
1475 1475 0x00, 0x00, //
1476 1476
1477 1477 // @1488 '^' (11 pixels wide)
1478 1478 0x30, 0x00, // ##
1479 1479 0x30, 0x00, // ##
1480 1480 0x48, 0x00, // # #
1481 1481 0x00, 0x00, //
1482 1482 0x00, 0x00, //
1483 1483 0x00, 0x00, //
1484 1484 0x00, 0x00, //
1485 1485 0x00, 0x00, //
1486 1486 0x00, 0x00, //
1487 1487 0x00, 0x00, //
1488 1488 0x00, 0x00, //
1489 1489 0x00, 0x00, //
1490 1490
1491 1491 // @1512 '_' (11 pixels wide)
1492 1492 0x00, 0x00, //
1493 1493 0x00, 0x00, //
1494 1494 0x00, 0x00, //
1495 1495 0x00, 0x00, //
1496 1496 0x00, 0x00, //
1497 1497 0x00, 0x00, //
1498 1498 0x00, 0x00, //
1499 1499 0x00, 0x00, //
1500 1500 0x00, 0x00, //
1501 1501 0x00, 0x00, //
1502 1502 0xFC, 0x01, // #######
1503 1503 0x00, 0x00, //
1504 1504
1505 1505 // @1536 '`' (11 pixels wide)
1506 1506 0x04, 0x00, // #
1507 1507 0x08, 0x00, // #
1508 1508 0x00, 0x00, //
1509 1509 0x00, 0x00, //
1510 1510 0x00, 0x00, //
1511 1511 0x00, 0x00, //
1512 1512 0x00, 0x00, //
1513 1513 0x00, 0x00, //
1514 1514 0x00, 0x00, //
1515 1515 0x00, 0x00, //
1516 1516 0x00, 0x00, //
1517 1517 0x00, 0x00, //
1518 1518
1519 1519 // @1560 'a' (11 pixels wide)
1520 1520 0x00, 0x00, //
1521 1521 0x00, 0x00, //
1522 1522 0x00, 0x00, //
1523 1523 0xE0, 0x00, // ###
1524 1524 0x90, 0x00, // # #
1525 1525 0x88, 0x00, // # #
1526 1526 0x88, 0x00, // # #
1527 1527 0x88, 0x00, // # #
1528 1528 0x70, 0x01, // ### #
1529 1529 0x00, 0x00, //
1530 1530 0x00, 0x00, //
1531 1531 0x00, 0x00, //
1532 1532
1533 1533 // @1584 'b' (11 pixels wide)
1534 1534 0x08, 0x00, // #
1535 1535 0x08, 0x00, // #
1536 1536 0x08, 0x00, // #
1537 1537 0x78, 0x00, // ####
1538 1538 0x88, 0x00, // # #
1539 1539 0x88, 0x00, // # #
1540 1540 0x88, 0x00, // # #
1541 1541 0x88, 0x00, // # #
1542 1542 0x78, 0x00, // ####
1543 1543 0x00, 0x00, //
1544 1544 0x00, 0x00, //
1545 1545 0x00, 0x00, //
1546 1546
1547 1547 // @1608 'c' (11 pixels wide)
1548 1548 0x00, 0x00, //
1549 1549 0x00, 0x00, //
1550 1550 0x00, 0x00, //
1551 1551 0x60, 0x00, // ##
1552 1552 0x90, 0x00, // # #
1553 1553 0x08, 0x00, // #
1554 1554 0x08, 0x00, // #
1555 1555 0x88, 0x00, // # #
1556 1556 0x70, 0x00, // ###
1557 1557 0x00, 0x00, //
1558 1558 0x00, 0x00, //
1559 1559 0x00, 0x00, //
1560 1560
1561 1561 // @1632 'd' (11 pixels wide)
1562 1562 0x80, 0x00, // #
1563 1563 0x80, 0x00, // #
1564 1564 0x80, 0x00, // #
1565 1565 0xF0, 0x00, // ####
1566 1566 0x88, 0x00, // # #
1567 1567 0x88, 0x00, // # #
1568 1568 0x88, 0x00, // # #
1569 1569 0x88, 0x00, // # #
1570 1570 0xF0, 0x00, // ####
1571 1571 0x00, 0x00, //
1572 1572 0x00, 0x00, //
1573 1573 0x00, 0x00, //
1574 1574
1575 1575 // @1656 'e' (11 pixels wide)
1576 1576 0x00, 0x00, //
1577 1577 0x00, 0x00, //
1578 1578 0x00, 0x00, //
1579 1579 0x38, 0x00, // ###
1580 1580 0x44, 0x00, // # #
1581 1581 0x24, 0x00, // # #
1582 1582 0x1C, 0x00, // ###
1583 1583 0x44, 0x00, // # #
1584 1584 0x38, 0x00, // ###
1585 1585 0x00, 0x00, //
1586 1586 0x00, 0x00, //
1587 1587 0x00, 0x00, //
1588 1588
1589 1589 // @1680 'f' (11 pixels wide)
1590 1590 0xC0, 0x00, // ##
1591 1591 0x20, 0x00, // #
1592 1592 0x20, 0x00, // #
1593 1593 0xF8, 0x00, // #####
1594 1594 0x20, 0x00, // #
1595 1595 0x20, 0x00, // #
1596 1596 0x20, 0x00, // #
1597 1597 0x20, 0x00, // #
1598 1598 0x20, 0x00, // #
1599 1599 0x00, 0x00, //
1600 1600 0x00, 0x00, //
1601 1601 0x00, 0x00, //
1602 1602
1603 1603 // @1704 'g' (11 pixels wide)
1604 1604 0x00, 0x00, //
1605 1605 0x00, 0x00, //
1606 1606 0x00, 0x00, //
1607 1607 0x30, 0x00, // ##
1608 1608 0x48, 0x00, // # #
1609 1609 0x44, 0x00, // # #
1610 1610 0x44, 0x00, // # #
1611 1611 0x44, 0x00, // # #
1612 1612 0x78, 0x00, // ####
1613 1613 0x40, 0x00, // #
1614 1614 0x20, 0x00, // #
1615 1615 0x1C, 0x00, // ###
1616 1616
1617 1617 // @1728 'h' (11 pixels wide)
1618 1618 0x08, 0x00, // #
1619 1619 0x08, 0x00, // #
1620 1620 0x08, 0x00, // #
1621 1621 0x68, 0x00, // # ##
1622 1622 0x98, 0x00, // ## #
1623 1623 0x88, 0x00, // # #
1624 1624 0x88, 0x00, // # #
1625 1625 0x88, 0x00, // # #
1626 1626 0x88, 0x00, // # #
1627 1627 0x00, 0x00, //
1628 1628 0x00, 0x00, //
1629 1629 0x00, 0x00, //
1630 1630
1631 1631 // @1752 'i' (11 pixels wide)
1632 1632 0x00, 0x00, //
1633 1633 0x20, 0x00, // #
1634 1634 0x00, 0x00, //
1635 1635 0x20, 0x00, // #
1636 1636 0x20, 0x00, // #
1637 1637 0x20, 0x00, // #
1638 1638 0x20, 0x00, // #
1639 1639 0x20, 0x00, // #
1640 1640 0x20, 0x00, // #
1641 1641 0x00, 0x00, //
1642 1642 0x00, 0x00, //
1643 1643 0x00, 0x00, //
1644 1644
1645 1645 // @1776 'j' (11 pixels wide)
1646 1646 0x00, 0x00, //
1647 1647 0x10, 0x00, // #
1648 1648 0x00, 0x00, //
1649 1649 0x10, 0x00, // #
1650 1650 0x10, 0x00, // #
1651 1651 0x10, 0x00, // #
1652 1652 0x10, 0x00, // #
1653 1653 0x10, 0x00, // #
1654 1654 0x10, 0x00, // #
1655 1655 0x10, 0x00, // #
1656 1656 0x12, 0x00, // # #
1657 1657 0x0C, 0x00, // ##
1658 1658
1659 1659 // @1800 'k' (11 pixels wide)
1660 1660 0x04, 0x00, // #
1661 1661 0x04, 0x00, // #
1662 1662 0x04, 0x00, // #
1663 1663 0x44, 0x00, // # #
1664 1664 0x24, 0x00, // # #
1665 1665 0x14, 0x00, // # #
1666 1666 0x1C, 0x00, // ###
1667 1667 0x24, 0x00, // # #
1668 1668 0x44, 0x00, // # #
1669 1669 0x00, 0x00, //
1670 1670 0x00, 0x00, //
1671 1671 0x00, 0x00, //
1672 1672
1673 1673 // @1824 'l' (11 pixels wide)
1674 1674 0x20, 0x00, // #
1675 1675 0x20, 0x00, // #
1676 1676 0x20, 0x00, // #
1677 1677 0x20, 0x00, // #
1678 1678 0x20, 0x00, // #
1679 1679 0x20, 0x00, // #
1680 1680 0x20, 0x00, // #
1681 1681 0x20, 0x00, // #
1682 1682 0x20, 0x00, // #
1683 1683 0x00, 0x00, //
1684 1684 0x00, 0x00, //
1685 1685 0x00, 0x00, //
1686 1686
1687 1687 // @1848 'm' (11 pixels wide)
1688 1688 0x00, 0x00, //
1689 1689 0x00, 0x00, //
1690 1690 0x00, 0x00, //
1691 1691 0x94, 0x00, // # # #
1692 1692 0x6C, 0x01, // ## ## #
1693 1693 0x24, 0x01, // # # #
1694 1694 0x24, 0x01, // # # #
1695 1695 0x24, 0x01, // # # #
1696 1696 0x24, 0x01, // # # #
1697 1697 0x00, 0x00, //
1698 1698 0x00, 0x00, //
1699 1699 0x00, 0x00, //
1700 1700
1701 1701 // @1872 'n' (11 pixels wide)
1702 1702 0x00, 0x00, //
1703 1703 0x00, 0x00, //
1704 1704 0x00, 0x00, //
1705 1705 0x68, 0x00, // # ##
1706 1706 0x98, 0x00, // ## #
1707 1707 0x88, 0x00, // # #
1708 1708 0x88, 0x00, // # #
1709 1709 0x88, 0x00, // # #
1710 1710 0x88, 0x00, // # #
1711 1711 0x00, 0x00, //
1712 1712 0x00, 0x00, //
1713 1713 0x00, 0x00, //
1714 1714
1715 1715 // @1896 'o' (11 pixels wide)
1716 1716 0x00, 0x00, //
1717 1717 0x00, 0x00, //
1718 1718 0x00, 0x00, //
1719 1719 0x70, 0x00, // ###
1720 1720 0x88, 0x00, // # #
1721 1721 0x88, 0x00, // # #
1722 1722 0x88, 0x00, // # #
1723 1723 0x88, 0x00, // # #
1724 1724 0x70, 0x00, // ###
1725 1725 0x00, 0x00, //
1726 1726 0x00, 0x00, //
1727 1727 0x00, 0x00, //
1728 1728
1729 1729 // @1920 'p' (11 pixels wide)
1730 1730 0x00, 0x00, //
1731 1731 0x00, 0x00, //
1732 1732 0x00, 0x00, //
1733 1733 0x3C, 0x00, // ####
1734 1734 0x44, 0x00, // # #
1735 1735 0x44, 0x00, // # #
1736 1736 0x44, 0x00, // # #
1737 1737 0x44, 0x00, // # #
1738 1738 0x3C, 0x00, // ####
1739 1739 0x04, 0x00, // #
1740 1740 0x04, 0x00, // #
1741 1741 0x04, 0x00, // #
1742 1742
1743 1743 // @1944 'q' (11 pixels wide)
1744 1744 0x00, 0x00, //
1745 1745 0x00, 0x00, //
1746 1746 0x00, 0x00, //
1747 1747 0xE0, 0x00, // ###
1748 1748 0x90, 0x00, // # #
1749 1749 0x88, 0x00, // # #
1750 1750 0x88, 0x00, // # #
1751 1751 0x88, 0x00, // # #
1752 1752 0xF0, 0x00, // ####
1753 1753 0x80, 0x00, // #
1754 1754 0x80, 0x00, // #
1755 1755 0x80, 0x00, // #
1756 1756
1757 1757 // @1968 'r' (11 pixels wide)
1758 1758 0x00, 0x00, //
1759 1759 0x00, 0x00, //
1760 1760 0x00, 0x00, //
1761 1761 0x70, 0x00, // ###
1762 1762 0x50, 0x00, // # #
1763 1763 0x10, 0x00, // #
1764 1764 0x10, 0x00, // #
1765 1765 0x10, 0x00, // #
1766 1766 0x10, 0x00, // #
1767 1767 0x00, 0x00, //
1768 1768 0x00, 0x00, //
1769 1769 0x00, 0x00, //
1770 1770
1771 1771 // @1992 's' (11 pixels wide)
1772 1772 0x00, 0x00, //
1773 1773 0x00, 0x00, //
1774 1774 0x00, 0x00, //
1775 1775 0x70, 0x00, // ###
1776 1776 0x08, 0x00, // #
1777 1777 0x10, 0x00, // #
1778 1778 0x20, 0x00, // #
1779 1779 0x40, 0x00, // #
1780 1780 0x38, 0x00, // ###
1781 1781 0x00, 0x00, //
1782 1782 0x00, 0x00, //
1783 1783 0x00, 0x00, //
1784 1784
1785 1785 // @2016 't' (11 pixels wide)
1786 1786 0x00, 0x00, //
1787 1787 0x10, 0x00, // #
1788 1788 0x10, 0x00, // #
1789 1789 0x38, 0x00, // ###
1790 1790 0x10, 0x00, // #
1791 1791 0x10, 0x00, // #
1792 1792 0x10, 0x00, // #
1793 1793 0x10, 0x00, // #
1794 1794 0x10, 0x00, // #
1795 1795 0x00, 0x00, //
1796 1796 0x00, 0x00, //
1797 1797 0x00, 0x00, //
1798 1798
1799 1799 // @2040 'u' (11 pixels wide)
1800 1800 0x00, 0x00, //
1801 1801 0x00, 0x00, //
1802 1802 0x00, 0x00, //
1803 1803 0x88, 0x00, // # #
1804 1804 0x88, 0x00, // # #
1805 1805 0x88, 0x00, // # #
1806 1806 0x88, 0x00, // # #
1807 1807 0x88, 0x00, // # #
1808 1808 0xF0, 0x00, // ####
1809 1809 0x00, 0x00, //
1810 1810 0x00, 0x00, //
1811 1811 0x00, 0x00, //
1812 1812
1813 1813 // @2064 'v' (11 pixels wide)
1814 1814 0x00, 0x00, //
1815 1815 0x00, 0x00, //
1816 1816 0x00, 0x00, //
1817 1817 0x88, 0x00, // # #
1818 1818 0x88, 0x00, // # #
1819 1819 0x50, 0x00, // # #
1820 1820 0x50, 0x00, // # #
1821 1821 0x20, 0x00, // #
1822 1822 0x20, 0x00, // #
1823 1823 0x00, 0x00, //
1824 1824 0x00, 0x00, //
1825 1825 0x00, 0x00, //
1826 1826
1827 1827 // @2088 'w' (11 pixels wide)
1828 1828 0x00, 0x00, //
1829 1829 0x00, 0x00, //
1830 1830 0x00, 0x00, //
1831 1831 0x24, 0x01, // # # #
1832 1832 0x24, 0x01, // # # #
1833 1833 0xB4, 0x00, // # ## #
1834 1834 0xB4, 0x00, // # ## #
1835 1835 0xA8, 0x00, // # # #
1836 1836 0x48, 0x00, // # #
1837 1837 0x00, 0x00, //
1838 1838 0x00, 0x00, //
1839 1839 0x00, 0x00, //
1840 1840
1841 1841 // @2112 'x' (11 pixels wide)
1842 1842 0x00, 0x00, //
1843 1843 0x00, 0x00, //
1844 1844 0x00, 0x00, //
1845 1845 0x84, 0x00, // # #
1846 1846 0x48, 0x00, // # #
1847 1847 0x30, 0x00, // ##
1848 1848 0x30, 0x00, // ##
1849 1849 0x48, 0x00, // # #
1850 1850 0x84, 0x00, // # #
1851 1851 0x00, 0x00, //
1852 1852 0x00, 0x00, //
1853 1853 0x00, 0x00, //
1854 1854
1855 1855 // @2136 'y' (11 pixels wide)
1856 1856 0x00, 0x00, //
1857 1857 0x00, 0x00, //
1858 1858 0x00, 0x00, //
1859 1859 0x08, 0x01, // # #
1860 1860 0x88, 0x00, // # #
1861 1861 0x90, 0x00, // # #
1862 1862 0x50, 0x00, // # #
1863 1863 0x60, 0x00, // ##
1864 1864 0x20, 0x00, // #
1865 1865 0x20, 0x00, // #
1866 1866 0x10, 0x00, // #
1867 1867 0x10, 0x00, // #
1868 1868
1869 1869 // @2160 'z' (11 pixels wide)
1870 1870 0x00, 0x00, //
1871 1871 0x00, 0x00, //
1872 1872 0x00, 0x00, //
1873 1873 0x78, 0x00, // ####
1874 1874 0x40, 0x00, // #
1875 1875 0x20, 0x00, // #
1876 1876 0x10, 0x00, // #
1877 1877 0x08, 0x00, // #
1878 1878 0x78, 0x00, // ####
1879 1879 0x00, 0x00, //
1880 1880 0x00, 0x00, //
1881 1881 0x00, 0x00, //
1882 1882
1883 1883 // @2184 '{' (11 pixels wide)
1884 1884 0x60, 0x00, // ##
1885 1885 0x10, 0x00, // #
1886 1886 0x10, 0x00, // #
1887 1887 0x10, 0x00, // #
1888 1888 0x10, 0x00, // #
1889 1889 0x18, 0x00, // ##
1890 1890 0x10, 0x00, // #
1891 1891 0x10, 0x00, // #
1892 1892 0x10, 0x00, // #
1893 1893 0x10, 0x00, // #
1894 1894 0x60, 0x00, // ##
1895 1895 0x00, 0x00, //
1896 1896
1897 1897 // @2208 '|' (11 pixels wide)
1898 1898 0x20, 0x00, // #
1899 1899 0x20, 0x00, // #
1900 1900 0x20, 0x00, // #
1901 1901 0x20, 0x00, // #
1902 1902 0x20, 0x00, // #
1903 1903 0x20, 0x00, // #
1904 1904 0x20, 0x00, // #
1905 1905 0x20, 0x00, // #
1906 1906 0x20, 0x00, // #
1907 1907 0x20, 0x00, // #
1908 1908 0x20, 0x00, // #
1909 1909 0x00, 0x00, //
1910 1910
1911 1911 // @2232 '}' (11 pixels wide)
1912 1912 0x18, 0x00, // ##
1913 1913 0x20, 0x00, // #
1914 1914 0x20, 0x00, // #
1915 1915 0x20, 0x00, // #
1916 1916 0x20, 0x00, // #
1917 1917 0x60, 0x00, // ##
1918 1918 0x20, 0x00, // #
1919 1919 0x20, 0x00, // #
1920 1920 0x20, 0x00, // #
1921 1921 0x20, 0x00, // #
1922 1922 0x18, 0x00, // ##
1923 1923 0x00, 0x00, //
1924 1924
1925 1925 // @2256 '~' (11 pixels wide)
1926 1926 0x00, 0x00, //
1927 1927 0x00, 0x00, //
1928 1928 0x00, 0x00, //
1929 1929 0x98, 0x00, // ## #
1930 1930 0x9C, 0x00, // ### #
1931 1931 0x64, 0x00, // # ##
1932 1932 0x00, 0x00, //
1933 1933 0x00, 0x00, //
1934 1934 0x00, 0x00, //
1935 1935 0x00, 0x00, //
1936 1936 0x00, 0x00, //
1937 1937 0x00, 0x00, //
1938 1938 };
1939 1939
1940 1940
1941 1941
1942 1942 sFONT ComicSansMS_18 = {
1943 1943 .table = ComicSansMS_18_TBL,
1944 1944 .Width = 16,
1945 1945 .Height = 18,
1946 1946 .bytesPerLine = 2
1947 1947 };
1948 1948
1949 1949 sFONT ComicSansMS_24 = {
1950 1950 .table = ComicSansMS_24_TBL,
1951 1951 .Width = 19,
1952 1952 .Height = 24,
1953 1953 .bytesPerLine = 3
1954 1954 };
1955 1955
1956 1956 sFONT ComicSansMS_8 = {
1957 1957 .table = comicSansMS_8ptBitmaps,
1958 1958 .Width = 11,
1959 1959 .Height = 12,
1960 1960 .bytesPerLine = 2
1961 1961 };
1962 1962
1963 1963
1964 1964
1965 1965 const uint8_t Monk_TBL[] = {
1966 1966
1967 1967 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xEE,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xAF,0xFB,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xDF,0xFF,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0xEF,0xFF,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xB0,0xFF,0xFF,0x07,0x00,0x00,0x00,0x00,0x00,0x40,0x01,0x00,0x00,0x00,0x00,0x00,0xF0,0xFF,0xFF,0x0F,0x00,0x00,0x00,0x00,0x00,0xF8,0x07,0x00,0x00,0x00,0x00,0x00,0xB0,0xFF,0xFF,0x07,0x00,0x00,0x00,0x00,0x00,0xFE,0x3F,0x00,0x00,0x00,0x00,0x00,0xF0,0xDF,0xFF,0x07,0x00,0x00,0x00,0x00,0x00,0xAF,0xFA,0x00,0x00,0x00,0x00,0x00,0x70,0x7F,0xFB,0x07,0x00,0x00,0x00,0x00,0x00,0xFF,0xFE,0x00,0x00,0x00,0x00,0x00,0xE0,0xDF,0xFE,0x03,0x00,0x00,0x00,0x00,0x80,0x6F,0xFD,0x01,0x00,0x00,0x00,0x00,0xA0,0xFF,0xDE,0x01,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x03,0x00,0x00,0x00,0x00,0xC0,0xBF,0xF5,0x03,0x00,0x00,0x00,0x00,0x80,0xFF,0xFD,0x03,0x00,0x00,0x00,0x00,0xC0,0x7F,0xFD,0x01,0x00,0x00,0x00,0x00,0x80,0xB5,0xFF,0x03,0x00,0x00,0x00,0x00,0xC0,0x5F,0xDB,0x01,0x00,0x00,0x00,0x00,0xC0,0xED,0xFF,0x03,0x00,0x00,0x00,0x00,0xC0,0xFF,0xFF,0x01,0x00,0x00,0x00,0x00,0xE0,0xAA,0xFF,0x03,0x00,0x00,0x00,0x00,0x40,0xBF,0xFA,0x01,0x00,0x00,0x00,0x00,0xE0,0xF6,0xFF,0x07,0x00,0x00,0x00,0x00,0x60,0xBE,0xFB,0x01,0x00,0x00,0x00,0x00,0xF0,0xBA,0xFF,0x03,0x00,0x00,0x00,0x00,0x70,0xBC,0xEE,0x00,0x00,0x00,0x00,0x00,0xF0,0xF6,0xFF,0x07,0x00,0x00,0x00,0x00,0x7C,0x75,0xBD,0x00,0x00,0x00,0x00,0x00,0xF0,0xAA,0xFF,0x0F,0x00,0x00,0x00,0x00,0x7E,0xF0,0xFE,0x01,0x00,0x00,0x00,0x00,0xE0,0xF5,0xFF,0x0F,0x00,0x00,0x00,0x80,0xFF,0xF0,0xF5,0x07,0x00,0x00,0x00,0x00,0xE0,0xFB,0xFF,0x07,0x00,0x00,0x00,0xE0,0x7F,0xF4,0xFF,0x0F,0x00,0x00,0x00,0x00,0xE0,0xFF,0xFF,0x03,0x00,0x00,0x00,0xF8,0xFF,0xC8,0xEF,0x3F,0x00,0x00,0x00,0x00,0xE0,0xFF,0xFF,0x07,0x00,0x00,0x00,0xFC,0xFF,0x8A,0xFF,0x7F,0x00,0x00,0x00,0x00,0x00,0xBE,0xFD,0x07,0x00,0x00,0x00,0xFF,0xFF,0x90,0xFF,0xFF,0x00,0x00,0x00,0x00,0x80,0x5F,0xEA,0x0F,0x00,0x00,0x80,0xFF,0xFF,0xA2,0xF7,0xFF,0x01,0x00,0x00,0x00,0xE0,0x3F,0xF8,0x1F,0x00,0x00,0x80,0xFF,0xFF,0x80,0xBF,0xFF,0x03,0x00,0x00,0x00,0xF8,0x1E,0xF8,0x7F,0x00,0x00,0xC0,0xFF,0xFF,0xC9,0x5F,0xFF,0x0F,0x00,0x00,0x00,0x3F,0x0E,0xFD,0xFF,0x01,0x00,0xC0,0xFF,0xFF,0x81,0xBF,0xFF,0x0F,0x00,0x00,0xC0,0x9F,0x27,0xFE,0xFF,0x07,0x00,0xC0,0xFF,0xFF,0x91,0xBF,0xFF,0x0F,0x00,0x00,0xE0,0x9F,0x0F,0xFE,0xFF,0x0F,0x00,0xE0,0xFF,0xFF,0xC1,0x5F,0xFF,0x0F,0x00,0x00,0xE0,0xCF,0x07,0xFF,0xFF,0x0F,0x00,0xE0,0xFF,0xFF,0x89,0xBF,0xFF,0x1F,0x00,0x00,0xC0,0xE7,0x87,0xFF,0xFF,0x0F,0x00,0xE0,0xFF,0xFF,0xC1,0xBF,0xFF,0x1F,0x00,0x00,0xE0,0xE7,0xC7,0xFF,0xFF,0x1F,0x00,0xE0,0xFF,0xFF,0x89,0xBF,0xFF,0x1F,0x00,0x00,0xF0,0xF3,0xC3,0xFF,0xFF,0x1F,0x00,0xE0,0xFF,0xFF,0xC3,0xFF,0xFF,0x1F,0x00,0x00,0xF8,0xF3,0xE3,0xFF,0xFF,0x1F,0x00,0xE0,0xFF,0xFF,0x81,0xDF,0xFF,0x1F,0x00,0x00,0xF8,0xF3,0xE1,0xFF,0xFF,0x3F,0x00,0xF0,0xFF,0xFF,0xD3,0xBF,0xFF,0x1F,0x00,0x00,0xF0,0xFB,0xF3,0xFF,0xFF,0x3F,0x00,0xE0,0xFF,0xFF,0x83,0xDF,0xFF,0x3F,0x00,0x00,0xF8,0xF9,0xF1,0xFF,0xFF,0x3F,0x00,0xE0,0xFF,0xFF,0xA3,0xFF,0xFF,0x1F,0x00,0x00,0xF8,0xF9,0xF9,0xFF,0xFF,0x3F,0x00,0xF0,0xFF,0xFF,0xC3,0xDF,0xFF,0x1F,0x00,0x00,0xF8,0xF9,0xF9,0xFF,0xFF,0x3F,0x00,0xE0,0xFF,0xFF,0xD3,0xDF,0xFF,0x1F,0x00,0x00,0xF8,0xFC,0xF8,0xFF,0xFF,0x7F,0x00,0xE0,0xFF,0xFF,0xC3,0xFF,0xFF,0x1F,0x00,0x00,0xF8,0xFC,0xFD,0xFF,0xFF,0x3F,0x00,0xE0,0xFF,0xFF,0xCB,0xDF,0xFF,0x1F,0x00,0x00,0xF8,0xFD,0xFC,0xFF,0xFF,0x7F,0x00,0xE0,0xFF,0xFF,0xE7,0xDF,0xFF,0x0F,0x00,0x00,0xFC,0xFC,0xFE,0xFF,0xFF,0x7F,0x00,0xE0,0xFF,0xFF,0xC3,0xDF,0xFF,0x0F,0x00,0x00,0xFE,0xFE,0xFE,0xFF,0xFF,0x7F,0x00,0xE0,0xFF,0xFF,0xD7,0xDF,0xFF,0x0F,0x00,0x00,0xFE,0xFE,0xFF,0xFF,0xFF,0x7F,0x00,0xE0,0xFF,0xFF,0xE7,0xDF,0xFF,0x0F,0x00,0x00,0xFC,0xFE,0xFF,0xFF,0xFF,0x7F,0x00,0xC0,0xFF,0xFF,0xE3,0xDF,0xFF,0x0F,0x00,0x00,0xFC,0xFE,0xFF,0xFF,0xFF,0x7F,0x00,0xE0,0xFF,0xFF,0xD7,0xDF,0xFF,0x0F,0x00,0x00,0x7C,0xFE,0xFF,0xFF,0xFF,0x7F,0x00,0xC0,0xFF,0xFF,0xE7,0xDF,0xFF,0x0F,0x00,0x00,0x7C,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0xC0,0xFF,0xFF,0xE7,0xDF,0xFF,0x0F,0x00,0x00,0x78,0xFE,0xFF,0xFF,0xFF,0x7F,0x00,0xC0,0xFF,0xFF,0xCF,0xDF,0xFF,0x0F,0x00,0x00,0x7C,0xFF,0xFF,0xFF,0xFF,0x7F,0x00,0xC0,0xFF,0xFF,0xEF,0xDF,0xFF,0x0F,0x00,0x00,0x7C,0xFF,0xFF,0xFF,0xFF,0x7F,0x00,0xC0,0xFF,0xFF,0xEF,0xFF,0xFF,0x1F,0x00,0x00,0x3E,0xFF,0xFF,0xFF,0xFF,0x3F,0x00,0x80,0xFF,0xFF,0xEF,0xFF,0xFF,0x0F,0x00,0x00,0x3E,0xFF,0xFF,0xFF,0xFF,0x3F,0x00,0x80,0xFF,0xFF,0xFF,0xFF,0xFF,0x0F,0x00,0x00,0x3E,0xFF,0xFF,0xFF,0xFF,0x7F,0x00,0x80,0xFF,0xFF,0xEF,0xFF,0xFF,0x0F,0x00,0x00,0x1F,0xFF,0xFF,0xFF,0xFF,0x3F,0x00,0x80,0xFF,0xFF,0xFF,0xFF,0xFF,0x07,0x00,0x00,0x5F,0xFF,0xFF,0xFF,0xFF,0x3F,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0x07,0x00,0x80,0x9F,0xFF,0xFF,0xFF,0xFF,0x1F,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0x07,0x00,0x80,0x1F,0xFF,0xFF,0xFF,0xFF,0x3F,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0x07,0x00,0x80,0x9F,0xFF,0xFF,0xFF,0xFF,0x1F,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0x0F,0x00,0xC0,0xBF,0xFF,0xFF,0xFF,0xFF,0x1F,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0x0F,0x00,0xC0,0xBF,0xFF,0xFF,0xFF,0xFF,0x1F,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0x0F,0x00,0xE0,0xFF,0xFF,0xFF,0xFF,0xFF,0x1F,0x00,0x00,0xFE,0xFF,0xFF,0xFF,0xFF,0x07,0x00,0xE0,0xFF,0xFF,0xFF,0xFF,0xFF,0x0F,0x00,0x00,0xFE,0xFF,0xFF,0xFF,0xFF,0x07,0x00,0xF0,0xFF,0xFF,0xFF,0xFF,0xA3,0x0F,0x00,0x00,0xFE,0xFF,0xFF,0xFF,0xFF,0x07,0x00,0xF0,0xFF,0xFF,0xFF,0xFF,0x0B,0x0E,0x00,0x00,0xFE,0xFF,0xFF,0xFF,0xFF,0x03,0x00,0xF8,0xFF,0xFF,0xFF,0xFF,0x7F,0x0D,0x00,0x00,0xFE,0xFF,0xFF,0xFF,0xFF,0x03,0x00,0xF8,0xFF,0xFF,0xFF,0xFF,0xFF,0x0B,0x00,0x00,0xFE,0xFF,0xFF,0xFF,0xCF,0x03,0x00,0xF8,0xFF,0xFF,0xFF,0xFF,0xFF,0x07,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x1F,0x03,0x00,0xFC,0xFF,0xFF,0xFF,0xFF,0xFF,0x07,0x00,0x00,0xFE,0xFF,0xFF,0xFF,0x3F,0x02,0x00,0xFC,0xFF,0xFF,0xFF,0xFF,0xFF,0x03,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0x03,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0x01,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0x01,0x00,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0x01,0x00,0x00,0xFF,0xE1,0xFF,0xFF,0x7F,0x03,0x00,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0x03,0x00,0x00,0x3F,0xFC,0xFF,0xFF,0xFF,0x03,0x00,0xFC,0xFF,0xFF,0xFF,0xFF,0xFF,0x01,0x00,0x00,0xBF,0xBF,0xFF,0xFF,0xFF,0x03,0x00,0xF0,0xFF,0xFF,0xFF,0xFF,0xFF,0x03,0x00,0x80,0xDF,0xFF,0xFF,0xFD,0xFF,0x07,0x00,0xE0,0xFF,0xFF,0xFF,0xFF,0xFF,0x03,0x00,0x80,0xFF,0xFF,0xFF,0xFF,0xFF,0x07,0x00,0xE0,0xFF,0xFF,0xFF,0xFF,0xFF,0x07,0x00,0xC0,0xFF,0xFF,0x7E,0xFF,0xFF,0x0F,0x00,0xC0,0xFF,0xFF,0xFF,0xFF,0xFF,0x0F,0x00,0xC0,0xFF,0xFF,0xD7,0xFF,0xFF,0x0F,0x00,0xC0,0xFF,0xFF,0xFF,0xFF,0xFF,0x0F,0x00,0xE0,0xFF,0xFF,0xFF,0xFF,0xFF,0x1F,0x00,0x80,0xFF,0xFF,0xFF,0xFF,0xFF,0x0F,0x00,0xE0,0xFF,0xFF,0xFB,0xFF,0xFF,0x1F,0x00,0xC0,0xFF,0xFF,0xFF,0xFF,0xFF,0x0F,0x00,0xF0,0xFF,0xFF,0xEE,0xFF,0xFF,0x1F,0x00,0xC0,0xFF,0xFF,0xFF,0xFF,0xFF,0x0F,0x00,0xF0,0xFF,0xFF,0xFB,0xFF,0xFF,0x1F,0x00,0xC0,0xFF,0xFF,0xFF,0xFF,0xFF,0x07,0x00,0xF0,0xFF,0xFF,0xFE,0xFF,0xFF,0x3F,0x00,0xE0,0xFF,0xFF,0xFF,0xFF,0xFF,0x07,0x00,0xF0,0xFF,0xFF,0xFF,0xFE,0xFF,0x3F,0x00,0xE0,0xFF,0xFF,0xFF,0xFF,0xFF,0x03,0x00,0xF8,0xFF,0xFF,0xFB,0xFF,0xFF,0x7F,0x00,0xE0,0xFF,0xFF,0xFF,0xFF,0xFF,0x01,0x00,0xF8,0xFF,0xFF,0xBF,0xFF,0xFF,0x7F,0x00,0xF0,0xFF,0xFF,0xFF,0xFF,0xFF,0x01,0x00,0xFC,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0xE0,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0xFC,0xFF,0xFF,0x07,0xFF,0xFF,0x7F,0x00,0xE0,0xFF,0xFF,0xFF,0xFF,0xFF,0x01,0x00,0xFC,0xFF,0xFF,0x07,0xFF,0xFF,0xFF,0x00,0xE0,0xFF,0xFF,0xFF,0xFF,0xFF,0x01,0x00,0xFC,0xFF,0xFF,0x03,0xFF,0xFF,0xFF,0x00,0xE0,0xFF,0xFF,0xFF,0xFF,0xFF,0x01,0x00,0xFC,0xFF,0xFF,0x03,0xFF,0xFF,0x7F,0x00,0xC0,0xFF,0xFF,0xFD,0xFF,0xFF,0x03,0x00,0xFC,0xFF,0xFF,0x01,0xFE,0xFF,0xFF,0x00,0xC0,0xFF,0xFF,0xF9,0xFF,0xFF,0x03,0x00,0xFC,0xFF,0x7F,0x00,0xFC,0xFF,0x7F,0x00,0xC0,0xFF,0xFF,0xF9,0xFF,0xFF,0x07,0x00,0xFC,0xFF,0x3F,0x00,0xFC,0xFF,0x7F,0x00,0xC0,0xFF,0xFF,0xF9,0xFF,0xFF,0x03,0x00,0xFC,0xFF,0x3F,0x00,0xF8,0xFF,0xFF,0x00,0xC0,0xFF,0xFF,0xF1,0xFF,0xFF,0x07,0x00,0xFC,0xFF,0x1F,0x00,0xF0,0xFF,0x7F,0x00,0xC0,0xFF,0xFF,0xF1,0xFF,0xFF,0x07,0x00,0xFC,0xFF,0x0F,0x00,0xE0,0xFF,0x7F,0x00,0xC0,0xFF,0xFF,0xE1,0xFF,0xFF,0x07,0x00,0xFE,0xFF,0x0F,0x00,0xC0,0xFF,0x7F,0x00,0x80,0xFF,0xFF,0xE1,0xFF,0xFF,0x07,0x00,0xFE,0xFF,0x0F,0x00,0x80,0xFF,0x7F,0x00,0xC0,0xFF,0xFF,0xE1,0xFF,0xFF,0x07,0x00,0xFE,0xFF,0x07,0x00,0x00,0xFF,0x7F,0x00,0x80,0xFF,0xFF,0xC1,0xFF,0xFF,0x07,0x00,0xFE,0xFF,0x07,0x00,0x00,0xFF,0xFF,0x00,0x80,0xFF,0xFF,0xC1,0xFF,0xFF,0x07,0x00,0xFF,0xFF,0x03,0x00,0x00,0xFF,0x7F,0x00,0x00,0xFF,0xFF,0x81,0xFF,0xFF,0x07,0x00,0xFF,0xFF,0x01,0x00,0x00,0xFF,0x7F,0x00,0x80,0xFF,0xFF,0x80,0xFF,0xFF,0x03,0x00,0xFF,0xFF,0x00,0x00,0x00,0xFF,0xFF,0x00,0x80,0xFF,0xFF,0x80,0xFF,0xFF,0x07,0x80,0xFF,0xFF,0x00,0x00,0x00,0xFF,0x7F,0x00,0xE8,0xFF,0xFF,0x00,0xFF,0xFF,0x0F,0x80,0xFF,0x7F,0x00,0x00,0x80,0xFF,0xFF,0x00,0xFC,0xFF,0x7F,0x00,0xFE,0xFF,0x1F,0x80,0xFF,0x7F,0x00,0x00,0x80,0xFF,0xFF,0x00,0xFE,0xFF,0x3F,0x00,0xC0,0xFF,0x1F,0x80,0xFF,0x7F,0x00,0x00,0x80,0xFF,0xFF,0x00,0xBE,0xFF,0x1F,0x00,0xC0,0xFF,0x1F,0x80,0xFF,0x7F,0x00,0x00,0x80,0xFF,0xFF,0x01,0x04,0xFC,0x07,0x00,0xC0,0xFF,0x1F,0xC0,0xFF,0x7F,0x00,0x00,0xC0,0xFF,0xFF,0x1F,0x00,0x3C,0x00,0x00,0xF0,0xFF,0x07,0xC0,0xFF,0x7F,0x00,0x00,0x80,0xFF,0xFF,0x1F,0x00,0x00,0x00,0x00,0xF0,0xDD,0x0E,0x80,0xFF,0x7F,0x00,0x00,0x00,0xFE,0xFF,0x3B,0x00,0x00,0x00,0x00,0x50,0xE0,0x03,0xF0,0xFF,0x7F,0x00,0x00,0x00,0x80,0xFF,0x2E,0x00,0x00,0x00,0x00,0x00,0x40,0x01,0xF8,0xFF,0x3F,0x00,0x00,0x00,0x00,0x1A,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xEC,0x55,0x0F,0x00,0x00,0x00,0x00,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0xD2,0x05,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
1968 1968 };
1969 1969
1970 1970 sFONT Monk_24 = {
1971 1971 .table = Monk_TBL,
1972 1972 .Width = 0x7F,
1973 1973 .Height = 0x7E,
1974 1974 .bytesPerLine = 16
1975 1975 };
1976 1976
1977 1977
@@ -1,245 +1,245
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the libuc, microcontroler library
3 3 -- Copyright (C) 2013, 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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
21 21 -------------------------------------------------------------------------------*/
22 22 #include <widget.h>
23 23 #include <terminal.h>
24 24 #include <stdint.h>
25 25 #include <stdio.h>
26 26 #include <gpio.h>
27 27 #include <core.h>
28 28 #include <malloc.h>
29 29
30 30 #define CHARXPOS(terminal,charwidth) (((terminal)->column * charwidth) + (terminal)->Xpos)
31 31 #define CHARYPOS(terminal,charheight) ((terminal)->line * charheight + (terminal)->Ypos+charheight)
32 32
33 33 streamdevice_ops TERMINAL_OPS=
34 34 {
35 35 .write = &terminal_write,
36 36 .read = &terminal_read,
37 37 .setpos= &terminal_setpos,
38 38 .close = NULL
39 39 };
40 40
41 41 int terminal_init(terminal_t* terminal,LCD_t* LCD,sFONT* font,streamdevice* strdev)
42 42 {
43 43 if((LCD!=NULL) && (font!=NULL) && (strdev!=NULL) && (terminal!=NULL))
44 44 {
45 45 terminal->LCD=LCD;
46 46 terminal->font=font;
47 47 terminal->line = 0;
48 48 terminal->column = 0;
49 49 terminal->horizontalSpace = 0;
50 50 terminal->verticalSpace = 0;
51 51 int charw=terminal->font->Width + terminal->horizontalSpace;
52 52 int charh=terminal->font->Height + terminal->verticalSpace;
53 53 terminal->textColor=0xFFFF;
54 54 terminal->backgroundColor=0x0000;
55 55 terminal_setgeometry(terminal,5,5,terminal->LCD->width-(10),terminal->LCD->height-(10));
56 56 strdev->_stream = (UHANDLE)terminal;
57 57 strdev->ops = &TERMINAL_OPS;
58 58 strdev->streamPt = 0;
59 59 terminal_clear(terminal);
60 60 terminal->LCD->paintFilRect(terminal->LCD,CHARXPOS(terminal, charw),CHARYPOS(terminal, charh)-charh,charw,charh,terminal->backgroundColor,0,terminal->backgroundColor);
61 61 terminal->buffer = (char*)malloc(terminal->lineCount*(terminal->columnCount + 1));
62 62 terminal->firstLine = 0;
63 63 terminal->lastLine = 0;
64 64 terminal->empty = 1;
65 65 for(int i=1;i<=terminal->lineCount;i++)
66 66 {
67 67 terminal->buffer[i * terminal->columnCount]='\n';
68 68 }
69 69 return 1;
70 70 }
71 71 return 0;
72 72 }
73 73
74 74 void terminal_setgeometry(terminal_t* terminal,uint16_t Xpos,uint16_t Ypos,uint16_t width,uint16_t height)
75 75 {
76 76 int charw=terminal->font->Width + terminal->horizontalSpace;
77 77 int charh=terminal->font->Height + terminal->verticalSpace;
78 78 if(terminal->LCD->height<(Ypos+height))
79 79 return;
80 80 if(terminal->LCD->width<(Xpos+width))
81 81 return;
82 82 terminal->Xpos = Xpos;
83 83 terminal->Ypos = Ypos;
84 84 terminal->height = height;
85 85 terminal->width = width;
86 86 terminal->lineCount = terminal->height/charh;
87 87 terminal->columnCount = (terminal->width/charw)-1;
88 88 terminal_clear(terminal);
89 89 }
90 90
91 91
92 92 void terminal_clear(terminal_t* terminal)
93 93 {
94 94 terminal->firstLine = 0;
95 95 terminal->lastLine = 0;
96 96 terminal->empty = 1;
97 97 terminal->line =0;
98 98 terminal->column=0;
99 99 terminal->LCD->paintFilRect(terminal->LCD,terminal->Xpos,terminal->Ypos,terminal->width,terminal->height,terminal->backgroundColor,0,terminal->backgroundColor);
100 100 }
101 101
102 102 void terminal_setbackgroundColor(terminal_t* terminal, uint32_t backgrooundColor)
103 103 {
104 104 terminal->backgroundColor = backgrooundColor;
105 105 }
106 106
107 107 void terminal_settextColor(terminal_t* terminal, uint32_t textColor)
108 108 {
109 109 terminal->textColor = textColor;
110 110 }
111 111
112 112
113 113 void terminal_movecursor(terminal_t* terminal,int n)
114 114 {
115 115 int charw=terminal->font->Width + terminal->horizontalSpace;
116 116 int charh=terminal->font->Height + terminal->verticalSpace;
117 117 terminal->column += n;
118 118 if(terminal->column>(terminal->columnCount))
119 119 {
120 120 terminal->line += (terminal->column)/terminal->columnCount;
121 121 terminal->line = terminal->line % terminal->lineCount;
122 122 terminal->column = (terminal->column % terminal->columnCount)-1;
123 123 int x=CHARXPOS(terminal, charw);
124 124 int y=CHARYPOS(terminal,charh)-charh;
125 125 int w=charw*(terminal->columnCount-terminal->column);
126 126 int h=charh;
127 terminal->LCD->paintFilRect(terminal->LCD,CHARXPOS(terminal, charw),CHARYPOS(terminal,charh)-charh,charw*(terminal->columnCount-terminal->column-1),charh,terminal->backgroundColor,0,terminal->backgroundColor);
127 //terminal->LCD->paintFilRect(terminal->LCD,CHARXPOS(terminal, charw),CHARYPOS(terminal,charh)-charh,charw*(terminal->columnCount-terminal->column-1),charh,terminal->backgroundColor,0,terminal->backgroundColor);
128 128 }
129 terminal->LCD->paintFilRect(terminal->LCD,CHARXPOS(terminal,charw),CHARYPOS(terminal,charh)-charh,charw,charh,terminal->backgroundColor,0,terminal->backgroundColor);
129 //terminal->LCD->paintFilRect(terminal->LCD,CHARXPOS(terminal,charw),CHARYPOS(terminal,charh)-charh,charw,charh,terminal->backgroundColor,0,terminal->backgroundColor);
130 130 }
131 131
132 132 void terminal_clearCurentLine(terminal_t* terminal)
133 133 {
134 134 int charw=terminal->font->Width + terminal->horizontalSpace;
135 135 int charh=terminal->font->Height + terminal->verticalSpace;
136 terminal->LCD->paintFilRect(terminal->LCD,terminal->Xpos,CHARYPOS(terminal, charh)-charh,terminal->width,charh,terminal->backgroundColor,0,terminal->backgroundColor);
136 // terminal->LCD->paintFilRect(terminal->LCD,terminal->Xpos,CHARYPOS(terminal, charh)-charh,terminal->width,charh,terminal->backgroundColor,0,terminal->backgroundColor);
137 137 }
138 138
139 139 int terminal_writenc(terminal_t* terminal,char* data, int n)
140 140 {
141 141 int charw=terminal->font->Width + terminal->horizontalSpace;
142 142 int charh=terminal->font->Height + terminal->verticalSpace;
143 143 int l=0;
144 144 char buffer[2]=" ";
145 145 while(l<n)
146 146 {
147 147
148 148 buffer[0]=data[l];
149 149 if(buffer[0]=='\n')
150 150 {
151 151 terminal->line= (terminal->line+1) % terminal->lineCount;
152 152 terminal->column = 0;
153 153 if(terminal->line==0)
154 154 terminal_clear(terminal);
155 155 else
156 156 terminal_clearCurentLine(terminal);
157 157 }else {
158 158 if(buffer[0]=='\t')
159 159 {
160 160 for(int i=0;i<1;i++)terminal_movecursor(terminal,1);
161 161 }else
162 162 if(terminal->column==0)terminal_clearCurentLine(terminal);
163 163 if(buffer[0]!='\r'){
164 terminal->LCD->paintFilRect(terminal->LCD,CHARXPOS(terminal,charw),CHARYPOS(terminal, charh)-charh,charw,charh,terminal->backgroundColor,0,terminal->backgroundColor);
164 // terminal->LCD->paintFilRect(terminal->LCD,CHARXPOS(terminal,charw),CHARYPOS(terminal, charh)-charh,charw,charh,terminal->backgroundColor,0,terminal->backgroundColor);
165 165 terminal->LCD->paintText(terminal->LCD,buffer,CHARXPOS(terminal,charw),CHARYPOS(terminal, charh),terminal->font,terminal->textColor);
166 166 terminal_movecursor(terminal,1);
167 167 }
168 168 }
169 169 l++;
170 170 }
171 171 return n;
172 172 }
173 173
174 174 void terminal_print_line(terminal_t* terminal,int line)
175 175 {
176 176 int charw=terminal->font->Width + terminal->horizontalSpace;
177 177 int charh=terminal->font->Height + terminal->verticalSpace;
178 178 terminal_clearCurentLine(terminal);
179 179 terminal->LCD->paintText(terminal->LCD,terminal->buffer+(line*(terminal->columnCount + 1)),CHARXPOS(terminal,charw),CHARYPOS(terminal, charh),terminal->font,terminal->textColor);
180 180 }
181 181
182 182 int terminal_writenc2(terminal_t* terminal,char* data, int n)
183 183 {
184 184 int charw=terminal->font->Width + terminal->horizontalSpace;
185 185 int charh=terminal->font->Height + terminal->verticalSpace;
186 186 /* First copy to buffer*/
187 187 int offset = (terminal->lastLine*(terminal->columnCount + 1)) + terminal->column;
188 188 for(int i=0;i<n;i++)
189 189 {
190 190 terminal->empty=0;
191 191 terminal->buffer[offset] = data[i];
192 192 if(data[i]=='\n')
193 193 {
194 194 offset = ((offset/(terminal->columnCount + 1) + 1) * (terminal->columnCount + 1));
195 195 }
196 196 else
197 197 {
198 198 offset++;
199 199 }
200 200 }
201 201 if(!terminal->empty)
202 202 {
203 203 for(int i=terminal->firstLine;i<=terminal->lastLine;i++)
204 204 {
205 205 terminal_print_line(terminal,i);
206 206 }
207 207 }
208 208 return n;
209 209 }
210 210
211 211
212 212
213 213 int terminal_write(streamdevice* device,void* data,int size, int n)
214 214 {
215 215 return terminal_writenc((terminal_t*)device->_stream,(char*) data,size*n);
216 216 }
217 217
218 218 int terminal_read(streamdevice* device,void* data,int size, int n)
219 219 {
220 220 return n*size;
221 221 }
222 222
223 223 int terminal_setpos(streamdevice* device,int pos)
224 224 {
225 225 return 1;
226 226 }
227 227
228 228 int terminal_close( streamdevice* device)
229 229 {
230 230 return 1;
231 231 }
232 232
233 233
234 234
235 235
236 236
237 237
238 238
239 239
240 240
241 241
242 242
243 243
244 244
245 245
@@ -1,69 +1,69
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the libuc, microcontroler library
3 3 -- Copyright (C) 2013, 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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
21 21 -------------------------------------------------------------------------------*/
22 22
23 23 #include <STMPE811.h>
24 24
25 25 int stmpe811init(STMPE811_t *dev, i2c_t i2cdev, uint8_t A0)
26 26 {
27 27
28 28 dev->devAddress = 0x82;
29 29 if(A0) dev->devAddress = 0x88;
30 30 dev->i2cdev = i2cdev;
31 31 return 1;
32 32 }
33 33
34 34 int stmpe811getID(STMPE811_t *dev)
35 35 {
36 36 if(dev != NULL)
37 37 {
38 38 char DATA[2];
39 39 DATA[0]=STMPE811_REGISTER_CHIP_ID;
40 40 i2cwrite(dev->i2cdev,dev->devAddress,DATA,1);
41 41 i2cread(dev->i2cdev,dev->devAddress,DATA,2);
42 42 uint16_t val=DATA[0];
43 43 val=(val<<8)+DATA[1];
44 44 return val;
45 45 }
46 46 return -1;
47 47 }
48 48
49 49
50 50
51 51
52 52
53 53
54 54
55 55
56 56
57 57
58 58
59 59
60 60
61 61
62 62
63 63
64 64
65 65
66 66
67 67
68 68
69 69
@@ -1,114 +1,114
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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
21 21 -------------------------------------------------------------------------------*/
22 22 #include <ina226.h>
23 23 #include <stdio.h>
24 24 #include <stddef.h>
25 25
26 26
27 27 int ina226open(INA226_t *dev, i2c_t i2cdev, uint16_t config, uint8_t A0, uint8_t A1, uint32_t shuntmOhm, uint32_t CurrentRangeuAmp)
28 28 {
29 29 if(dev != NULL)
30 30 {
31 31 dev->i2cdev=i2cdev;
32 32 dev->devAddress = INA226_I2C_ADDRESS | (A0 & 1) | ((A1<<2) & 5);
33 33 printf("dev->devAddress = %x\n\r",dev->devAddress);
34 34 dev->shuntmOhm = shuntmOhm;
35 35 dev->CurrentRangeuAmp = CurrentRangeuAmp;
36 36 ina226setReg(dev,INA226_Configuration_Reg,0x8000);
37 37 ina226setReg(dev,INA226_Configuration_Reg,config);
38 38 return ina226calibrate(dev,shuntmOhm,CurrentRangeuAmp);
39 39 }
40 40 return -1;
41 41 }
42 42
43 43 uint16_t ina226getID(INA226_t* dev)
44 44 {
45 45 if(dev != NULL)
46 46 {
47 47 uint16_t id=ina226getReg(dev,INA226_Die_ID_Reg);
48 48 return id;
49 49 }
50 50 return -1;
51 51 }
52 52
53 53
54 54 int ina226calibrate(INA226_t* dev,uint32_t shuntmOhm, uint32_t CurrentRangeuAmp)
55 55 {
56 56 dev->shuntmOhm = shuntmOhm;
57 57 dev->CurrentRangeuAmp = CurrentRangeuAmp;
58 58 uint32_t CAL= (uint32_t)(5210000/(shuntmOhm*(CurrentRangeuAmp>>15)));
59 59 return ina226setReg(dev,INA226_Calibration_Reg,(uint16_t)CAL);
60 60 }
61 61
62 62 uint32_t ina226getBusVoltage(INA226_t *dev)
63 63 {
64 64 uint32_t busVoltage= ina226getReg(dev,INA226_Bus_Voltage_Reg);
65 65 busVoltage*= 1250;
66 66 return busVoltage;
67 67 }
68 68
69 69 uint32_t ina226getPower(INA226_t *dev)
70 70 {
71 71 uint32_t power= ina226getReg(dev,INA226_Power_Reg);
72 72 power*= ((dev->CurrentRangeuAmp>>15)*25);
73 73 return power;
74 74 }
75 75
76 76 int32_t ina226getCurrent(INA226_t *dev)
77 77 {
78 78 int32_t current= ina226getReg(dev,INA226_Current_Reg);
79 79 current<<=16;
80 80 current>>=16;
81 81 current = current*(dev->CurrentRangeuAmp>>15);
82 82 return current;
83 83 }
84 84
85 85 uint16_t ina226getReg(INA226_t* dev,char reg)
86 86 {
87 87 if(dev != NULL)
88 88 {
89 89 char DATA[2];
90 90 DATA[0]=reg;
91 91 i2cwrite(dev->i2cdev,dev->devAddress,DATA,1);
92 92 i2cread(dev->i2cdev,dev->devAddress,DATA,2);
93 93 uint16_t val=DATA[0];
94 94 val=(val<<8)+DATA[1];
95 95 return val;
96 96 }
97 97 return -1;
98 98 }
99 99
100 100
101 101 int ina226setReg(INA226_t* dev,char reg,int16_t value)
102 102 {
103 103 if(dev != NULL)
104 104 {
105 105 char DATA[3];
106 106 DATA[0]=INA226_Calibration_Reg;
107 107 DATA[1]=(char)(0xff & (value>>8));
108 108 DATA[2]=(char)(0xff & value);
109 109 if(3==i2cwrite(dev->i2cdev,dev->devAddress,DATA,3))return 1;
110 110 }
111 111 return -1;
112 112 }
113 113
114 114
@@ -1,41 +1,41
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the libuc, microcontroler library
3 3 -- Copyright (C) 2013, 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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
21 21 -------------------------------------------------------------------------------*/
22 22
23 23 #include <thread.h>
24 24
25 25
26 26 int threadcreate(thread_t *thread, void *stack, int stackSize)
27 27 {
28 28 return 0;
29 29 }
30 30
31 31
32 32 int threadstart(thread_t *thread)
33 33 {
34 34 return 0;
35 35 }
36 36
37 37
38 38 int threadstop(thread_t *thread)
39 39 {
40 40 return 0;
41 41 }
@@ -1,56 +1,56
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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
21 21 -------------------------------------------------------------------------------*/
22 22 #ifndef B24LC0X_H
23 23 #define B24LC0X_H
24 24
25 25 #include <i2c.h>
26 26 #include <uhandle.h>
27 27
28 28 typedef struct eeprom24lc0xDev
29 29 {
30 30 i2c_t iicdev;
31 31 unsigned char devAddress;
32 32 unsigned char size;
33 33 }eeprom24lc0xDev;
34 34
35 35
36 36
37 37 extern void eeprom24lc0xopen(eeprom24lc0xDev* dev,i2c_t iicdev,unsigned char A0_A1_A2_val,unsigned int size);
38 38
39 39 extern void eeprom24lc0xpagewrite(eeprom24lc0xDev* dev,unsigned char address,unsigned char* page);
40 40 extern void eeprom24lc0xpageread(eeprom24lc0xDev* dev,unsigned char address,unsigned char* page);
41 41 extern void eeprom24lc0xbytewrite(eeprom24lc0xDev* dev,unsigned char address,unsigned char data);
42 42 extern unsigned char eeprom24lc0xbyteread(eeprom24lc0xDev* dev,unsigned char address);
43 43 extern void eeprom24lc0xreadn(eeprom24lc0xDev* dev,unsigned char address,unsigned char* data, unsigned int count);
44 44 extern void eeprom24lc0xwriten(eeprom24lc0xDev* dev,unsigned char address,unsigned char* data, unsigned int count);
45 45
46 46
47 47
48 48
49 49 #endif
50 50
51 51
52 52
53 53
54 54
55 55
56 56
@@ -1,72 +1,72
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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
21 21 -------------------------------------------------------------------------------*/
22 22 #ifndef TERMINAL_H
23 23 #define TERMINAL_H
24 24 #include <stdint.h>
25 25 #include <widget.h>
26 26 #include <streamdevices.h>
27 27 #include <genericLCD_Controler.h>
28 28 #include <fonts.h>
29 29
30 30 typedef struct terminal_t
31 31 {
32 32 uint16_t line;
33 33 uint16_t column;
34 34 uint16_t lineCount;
35 35 uint16_t columnCount;
36 36 uint16_t firstLine;
37 37 uint16_t lastLine;
38 38 uint16_t Xpos;
39 39 uint16_t Ypos;
40 40 uint16_t width;
41 41 uint16_t height;
42 42 uint32_t backgroundColor;
43 43 uint32_t textColor;
44 44 int8_t verticalSpace;
45 45 int8_t horizontalSpace;
46 46 int8_t empty;
47 47 LCD_t* LCD;
48 48 sFONT* font;
49 49 char* buffer;
50 50 }terminal_t;
51 51
52 52 int terminal_init(terminal_t* terminal,LCD_t* LCD,sFONT* font,streamdevice* strdev);
53 53 void terminal_setgeometry(terminal_t* terminal,uint16_t Xpos,uint16_t Ypos,uint16_t width,uint16_t height);
54 54 void terminal_clear(terminal_t* terminal);
55 55 void terminal_setbackgroundColor(terminal_t* terminal, uint32_t backgrooundColor);
56 56 void terminal_settextColor(terminal_t* terminal, uint32_t textColor);
57 57 void terminal_movecursor(terminal_t* terminal,int n);
58 58 void terminal_clearCurentLine(terminal_t* terminal);
59 59 int terminal_write(streamdevice* device,void* data,int size, int n);
60 60 int terminal_read(streamdevice* device,void* data,int size, int n);
61 61 int terminal_setpos(streamdevice* device,int pos);
62 62 int terminal_close(streamdevice* device);
63 63
64 64
65 65
66 66
67 67
68 68
69 69
70 70
71 71
72 72 #endif
@@ -1,115 +1,115
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the libuc, microcontroler library
3 3 -- Copyright (C) 2013, 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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
21 21 -------------------------------------------------------------------------------*/
22 22 #ifndef STMPE811_H
23 23 #define STMPE811_H
24 24 #include <stdio.h>
25 25 #include <uhandle.h>
26 26 #include <genericTC_Controler.h>
27 27 #include <stdint.h>
28 28 #include <fonts.h>
29 29 #include <i2c.h>
30 30
31 31 typedef struct STMPE811_t
32 32 {
33 33 i2c_t i2cdev;
34 34 uint8_t devAddress;
35 35 }STMPE811_t;
36 36
37 37
38 38 extern int stmpe811init(STMPE811_t *dev, i2c_t i2cdev, uint8_t A0);
39 39 extern int stmpe811getID(STMPE811_t *dev);
40 40
41 41
42 42
43 43 #define STMPE811_REGISTER_CHIP_ID ((uint32_t) 0x0000 )
44 44 #define STMPE811_REGISTER_ID_VER ((uint32_t) 0x0002 )
45 45 #define STMPE811_REGISTER_SYS_CTRL1 ((uint32_t) 0x0003 )
46 46 #define STMPE811_REGISTER_SYS_CTRL2 ((uint32_t) 0x0004 )
47 47 #define STMPE811_REGISTER_SPI_CFG ((uint32_t) 0x0008 )
48 48 #define STMPE811_REGISTER_INT_CTRL ((uint32_t) 0x0009 )
49 49 #define STMPE811_REGISTER_INT_EN ((uint32_t) 0x000A )
50 50 #define STMPE811_REGISTER_INT_STA ((uint32_t) 0x000B )
51 51 #define STMPE811_REGISTER_GPIO_EN ((uint32_t) 0x000C )
52 52 #define STMPE811_REGISTER_GPIO_INT_STA ((uint32_t) 0x000D )
53 53 #define STMPE811_REGISTER_ADC_INT_EN ((uint32_t) 0x000E )
54 54 #define STMPE811_REGISTER_ADC_INT_STA ((uint32_t) 0x000F )
55 55 #define STMPE811_REGISTER_GPIO_SET_PIN ((uint32_t) 0x0010 )
56 56 #define STMPE811_REGISTER_GPIO_CLR_PIN ((uint32_t) 0x0011 )
57 57 #define STMPE811_REGISTER_GPIO_MP_STA ((uint32_t) 0x0012 )
58 58 #define STMPE811_REGISTER_GPIO_DIR ((uint32_t) 0x0013 )
59 59 #define STMPE811_REGISTER_GPIO_ED ((uint32_t) 0x0014 )
60 60 #define STMPE811_REGISTER_GPIO_RE ((uint32_t) 0x0015 )
61 61 #define STMPE811_REGISTER_GPIO_FE ((uint32_t) 0x0016 )
62 62 #define STMPE811_REGISTER_GPIO_AF ((uint32_t) 0x0017 )
63 63 #define STMPE811_REGISTER_ADC_CTRL1 ((uint32_t) 0x0020 )
64 64 #define STMPE811_REGISTER_ADC_CTRL2 ((uint32_t) 0x0021 )
65 65 #define STMPE811_REGISTER_ADC_CAPT ((uint32_t) 0x0022 )
66 66 #define STMPE811_REGISTER_ADC_DATA_CH0 ((uint32_t) 0x0030 )
67 67 #define STMPE811_REGISTER_ADC_DATA_CH1 ((uint32_t) 0x0032 )
68 68 #define STMPE811_REGISTER_ADC_DATA_CH2 ((uint32_t) 0x0034 )
69 69 #define STMPE811_REGISTER_ADC_DATA_CH3 ((uint32_t) 0x0036 )
70 70 #define STMPE811_REGISTER_ADC_DATA_CH4 ((uint32_t) 0x0038 )
71 71 #define STMPE811_REGISTER_ADC_DATA_CH5 ((uint32_t) 0x003A )
72 72 #define STMPE811_REGISTER_ADC_DATA_CH6 ((uint32_t) 0x003C )
73 73 #define STMPE811_REGISTER_ADC_DATA_CH7 ((uint32_t) 0x003E )
74 74 #define STMPE811_REGISTER_TSC_CTRL ((uint32_t) 0x0040 )
75 75 #define STMPE811_REGISTER_TSC_CFG ((uint32_t) 0x0041 )
76 76 #define STMPE811_REGISTER_WDW_TR_X ((uint32_t) 0x0042 )
77 77 #define STMPE811_REGISTER_WDW_TR_Y ((uint32_t) 0x0044 )
78 78 #define STMPE811_REGISTER_WDW_BL_X ((uint32_t) 0x0046 )
79 79 #define STMPE811_REGISTER_WDW_BL_Y ((uint32_t) 0x0048 )
80 80 #define STMPE811_REGISTER_FIFO_TH ((uint32_t) 0x004A )
81 81 #define STMPE811_REGISTER_FIFO_STA ((uint32_t) 0x004B )
82 82 #define STMPE811_REGISTER_FIFO_SIZE ((uint32_t) 0x004C )
83 83 #define STMPE811_REGISTER_TSC_DATA_X ((uint32_t) 0x004D )
84 84 #define STMPE811_REGISTER_TSC_DATA_Y ((uint32_t) 0x004F )
85 85 #define STMPE811_REGISTER_TSC_DATA_Z ((uint32_t) 0x0051 )
86 86 #define STMPE811_REGISTER_TSC_DATA_XYZ ((uint32_t) 0x0052 )
87 87 #define STMPE811_REGISTER_TSC_FRACTION_Z ((uint32_t) 0x0056 )
88 88 #define STMPE811_REGISTER_TSC_DATA ((uint32_t) 0x0057 )
89 89 #define STMPE811_REGISTER_TSC_I_DRIVE ((uint32_t) 0x0058 )
90 90 #define STMPE811_REGISTER_TSC_SHIELD ((uint32_t) 0x0059 )
91 91 #define STMPE811_REGISTER_TEMP_CTRL ((uint32_t) 0x0060 )
92 92 #define STMPE811_REGISTER_TEMP_DATA ((uint32_t) 0x0061 )
93 93 #define STMPE811_REGISTER_TEMP_TH ((uint32_t) 0x0062 )
94 94
95 95
96 96 #endif
97 97
98 98
99 99
100 100
101 101
102 102
103 103
104 104
105 105
106 106
107 107
108 108
109 109
110 110
111 111
112 112
113 113
114 114
115 115
@@ -1,37 +1,37
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the libuc, microcontroler library
3 3 -- Copyright (C) 2013, 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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
21 21 -------------------------------------------------------------------------------*/
22 22 #ifndef GENERICTC_CONTROLER_H
23 23 #define GENERICTC_CONTROLER_H
24 24
25 25 #include <uhandle.h>
26 26 #include <stdint.h>
27 27 #include <fonts.h>
28 28
29 29
30 30
31 31
32 32 #endif /*GENERICTC_CONTROLER_H*/
33 33
34 34
35 35
36 36
37 37
@@ -1,75 +1,75
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the libuc, microcontroler library
3 3 -- Copyright (C) 2013, 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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
21 21 -------------------------------------------------------------------------------*/
22 22 #ifndef N25Q128_H
23 23 #define N25Q128_H
24 24
25 25 #include <spi.h>
26 26 #include <uhandle.h>
27 27 #include <stdint.h>
28 28
29 29 typedef struct eepromN25Q128Dev
30 30 {
31 31 spi_t spidev;
32 32 void (*select)(int sel);
33 33 void (*writeprotect)(int wp);
34 34 void (*holdreset)(int hr);
35 35 }eepromN25Q128Dev;
36 36
37 37 #define N25Q128_PAGE_SZ 256
38 38 #define N25Q128_CAPACITY_IN_BYTES (1024*1024*16) /*16MB*/
39 39
40 40 #define N25Q128_READID 0x9E
41 41 #define N25Q128_READ 0x03
42 42 #define N25Q128_FASTREAD 0x0B
43 43 #define N25Q128_DOFR 0x3B
44 44 #define N25Q128_DIOFR 0xBB
45 45 #define N25Q128_QOFR 0x6B
46 46 #define N25Q128_QIOFR 0xEB
47 47 #define N25Q128_ROTP 0x4B
48 48 #define N25Q128_WREN 0x06
49 49 #define N25Q128_WRDI 0x04
50 50 #define N25Q128_PP 0x02
51 51
52 52
53 53
54 54
55 55
56 56 extern void eepromN25Q128open(eepromN25Q128Dev* dev,spi_t spidev,void (*select)(int sel),void (*writeprotect)(int wp),void (*holdreset)(int hr));
57 57 extern void eepromN25Q128pagewrite(eepromN25Q128Dev* dev,uint32_t address,unsigned char* page);
58 58 extern void eepromN25Q128pageread(eepromN25Q128Dev* dev,uint32_t address,unsigned char* page);
59 59 extern void eepromN25Q128bytewrite(eepromN25Q128Dev* dev,uint32_t address,unsigned char data);
60 60 extern unsigned char eepromN25Q128byteread(eepromN25Q128Dev* dev,uint32_t address);
61 61 extern void eepromN25Q128readn(eepromN25Q128Dev* dev,uint32_t address,unsigned char* data, unsigned int count);
62 62 extern void eepromN25Q128writen(eepromN25Q128Dev* dev,uint32_t address,unsigned char* data, unsigned int count);
63 63 extern void eepromN25Q128enablewrite(eepromN25Q128Dev* dev);
64 64
65 65
66 66
67 67
68 68 #endif
69 69
70 70
71 71
72 72
73 73
74 74
75 75
@@ -1,97 +1,97
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 #-- Mail : alexis.jeandet@gmail.com
20 #-- Mail : alexis.jeandet@member.fsf.org
21 21 #-------------------------------------------------------------------------------*/
22 22 #ifndef VS10XX_H
23 23 #define VS10XX_H
24 24 #include <uhandle.h>
25 25 #include <spi.h>
26 26
27 27 #define VSMODE 0
28 28 #define VSSTATUS 1
29 29 #define VSBASS 2
30 30 #define VSCLOCKF 3
31 31 #define VSDECODE_TIME 4
32 32 #define VSAUDATA 5
33 33 #define VSWRAM 6
34 34 #define VSWRAMADDR 7
35 35 #define VSHDAT0 8
36 36 #define VSHDAT1 9
37 37 #define VSAIADDR 0xA
38 38 #define VSVOL 0xB
39 39 #define VSAICTRL0 0xC
40 40 #define VSAICTRL1 0xD
41 41 #define VSAICTRL2 0xE
42 42 #define VSAICTRL3 0xF
43 43
44 44 typedef enum VS10XXVER_en
45 45 {
46 46 UNKNOWN,
47 47 VS1001,
48 48 VS1011,
49 49 VS1002,
50 50 VS1003,
51 51 VS1053,
52 52 VS1033,
53 53 VS1103
54 54 }VS10XXVER_en;
55 55
56 56 typedef struct vs10XXDev
57 57 {
58 58 spi_t SPIdev;
59 59 void (*setxCS)(char);
60 60 void (*setxRST)(char);
61 61 void (*setxDCS)(char);
62 62 int (*getDREQ)();
63 63 VS10XXVER_en VERSION;
64 64 }vs10XXDev;
65 65
66 66
67 67 void vs10XXopen(vs10XXDev* codec,spi_t dev, void (*setxCS)(char),void (*setxRST)(char),void (*setxDCS)(char),int (*getDREQ)());
68 68 void vs10XXsoftreset(vs10XXDev* dev);
69 69 int vs10XXcmdread(vs10XXDev* dev,char address);
70 70 void vs10XXcmdwrite(vs10XXDev* dev,char address,int value);
71 71 void vs10XXstream32bytes(vs10XXDev* dev,char* buffer);
72 72 void vs10XXsetCansel(vs10XXDev* dev);
73 73 int vs10XXcanselAccepted(vs10XXDev* dev);
74 74 void vs10XXsoftReset(vs10XXDev* dev);
75 75 //extern void vs10XXclearXCS();
76 76 //extern void vs10XXsetXCS();
77 77 //extern int vs10XXDREQ();
78 78
79 79 #endif //VS10XX_H
80 80
81 81
82 82
83 83
84 84
85 85
86 86
87 87
88 88
89 89
90 90
91 91
92 92
93 93
94 94
95 95
96 96
97 97
@@ -1,196 +1,196
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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
21 21 -------------------------------------------------------------------------------*/
22 22 #ifndef FAT32_H
23 23 #define FAT32_H
24 24 #include <mbr.h>
25 25 #include <libucfs.h>
26 26 #include <ucdirent.h>
27 27 #include <stdint.h>
28 28 #include <stdint-gcc.h>
29 29 /*BPB (Boot Sector) Offsets */
30 30
31 31 #define BS_jmpBootoff 0
32 32 #define BS_OEMNameoff 3
33 33 #define BPB_BytsPerSecoff 11
34 34 #define BPB_SecPerClusoff 13
35 35 #define BPB_RsvdSecCntoff 14
36 36 #define BPB_NumFATsoff 16
37 37 #define BPB_RootEntCntoff 17
38 38 #define BPB_TotSec16off 19
39 39 #define BPB_Mediaoff 21
40 40 #define BPB_FATSz16off 22
41 41 #define BPB_SecPerTrkoff 24
42 42 #define BPB_NumHeadsoff 26
43 43 #define BPB_HiddSecoff 28
44 44 #define BPB_TotSec32off 32
45 45 /*FAT16*/
46 46 #define BS_DrvNumFAT16off 36
47 47 #define BS_Reserved1FAT16off 37
48 48 #define BS_BootSigFAT16off 38
49 49 #define BS_VolIDFAT16off 39
50 50 #define BS_VolLabFAT16off 43
51 51 #define BS_FilSysTypeFAT16off 54
52 52 /*FAT32*/
53 53 #define BPB_FATSz32off 36
54 54 #define BPB_ExtFlagsoff 40
55 55 #define BPB_FSVeroff 42
56 56 #define BPB_RootClusoff 44
57 57 #define BPB_FSInfooff 48
58 58 #define BPB_BkBootSecoff 50
59 59 #define BPB_Reservedoff 52
60 60 #define BS_DrvNumFAT32off 64
61 61 #define BS_Reserved1FAT32off 65
62 62 #define BS_BootSigFAT32off 66
63 63 #define BS_VolIDFAT32off 67
64 64 #define BS_VolLabFAT32off 71
65 65 #define BS_FilSysTypeFAT32off 82
66 66
67 67
68 68 #define DIR_Nameoff 0
69 69 #define DIR_Attroff 0xb
70 70 #define DIR_FstClusHIoff 0x14
71 71 #define DIR_FstClusLOoff 0x1A
72 72 #define DIR_FileSizeoff 0x1c
73 73 #define DIR_CrtTimeTenthoff 13
74 74 #define DIR_CrtTimeoff 14
75 75 #define DIR_CrtDateoff 16
76 76 #define DIR_LstAccDateoff 18
77 77 #define DIR_WrtTimeoff 22
78 78 #define DIR_WrtDateoff 24
79 79
80 80
81 81
82 82 #define FATBadpart 1
83 83 #define FATBabArg 2
84 84 #define FATReadErr 3
85 85 #define FATnoErr 0
86 86
87 87 /*
88 88 TODO :
89 89 intergrate a per BLKDEV or per partition buffer.
90 90 */
91 91 typedef struct FAT32fs
92 92 {
93 93 uint16_t BPB_BytsPerSec;
94 94 uint16_t BPB_RsvdSecCnt;
95 95 uint32_t BPB_FATSz32;
96 96 uint32_t BPB_RootClus;
97 97 uint32_t fat_begin_lba;
98 98 uint32_t cluster_begin_lba;
99 99 uint8_t BPB_SecPerClus;
100 100 uint8_t BPB_NumFATs;
101 101 char valide;
102 102 dikpartition* part;
103 103 }FAT32fs;
104 104
105 105
106 106 #define castUI64(val) ((uint64_t)(val))
107 107 #define castUI32(val) ((uint32_t)(val))
108 108 #define castUI16(val) ((uint16_t)(val))
109 109 #define castUI8(val) ((uint8_t)(val))
110 110
111 111 #define castI64(val) ((int64_t)(val))
112 112 #define castI32(val) ((int32_t)(val))
113 113 #define castI16(val) ((int16_t)(val))
114 114 #define castI8(val) ((int8_t)(val))
115 115
116 116 /*
117 117 TODO :
118 118 Should add global function for casting with endianness care.
119 119 have a look at REV, REV16, REVSH, and RBIT ARMV7m asm
120 120 */
121 121
122 122 #if __BYTE_ORDER__==__ORDER_BIG_ENDIAN__
123 123 #define fat32Ui8_2_Ui32(table,lsBindex) ((uint32_t)((0xFF&(table[lsBindex]))+(0xFF00&(((uint32_t)table[lsBindex+1])<<8))+(0xFF0000&(((uint32_t)table[lsBindex+2])<<16))+(0xFF000000&(((uint32_t)table[lsBindex+3])<<24))))
124 124 #define fat32Ui8_2_Ui16(table,lsBindex) ((uint16_t)((0xFF&(table[lsBindex]))+(0xFF00&(((uint16_t)table[lsBindex+1])<<8))))
125 125 #define fat32extract16b(table, LSBOffset) (uint16_t)(( (uint16_t) ((uint8_t)table[(LSBOffset)]) ) + (uint16_t)( ((uint8_t)table[(LSBOffset)+1]) << 8 ))
126 126 #define fat32extract32b(table, LSBOffset) (uint32_t)(( (uint32_t) ((uint8_t)table[(LSBOffset)]) ) + (uint32_t)( ((uint8_t)table[(LSBOffset)+1]) << 8 )+ (uint32_t)( ((uint8_t)table[(LSBOffset)+2]) << 16 )+ (uint32_t)( ((uint8_t)table[(LSBOffset)+3]) << 24 ))
127 127 #else
128 128 #define fat32Ui8_2_Ui32(table,lsBindex) ((uint32_t)((0xFF&(table[lsBindex]))+(0xFF00&(((uint32_t)table[lsBindex+1])<<8))+(0xFF0000&(((uint32_t)table[lsBindex+2])<<16))+(0xFF000000&(((uint32_t)table[lsBindex+3])<<24))))
129 129 #define fat32Ui8_2_Ui16(table,lsBindex) ((uint16_t)((0xFF&(table[lsBindex]))+(0xFF00&(((uint16_t)table[lsBindex+1])<<8))))
130 130 #define fat32extract16b(table, LSBOffset) (uint16_t)(( (uint16_t) ((uint8_t)table[(LSBOffset)]) ) + (uint16_t)( ((uint8_t)table[(LSBOffset)+1]) << 8 ))
131 131 #define fat32extract32b(table, LSBOffset) (uint32_t)(( (uint32_t) ((uint8_t)table[(LSBOffset)]) ) + (uint32_t)( ((uint8_t)table[(LSBOffset)+1]) << 8 )+ (uint32_t)( ((uint8_t)table[(LSBOffset)+2]) << 16 )+ (uint32_t)( ((uint8_t)table[(LSBOffset)+3]) << 24 ))
132 132 #endif
133 133
134 134
135 135 /* Get the first sector lba of given cluster number*/
136 136 #define clusterlba(fs,cluster_number) ((uint32_t)fs->cluster_begin_lba + (((uint32_t)cluster_number) - (2)) * (uint32_t)fs->BPB_SecPerClus)
137 137
138 138 //#define fat32clusterinfatsect(fs,cluster_number) ((((uint32_t)(cluster_number))>>6) + fs->fat_begin_lba)
139 139 #define fat32clusterinfatsect(fs,cluster_number) ((((uint32_t)(cluster_number))>>7) + fs->fat_begin_lba)
140 140 #define fat32clusterinfatoff(cluster_number) (((cluster_number)&0x7F)*4)
141 141
142 142 /*Get cluster index in FAT Table from sector address*/
143 143 #define fat32masksectorlba(sectorlba,fs) (sectorlba)//(sectorlba & (castUI32(-1)^castUI32(fs->BPB_SecPerClus-1)))
144 144 #define fat32sectorlbatoclusternum(fs,sectorlba) (((fat32masksectorlba(castUI32(sectorlba),fs) -(castUI32(fs->cluster_begin_lba)))/castUI32(fs->BPB_SecPerClus))+castUI32(2))
145 145
146 146
147 147 #ifdef FAT32_PRIVATE
148 148 #define fat32sectorreadout(fs,fatsec) \
149 149 if((lastSecAddrs!=(fatsec)) || (lastFATFS!=(fs))) /*Check if sector already buffered*/ \
150 150 {\
151 151 if((fs)->part->phy->read((fs)->part->phy,fat32buff,(fatsec),1)!=RES_OK) \
152 152 {\
153 153 return DIRENT_ReadErr;\
154 154 }\
155 155 }\
156 156 lastSecAddrs=(fatsec);\
157 157 lastFATFS=(fs);
158 158 #endif
159 159
160 160 extern int fat32open(FAT32fs* fs,dikpartition* part);
161 161 extern int fat32mkdirent(FAT32fs* fs,ucdirent* dirent);
162 162 extern int fat32getVolName(FAT32fs* fs,char* Name);
163 163 extern int fat32getrootfirstent(ucdirent* entry);
164 164 extern int fat32nextdirent(ucdirent* entry);
165 165 extern int fat32nextsectorlba(FAT32fs* fs,uint32_t lastsector_lba,uint32_t* nextsector_lba);
166 166 extern int fat32prevsectorlba(FAT32fs* fs,uint32_t lastsector_lba,uint32_t *nextsector_lba);
167 167 extern int fat32prevsectorlba2(FAT32fs* fs,ucdirent* entry,uint32_t lastsector_lba,uint32_t *nextsector_lba);
168 168 extern uint32_t fat32getdirentlba(ucdirent* entry);
169 169 extern int fat32getdirentname(ucdirent* entry,char* nameBuffer);
170 170
171 171 #endif
172 172
173 173
174 174
175 175
176 176
177 177
178 178
179 179
180 180
181 181
182 182
183 183
184 184
185 185
186 186
187 187
188 188
189 189
190 190
191 191
192 192
193 193
194 194
195 195
196 196
@@ -1,72 +1,72
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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
21 21 -------------------------------------------------------------------------------*/
22 22 #ifndef MBR_H
23 23 #define MBR_H
24 24 #include <uhandle.h>
25 25 #include <blkdevice.h>
26 26
27 27 #define BootFlagoffset 0
28 28 #define TypeCodeoffset 4
29 29 #define LBABeginoffset 8
30 30 #define NumOfSecoffset 12
31 31
32 32 #define MBRBadMbr 1
33 33 #define MBRBabArg 2
34 34 #define MBRReadErr 3
35 35 #define MBRnoErr 0
36 36
37 37 #define isFat32(TypeCode) (((TypeCode)==0x0b)||((TypeCode)==0x0c))
38 38
39 39 typedef struct dikpartition
40 40 {
41 41 char TypeCode;
42 42 char valide;
43 43 unsigned int LBABegin;
44 44 unsigned int NumOfSec;
45 45 blkdevice* phy;
46 46 }dikpartition;
47 47
48 48
49 49 int mbropen(blkdevice* phy,dikpartition* part,char partNum);
50 50
51 51
52 52 #endif
53 53
54 54
55 55
56 56
57 57
58 58
59 59
60 60
61 61
62 62
63 63
64 64
65 65
66 66
67 67
68 68
69 69
70 70
71 71
72 72
@@ -1,106 +1,106
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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
21 21 -------------------------------------------------------------------------------*/
22 22 #ifndef SDCARD_H
23 23 #define SDCARD_H
24 24 #include "blkdevice.h"
25 25 #include <libucstrings.h>
26 26 #include <uhandle.h>
27 27
28 28 /* MMC/SD command */
29 29 #define CMD0 (0) /* GO_IDLE_STATE */
30 30 #define CMD1 (1) /* SEND_OP_COND (MMC) */
31 31 #define ACMD41 (0x80+41) /* SEND_OP_COND (SDC) */
32 32 #define CMD8 (8) /* SEND_IF_COND */
33 33 #define CMD9 (9) /* SEND_CSD */
34 34 #define CMD10 (10) /* SEND_CID */
35 35 #define CMD12 (12) /* STOP_TRANSMISSION */
36 36 #define ACMD13 (0x80+13) /* SD_STATUS (SDC) */
37 37 #define CMD16 (16) /* SET_BLOCKLEN */
38 38 #define CMD17 (17) /* READ_SINGLE_BLOCK */
39 39 #define CMD18 (18) /* READ_MULTIPLE_BLOCK */
40 40 #define CMD23 (23) /* SET_BLOCK_COUNT (MMC) */
41 41 #define ACMD23 (0x80+23) /* SET_WR_BLK_ERASE_COUNT (SDC) */
42 42 #define CMD24 (24) /* WRITE_BLOCK */
43 43 #define CMD25 (25) /* WRITE_MULTIPLE_BLOCK */
44 44 #define CMD32 (32) /* ERASE_ER_BLK_START */
45 45 #define CMD33 (33) /* ERASE_ER_BLK_END */
46 46 #define CMD38 (38) /* ERASE */
47 47 #define CMD55 (55) /* APP_CMD */
48 48 #define CMD58 (58) /* READ_OCR */
49 49
50 50 /* Card type flags (CardType) */
51 51 #define CT_MMC 0x01 /* MMC ver 3 */
52 52 #define CT_SD1 0x02 /* SD ver 1 */
53 53 #define CT_SD2 0x04 /* SD ver 2 */
54 54 #define CT_SDC (CT_SD1|CT_SD2) /* SD */
55 55 #define CT_BLOCK 0x08 /* Block addressing */
56 56
57 57 struct sdcard_str
58 58 {
59 59 UHANDLE phy;
60 60 int (*rcvr_mmc) (UHANDLE phy,char *buff,uint32_t bc);
61 61 int (*xmit_mmc) (UHANDLE phy,const char *buff,uint32_t bc);
62 62 int (*setspeed) (UHANDLE phy,uint32_t speed);
63 63 uint32_t (*getspeed) (UHANDLE phy);
64 64 DSTATUS Stat;
65 65 char CardType;
66 66 };
67 67
68 68 typedef volatile struct sdcard_str sdcardDev;
69 69
70 70 //extern void sdcardmake(sdcardDev* sdcard,UHANDLE phy,void (*rcvr_mmc) (UHANDLE,char *,uint32_t ),void (*xmit_mmc) (UHANDLE,const char *,uint32_t ),void (*setspeed) (UHANDLE phy,uint32_t speed),uint32_t (*getspeed) (UHANDLE phy));
71 71 //extern void sdcardmakeblkdev(blkdevice* dev,sdcardDev* sdcard, blkdevselect_t select,blkdevpower_t power,blkdevdetect_t detect,blkdevwriteprotected_t writeprotected);
72 72
73 73
74 74 #endif
75 75
76 76
77 77
78 78
79 79
80 80
81 81
82 82
83 83
84 84
85 85
86 86
87 87
88 88
89 89
90 90
91 91
92 92
93 93
94 94
95 95
96 96
97 97
98 98
99 99
100 100
101 101
102 102
103 103
104 104
105 105
106 106
@@ -1,150 +1,150
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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
21 21 -------------------------------------------------------------------------------*/
22 22 /*
23 23 TODO:
24 24 Add SPI slave mode
25 25 Add interrupt interface
26 26 */
27 27
28 28 #ifndef SPI_H
29 29 #define SPI_H
30 30 #include <stdint.h>
31 31 #include <uhandle.h>
32 32
33 33 #ifdef __cplusplus
34 34 extern "C" {
35 35 #endif
36 36
37 37 /*
38 38 typedef struct spi_t
39 39 {
40 40 void* _dev;
41 41 int cfg;
42 42 int speed;
43 43 }spi_t;*/
44 44
45 45 typedef int spi_t;
46 46
47 47 #define spi1 ((spi_t)0)
48 48 #define spi2 ((spi_t)1)
49 49 #define spi3 ((spi_t)2)
50 50 #define spi4 ((spi_t)3)
51 51 #define spi5 ((spi_t)4)
52 52 #define spi6 ((spi_t)5)
53 53 #define spi7 ((spi_t)6)
54 54 #define spi8 ((spi_t)7)
55 55 #define spi9 ((spi_t)8)
56 56
57 57
58 58 typedef enum
59 59 {
60 60 spi4bits = 0x3,
61 61 spi5bits = 0x4,
62 62 spi6bits = 0x5,
63 63 spi7bits = 0x6,
64 64 spi8bits = 0x7,
65 65 spi9bits = 0x8,
66 66 spi10bits = 0x9,
67 67 spi11bits = 0xA,
68 68 spi12bits = 0xB,
69 69 spi13bits = 0xC,
70 70 spi14bits = 0xD,
71 71 spi15bits = 0xE,
72 72 spi16bits = 0xF
73 73 }spibits_t;
74 74
75 75 #define SPIBITSMASK 0xF
76 76
77 77 typedef enum
78 78 {
79 79 spislave = 0x00,
80 80 spimaster = 0x10
81 81 }spimode_t;
82 82
83 83 #define SPIMODEMASK 0x10
84 84
85 85 typedef enum
86 86 {
87 87 spiclkinhlow = 0x00,
88 88 spiclkinhhigh = 0x20
89 89 }spiclkinhlvl_t;
90 90
91 91 #define SPICLKINHLVLMASK 0x20
92 92
93 93
94 94 typedef enum
95 95 {
96 96 spiclkfirstedge = 0x00,
97 97 spiclksecondedge = 0x40
98 98 }spiclkphase_t;
99 99
100 100 #define SPICLKPHASEMASK 0x40
101 101
102 102 typedef enum
103 103 {
104 104 spimsbfirst = 0x00,
105 105 spilsbfirst = 0x80
106 106 }spibitorder_t;
107 107
108 108 #define SPIBITORDERMASK 0x80
109 109
110 110
111 111 extern spi_t spiopen(int count);
112 112 extern spi_t spiopenandconfig(int count,uint32_t cfg,uint32_t speed,uint32_t MOSIpin,uint32_t MISOpin,uint32_t SCKpin,uint32_t SCSpin);
113 113 extern int spiclose(spi_t spidev);
114 114 extern int spisetpins(spi_t spidev,uint32_t MOSIpin,uint32_t MISOpin,uint32_t SCKpin,uint32_t SCSpin);
115 115 extern int spienable(spi_t spidev);
116 116 extern int spidisable(spi_t spidev);
117 117 extern int spitransactionfinished(spi_t spidev);
118 118 extern int spisetconfig(spi_t spidev,uint32_t config,uint32_t speed);
119 119 extern int spisetspeed(spi_t spidev, uint32_t speed);
120 120 extern uint32_t spigetspeed(spi_t spidev);
121 121 extern int spisetbitorder(spi_t spidev,spibitorder_t order);
122 122 extern int spisetdatabits(spi_t spidev,spibits_t bitscnt);
123 123 extern int spisetclkinhlevel(spi_t spidev,spiclkinhlvl_t level);
124 124 extern int spisetclkphase(spi_t spidev,spiclkphase_t phase);
125 125 extern int spiputw(spi_t spidev,uint16_t data);
126 126 extern uint16_t spigetw(spi_t spidev);
127 127 extern int spiputs(spi_t spidev,char* s);
128 128 extern int spigets(spi_t spidev,char* s);
129 129 extern int spiputnw(spi_t spidev,uint16_t* w,int n);
130 130 extern int spigetnw(spi_t spidev,uint16_t* w,int n);
131 131 extern int spiputnc(spi_t spidev,char* c,int n);
132 132 extern int spigetnc(spi_t spidev,char* c,int n);
133 133 extern int spiavailiabledata(spi_t spidev);
134 134
135 135 #ifdef __cplusplus
136 136 }
137 137 #endif
138 138 #endif //SPI_H
139 139
140 140
141 141
142 142
143 143
144 144
145 145
146 146
147 147
148 148
149 149
150 150
@@ -1,71 +1,71
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the libuc, microcontroler library
3 3 -- Copyright (C) 2013, 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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
21 21 -------------------------------------------------------------------------------*/
22 22 #ifndef THREAD_H
23 23 #define THREAD_H
24 24 #include <stdint.h>
25 25 #include <uhandle.h>
26 26 #include <streamdevices.h>
27 27
28 28 #ifdef __cplusplus
29 29 extern "C" {
30 30 #endif
31 31
32 32 /*
33 33 This structure holds the thread context. To do so, you need to keep a track of the programm counter,
34 34 to change the stack pointer for each thread and to save all registers needing to be saved. Since the
35 35 number of regiter to be saved vary from one processor to an other, it's easier to save them in the
36 36 owner thread stack;
37 37 */
38 38 typedef struct thread_t
39 39 {
40 40 int (*func)(void*);
41 41 void* __stack__;
42 42 void* __programmCounter__;
43 43 void* __registers__;
44 44 }thread_t;
45 45
46 46
47 47 extern int threadcreate(thread_t* thread,void* stack,int stackSize);
48 48 extern int threadstart(thread_t* thread);
49 49 extern int threadstop(thread_t* thread);
50 50
51 51 #ifdef __THREAD_PRIVATE__
52 52 extern void __cpusavecontext(void* dataspace);
53 53 extern void __cpurestorecontext(void* dataspace);
54 54 #endif
55 55
56 56 #ifdef __cplusplus
57 57 }
58 58 #endif
59 59 #endif //THREAD_H
60 60
61 61
62 62
63 63
64 64
65 65
66 66
67 67
68 68
69 69
70 70
71 71
@@ -1,126 +1,126
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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
21 21 -------------------------------------------------------------------------------*/
22 22 #include <core.h>
23 23 #include <stdint.h>
24 24 #include <stdlib.h>
25 25 #include <stdio.h>
26 26 #include <gpio.h>
27 27 #include <unistd.h>
28 28
29 29 extern uint32_t OSC0;
30 30 extern uint32_t INTOSC;
31 31 extern uint32_t RTCOSC;
32 32
33 33 volatile uint32_t tickCounter=0;
34 34
35 35
36 36 void SysTick_Handler(void)
37 37 {
38 38 tickCounter+=1;
39 39 // if((tickCounter&0xFFF)==0x800)
40 40 // gpiosetval(PC15,!gpiogetval(PC15));
41 41 }
42 42
43 43 void delay_us(uint32_t value)
44 44 {
45 45 usleep(value);
46 46 }
47 47
48 48 void delay_100us(uint32_t value)
49 49 {
50 50 usleep(value*100);
51 51 }
52 52
53 53 uint32_t getAPB1Freq()
54 54 {
55 55 return 0;
56 56 }
57 57
58 58 uint32_t getAPB2Freq()
59 59 {
60 60 return 0;
61 61 }
62 62
63 63
64 64 uint32_t getCpuFreq()
65 65 {
66 66 return 0;
67 67 }
68 68
69 69 void reset_AHB1()
70 70 {
71 71 }
72 72
73 73 void reset_AHB2()
74 74 {
75 75
76 76 }
77 77
78 78 void reset_APB1()
79 79 {
80 80
81 81 }
82 82
83 83 void reset_APB2()
84 84 {
85 85
86 86 }
87 87
88 88
89 89
90 90
91 91
92 92 int optimizePLLcfg(uint32_t freq, uint32_t srcfreq,uint32_t PLLM,uint32_t* PLLP, uint32_t* PLLN,uint8_t* AHBPRindx)
93 93 {
94 94
95 95 return 1;
96 96 }
97 97
98 98
99 99 int setPll(uint32_t freq)
100 100 {
101 101
102 102 return freq;
103 103 }
104 104
105 105 void configureSysTick()
106 106 {
107 107
108 108 }
109 109
110 110 int setCpuFreq(uint32_t freq)
111 111 {
112 112
113 113 return 0;
114 114 }
115 115
116 116
117 117 void enable_FPU()
118 118 {
119 119
120 120 }
121 121
122 122
123 123
124 124
125 125
126 126
@@ -1,81 +1,81
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the libuc, microcontroler library
3 3 -- Copyright (C) 2013, 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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
21 21 -------------------------------------------------------------------------------*/
22 22
23 23
24 24 #define __THREAD_PRIVATE__
25 25 #include <thread.h>
26 26
27 27 /*
28 28 For CM4 cf lazy Stacking and context switching form ARM
29 29 List of automatically saved registers:
30 30 R0
31 31 R1
32 32 R2
33 33 R3
34 34 R4
35 35 R5
36 36 R6
37 37 R7
38 38 R8
39 39 R9
40 40 R10
41 41 R11
42 42 R12
43 43 R13(SP)
44 44 R14(LR)
45 45 R15(PC)
46 46 xPSR
47 47 S0 to S15 (if enabled)
48 48
49 49 List of registers to save:
50 50 S16 to S31
51 51 */
52 52
53 53
54 54 void __cpusavecontext(void* dataspace)
55 55 {
56 56
57 57 }
58 58
59 59 void __cpurestorecontext(void* dataspace)
60 60 {
61 61
62 62 }
63 63
64 64
65 65
66 66
67 67
68 68
69 69
70 70
71 71
72 72
73 73
74 74
75 75
76 76
77 77
78 78
79 79
80 80
81 81
@@ -1,119 +1,119
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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
21 21 -------------------------------------------------------------------------------*/
22 22 #include <gpio.h>
23 23
24 24
25 25
26 26 gpio_t gpioopen(uint32_t gpio)
27 27 {
28 28 gpio &= -1^GPIOSPEEDMASK;
29 29 gpio |= gpiolowspeed;
30 30 gpio &= -1^GPIODIRMASK;
31 31 gpio |= gpioindir;
32 32 gpio &= -1^GPIOOUTTYPEMASK;
33 33 gpio |= gpiopushpulltype;
34 34 gpio &= -1^GPIOPULLTYPEMASK;
35 35 gpio |= gpionopulltype;
36 36 return gpio;
37 37 }
38 38
39 39
40 40 void gpioclose(gpio_t gpio)
41 41 {
42 42 }
43 43
44 44 void gpiosetconfig(gpio_t* gpio)
45 45 {
46 46 gpiosetdir(gpio, (*gpio & GPIODIRMASK));
47 47 gpiosetspeed(gpio, (*gpio & GPIOSPEEDMASK));
48 48 gpiosetouttype(gpio, (*gpio & GPIOOUTTYPEMASK));
49 49 gpiosetpulltype(gpio, (*gpio & GPIOPULLTYPEMASK));
50 50 }
51 51
52 52 extern void gpiosetspeed(gpio_t* gpio,gpiospeed_t speed)
53 53 {
54 54
55 55 }
56 56
57 57
58 58 void gpiosetdir(gpio_t* gpio,gpiodir_t dir)
59 59 {
60 60
61 61
62 62 }
63 63
64 64
65 65 void gpiosetouttype(gpio_t* gpio, gpioouttype_t outtype)
66 66 {
67 67
68 68 }
69 69
70 70
71 71 void gpiosetpulltype(gpio_t* gpio,gpiopulltype_t pulltype)
72 72 {
73 73
74 74 }
75 75
76 76 void gpioset(gpio_t gpio)
77 77 {
78 78
79 79 }
80 80
81 81
82 82 void gpioclr(gpio_t gpio)
83 83 {
84 84
85 85 }
86 86
87 87 void gpiosetval(gpio_t gpio,int val)
88 88 {
89 89
90 90 }
91 91
92 92 int gpiogetval(gpio_t gpio)
93 93 {
94 94 return 0;
95 95 }
96 96
97 97
98 98
99 99
100 100
101 101
102 102
103 103
104 104
105 105
106 106
107 107
108 108
109 109
110 110
111 111
112 112
113 113
114 114
115 115
116 116
117 117
118 118
119 119
@@ -1,132 +1,132
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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
21 21 -------------------------------------------------------------------------------*/
22 22
23 23 #include <i2c.h>
24 24 #include <gpio.h>
25 25
26 26
27 27 int i2ctimeout=1000*1000;
28 28
29 29
30 30 i2c_t i2copen(int count)
31 31 {
32 32 return -1;
33 33 }
34 34
35 35 i2c_t i2copenandconfig(int count,uint32_t cfg,uint32_t speed,uint32_t SDA,uint32_t SCL)
36 36 {
37 37 i2c_t dev = i2copen(count);
38 38 if(dev!=-1)
39 39 {
40 40 i2cclose(dev);
41 41 i2csetpins(dev,SDA,SCL);
42 42 i2copen(count);
43 43 i2csetspeed(dev,speed);
44 44 i2cenable(count);
45 45 }
46 46 return dev;
47 47 }
48 48
49 49 int i2cclose(i2c_t dev)
50 50 {
51 51 return 1;
52 52 }
53 53
54 54 int i2csetpins(i2c_t dev, uint32_t SDA, uint32_t SCL)
55 55 {
56 56 if((dev<i2c4)&&(dev>=i2c1))
57 57 {
58 58 return 0;
59 59 }
60 60 return -1;
61 61 }
62 62
63 63 int i2cenable(i2c_t dev)
64 64 {
65 65 if((dev<i2c4)&&(dev>=i2c1))
66 66 {
67 67
68 68 return 0;
69 69 }
70 70 return -1;
71 71 }
72 72
73 73 int i2cdisable(i2c_t dev)
74 74 {
75 75 if((dev<i2c4)&&(dev>=i2c1))
76 76 {
77 77
78 78 return 0;
79 79 }
80 80 return -1;
81 81 }
82 82
83 83
84 84 int i2csetspeed(i2c_t dev,uint32_t speed)
85 85 {
86 86 if((dev<i2c4)&&(dev>=i2c1))
87 87 {
88 88 return 0;
89 89 }
90 90 return -1;
91 91 }
92 92
93 93 int i2cbusy(i2c_t dev)
94 94 {
95 95 if((dev<i2c4)&&(dev>=i2c1))
96 96 {
97 97 return 0; /* Dev isn't busy */
98 98 }
99 99 return -1; /* Error, dev is out of range */
100 100 }
101 101
102 102 int i2cwrite(i2c_t dev,char address,char* data,int count)
103 103 {
104 104 if((dev<i2c4)&&(dev>=i2c1))
105 105 {
106 106
107 107 return 0;
108 108 }
109 109 return -1;
110 110 }
111 111
112 112 int i2cread(i2c_t dev,char address,char* data,int count)
113 113 {
114 114 if((dev<i2c4)&&(dev>=i2c1))
115 115 {
116 116 return 0;
117 117 }
118 118 return -1;
119 119 }
120 120
121 121
122 122 int i2cStatusCheck(i2c_t dev,int32_t flagMask)
123 123 {
124 124 int32_t flag;
125 125 if((dev<i2c4)&&(dev>=i2c1))
126 126 {
127 127 return 0;
128 128 }
129 129 return -1;
130 130 }
131 131
132 132
@@ -1,237 +1,304
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the libuc, microcontroler library
3 3 -- Copyright (C) 2013, 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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
21 21 -------------------------------------------------------------------------------*/
22 22
23 23 #include <SDL.h>
24 24 #include <malloc.h>
25 25 #include "SDLCD.h"
26 26
27 27 SDL_Surface *screen;
28 28 SDL_Overlay *bmp;
29 29
30 30 int SDLCD_Xpos=0;
31 31 int SDLCD_Ypos=0;
32 32 int SDLCD_XWinStrt=0;
33 33 int SDLCD_YWinStrt=0;
34 34 int SDLCD_XWinEnd=0;
35 35 int SDLCD_YWinEnd=0;
36 36
37 37 void* SDLCD_buffer;
38 38 int SDLCD_bpp;
39 39 void SDLCD_putpixel(SDL_Surface *surface, int x, int y, Uint32 pixel);
40 40
41 41 void SDLCD_mkscreen(int resx,int resy,int bpp,int lcdtype)
42 42 {
43 43 int i=0;
44 44 if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER)) {
45 45 fprintf(stderr, "Could not initialize SDL - %s\n", SDL_GetError());
46 46 exit(1);
47 47 }
48 48 screen = SDL_SetVideoMode(resx, resy, bpp, 0);
49 49 if(!screen) {
50 50 fprintf(stderr, "SDL: could not set video mode - exiting\n");
51 51 exit(1);
52 52 }
53 53 if ( SDL_MUSTLOCK(screen) ) {
54 54 if ( SDL_LockSurface(screen) < 0 ) {
55 55 fprintf(stderr, "Can’t lock screen: %s\n", SDL_GetError());
56 56 return;
57 57 }
58 58 }
59 59 if ( SDL_MUSTLOCK(screen) ) {
60 60 SDL_UnlockSurface(screen);
61 61 }
62 62 SDL_UpdateRect(screen, 0, 0, resx, resy);
63 63 SDLCD_buffer = malloc(resx*resy*bpp/8);
64 64 SDLCD_bpp = bpp;
65 65 for(i=0;i<(resx*resy);i++)
66 66 {
67 67 SDLCD_putpixel(screen, i%resx, (i/resx), 0xFFFF);
68 68 }
69 69 }
70 70
71 71
72 72
73 73 int SDLCD_init()
74 74 {
75 75
76 76 }
77 77
78 78 void SDLCD_writereg(uint32_t reg,uint32_t data)
79 79 {
80 80 switch (reg) {
81 81 case ILI9328_REGISTER_HORIZONTALGRAMADDRESSSET:
82 82 SDLCD_Xpos = data;
83 83 break;
84 84 case ILI9328_REGISTER_VERTICALGRAMADDRESSSET:
85 85 SDLCD_Ypos = data;
86 86 break;
87 87 case ILI9328_REGISTER_HORIZONTALADDRESSSTARTPOSITION:
88 88 SDLCD_XWinStrt = data;
89 89 break;
90 90 case ILI9328_REGISTER_HORIZONTALADDRESSENDPOSITION:
91 91 SDLCD_XWinEnd = data;
92 92 break;
93 93 case ILI9328_REGISTER_VERTICALADDRESSSTARTPOSITION:
94 94 SDLCD_YWinStrt = data;
95 95 break;
96 96 case ILI9328_REGISTER_VERTICALADDRESSENDPOSITION:
97 97 SDLCD_YWinEnd = data;
98 98 break;
99 99 default:
100 100 break;
101 101 }
102 102 }
103 103
104 104 uint32_t SDLCD_readreg(uint32_t reg)
105 105 {
106 106 return 0;
107 107 }
108 108
109 109
110 110 void SDLCD_putpixel(SDL_Surface *surface, int x, int y, Uint32 pixel)
111 111 {
112 112 int bpp = surface->format->BytesPerPixel;
113 113 /* Here p is the address to the pixel we want to set */
114 114 Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;
115 115 switch(bpp) {
116 116 case 1:
117 117 *p = pixel;
118 118 break;
119 119 case 2:
120 120 *(Uint16 *)p = pixel;
121 121 break;
122 122 case 3:
123 123 if(SDL_BYTEORDER == SDL_BIG_ENDIAN) {
124 124 p[0] = (pixel >> 16) & 0xff;
125 125 p[1] = (pixel >> 8) & 0xff;
126 126 p[2] = pixel & 0xff;
127 127 } else {
128 128 p[0] = pixel & 0xff;
129 129 p[1] = (pixel >> 8) & 0xff;
130 130 p[2] = (pixel >> 16) & 0xff;
131 131 }
132 132 break;
133 133 case 4:
134 134 *(Uint32 *)p = pixel;
135 135 break;
136 136 }
137 137 }
138 138
139 void SDLCD_putpixel_16bpp(SDL_Surface *surface, int x, int y, Uint32 pixel)
140 {
141 Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * surface->format->BytesPerPixel;
142 *(Uint16 *)p = pixel;
143 }
144
145 Uint32 SDLCD_getpixel_16bpp(SDL_Surface *surface, int x, int y)
146 {
147 Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * surface->format->BytesPerPixel;
148 return *(Uint16 *)p;
149 }
150
139 151 Uint32 SDLCD_getpixel(SDL_Surface *surface, int x, int y)
140 152 {
141 153 int bpp = surface->format->BytesPerPixel;
142 154 /* Here p is the address to the pixel we want to retrieve */
143 155 Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;
144 156 switch(bpp) {
145 157 case 1:
146 158 return *p;
147 159 case 2:
148 160 return *(Uint16 *)p;
149 161 case 3:
150 162 if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
151 163 return p[0] << 16 | p[1] << 8 | p[2];
152 164 else
153 165 return p[0] | p[1] << 8 | p[2] << 16;
154 166 case 4:
155 167 return *(Uint32 *)p;
156 168 default:
157 169 return 0;
158 170 }
159 171 /* shouldn’t happen, but avoids warnings */
160 172 }
161 173
162 174 void SDLCD_writeGRAM(void* buffer,uint32_t count)
163 175 {
164 176 int i=0;
165 177 u_int16_t* ptr=(u_int16_t*)SDLCD_buffer;
166 178 u_int16_t* inptr=(u_int16_t*)buffer;
167 179 if ( SDL_MUSTLOCK(screen) ) {
168 180 if ( SDL_LockSurface(screen) < 0 ) {
169 181 fprintf(stderr, "Can’t lock screen: %s\n", SDL_GetError());
170 182 return;
171 183 }
172 184 }
173 185 for(i=0;i<count;i++)
174 186 {
175 SDLCD_putpixel(screen,SDLCD_Xpos,SDLCD_Ypos,inptr[i]);
187 SDLCD_putpixel_16bpp(screen,SDLCD_Xpos,SDLCD_Ypos,inptr[i]);
176 188 SDLCD_Xpos+=1;
177 189 ptr[i]=inptr[i];
178 190 if(SDLCD_Xpos>=SDLCD_XWinEnd)
179 191 {
180 192 SDLCD_Xpos=SDLCD_XWinStrt;
181 193 SDLCD_Ypos+=1;
182 194 }
183 195 if(SDLCD_Ypos>=SDLCD_YWinEnd)
184 196 {
185 197 SDLCD_Ypos=SDLCD_YWinStrt;
186 198 }
187 199 }
188 200 if ( SDL_MUSTLOCK(screen) ) {
189 201 SDL_UnlockSurface(screen);
190 202 }
203 // SDL_UpdateRect(screen, SDLCD_XWinStrt, SDLCD_YWinStrt, SDLCD_XWinEnd-SDLCD_XWinStrt, SDLCD_YWinEnd-SDLCD_YWinStrt);
191 204 SDL_UpdateRect(screen, 0, 0, screen->w, screen->h);
192 205 }
193 206
207 void SDLCD_writeGRAM_16bpp(void* buffer,uint32_t count)
208 {
209 int i=0;
210 u_int16_t* inptr=(u_int16_t*)buffer;
211 if ( SDL_MUSTLOCK(screen) ) {
212 if ( SDL_LockSurface(screen) < 0 ) {
213 fprintf(stderr, "Can’t lock screen: %s\n", SDL_GetError());
214 return;
215 }
216 }
217 for(i=0;i<count;i++)
218 {
219 *(( Uint16 * ) screen->pixels + SDLCD_Ypos * screen->pitch / 2 + SDLCD_Xpos)=inptr[i];
220 SDLCD_Xpos+=1;
221 if(SDLCD_Xpos>=SDLCD_XWinEnd)
222 {
223 SDLCD_Xpos=SDLCD_XWinStrt;
224 SDLCD_Ypos+=1;
225 }
226 if(SDLCD_Ypos>=SDLCD_YWinEnd)
227 {
228 SDLCD_Ypos=SDLCD_YWinStrt;
229 }
230 }
231 if ( SDL_MUSTLOCK(screen) ) {
232 SDL_UnlockSurface(screen);
233 }
234 // SDL_UpdateRect(screen, SDLCD_XWinStrt, SDLCD_YWinStrt, SDLCD_XWinEnd-SDLCD_XWinStrt, SDLCD_YWinEnd-SDLCD_YWinStrt);
235 SDL_UpdateRect(screen, 0, 0, screen->w, screen->h);
236 }
237
238 void SDLCD_readGRAM_16bpp(void* buffer,uint32_t count)
239 {
240 int i=0;
241 u_int16_t* ptr=(u_int16_t*)SDLCD_buffer;
242 u_int16_t* inptr=(u_int16_t*)buffer;
243 for(i=0;i<count;i++)
244 {
245 inptr[i]=*(( Uint16 * ) screen->pixels + SDLCD_Ypos * screen->pitch / 2 + SDLCD_Xpos);
246 SDLCD_Xpos+=1;
247 ptr[i]=inptr[i];
248 if(SDLCD_Xpos>=SDLCD_XWinEnd)
249 {
250 SDLCD_Xpos=SDLCD_XWinStrt;
251 SDLCD_Ypos+=1;
252 }
253 if(SDLCD_Ypos>=SDLCD_YWinEnd)
254 {
255 SDLCD_Ypos=SDLCD_YWinStrt;
256 }
257 }
258
259 }
260
194 261 void SDLCD_readGRAM(void* buffer,uint32_t count)
195 262 {
196 263 int i=0;
197 264 u_int16_t* ptr=(u_int16_t*)SDLCD_buffer;
198 265 u_int16_t* inptr=(u_int16_t*)buffer;
199 266 for(i=0;i<count;i++)
200 267 {
201 inptr[i]=SDLCD_getpixel(screen,SDLCD_Xpos,SDLCD_Ypos);
268 inptr[i]=SDLCD_getpixel_16bpp(screen,SDLCD_Xpos,SDLCD_Ypos);
202 269 SDLCD_Xpos+=1;
203 270 ptr[i]=inptr[i];
204 271 if(SDLCD_Xpos>=SDLCD_XWinEnd)
205 272 {
206 273 SDLCD_Xpos=SDLCD_XWinStrt;
207 274 SDLCD_Ypos+=1;
208 275 }
209 276 if(SDLCD_Ypos>=SDLCD_YWinEnd)
210 277 {
211 278 SDLCD_Ypos=SDLCD_YWinStrt;
212 279 }
213 280 }
214 281
215 282 }
216 283
217 284
218 285
219 286
220 287
221 288
222 289
223 290
224 291
225 292
226 293
227 294
228 295
229 296
230 297
231 298
232 299
233 300
234 301
235 302
236 303
237 304
@@ -1,46 +1,48
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the libuc, microcontroler library
3 3 -- Copyright (C) 2013, 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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
21 21 -------------------------------------------------------------------------------*/
22 22
23 23 #include <SDL.h>
24 24 #include <ili9328.h>
25 25 #include <stdint.h>
26 26
27 27 #define LCDILI9328 9328
28 28
29 29 extern SDL_Surface *screen;
30 30 extern SDL_Overlay *bmp;
31 31
32 32 extern void SDLCD_mkscreen(int resx,int resy,int bbp,int lcdtype);
33 33 extern int SDLCD_init();
34 34 extern void SDLCD_writereg(uint32_t reg,uint32_t data);
35 35 extern uint32_t SDLCD_readreg(uint32_t reg);
36 36 extern void SDLCD_writeGRAM(void* buffer,uint32_t count);
37 extern void SDLCD_writeGRAM_16bpp(void* buffer,uint32_t count);
37 38 extern void SDLCD_readGRAM(void* buffer,uint32_t count);
39 extern void SDLCD_readGRAM_16bpp(void* buffer,uint32_t count);
38 40
39 41
40 42
41 43
42 44
43 45
44 46
45 47
46 48
@@ -1,255 +1,255
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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
21 21 -------------------------------------------------------------------------------*/
22 22
23 23 #include <spi.h>
24 24 #include <gpio.h>
25 25
26 26
27 27
28 28 spi_t spiopen(int count)
29 29 {
30 30
31 31 return -1;
32 32 }
33 33
34 34 spi_t spiopenandconfig(int count, uint32_t cfg, uint32_t speed, uint32_t MOSIpin, uint32_t MISOpin, uint32_t SCKpin, uint32_t SCSpin)
35 35 {
36 36 spi_t dev = spiopen(count);
37 37 if(dev!=-1)
38 38 {
39 39 spidisable(dev);
40 40 spisetpins(dev,MOSIpin, MISOpin, SCKpin, SCSpin);
41 41 spienable(dev);
42 42 spisetconfig(dev,cfg,speed);
43 43 }
44 44 return dev;
45 45 }
46 46
47 47
48 48 int spiclose(spi_t spidev)
49 49 {
50 50 if((spidev<3)&&(spidev>=0))
51 51 {
52 52
53 53 return 1;
54 54 }
55 55 return -1;
56 56 }
57 57
58 58 int spisetpins(spi_t spidev,uint32_t MOSIpin,uint32_t MISOpin,uint32_t SCKpin,uint32_t SCSpin)
59 59 {
60 60 if((spidev<3)&&(spidev>=0))
61 61 {
62 62
63 63 return 1;
64 64 }
65 65 return -1;
66 66 }
67 67
68 68
69 69 int spienable(spi_t spidev)
70 70 {
71 71 if((spidev<3)&&(spidev>=0))
72 72 {
73 73 return 1;
74 74 }
75 75 return -1;
76 76 }
77 77
78 78
79 79 int spidisable(spi_t spidev)
80 80 {
81 81 if((spidev<3)&&(spidev>=0))
82 82 {
83 83 return 1;
84 84 }
85 85 return -1;
86 86 }
87 87
88 88 int spisetconfig(spi_t spidev, uint32_t config, uint32_t speed)
89 89 {
90 90 if((spidev<3)&&(spidev>=0))
91 91 {
92 92 return 0;
93 93 }
94 94 return 1;
95 95 }
96 96
97 97 int spisetspeed(spi_t spidev, uint32_t speed)
98 98 {
99 99 if((spidev<3)&&(spidev>=0))
100 100 {
101 101 return 1;
102 102 }
103 103 return -1;
104 104 }
105 105
106 106 uint32_t spigetspeed(spi_t spidev)
107 107 {
108 108 if((spidev<3)&&(spidev>=0))
109 109 {
110 110
111 111 return 0;
112 112 }
113 113 return -1;
114 114 }
115 115
116 116 int spisetdatabits(spi_t spidev,spibits_t bitscnt)
117 117 {
118 118 if((spidev<3)&&(spidev>=0))
119 119 {
120 120 return 0;
121 121 }
122 122 return -1;
123 123 }
124 124
125 125 int spisetbitorder(spi_t spidev,spibitorder_t order)
126 126 {
127 127 if((spidev<3)&&(spidev>=0))
128 128 {
129 129 return 1;
130 130 }
131 131 return -1;
132 132 }
133 133
134 134 int spisetclkinhlevel(spi_t spidev,spiclkinhlvl_t level)
135 135 {
136 136 if((spidev<3)&&(spidev>=0))
137 137 {
138 138 return 1;
139 139 }
140 140 return -1;
141 141 }
142 142
143 143 int spisetclkphase(spi_t spidev,spiclkphase_t phase)
144 144 {
145 145 if((spidev<3)&&(spidev>=0))
146 146 {
147 147 return 1;
148 148 }
149 149 return -1;
150 150 }
151 151
152 152 int spiputw(spi_t spidev,uint16_t data)
153 153 {
154 154 if((spidev<3)&&(spidev>=0))
155 155 {
156 156 return 0;
157 157 }
158 158 return -1;
159 159 }
160 160 uint16_t spigetw(spi_t spidev)
161 161 {
162 162 if((spidev<3)&&(spidev>=0))
163 163 {
164 164 return 0;
165 165 }
166 166 return -1;
167 167 }
168 168
169 169 int spiputs(spi_t spidev,char* s)
170 170 {
171 171 while (*s) spiputw(spidev,*s++);
172 172 return 1;
173 173 }
174 174
175 175 int spigets(spi_t spidev,char* s)
176 176 {
177 177 do
178 178 {
179 179 (*s) = spigetw(spidev);
180 180 }
181 181 while(*s++);
182 182 return 1;
183 183 }
184 184
185 185 int spiputnw(spi_t spidev,uint16_t* w,int n)
186 186 {
187 187 while(n!=0)
188 188 {
189 189 spiputw(spidev,*w++);
190 190 n--;
191 191 }
192 192 return 1;
193 193 }
194 194
195 195 int spigetnw(spi_t spidev,uint16_t* w,int n)
196 196 {
197 197 while(n!=0)
198 198 {
199 199 *w++=spigetw(spidev);
200 200 n--;
201 201 }
202 202 return 1;
203 203 }
204 204
205 205 int spiputnc(spi_t spidev,char* c,int n)
206 206 {
207 207 while(n!=0)
208 208 {
209 209 spiputw(spidev,*c++);
210 210 n--;
211 211 }
212 212 return 1;
213 213 }
214 214
215 215 int spigetnc(spi_t spidev,char* c,int n)
216 216 {
217 217 while(n!=0)
218 218 {
219 219 *c++=spigetw(spidev);
220 220 n--;
221 221 }
222 222 return 1;
223 223 }
224 224
225 225 int spiavailiabledata(spi_t spidev)
226 226 {
227 227 return 0;
228 228 }
229 229
230 230
231 231 int spitransactionfinished(spi_t spidev)
232 232 {
233 233 if((spidev<3)&&(spidev>=0))
234 234 {
235 235 return 1;
236 236 }
237 237 return 0;
238 238 }
239 239
240 240
241 241
242 242
243 243
244 244
245 245
246 246
247 247
248 248
249 249
250 250
251 251
252 252
253 253
254 254
255 255
@@ -1,226 +1,226
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the libuc, microcontroler library
3 3 -- Copyright (C) 2013, 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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
21 21 -------------------------------------------------------------------------------*/
22 22
23 23 #include <uart.h>
24 24 #include <gpio.h>
25 25 #include <stdio.h>
26 26
27 27
28 28
29 29 int _uartstrsetpos(streamdevice* device,int pos);
30 30 int _uartstrread(streamdevice* device,void* data,int size, int n);
31 31 int _uartstrwrite(streamdevice* device,void* data,int size, int n);
32 32
33 33 streamdevice_ops UART_OPS=
34 34 {
35 35 .write = &_uartstrwrite,
36 36 .read = &_uartstrread,
37 37 .setpos= &_uartstrsetpos,
38 38 .close = NULL
39 39 };
40 40
41 41 uart_t uartopen(int count)
42 42 {
43 43 return -1;
44 44 }
45 45
46 46 uart_t uartopenandconfig(int count, uint32_t cfg, uint32_t speed, uint32_t TXpin, uint32_t RXpin, uint32_t RTSpin, uint32_t CTSpin)
47 47 {
48 48 uart_t dev= uartopen(count);
49 49 uartsetconfig(dev,cfg,speed);
50 50 uartsetpins(dev,TXpin,RXpin,RTSpin,CTSpin);
51 51 return dev;
52 52 }
53 53
54 54
55 55 int uartclose(uart_t uart)
56 56 {
57 57 return 1;
58 58 }
59 59
60 60 int uartsetpins(uart_t uart,uint32_t TXpin,uint32_t RXpin,uint32_t RTSpin,uint32_t CTSpin)
61 61 {
62 62 if(uart >5)return -1;
63 63 if(uart <0)return -1;
64 64 return 1;
65 65 }
66 66
67 67 int uartsetconfig(uart_t uart, uint32_t cfg, uint32_t speed)
68 68 {
69 69 int res=1;
70 70 uartdisable(uart);
71 71 uartsetspeed(uart,speed);
72 72 uartsetparity(uart,cfg & UARTPARITYMASK);
73 73 uartsetdatabits(uart,cfg & UARTBITSMASK);
74 74 uartsetstopbits(uart,cfg & UARTSTOPBITSMASK);
75 75 uartenable(uart);
76 76 return res;
77 77 }
78 78
79 79 int uartenable(uart_t uart)
80 80 {
81 81 if((uart<6)&&(uart>=0))
82 82 {
83 83 return 1;
84 84 }
85 85 return -1;
86 86 }
87 87
88 88 int uartdisable(uart_t uart)
89 89 {
90 90 if((uart<6)&&(uart>=0))
91 91 {
92 92 return 1;
93 93 }
94 94 return -1;
95 95 }
96 96
97 97 int uartsetspeed(uart_t uart,uint32_t speed)
98 98 {
99 99 if((uart<6)&&(uart>=0))
100 100 {
101 101 return 1;
102 102 }
103 103 return -1;
104 104 }
105 105
106 106 int uartsetparity(uart_t uart,uartparity_t parity)
107 107 {
108 108 if((uart<6)&&(uart>=0))
109 109 {
110 110 return 1;
111 111 }
112 112 return -1;
113 113 }
114 114
115 115 int uartsetdatabits(uart_t uart,uartbits_t databits)
116 116 {
117 117 if((uart<6)&&(uart>=0))
118 118 {
119 119 return 1;
120 120 }
121 121 return -1;
122 122 }
123 123
124 124 int uartsetstopbits(uart_t uart,uartstopbits_t stopbits)
125 125 {
126 126 if((uart<6)&&(uart>=0))
127 127 {
128 128 return 1;
129 129 }
130 130 return -1;
131 131 }
132 132
133 133 int uartputc(uart_t uart,char c)
134 134 {
135 135 if((uart<6)&&(uart>=0))
136 136 {
137 137 return 1;
138 138 }
139 139 return -1;
140 140 }
141 141
142 142 char uartgetc(uart_t uart)
143 143 {
144 144 if((uart<6)&&(uart>=0))
145 145 {
146 146 return 0;
147 147 }
148 148 return -1;
149 149 }
150 150
151 151 int uartputs(uart_t uart,char* s)
152 152 {
153 153 while (*s) uartputc(uart,*s++);
154 154 return 1;
155 155 }
156 156
157 157 int uartgets(uart_t uart,char* s)
158 158 {
159 159 do
160 160 {
161 161 (*s) = uartgetc(uart);
162 162 }
163 163 while(*s++);
164 164 return 1;
165 165 }
166 166
167 167 int uartputnc(uart_t uart,char* c,int n)
168 168 {
169 169 int l=0;
170 170 while(l<n)
171 171 {
172 172 uartputc(uart,*c++);
173 173 l++;
174 174 }
175 175 return n;
176 176 }
177 177
178 178 int uartgetnc(uart_t uart,char* c,int n)
179 179 {
180 180 int l=0;
181 181 while(l<n)
182 182 {
183 183 *c++=uartgetc(uart);
184 184 l++;
185 185 }
186 186 return n;
187 187 }
188 188
189 189 int uartavailiabledata(uart_t uart)
190 190 {
191 191 if((uart<6)&&(uart>=0))
192 192 {
193 193 return 1;
194 194 }
195 195 return -1;
196 196 }
197 197
198 198
199 199 int _uartstrwrite(streamdevice* device,void* data,int size, int n)
200 200 {
201 201 return uartputnc((uart_t) device->_stream,(char*) data,size*n);
202 202 }
203 203
204 204 int _uartstrread(streamdevice* device,void* data,int size, int n)
205 205 {
206 206 return uartgetnc((uart_t) device->_stream,(char*) data,size*n);
207 207 }
208 208
209 209 int _uartstrsetpos(streamdevice* device,int pos)
210 210 {
211 211 return 1;
212 212 }
213 213
214 214 int uartmkstreamdev(uart_t uart,streamdevice* strdev)
215 215 {
216 216 strdev->_stream = (UHANDLE)uart;
217 217 strdev->ops = &UART_OPS;
218 218 strdev->streamPt = 0;
219 219 return 1;
220 220 }
221 221
222 222
223 223
224 224
225 225
226 226
@@ -1,378 +1,378
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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
21 21 -------------------------------------------------------------------------------*/
22 22 #include <core.h>
23 23 #include <stm32f4xx_rcc.h>
24 24 #include <stdint.h>
25 25 #include <stdlib.h>
26 26 #include <stdio.h>
27 27 #include <core_cm4.h>
28 28 #include <gpio.h>
29 29
30 30 extern uint32_t OSC0;
31 31 extern uint32_t INTOSC;
32 32 extern uint32_t RTCOSC;
33 33
34 34 volatile uint32_t tickCounter=0;
35 35
36 36
37 37 void SysTick_Handler(void)
38 38 {
39 39 tickCounter+=1;
40 40 if((tickCounter&0xFFF)==0x800)
41 41 gpiosetval(PC15,!gpiogetval(PC15));
42 42 }
43 43
44 44 void delay_us(uint32_t value)
45 45 {
46 46 extern uint32_t currentCpuFreq;
47 47 if(value)
48 48 {
49 49 uint32_t tickperus=currentCpuFreq/(1000*10);
50 50 uint32_t tickCounterSnap = SysTick->VAL+((value%100)*tickperus);
51 51 uint32_t targetVal=tickCounterSnap +(value/100);
52 52 if(targetVal < tickCounterSnap)
53 53 {
54 54 while(tickCounter > targetVal);
55 55 }
56 56 while((tickCounter < targetVal) | (SysTick->VAL<tickCounterSnap));
57 57 }
58 58 }
59 59
60 60 void delay_100us(uint32_t value)
61 61 {
62 62 if(value)
63 63 {
64 64 uint32_t tickCounterSnap = tickCounter;
65 65 uint32_t SysTickSnap = SysTick->VAL;
66 66 uint32_t targetVal=tickCounterSnap +(value);
67 67 if(targetVal < tickCounterSnap)
68 68 {
69 69 while(tickCounter > targetVal);
70 70 }
71 71 while((tickCounter < targetVal) | (SysTick->VAL<SysTickSnap));
72 72 }
73 73 }
74 74
75 75 uint32_t getAPB1Freq()
76 76 {
77 77 RCC_ClocksTypeDef RCC_ClocksStatus;
78 78 RCC_GetClocksFreq(&RCC_ClocksStatus);
79 79 return RCC_ClocksStatus.PCLK1_Frequency;
80 80 }
81 81
82 82 uint32_t getAPB2Freq()
83 83 {
84 84 RCC_ClocksTypeDef RCC_ClocksStatus;
85 85 RCC_GetClocksFreq(&RCC_ClocksStatus);
86 86 return RCC_ClocksStatus.PCLK2_Frequency;
87 87 }
88 88
89 89
90 90 uint32_t getCpuFreq()
91 91 {
92 92 uint32_t cpufreq = OSC0;
93 93 uint32_t PLLN,PLLM,PLLP;
94 94
95 95 if((RCC->CFGR & 0xC) == 8) //PLL used as sys clk
96 96 {
97 97 uint32_t pllinput=INTOSC;
98 98 if((RCC->PLLCFGR & (1<<22)) == (1<<22))
99 99 {
100 100 pllinput=OSC0;
101 101 }
102 102 PLLN = (RCC->PLLCFGR>>6) & 0x1FF;
103 103 PLLM = RCC->PLLCFGR & 0x3F;
104 104 PLLP = 1<<(((RCC->PLLCFGR>>16) & 3 )+1);
105 105 cpufreq = (pllinput * PLLN )/(PLLM*PLLP);
106 106 }
107 107 else if((RCC->CFGR & 0xC) == 0) //HSI used as sys clk
108 108 {
109 109 cpufreq=INTOSC;
110 110 }
111 111 if((RCC->CFGR & (1<<7))==1<<7)
112 112 {
113 113 return cpufreq>>((RCC->CFGR & (7<<4))>>4);
114 114 }
115 115 return cpufreq;
116 116 }
117 117
118 118 void reset_AHB1()
119 119 {
120 120 RCC->AHB1RSTR = -1;
121 121 RCC->AHB1RSTR = 0;
122 122 }
123 123
124 124 void reset_AHB2()
125 125 {
126 126 RCC->AHB2RSTR = -1;
127 127 RCC->AHB2RSTR = 0;
128 128 }
129 129
130 130 void reset_APB1()
131 131 {
132 132 RCC->APB1RSTR = -1;
133 133 RCC->APB1RSTR = 0;
134 134 }
135 135
136 136 void reset_APB2()
137 137 {
138 138 RCC->APB2RSTR = -1;
139 139 RCC->APB2RSTR = 0;
140 140 }
141 141
142 142
143 143
144 144 /*
145 145 | 2.7->3.6V
146 146 -------------------------
147 147 0WS | 0<HCLK<=30
148 148 1WS | 30<HCLK<=60
149 149 2WS | 60<HCLK<=90
150 150 3WS | 90<HCLK<=120
151 151 4WS | 120<HCLK<=150
152 152 5WS | 150<HCLK<=168
153 153
154 154 f(VCO clock) = f(PLL clock input) × (PLLN / PLLM) [1]
155 155 64MHz <= f(VCO clock) <= 432MHz [2]
156 156
157 157 f(VCO clock input) must be between 1MHz and 2MHz and as close to 2MHz as possible!! [3]
158 158
159 159 f(PLL general clock output) = f(VCO clock) / PLLP [4]
160 160
161 161 CPU<168MHz AHB1<168MHz AHB2<168MHz APB1<42MHz APB2<84MHz [5]
162 162
163 163 ! 63<=PLLN<=432 [6]
164 164 ! 2<=PLLM<=63 [7]
165 165 ! PLLP=2,4,6,8 [8]
166 166 4<=PLLM*PLLP<=504
167 167
168 168 F= f(PLL clock input) * A/B with
169 169 63<=A<=432
170 170 4<=B<=504
171 171
172 172 */
173 173
174 174
175 175 int optimizePLLcfg(uint32_t freq, uint32_t srcfreq,uint32_t PLLM,uint32_t* PLLP, uint32_t* PLLN,uint8_t* AHBPRindx)
176 176 {
177 177 uint32_t AHBPRtbl[9]={1,2,4,8,16,64,128,256,512};
178 178 uint32_t AHBPR=0,AHBPR_r=0,PLLN_r=0,PLLP_r=0;
179 179 uint32_t Fplli=0;
180 180 int32_t f_error=100000000;
181 181 int32_t f_errornw=100000000;
182 182 Fplli = srcfreq / PLLM;
183 183 //not efficient but should find the best parameters
184 184 for((*AHBPRindx)=0;(*AHBPRindx)<9;(*AHBPRindx)++) //lowest priority
185 185 {
186 186 AHBPR = AHBPRtbl[(*AHBPRindx)];
187 187 for(*PLLP=2;*PLLP<9;*PLLP+=2)
188 188 {
189 189 *PLLN = (freq*(*PLLP)*AHBPR)/Fplli;
190 190 if(((*PLLN)>62) && ((*PLLN)<433) && ((Fplli * (*PLLN)) < 433000000))
191 191 {
192 192 f_errornw = abs((int32_t)((int32_t)((Fplli*(*PLLN))/((*PLLP)*AHBPR))-freq));
193 193 if( ( (f_error)>(f_errornw) ) || ( (*AHBPRindx==0)&&(*PLLP==2)&&(*PLLN==63) ) )
194 194 {
195 195 f_error=f_errornw;
196 196 PLLN_r = *PLLN;
197 197 PLLP_r = *PLLP;
198 198 AHBPR_r=*AHBPRindx;
199 199 if(f_error==0)
200 200 {
201 201 *PLLN = PLLN_r;
202 202 *PLLP = PLLP_r;
203 203 *AHBPRindx = AHBPR_r;
204 204 return 1;
205 205 }
206 206 }
207 207 }
208 208 }
209 209 }
210 210 *PLLN = PLLN_r;
211 211 *PLLP = PLLP_r;
212 212 *AHBPRindx = AHBPR_r;
213 213 return 1;
214 214 }
215 215
216 216
217 217 int setPll(uint32_t freq)
218 218 {
219 219 extern uint32_t OSC0;
220 220 extern uint32_t INTOSC;
221 221 uint32_t srcfreq = INTOSC;
222 222 uint8_t AHBPRindx;
223 223 uint32_t AHBPRtbl[9]={1,2,4,8,16,64,128,256,512};
224 224 uint32_t PLLN=0,PLLM=0,PLLP=0,AHBPR=0;
225 225 uint32_t Fplli=0;
226 226 if((RCC->PLLCFGR & (1<<22))==(1<<22))
227 227 {
228 228 srcfreq = OSC0;
229 229 }
230 230 PLLM = srcfreq / 1500000; // [3]
231 231 Fplli = srcfreq / PLLM;
232 232 optimizePLLcfg(freq,srcfreq,PLLM,&PLLP,&PLLN,&AHBPRindx);
233 233 srcfreq = (Fplli*PLLN)/(PLLP*AHBPRtbl[AHBPRindx]); //Put real clk freq in srcfreq for return value
234 234 //now switch to HSIs
235 235 if((RCC->CR & 1)==0)RCC->CR |= 1; //turn ON HSI
236 236 while((RCC->CR & 2)!=2); //wait for HSI Ready
237 237 RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_SW));
238 238 RCC->CFGR |= RCC_CFGR_SW_HSI; //set HSI as main clk
239 239 while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS ) != RCC_CFGR_SWS_HSI);
240 240 RCC->CR &= ~(1<<24); //Turn OFF PLL
241 241 RCC->PLLCFGR &= ~0x37FFF; //clear PLLP PLLM PLLN
242 242 RCC->PLLCFGR |= PLLM + (PLLN<<6) + (((PLLP>>1) -1)<<16);
243 243 RCC->CR |= RCC_CR_PLLON; //Turn ON PLL
244 244 while((RCC->CR & (1<<25))!=(1<<25)); //wait for PLL Ready
245 245 if(AHBPRindx!=0)AHBPRindx|=0x8;
246 246 RCC->CFGR &= ~(0xF<<4);
247 247 RCC->CFGR |= (uint32_t)(AHBPRindx<<4);
248 248 AHBPR=0;
249 249 while((srcfreq>>AHBPR)>42000000)AHBPR++; //[5] //Thune APB1 prescaler to keep APB1 CLK below 42MHz
250 250 if(AHBPR!=0)
251 251 {
252 252 AHBPR-=1;
253 253 AHBPR|=0x4;
254 254 }
255 255 RCC->CFGR &= ~(0x7<<10);
256 256 RCC->CFGR |= (uint32_t)(AHBPR<<10);
257 257 AHBPR=0;
258 258 while((srcfreq>>AHBPR)>84000000)AHBPR++; //[5] //Thune APB2 prescaler to keep APB2 CLK below 42MHz
259 259 if(AHBPR!=0)
260 260 {
261 261 AHBPR-=1;
262 262 AHBPR|=0x4;
263 263 }
264 264 RCC->CFGR &= ~(0x7<<13);
265 265 RCC->CFGR |= (uint32_t)(AHBPR<<13);
266 266 FLASH->ACR |= FLASH_ACR_LATENCY_7WS;
267 267 RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_SW));//Switch to PLL as main clk source
268 268 RCC->CFGR |= RCC_CFGR_SW_PLL;
269 269 /* Wait untill the main PLL is used as system clock source */
270 270 while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS ) != RCC_CFGR_SWS_PLL);
271 271 if(srcfreq>150000000)
272 272 {
273 273 FLASH->ACR &= (~7)|FLASH_ACR_LATENCY_5WS;
274 274 }
275 275 if((srcfreq<150000000) && (srcfreq>=120000000))
276 276 {
277 277 FLASH->ACR &= (~7)|FLASH_ACR_LATENCY_4WS;
278 278 }
279 279 if((srcfreq<120000000) && (srcfreq>=90000000))
280 280 {
281 281 FLASH->ACR &= (~7)|FLASH_ACR_LATENCY_3WS;
282 282 }
283 283 if((srcfreq<90000000) && (srcfreq>=60000000))
284 284 {
285 285 FLASH->ACR &= (~7)|FLASH_ACR_LATENCY_2WS;
286 286 }
287 287 if((srcfreq<60000000) && (srcfreq>=30000000))
288 288 {
289 289 FLASH->ACR &= (~7)|FLASH_ACR_LATENCY_1WS;
290 290 }
291 291 if(srcfreq<30000000)
292 292 {
293 293 FLASH->ACR &= (~7)|FLASH_ACR_LATENCY_0WS;
294 294 }
295 295 return srcfreq;
296 296 }
297 297
298 298 void configureSysTick()
299 299 {
300 300 extern uint32_t currentCpuFreq;
301 301 uint32_t us=currentCpuFreq/(1000*10);
302 302 SysTick_Config(us);
303 303 }
304 304
305 305 int setCpuFreq(uint32_t freq)
306 306 {
307 307 extern uint32_t OSC0;
308 308 extern uint32_t INTOSC;
309 309 uint8_t i=0;
310 310 uint32_t curentFeq = getCpuFreq();
311 311 if(curentFeq==freq)return curentFeq;
312 312 if((freq>2000000) && (freq<=250000000)) //be carefull with 250MHz!!!
313 313 {
314 314 if((RCC->CFGR & 0xC) == 8) //PLL used as sys clk
315 315 {
316 316 return setPll(freq);
317 317 }
318 318 else if((RCC->CFGR & 0xC) == 0) //HSI used as sys clk
319 319 {
320 320 if((INTOSC%freq)==0) //now check if we can directly divide HSI
321 321 {
322 322 if(freq==INTOSC)
323 323 {
324 324 RCC->CFGR &= ~(0xF<<4);
325 325 return freq;
326 326 }
327 327 for(i=1;i<8;i++)
328 328 {
329 329 if((freq<<i)==INTOSC)
330 330 {
331 331 RCC->CFGR &= ~(0xF<<4);
332 332 RCC->CFGR |= ((0x8|i)<<4);
333 333 return freq;
334 334 }
335 335 }
336 336 }
337 337 else
338 338 return setPll(freq);
339 339 }
340 340 else //HSE used as sys clk
341 341 {
342 342 if((OSC0%freq)==0) //now check if we can directly divide HSI
343 343 {
344 344 if(freq==OSC0)
345 345 {
346 346 RCC->CFGR &= ~(0xF<<4);
347 347 return freq;
348 348 }
349 349 for(i=1;i<8;i++)
350 350 {
351 351 if((freq<<i)==OSC0)
352 352 {
353 353 RCC->CFGR &= ~(0xF<<4);
354 354 RCC->CFGR |= ((0x8|i)<<4);
355 355 return freq;
356 356 }
357 357 }
358 358 }
359 359 else
360 360 return setPll(freq);
361 361 }
362 362 }
363 363 return 0;
364 364 }
365 365
366 366
367 367 void enable_FPU()
368 368 {
369 369 SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2)); /* set CP10 and CP11 Full Access */
370 370 __asm__("dsb");
371 371 __asm__("isb");
372 372 }
373 373
374 374
375 375
376 376
377 377
378 378
@@ -1,81 +1,81
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the libuc, microcontroler library
3 3 -- Copyright (C) 2013, 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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
21 21 -------------------------------------------------------------------------------*/
22 22
23 23
24 24 #define __THREAD_PRIVATE__
25 25 #include <thread.h>
26 26
27 27 /*
28 28 For CM4 cf lazy Stacking and context switching form ARM
29 29 List of automatically saved registers:
30 30 R0
31 31 R1
32 32 R2
33 33 R3
34 34 R4
35 35 R5
36 36 R6
37 37 R7
38 38 R8
39 39 R9
40 40 R10
41 41 R11
42 42 R12
43 43 R13(SP)
44 44 R14(LR)
45 45 R15(PC)
46 46 xPSR
47 47 S0 to S15 (if enabled)
48 48
49 49 List of registers to save:
50 50 S16 to S31
51 51 */
52 52
53 53
54 54 void __cpusavecontext(void* dataspace)
55 55 {
56 56
57 57 }
58 58
59 59 void __cpurestorecontext(void* dataspace)
60 60 {
61 61
62 62 }
63 63
64 64
65 65
66 66
67 67
68 68
69 69
70 70
71 71
72 72
73 73
74 74
75 75
76 76
77 77
78 78
79 79
80 80
81 81
@@ -1,392 +1,392
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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
21 21 -------------------------------------------------------------------------------*/
22 22 #include <gpio.h>
23 23 #include <stm32f4xx_gpio.h>
24 24 #include <stm32f4xx_rcc.h>
25 25
26 26 #define GPIOGETPORT(gpio) ((GPIO_TypeDef*)(((((uint32_t)gpio) & (uint32_t)0x0000FF00)*(uint32_t)4) + (uint32_t)GPIOA))
27 27 #define GPIOPORTNUM(gpio) (((uint32_t)(gpio) & (uint32_t)0x0000FF00)>>(uint32_t)8)
28 28
29 29
30 30 gpio_t gpioopen(uint32_t gpio)
31 31 {
32 32 gpio &= -1^GPIOSPEEDMASK;
33 33 gpio |= gpiolowspeed;
34 34 gpio &= -1^GPIODIRMASK;
35 35 gpio |= gpioindir;
36 36 gpio &= -1^GPIOOUTTYPEMASK;
37 37 gpio |= gpiopushpulltype;
38 38 gpio &= -1^GPIOPULLTYPEMASK;
39 39 gpio |= gpionopulltype;
40 40 gpiosetconfig(&gpio);
41 41 RCC_AHB1PeriphClockCmd(((uint32_t)0x00000001<<GPIOPORTNUM(gpio)), ENABLE);
42 42 return gpio;
43 43 }
44 44
45 45
46 46 void gpioclose(gpio_t gpio)
47 47 {
48 48 }
49 49
50 50 void gpiosetconfig(gpio_t* gpio)
51 51 {
52 52 gpiosetdir(gpio, (*gpio & GPIODIRMASK));
53 53 gpiosetspeed(gpio, (*gpio & GPIOSPEEDMASK));
54 54 gpiosetouttype(gpio, (*gpio & GPIOOUTTYPEMASK));
55 55 gpiosetpulltype(gpio, (*gpio & GPIOPULLTYPEMASK));
56 56 }
57 57
58 58 extern void gpiosetspeed(gpio_t* gpio,gpiospeed_t speed)
59 59 {
60 60 GPIO_TypeDef* GPIOx = GPIOGETPORT((*gpio));
61 61 switch(speed)
62 62 {
63 63 case gpiolowspeed :
64 64 if((*gpio & 0xFF)==0xFF)
65 65 {
66 66 for(int i=0;i<16;i++)
67 67 {
68 68 GPIOx->OSPEEDR &= ~(GPIO_OSPEEDER_OSPEEDR0 << (i * 2));
69 69 GPIOx->OSPEEDR |= ((uint32_t)(GPIO_Speed_2MHz) << (i * 2));
70 70 }
71 71 }
72 72 else
73 73 {
74 74 GPIOx->OSPEEDR &= ~(GPIO_OSPEEDER_OSPEEDR0 << ((*gpio & 0xFF) * 2));
75 75 GPIOx->OSPEEDR |= ((uint32_t)(GPIO_Speed_2MHz) << ((*gpio & 0xFF) * 2));
76 76 }
77 77 *gpio &= ~GPIOSPEEDMASK;
78 78 *gpio |= gpiolowspeed;
79 79 break;
80 80 case gpiomediumspeed :
81 81 if((*gpio & 0xFF)==0xFF)
82 82 {
83 83 for(int i=0;i<16;i++)
84 84 {
85 85 GPIOx->OSPEEDR &= ~(GPIO_OSPEEDER_OSPEEDR0 << (i * 2));
86 86 GPIOx->OSPEEDR |= ((uint32_t)(GPIO_Speed_25MHz) << (i * 2));
87 87 }
88 88 }
89 89 else
90 90 {
91 91 GPIOx->OSPEEDR &= ~(GPIO_OSPEEDER_OSPEEDR0 << ((*gpio & 0xFF) * 2));
92 92 GPIOx->OSPEEDR |= ((uint32_t)(GPIO_Speed_25MHz) << ((*gpio & 0xFF) * 2));
93 93 }
94 94 *gpio &= ~GPIOSPEEDMASK;
95 95 *gpio |= gpiomediumspeed;
96 96 break;
97 97 case gpiofastspeed :
98 98 if((*gpio & 0xFF)==0xFF)
99 99 {
100 100 for(int i=0;i<16;i++)
101 101 {
102 102 GPIOx->OSPEEDR &= ~(GPIO_OSPEEDER_OSPEEDR0 << (i * 2));
103 103 GPIOx->OSPEEDR |= ((uint32_t)(GPIO_Speed_50MHz) << (i * 2));
104 104 }
105 105 }
106 106 else
107 107 {
108 108 GPIOx->OSPEEDR &= ~(GPIO_OSPEEDER_OSPEEDR0 << ((*gpio & 0xFF) * 2));
109 109 GPIOx->OSPEEDR |= ((uint32_t)(GPIO_Speed_50MHz) << ((*gpio & 0xFF) * 2));
110 110 }
111 111 *gpio &= ~GPIOSPEEDMASK;
112 112 *gpio |= gpiofastspeed;
113 113 break;
114 114 case gpiohighspeed :
115 115 if((*gpio & 0xFF)==0xFF)
116 116 {
117 117 for(int i=0;i<16;i++)
118 118 {
119 119 GPIOx->OSPEEDR &= ~(GPIO_OSPEEDER_OSPEEDR0 << (i * 2));
120 120 GPIOx->OSPEEDR |= ((uint32_t)(GPIO_Speed_100MHz) << (i * 2));
121 121 }
122 122 }
123 123 else
124 124 {
125 125 GPIOx->OSPEEDR &= ~(GPIO_OSPEEDER_OSPEEDR0 << ((*gpio & 0xFF) * 2));
126 126 GPIOx->OSPEEDR |= ((uint32_t)(GPIO_Speed_100MHz) << ((*gpio & 0xFF) * 2));
127 127 }
128 128 *gpio &= ~GPIOSPEEDMASK;
129 129 *gpio |= gpiohighspeed;
130 130 break;
131 131 }
132 132 }
133 133
134 134
135 135 void gpiosetdir(gpio_t* gpio,gpiodir_t dir)
136 136 {
137 137 GPIO_TypeDef* GPIOx = GPIOGETPORT((*gpio));
138 138 switch(dir)
139 139 {
140 140 case gpiooutdir:
141 141 if((*gpio & 0xFF)==0xFF)
142 142 {
143 143 for(int i=0;i<16;i++)
144 144 {
145 145 GPIOx->MODER &= ~(GPIO_MODER_MODER0 << (i * 2));
146 146 GPIOx->MODER |= (GPIO_Mode_OUT << (i * 2));
147 147 }
148 148 }
149 149 else
150 150 {
151 151 GPIOx->MODER &= ~(GPIO_MODER_MODER0 << ((*gpio & 0xFF) * 2));
152 152 GPIOx->MODER |= (GPIO_Mode_OUT << ((*gpio & 0xFF) * 2));
153 153 }
154 154 *gpio &= ~GPIODIRMASK;
155 155 *gpio |= gpiooutdir;
156 156 break;
157 157 case gpioaf:
158 158 if((*gpio & 0xFF)==0xFF)
159 159 {
160 160 for(int i=0;i<16;i++)
161 161 {
162 162 GPIOx->MODER &= ~(GPIO_MODER_MODER0 << (i * 2));
163 163 GPIOx->MODER |= (GPIO_Mode_AF << (i * 2));
164 164 }
165 165 }
166 166 else
167 167 {
168 168 GPIOx->MODER &= ~(GPIO_MODER_MODER0 << ((*gpio & 0xFF) * 2));
169 169 GPIOx->MODER |= (GPIO_Mode_AF << ((*gpio & 0xFF) * 2));
170 170 }
171 171 *gpio &= ~GPIODIRMASK;
172 172 *gpio |= gpioaf;
173 173 break;
174 174 case gpioan:
175 175 if((*gpio & 0xFF)==0xFF)
176 176 {
177 177 for(int i=0;i<16;i++)
178 178 {
179 179 GPIOx->MODER &= ~(GPIO_MODER_MODER0 << (i * 2));
180 180 GPIOx->MODER |= (GPIO_Mode_AN << (i * 2));
181 181 }
182 182 }
183 183 else
184 184 {
185 185 GPIOx->MODER &= ~(GPIO_MODER_MODER0 << ((*gpio & 0xFF) * 2));
186 186 GPIOx->MODER |= (GPIO_Mode_AN << ((*gpio & 0xFF) * 2));
187 187 }
188 188 *gpio &= ~GPIODIRMASK;
189 189 *gpio |= gpioan;
190 190 break;
191 191 default :
192 192 if((*gpio & 0xFF)==0xFF)
193 193 {
194 194 for(int i=0;i<16;i++)
195 195 {
196 196 GPIOx->MODER &= ~(GPIO_MODER_MODER0 << (i * 2));
197 197 GPIOx->MODER |= (GPIO_Mode_IN << (i * 2));
198 198 }
199 199 }
200 200 else
201 201 {
202 202 GPIOx->MODER &= ~(GPIO_MODER_MODER0 << ((*gpio & 0xFF) * 2));
203 203 GPIOx->MODER |= (GPIO_Mode_IN << ((*gpio & 0xFF) * 2));
204 204 }
205 205 *gpio &= ~GPIODIRMASK;
206 206 *gpio |= gpioindir;
207 207 break;
208 208 }
209 209
210 210 }
211 211
212 212
213 213 void gpiosetouttype(gpio_t* gpio, gpioouttype_t outtype)
214 214 {
215 215 GPIO_TypeDef* GPIOx = GPIOGETPORT((*gpio));
216 216 if(outtype == gpioopendraintype)
217 217 {
218 218 if((*gpio & 0xFF)==0xFF)
219 219 {
220 220 for(int i=0;i<16;i++)
221 221 {
222 222 GPIOx->OTYPER &= ~((GPIO_OTYPER_OT_0) << ((uint16_t)i));
223 223 GPIOx->OTYPER |= (uint16_t)(GPIO_OType_OD<<((uint16_t)i));
224 224 }
225 225 }
226 226 else
227 227 {
228 228 GPIOx->OTYPER &= ~((GPIO_OTYPER_OT_0) << ((uint16_t)(*gpio & 0xFF)));
229 229 GPIOx->OTYPER |= (uint16_t)(GPIO_OType_OD<<((uint16_t)(*gpio & 0xFF)));
230 230 }
231 231 *gpio &= ~GPIOOUTTYPEMASK;
232 232 *gpio |= gpioopendraintype;
233 233 }
234 234 else
235 235 {
236 236 if((*gpio & 0xFF)==0xFF)
237 237 {
238 238 for(int i=0;i<16;i++)
239 239 {
240 240 GPIOx->OTYPER &= ~((GPIO_OTYPER_OT_0) << ((uint16_t)i));
241 241 GPIOx->OTYPER |= (uint16_t)(GPIO_OType_PP<<((uint16_t)i));
242 242 }
243 243 }
244 244 else
245 245 {
246 246 GPIOx->OTYPER &= ~((GPIO_OTYPER_OT_0) << ((uint16_t)(*gpio & 0xFF)));
247 247 GPIOx->OTYPER |= (uint16_t)(GPIO_OType_PP<<((uint16_t)(*gpio & 0xFF)));
248 248 }
249 249 *gpio &= ~GPIOOUTTYPEMASK;
250 250 *gpio |= gpiopushpulltype;
251 251 }
252 252 }
253 253
254 254
255 255 void gpiosetpulltype(gpio_t* gpio,gpiopulltype_t pulltype)
256 256 {
257 257 GPIO_TypeDef* GPIOx = GPIOGETPORT(*gpio);
258 258 switch(pulltype)
259 259 {
260 260 case gpiopulluptype:
261 261 if((*gpio & 0xFF)==0xFF)
262 262 {
263 263 for(int i=0;i<16;i++)
264 264 {
265 265 GPIOx->PUPDR &= ~(GPIO_PUPDR_PUPDR0 << ((uint16_t)i * 2));
266 266 GPIOx->PUPDR |= (GPIO_PuPd_UP << (i * 2));
267 267 }
268 268 }
269 269 else
270 270 {
271 271 GPIOx->PUPDR &= ~(GPIO_PUPDR_PUPDR0 << ((uint16_t)(*gpio & 0xFF) * 2));
272 272 GPIOx->PUPDR |= (GPIO_PuPd_UP << ((*gpio & 0xFF) * 2));
273 273 }
274 274 *gpio &= ~GPIOPULLTYPEMASK;
275 275 *gpio |= gpiopulluptype;
276 276 break;
277 277 case gpiopulldowntype:
278 278 if((*gpio & 0xFF)==0xFF)
279 279 {
280 280 for(int i=0;i<16;i++)
281 281 {
282 282 GPIOx->PUPDR &= ~(GPIO_PUPDR_PUPDR0 << ((uint16_t)i * 2));
283 283 GPIOx->PUPDR |= (GPIO_PuPd_DOWN << (i * 2));
284 284 }
285 285 }
286 286 else
287 287 {
288 288 GPIOx->PUPDR &= ~(GPIO_PUPDR_PUPDR0 << ((uint16_t)(*gpio & 0xFF) * 2));
289 289 GPIOx->PUPDR |= (GPIO_PuPd_DOWN << ((*gpio & 0xFF) * 2));
290 290 }
291 291 *gpio &= ~GPIOPULLTYPEMASK;
292 292 *gpio |= gpiopulldowntype;
293 293 break;
294 294 default :
295 295 if((*gpio & 0xFF)==0xFF)
296 296 {
297 297 for(int i=0;i<16;i++)
298 298 {
299 299 GPIOx->PUPDR &= ~(GPIO_PUPDR_PUPDR0 << ((uint16_t)i * 2));
300 300 GPIOx->PUPDR |= (GPIO_PuPd_NOPULL << (i * 2));
301 301 }
302 302 }
303 303 else
304 304 {
305 305 GPIOx->PUPDR &= ~(GPIO_PUPDR_PUPDR0 << ((uint16_t)(*gpio & 0xFF) * 2));
306 306 GPIOx->PUPDR |= (GPIO_PuPd_NOPULL << ((*gpio & 0xFF) * 2));
307 307 }
308 308 *gpio &= ~GPIOPULLTYPEMASK;
309 309 *gpio |= gpionopulltype;
310 310 break;
311 311 }
312 312 }
313 313
314 314 void gpioset(gpio_t gpio)
315 315 {
316 316 GPIO_TypeDef* GPIOx = GPIOGETPORT(gpio);
317 317 if((gpio & 0xFF)==0xFF)
318 318 {
319 319 GPIOx->BSRRL = -1;
320 320 }
321 321 else
322 322 {
323 323 GPIOx->BSRRL = 1<<(gpio & 0xFF);
324 324 }
325 325 }
326 326
327 327
328 328 void gpioclr(gpio_t gpio)
329 329 {
330 330 GPIO_TypeDef* GPIOx = GPIOGETPORT(gpio);
331 331 if((gpio & 0xFF)==0xFF)
332 332 {
333 333 GPIOx->BSRRH = -1;
334 334 }
335 335 else
336 336 {
337 337 GPIOx->BSRRH = 1<<(gpio & 0xFF);
338 338 }
339 339 }
340 340
341 341 void gpiosetval(gpio_t gpio,int val)
342 342 {
343 343 GPIO_TypeDef* GPIOx = GPIOGETPORT(gpio);
344 344 if((gpio & 0xFF)==0xFF)
345 345 {
346 346 GPIOx->ODR = val;
347 347 }
348 348 else
349 349 {
350 350 if(val)
351 351 GPIOx->BSRRL = 1<<(gpio & 0xFF);
352 352 else
353 353 GPIOx->BSRRH = 1<<(gpio & 0xFF);
354 354 }
355 355 }
356 356
357 357 int gpiogetval(gpio_t gpio)
358 358 {
359 359 GPIO_TypeDef* GPIOx = GPIOGETPORT(gpio);
360 360 if((gpio & 0xFF)==0xFF)
361 361 {
362 362 return GPIOx->IDR;
363 363 }
364 364 else
365 365 {
366 366 return ((GPIOx->IDR>>(gpio & 0xFF)) & 1);
367 367 }
368 368 }
369 369
370 370
371 371
372 372
373 373
374 374
375 375
376 376
377 377
378 378
379 379
380 380
381 381
382 382
383 383
384 384
385 385
386 386
387 387
388 388
389 389
390 390
391 391
392 392
@@ -1,386 +1,386
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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
21 21 -------------------------------------------------------------------------------*/
22 22
23 23 #include <i2c.h>
24 24 #include <stm32f4xx_usart.h>
25 25 #include <stm32f4xx_rcc.h>
26 26 #include <stm32f4xx_gpio.h>
27 27 #include <gpio.h>
28 28 #include <core.h>
29 29
30 30 #define GPIOGETPORT(gpio) ((GPIO_TypeDef*)(((((uint32_t)gpio) & (uint32_t)0x0000FF00)*(uint32_t)4) + (uint32_t)GPIOA))
31 31 #define GPIOPORTNUM(gpio) (((uint32_t)(gpio) & (uint32_t)0x0000FF00)>>(uint32_t)8)
32 32
33 33 int i2ctimeout=1000*1000;
34 34
35 35 I2C_TypeDef* _i2c_dev_table[3]={I2C1,I2C2,I2C3};
36 36
37 37 i2c_t i2copen(int count)
38 38 {
39 39 #define _INIT_DEV(_RCC_) \
40 40 RCC_APB1PeriphClockCmd(_RCC_, ENABLE); \
41 41 RCC_APB1PeriphResetCmd(_RCC_, ENABLE); \
42 42 RCC_APB1PeriphResetCmd(_RCC_, DISABLE);
43 43
44 44 switch(count)
45 45 {
46 46 case i2c1:
47 47 _INIT_DEV(RCC_APB1Periph_I2C1);
48 48 return i2c1;
49 49 break;
50 50 case i2c2:
51 51 _INIT_DEV(RCC_APB1Periph_I2C2);
52 52 return i2c2;
53 53 break;
54 54 case i2c3:
55 55 _INIT_DEV(RCC_APB1Periph_I2C3);
56 56 return i2c3;
57 57 break;
58 58 default:
59 59 break;
60 60 }
61 61 return -1;
62 62 }
63 63
64 64 i2c_t i2copenandconfig(int count,uint32_t cfg,uint32_t speed,uint32_t SDA,uint32_t SCL)
65 65 {
66 66 i2c_t dev = i2copen(count);
67 67 if(dev!=-1)
68 68 {
69 69 i2cclose(dev);
70 70 i2csetpins(dev,SDA,SCL);
71 71 i2copen(count);
72 72 i2csetspeed(dev,speed);
73 73 i2cenable(count);
74 74 }
75 75 return dev;
76 76 }
77 77
78 78 int i2cclose(i2c_t dev)
79 79 {
80 80 switch(dev)
81 81 {
82 82 case i2c1:
83 83 RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C1, ENABLE);
84 84 break;
85 85 case i2c2:
86 86 RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C2, ENABLE);
87 87 break;
88 88 case i2c3:
89 89 RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C3, ENABLE);
90 90 break;
91 91 default:
92 92 break;
93 93 }
94 94 return 1;
95 95 }
96 96
97 97 int i2csetpins(i2c_t dev, uint32_t SDA, uint32_t SCL)
98 98 {
99 99 if((dev<i2c4)&&(dev>=i2c1))
100 100 {
101 101 gpio_t SDApin,SCLpin;
102 102 SDApin = gpioopen(SDA);
103 103 SCLpin = gpioopen(SCL);
104 104 SDApin |= gpiolowspeed | gpioaf | gpioopendraintype | gpionopulltype;
105 105 SCLpin |= gpiolowspeed | gpiooutdir | gpioopendraintype | gpionopulltype;
106 106 gpiosetconfig(&SCLpin);
107 107 for(int i=0;i<32;i++)
108 108 {
109 109 gpioclr(SCLpin);
110 110 for(int l=0;l<200;l++)
111 111 {__asm__("nop");}
112 112 gpioset(SCLpin);
113 113 for(int l=0;l<200;l++)
114 114 {__asm__("nop");}
115 115 }
116 116 SCLpin = gpioopen(SCL);
117 117 SCLpin |= gpiolowspeed | gpioaf | gpioopendraintype | gpionopulltype;
118 118 gpiosetconfig(&SDApin);
119 119 gpiosetconfig(&SCLpin);
120 120 uint8_t gpioAFi2cx = GPIO_AF_I2C1;
121 121 switch(dev)
122 122 {
123 123 case i2c1:
124 124 gpioAFi2cx = GPIO_AF_I2C1;
125 125 break;
126 126 case i2c2:
127 127 gpioAFi2cx = GPIO_AF_I2C2;
128 128 break;
129 129 case i2c3:
130 130 gpioAFi2cx = GPIO_AF_I2C3;
131 131 break;
132 132 default:
133 133 break;
134 134 }
135 135 GPIO_PinAFConfig(GPIOGETPORT(SDApin), (uint8_t)(SDApin & 0xF), gpioAFi2cx);
136 136 GPIO_PinAFConfig(GPIOGETPORT(SCLpin), (uint8_t)(SCLpin & 0xF), gpioAFi2cx);
137 137 return 0;
138 138 }
139 139 return -1;
140 140 }
141 141
142 142 int i2cenable(i2c_t dev)
143 143 {
144 144 if((dev<i2c4)&&(dev>=i2c1))
145 145 {
146 146 I2C_TypeDef* _dev_ = _i2c_dev_table[(int)dev];
147 147 _dev_->CR1 |=1 ;
148 148 return 0;
149 149 }
150 150 return -1;
151 151 }
152 152
153 153 int i2cdisable(i2c_t dev)
154 154 {
155 155 if((dev<i2c4)&&(dev>=i2c1))
156 156 {
157 157 I2C_TypeDef* _dev_ = _i2c_dev_table[(int)dev];
158 158 _dev_->CR1 &= ~1;
159 159 return 0;
160 160 }
161 161 return -1;
162 162 }
163 163
164 164
165 165 int i2csetspeed(i2c_t dev,uint32_t speed)
166 166 {
167 167 if((dev<i2c4)&&(dev>=i2c1))
168 168 {
169 169 I2C_TypeDef* _dev_ = _i2c_dev_table[(int)dev];
170 170 int32_t APB1Freq=getAPB1Freq()/1000000;
171 171 if((APB1Freq>1)&&(APB1Freq<43))
172 172 {
173 173
174 174 uint16_t tmpreg=_dev_->CR2;
175 175 tmpreg &= ~(0x1f);
176 176 tmpreg |= APB1Freq;
177 177 _dev_->CR2=tmpreg;
178 178 i2cdisable(dev);
179 179 tmpreg=_dev_->CCR;
180 180 APB1Freq=getAPB1Freq();
181 181 if(speed>100000) //100kHz= standard mode, 400kHz= fast mode
182 182 {
183 183 if(speed<=400000)
184 184 {
185 185 tmpreg |= 1<<15;
186 186 tmpreg &= ~(1<<14);
187 187 tmpreg &= ~(0xfff);
188 188 tmpreg |= 0xfff & (APB1Freq/(3*speed));
189 189 }
190 190 }
191 191 else
192 192 {
193 193 tmpreg &= ~(1<<15);
194 194 tmpreg &= ~(0xfff);
195 195 tmpreg |= 0xfff & (APB1Freq/(2*speed));
196 196 }
197 197 _dev_->CCR=tmpreg;
198 198 tmpreg=_dev_->TRISE;
199 199 tmpreg &= ~(0x3f);
200 200 tmpreg |= (APB1Freq/1000000)+1;
201 201 _dev_->TRISE = tmpreg;
202 202 i2cenable(dev);
203 203 return 0;
204 204 }
205 205 }
206 206 return -1;
207 207 }
208 208
209 209 int i2cbusy(i2c_t dev)
210 210 {
211 211 if((dev<i2c4)&&(dev>=i2c1))
212 212 {
213 213 I2C_TypeDef* _dev_ = _i2c_dev_table[(int)dev];
214 214 if((_dev_->SR2 & 2) ==2) return 1; /* Dev is busy */
215 215 return 0; /* Dev isn't busy */
216 216 }
217 217 return -1; /* Error, dev is out of range */
218 218 }
219 219
220 220 int i2cwrite(i2c_t dev,char address,char* data,int count)
221 221 {
222 222 if((dev<i2c4)&&(dev>=i2c1))
223 223 {
224 224 int timeout=i2ctimeout;
225 225 I2C_TypeDef* _dev_ = _i2c_dev_table[(int)dev];
226 226 while(i2cbusy(dev))
227 227 {
228 228 if(0==(timeout--))
229 229 {
230 230 printf("Exited on timeout @ line %d\n\r",__LINE__);
231 231 return -1;
232 232 }
233 233 }
234 234 _dev_->CR1 |= 1<<8;
235 235 timeout=i2ctimeout;
236 236 while(!i2cStatusCheck(dev,((uint32_t)0x00030001)))
237 237 {
238 238 if(0==(timeout--))
239 239 {
240 240 printf("Exited on timeout @ line %d\n\r",__LINE__);
241 241 return -1;
242 242 }
243 243 }
244 244 _dev_->DR= address<<1;
245 245 timeout=i2ctimeout;
246 246 while(!i2cStatusCheck(dev, ((uint32_t)0x00070082)))
247 247 {
248 248 if(0==(timeout--))
249 249 {
250 250 printf("Exited on timeout @ line %d\n\r",__LINE__);
251 251 return -1;
252 252 }
253 253 }
254 254 address=_dev_->SR2;
255 255 for(int i=0;i<count;i++)
256 256 {
257 257 timeout=i2ctimeout;
258 258 while(!i2cStatusCheck(dev,((uint32_t)0x00070080)))
259 259 {
260 260 if(0==(timeout--))
261 261 {
262 262 printf("Exited on timeout @ line %d\n\r",__LINE__);
263 263 return -1;
264 264 }
265 265 }
266 266 _dev_->DR= data[i];
267 267 }
268 268 timeout=i2ctimeout;
269 269 while(!i2cStatusCheck(dev,1<<7))
270 270 {
271 271 if(0==(timeout--))
272 272 {
273 273 printf("Exited on timeout @ line %d\n\r",__LINE__);
274 274 return -1;
275 275 }
276 276 }
277 277 timeout=i2ctimeout;
278 278 while(!i2cStatusCheck(dev,1<<2))
279 279 {
280 280 if(0==(timeout--))
281 281 {
282 282 printf("Exited on timeout @ line %d\n\r",__LINE__);
283 283 return -1;
284 284 }
285 285 }
286 286 _dev_->CR1 |= 1<<9;
287 287 return count;
288 288 }
289 289 return -1;
290 290 }
291 291
292 292 int i2cread(i2c_t dev,char address,char* data,int count)
293 293 {
294 294 if((dev<i2c4)&&(dev>=i2c1))
295 295 {
296 296 int i=0;
297 297 int timeout=i2ctimeout;
298 298 while(i2cbusy(dev))
299 299 {
300 300 if(0==(timeout--))
301 301 {
302 302 printf("Exited on timeout @ line %d\n\r",__LINE__);
303 303 return -1;
304 304 }
305 305 }
306 306 I2C_TypeDef* _dev_ = _i2c_dev_table[(int)dev];
307 307 _dev_->CR1 |= (1<<8) + (1<<10);
308 308 timeout=i2ctimeout;
309 309 while(!i2cStatusCheck(dev,0x00030001))
310 310 {
311 311 if(0==(timeout--))
312 312 {
313 313 printf("Exited on timeout @ line %d\n\r",__LINE__);
314 314 return -1;
315 315 }
316 316 }
317 317 _dev_->DR= (address<<1) + 1;
318 318 while(!i2cStatusCheck(dev,0x000002))
319 319 {
320 320 if(0==(timeout--))
321 321 {
322 322 printf("Exited on timeout @ line %d\n\r",__LINE__);
323 323 return -1;
324 324 }
325 325 }
326 326 if(count==1)
327 327 {
328 328 _dev_->CR1 &= ~(1<<10);
329 329 }
330 330 address=_dev_->SR2;
331 331 for(i=0;i<(count-1);i++)
332 332 {
333 333 timeout=i2ctimeout;
334 334 while(!i2cStatusCheck(dev,0x0000040))
335 335 {
336 336 if(0==(timeout--))
337 337 {
338 338 printf("Exited on timeout @ line %d\n\r",__LINE__);
339 339 return -1;
340 340 }
341 341 }
342 342 data[i]=_dev_->DR;
343 343 }
344 344 _dev_->CR1 &= ~(1<<10);
345 345 _dev_->CR1 |= 1<<9;
346 346 timeout=i2ctimeout;
347 347 while(!i2cStatusCheck(dev,0x0000040))
348 348 {
349 349 if(0==(timeout--))
350 350 {
351 351 printf("Exited on timeout @ line %d\n\r",__LINE__);
352 352 return -1;
353 353 }
354 354 }
355 355 data[i]=_dev_->DR;
356 356 timeout=i2ctimeout;
357 357 while(_dev_->CR1 & ((uint16_t)0x0200))
358 358 {
359 359 if(0==(timeout--))
360 360 {
361 361 printf("Exited on timeout @ line %d\n\r",__LINE__);
362 362 return -1;
363 363 }
364 364 }
365 365 _dev_->CR1 |= 1<<10;
366 366 return count;
367 367 }
368 368 return -1;
369 369 }
370 370
371 371
372 372 int i2cStatusCheck(i2c_t dev,int32_t flagMask)
373 373 {
374 374 int32_t flag;
375 375 if((dev<i2c4)&&(dev>=i2c1))
376 376 {
377 377 I2C_TypeDef* _dev_ = _i2c_dev_table[(int)dev];
378 378 flag= _dev_->SR1 + (_dev_->SR2<<16);
379 379 if(flagMask==(flag & flagMask))
380 380 return 1;
381 381 return 0;
382 382 }
383 383 return -1;
384 384 }
385 385
386 386
@@ -1,121 +1,121
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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
21 21 -------------------------------------------------------------------------------*/
22 22
23 23 #include <i2c.h>
24 24 #include <stm32f4xx_usart.h>
25 25 #include <stm32f4xx_rcc.h>
26 26 #include <stm32f4xx_gpio.h>
27 27 #include <stm32f4xx_sdio.h>
28 28 #include <gpio.h>
29 29 #include <core.h>
30 30 #include <sdcard.h>
31 31 #include <sdcard-sdio.h>
32 32
33 33 void sdcardsdiomake(sdcardDev* sdcard,UHANDLE phy,void (*rcvr_mmc) (UHANDLE,char *,uint32_t ),void (*xmit_mmc) (UHANDLE,const char *,uint32_t ),void (*setspeed) (UHANDLE phy,uint32_t speed),uint32_t (*getspeed) (UHANDLE phy))
34 34 {
35 35 sdcard->phy = phy;
36 36 sdcard->rcvr_mmc = rcvr_mmc;
37 37 sdcard->xmit_mmc = xmit_mmc;
38 38 sdcard->setspeed = setspeed;
39 39 sdcard->getspeed = getspeed;
40 40 }
41 41
42 42 void sdcardsdiomakeblkdev(blkdevice* dev,sdcardDev* sdcard, blkdevselect_t select,blkdevpower_t power,blkdevdetect_t detect,blkdevwriteprotected_t writeprotected)
43 43 {
44 44 dev->phy=sdcard;
45 45 dev->select=select;
46 46 dev->power = power;
47 47 dev->detect = detect;
48 48 dev->writeprotected = writeprotected;
49 49 /*dev->write = sdcarddisk_write;
50 50 dev->read = sdcarddisk_read;
51 51 dev->ioctl = sdcarddisk_ioctl;
52 52 dev->initialize = sdcarddisk_initialize;
53 53 dev->status = sdcarddisk_status;*/
54 54 }
55 55
56 56 int sdcardselect (blkdeviceptr _this)
57 57 {
58 58
59 59 }
60 60
61 61 void sdcarddeselect (blkdeviceptr _this)
62 62 {
63 63
64 64 }
65 65
66 66 int sdcardwait_ready (sdcardDev* sdcard)
67 67 {
68 68
69 69 }
70 70
71 71 int sdcardxmit_datablock (sdcardDev* sdcard,const char *buff,char token)
72 72 {
73 73
74 74 }
75 75
76 76 int sdcardrcvr_datablock (sdcardDev* sdcard,char *buff,uint32_t btr)
77 77 {
78 78
79 79 }
80 80
81 81 char sdcardsend_cmd (blkdeviceptr _this,char cmd,uint32_t arg)
82 82 {
83 83
84 84 }
85 85
86 86 DSTATUS sdcarddisk_status (blkdeviceptr _this)
87 87 {
88 88 return RES_OK;
89 89 }
90 90
91 91 DSTATUS sdcarddisk_initialize (blkdeviceptr _this)
92 92 {
93 93 return RES_OK;
94 94 }
95 95
96 96 DRESULT sdcarddisk_read (blkdeviceptr _this,char *buff,uint32_t sector,char count)
97 97 {
98 98 return RES_OK;
99 99 }
100 100
101 101 DRESULT sdcarddisk_write (blkdeviceptr _this,const char *buff,uint32_t sector,char count)
102 102 {
103 103
104 104 }
105 105
106 106 DRESULT sdcarddisk_ioctl (blkdeviceptr _this,char ctrl,void *buff)
107 107 {
108 108 return RES_OK;
109 109 }
110 110
111 111
112 112
113 113
114 114
115 115
116 116
117 117
118 118
119 119
120 120
121 121
@@ -1,470 +1,470
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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
21 21 -------------------------------------------------------------------------------*/
22 22
23 23 #include <spi.h>
24 24 #include <stm32f4xx_rcc.h>
25 25 #include <stm32f4xx_gpio.h>
26 26 #include <gpio.h>
27 27 #define GPIOGETPORT(gpio) ((GPIO_TypeDef*)(((((uint32_t)gpio) & (uint32_t)0x0000FF00)*(uint32_t)4) + (uint32_t)GPIOA))
28 28 #define GPIOPORTNUM(gpio) (((uint32_t)(gpio) & (uint32_t)0x0000FF00)>>(uint32_t)8)
29 29
30 30
31 31 SPI_TypeDef* _spi_dev_table[3]={SPI1,SPI2,SPI3};
32 32
33 33 spi_t spiopen(int count)
34 34 {
35 35 #define _INIT_DEV(_RCC_) \
36 36 RCC_APB1PeriphClockCmd(_RCC_, ENABLE); \
37 37 RCC_APB1PeriphResetCmd(_RCC_, ENABLE); \
38 38 RCC_APB1PeriphResetCmd(_RCC_, DISABLE); \
39 39 RCC_APB1PeriphClockCmd(_RCC_, ENABLE);
40 40
41 41 switch(count)
42 42 {
43 43 case spi1:
44 44 RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE);
45 45 RCC_APB2PeriphResetCmd(RCC_APB2Periph_SPI1, ENABLE);
46 46 RCC_APB2PeriphResetCmd(RCC_APB2Periph_SPI1, DISABLE);
47 47 RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE);
48 48 return spi1;
49 49 break;
50 50 case spi2:
51 51 _INIT_DEV(RCC_APB1Periph_SPI2);
52 52 return spi2;
53 53 break;
54 54 case spi3:
55 55 _INIT_DEV(RCC_APB1Periph_SPI3);
56 56 return spi3;
57 57 break;
58 58 default:
59 59 break;
60 60 }
61 61 return -1;
62 62 }
63 63
64 64 spi_t spiopenandconfig(int count, uint32_t cfg, uint32_t speed, uint32_t MOSIpin, uint32_t MISOpin, uint32_t SCKpin, uint32_t SCSpin)
65 65 {
66 66 spi_t dev = spiopen(count);
67 67 if(dev!=-1)
68 68 {
69 69 spidisable(dev);
70 70 spisetpins(dev,MOSIpin, MISOpin, SCKpin, SCSpin);
71 71 spienable(dev);
72 72 spisetconfig(dev,cfg,speed);
73 73 }
74 74 return dev;
75 75 }
76 76
77 77
78 78 int spiclose(spi_t spidev)
79 79 {
80 80 if((spidev<3)&&(spidev>=0))
81 81 {
82 82 switch(spidev)
83 83 {
84 84 case spi1:
85 85 RCC_APB2PeriphResetCmd(RCC_APB2Periph_SPI1, ENABLE);
86 86 break;
87 87 case spi2:
88 88 RCC_APB1PeriphResetCmd(RCC_APB1Periph_SPI2, ENABLE);
89 89 break;
90 90 case spi3:
91 91 RCC_APB1PeriphResetCmd(RCC_APB1Periph_SPI3, ENABLE);
92 92 break;
93 93 default:
94 94 return -1;
95 95 break;
96 96 }
97 97 return 1;
98 98 }
99 99 return -1;
100 100 }
101 101
102 102 int spisetpins(spi_t spidev,uint32_t MOSIpin,uint32_t MISOpin,uint32_t SCKpin,uint32_t SCSpin)
103 103 {
104 104 if((spidev<3)&&(spidev>=0))
105 105 {
106 106 SPI_TypeDef* _dev_ = _spi_dev_table[(int)spidev];
107 107 gpio_t MISO,MOSI,SCK,SCS;
108 108 uint8_t gpioAFspix = GPIO_AF_SPI1;
109 109 switch(spidev)
110 110 {
111 111 case spi1:
112 112 gpioAFspix = GPIO_AF_SPI1;
113 113 break;
114 114 case spi2:
115 115 gpioAFspix = GPIO_AF_SPI2;
116 116 break;
117 117 case spi3:
118 118 gpioAFspix = GPIO_AF_SPI3;
119 119 break;
120 120 default:
121 121 break;
122 122 }
123 123 if(MISOpin!=-1)
124 124 {
125 125 MISO = gpioopen(MISOpin);
126 126 MISO |= gpiohighspeed | gpioaf | gpiopushpulltype | gpionopulltype;
127 127 gpiosetconfig(&MISO);
128 128 GPIO_PinAFConfig(GPIOGETPORT(MISO), (uint8_t)(MISO & 0xF), gpioAFspix);
129 129 }
130 130 if(MOSIpin!=-1)
131 131 {
132 132 MOSI = gpioopen(MOSIpin);
133 133 MOSI |= gpiohighspeed | gpioaf | gpiopushpulltype | gpionopulltype;
134 134 gpiosetconfig(&MOSI);
135 135 GPIO_PinAFConfig(GPIOGETPORT(MOSI), (uint8_t)(MOSI & 0xF), gpioAFspix);
136 136 }
137 137
138 138 if(SCKpin!=-1)
139 139 {
140 140 SCK = gpioopen(SCKpin);
141 141 SCK |= gpiohighspeed | gpioaf | gpiopushpulltype | gpionopulltype;
142 142 gpiosetconfig(&SCK);
143 143 GPIO_PinAFConfig(GPIOGETPORT(SCK), (uint8_t)(SCK & 0xF), gpioAFspix);
144 144 }
145 145
146 146 if(SCSpin!=-1)
147 147 {
148 148 SCS = gpioopen(SCSpin);
149 149 SCS |= gpiohighspeed | gpioaf | gpiopushpulltype | gpionopulltype;
150 150 gpiosetconfig(&SCS);
151 151 GPIO_PinAFConfig(GPIOGETPORT(SCS), (uint8_t)(SCS & 0xF), gpioAFspix);
152 152 _dev_->CR2 |= (1<<2);
153 153 }
154 154 else
155 155 {
156 156 _dev_->CR2 &= ~(1<<2);
157 157 }
158 158 return 1;
159 159 }
160 160 return -1;
161 161 }
162 162
163 163
164 164 int spienable(spi_t spidev)
165 165 {
166 166 if((spidev<3)&&(spidev>=0))
167 167 {
168 168 SPI_TypeDef* _dev_ = _spi_dev_table[(int)spidev];
169 169 _dev_->CR1 |= (1<<6);
170 170 return 1;
171 171 }
172 172 return -1;
173 173 }
174 174
175 175
176 176 int spidisable(spi_t spidev)
177 177 {
178 178 if((spidev<3)&&(spidev>=0))
179 179 {
180 180 SPI_TypeDef* _dev_ = _spi_dev_table[(int)spidev];
181 181 _dev_->CR1 &= ~(1<<6);
182 182 return 1;
183 183 }
184 184 return -1;
185 185 }
186 186
187 187 int spisetconfig(spi_t spidev, uint32_t config, uint32_t speed)
188 188 {
189 189 if((spidev<3)&&(spidev>=0))
190 190 {
191 191 SPI_TypeDef* _dev_ = _spi_dev_table[(int)spidev];
192 192 _dev_->CR2 |= (1<<2);
193 193 _dev_->CR1 |= (1<<2);
194 194 spisetspeed(spidev,speed);
195 195 spisetdatabits(spidev,config & SPIBITSMASK);
196 196 spisetbitorder(spidev,config & SPIBITORDERMASK);
197 197 spisetclkinhlevel(spidev,config & SPICLKINHLVLMASK);
198 198 spisetclkphase(spidev,config & SPICLKPHASEMASK);
199 199 return 0;
200 200 }
201 201 return 1;
202 202 }
203 203
204 204 int spisetspeed(spi_t spidev, uint32_t speed)
205 205 {
206 206 if((spidev<3)&&(spidev>=0))
207 207 {
208 208 SPI_TypeDef* _dev_ = _spi_dev_table[(int)spidev];
209 209 uint32_t apbclock = 0x00;
210 210 RCC_ClocksTypeDef RCC_ClocksStatus;
211 211 RCC_GetClocksFreq(&RCC_ClocksStatus);
212 212 if (_dev_ == SPI1)
213 213 {
214 214 apbclock = RCC_ClocksStatus.PCLK2_Frequency;
215 215 }
216 216 else
217 217 {
218 218 apbclock = RCC_ClocksStatus.PCLK1_Frequency;
219 219 }
220 220 int32_t speederror = 0x7FFFFFFF; //max error
221 221 int32_t prev_speederror = 0x7FFFFFFF;
222 222 int32_t realspeed = 0;
223 223 unsigned char divider = 0;
224 224 do
225 225 {
226 226 divider ++;
227 227 prev_speederror = speederror;
228 228 realspeed = apbclock>>(divider);
229 229 speederror = realspeed - speed;
230 230 if(speederror<0)speederror=-speederror;
231 231 if(divider>8)break;
232 232 }while(speederror<prev_speederror);
233 233 speed = apbclock>>(divider-1);
234 234 divider-=2;
235 235 _dev_->CR1 &= 0xFFD7; // clear prescaler bits 3:5
236 236 _dev_->CR1 |= ((0x7 & divider)<<3);
237 237 return 1;
238 238 }
239 239 return -1;
240 240 }
241 241
242 242 uint32_t spigetspeed(spi_t spidev)
243 243 {
244 244 if((spidev<3)&&(spidev>=0))
245 245 {
246 246 SPI_TypeDef* _dev_ = _spi_dev_table[(int)spidev];
247 247 uint32_t apbclock = 0x00;
248 248 RCC_ClocksTypeDef RCC_ClocksStatus;
249 249 RCC_GetClocksFreq(&RCC_ClocksStatus);
250 250 if (_dev_ == SPI1)
251 251 {
252 252 apbclock = RCC_ClocksStatus.PCLK2_Frequency;
253 253 }
254 254 else
255 255 {
256 256 apbclock = RCC_ClocksStatus.PCLK1_Frequency;
257 257 }
258 258 int BR= (_dev_->CR1>>3)&0x7;
259 259 return apbclock>>(BR+1);
260 260 }
261 261 return -1;
262 262 }
263 263
264 264 int spisetdatabits(spi_t spidev,spibits_t bitscnt)
265 265 {
266 266 if((spidev<3)&&(spidev>=0))
267 267 {
268 268 SPI_TypeDef* _dev_ = _spi_dev_table[(int)spidev];
269 269 int result = 0;
270 270 switch(bitscnt)
271 271 {
272 272 case spi8bits:
273 273 _dev_->CR1 &= ~(1<<11);
274 274 result = 1;
275 275 break;
276 276 case spi16bits:
277 277 _dev_->CR1 |= (1<<11);
278 278 result = 1;
279 279 break;
280 280 default:
281 281 result =-1;
282 282 break;
283 283 }
284 284 return result;
285 285 }
286 286 return -1;
287 287 }
288 288
289 289 int spisetbitorder(spi_t spidev,spibitorder_t order)
290 290 {
291 291 if((spidev<3)&&(spidev>=0))
292 292 {
293 293 SPI_TypeDef* _dev_ = _spi_dev_table[(int)spidev];
294 294 if(order==spimsbfirst)
295 295 {
296 296 _dev_->CR1 &= ~(1<<7);
297 297 return 1;
298 298 }
299 299 else
300 300 {
301 301 if(order==spilsbfirst)
302 302 {
303 303 _dev_->CR1 |= (1<<7);
304 304 return 1;
305 305 }
306 306 else return -1;
307 307 }
308 308 }
309 309 return -1;
310 310 }
311 311
312 312 int spisetclkinhlevel(spi_t spidev,spiclkinhlvl_t level)
313 313 {
314 314 if((spidev<3)&&(spidev>=0))
315 315 {
316 316 SPI_TypeDef* _dev_ = _spi_dev_table[(int)spidev];
317 317 if(level==spiclkinhlow)
318 318 {
319 319 _dev_->CR1 &= ~(1<<1);
320 320 return 1;
321 321 }
322 322 else
323 323 {
324 324 if(level==spiclkinhhigh)
325 325 {
326 326 _dev_->CR1 |= (1<<1);
327 327 return 1;
328 328 }
329 329 else return -1;
330 330 }
331 331 }
332 332 return -1;
333 333 }
334 334
335 335 int spisetclkphase(spi_t spidev,spiclkphase_t phase)
336 336 {
337 337 if((spidev<3)&&(spidev>=0))
338 338 {
339 339 SPI_TypeDef* _dev_ = _spi_dev_table[(int)spidev];
340 340 if(phase==spiclkfirstedge)
341 341 {
342 342 _dev_->CR1 &= ~1;
343 343 return 1;
344 344 }
345 345 else
346 346 {
347 347 if(phase==spiclksecondedge)
348 348 {
349 349 _dev_->CR1 |= 1;
350 350 return 1;
351 351 }
352 352 else return -1;
353 353 }
354 354 }
355 355 return -1;
356 356 }
357 357
358 358 int spiputw(spi_t spidev,uint16_t data)
359 359 {
360 360 if((spidev<3)&&(spidev>=0))
361 361 {
362 362 SPI_TypeDef* _dev_ = _spi_dev_table[(int)spidev];
363 363 while(((_dev_->SR & (1<<1)) == 0) );
364 364 _dev_->DR = data;
365 365 while(((_dev_->SR & (1<<0)) == 0) );
366 366 return _dev_->DR;
367 367 }
368 368 return -1;
369 369 }
370 370 uint16_t spigetw(spi_t spidev)
371 371 {
372 372 if((spidev<3)&&(spidev>=0))
373 373 {
374 374 SPI_TypeDef* _dev_ = _spi_dev_table[(int)spidev];
375 375 while(((_dev_->SR & (1<<1)) == 0) );
376 376 _dev_->DR = 0xFFFF;
377 377 while(((_dev_->SR & (1<<0)) == 0) );
378 378 return _dev_->DR;
379 379 }
380 380 return -1;
381 381 }
382 382
383 383 int spiputs(spi_t spidev,char* s)
384 384 {
385 385 while (*s) spiputw(spidev,*s++);
386 386 return 1;
387 387 }
388 388
389 389 int spigets(spi_t spidev,char* s)
390 390 {
391 391 do
392 392 {
393 393 (*s) = spigetw(spidev);
394 394 }
395 395 while(*s++);
396 396 return 1;
397 397 }
398 398
399 399 int spiputnw(spi_t spidev,uint16_t* w,int n)
400 400 {
401 401 while(n!=0)
402 402 {
403 403 spiputw(spidev,*w++);
404 404 n--;
405 405 }
406 406 return 1;
407 407 }
408 408
409 409 int spigetnw(spi_t spidev,uint16_t* w,int n)
410 410 {
411 411 while(n!=0)
412 412 {
413 413 *w++=spigetw(spidev);
414 414 n--;
415 415 }
416 416 return 1;
417 417 }
418 418
419 419 int spiputnc(spi_t spidev,char* c,int n)
420 420 {
421 421 while(n!=0)
422 422 {
423 423 spiputw(spidev,*c++);
424 424 n--;
425 425 }
426 426 return 1;
427 427 }
428 428
429 429 int spigetnc(spi_t spidev,char* c,int n)
430 430 {
431 431 while(n!=0)
432 432 {
433 433 *c++=spigetw(spidev);
434 434 n--;
435 435 }
436 436 return 1;
437 437 }
438 438
439 439 int spiavailiabledata(spi_t spidev)
440 440 {
441 441 return 0;
442 442 }
443 443
444 444
445 445 int spitransactionfinished(spi_t spidev)
446 446 {
447 447 SPI_TypeDef* _dev_ = _spi_dev_table[(int)spidev];
448 448 if((spidev<3)&&(spidev>=0))
449 449 {
450 450 if((_dev_->SR & (1<<7)) == (1<<7))return 1;
451 451 }
452 452 return 0;
453 453 }
454 454
455 455
456 456
457 457
458 458
459 459
460 460
461 461
462 462
463 463
464 464
465 465
466 466
467 467
468 468
469 469
470 470
@@ -1,465 +1,465
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 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@member.fsf.org
21 21 -------------------------------------------------------------------------------*/
22 22
23 23 #include <uart.h>
24 24 #include <stm32f4xx_usart.h>
25 25 #include <stm32f4xx_rcc.h>
26 26 #include <stm32f4xx_gpio.h>
27 27 #include <gpio.h>
28 28 #include <stdio.h>
29 29
30 30 #define GPIOGETPORT(gpio) ((GPIO_TypeDef*)(((((uint32_t)gpio) & (uint32_t)0x0000FF00)*(uint32_t)4) + (uint32_t)GPIOA))
31 31 #define GPIOPORTNUM(gpio) (((uint32_t)(gpio) & (uint32_t)0x0000FF00)>>(uint32_t)8)
32 32
33 33 USART_TypeDef* _uart_dev_table[6]={USART1,USART2,USART3,UART4,UART5,USART6};
34 34
35 35
36 36 int _uartstrsetpos(streamdevice* device,int pos);
37 37 int _uartstrread(streamdevice* device,void* data,int size, int n);
38 38 int _uartstrwrite(streamdevice* device,void* data,int size, int n);
39 39
40 40 streamdevice_ops UART_OPS=
41 41 {
42 42 .write = &_uartstrwrite,
43 43 .read = &_uartstrread,
44 44 .setpos= &_uartstrsetpos,
45 45 .close = NULL
46 46 };
47 47
48 48 uart_t uartopen(int count)
49 49 {
50 50
51 51 switch(count)
52 52 {
53 53 case uart1:
54 54 RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);
55 55 RCC_APB2PeriphResetCmd(RCC_APB2Periph_USART1, ENABLE);
56 56 RCC_APB2PeriphResetCmd(RCC_APB2Periph_USART1, DISABLE);
57 57 RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);
58 58 USART1->CR3 &= ~((1<<8) + (1<<9));
59 59 return uart1;
60 60 break;
61 61 case uart2:
62 62 RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE);
63 63 RCC_APB1PeriphResetCmd(RCC_APB1Periph_USART2, ENABLE);
64 64 RCC_APB1PeriphResetCmd(RCC_APB1Periph_USART2, DISABLE);
65 65 RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE);
66 66 USART2->CR3 &= ~((1<<8) + (1<<9));
67 67 return uart2;
68 68 break;
69 69 case uart3:
70 70 RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE);
71 71 RCC_APB1PeriphResetCmd(RCC_APB1Periph_USART3, ENABLE);
72 72 RCC_APB1PeriphResetCmd(RCC_APB1Periph_USART3, DISABLE);
73 73 RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE);
74 74 USART3->CR3 &= ~((1<<8) + (1<<9));
75 75 return uart3;
76 76 break;
77 77 case uart4:
78 78 RCC_APB1PeriphResetCmd(RCC_APB1Periph_UART4, ENABLE);
79 79 RCC_APB1PeriphResetCmd(RCC_APB1Periph_UART4, DISABLE);
80 80 RCC_APB1PeriphClockCmd(RCC_APB1Periph_UART4, ENABLE);
81 81 UART4->CR3 &= ~((1<<8) + (1<<9));
82 82 return uart4;
83 83 break;
84 84 case uart5:
85 85 RCC_APB1PeriphResetCmd(RCC_APB1Periph_UART5, ENABLE);
86 86 RCC_APB1PeriphResetCmd(RCC_APB1Periph_UART5, DISABLE);
87 87 RCC_APB1PeriphClockCmd(RCC_APB1Periph_UART5, ENABLE);
88 88 return uart5;
89 89 break;
90 90 case uart6:
91 91 RCC_APB2PeriphResetCmd(RCC_APB2Periph_USART6, ENABLE);
92 92 RCC_APB2PeriphResetCmd(RCC_APB2Periph_USART6, DISABLE);
93 93 RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART6, ENABLE);
94 94 return uart6;
95 95 break;
96 96 default:
97 97 break;
98 98 }
99 99 return -1;
100 100 }
101 101
102 102 uart_t uartopenandconfig(int count, uint32_t cfg, uint32_t speed, uint32_t TXpin, uint32_t RXpin, uint32_t RTSpin, uint32_t CTSpin)
103 103 {
104 104 uart_t dev= uartopen(count);
105 105 uartsetconfig(dev,cfg,speed);
106 106 uartsetpins(dev,TXpin,RXpin,RTSpin,CTSpin);
107 107 return dev;
108 108 }
109 109
110 110
111 111 int uartclose(uart_t uart)
112 112 {
113 113 switch(uart)
114 114 {
115 115 case uart1:
116 116 RCC_APB2PeriphResetCmd(RCC_APB2Periph_USART1, ENABLE);
117 117 break;
118 118 case uart2:
119 119 RCC_APB1PeriphResetCmd(RCC_APB1Periph_USART2, ENABLE);
120 120 break;
121 121 case uart3:
122 122 RCC_APB1PeriphResetCmd(RCC_APB1Periph_USART3, ENABLE);
123 123 break;
124 124 case uart4:
125 125 RCC_APB1PeriphResetCmd(RCC_APB1Periph_UART4, ENABLE);
126 126 break;
127 127 case uart5:
128 128 RCC_APB1PeriphResetCmd(RCC_APB1Periph_UART5, ENABLE);
129 129 break;
130 130 case uart6:
131 131 RCC_APB2PeriphResetCmd(RCC_APB2Periph_USART6, ENABLE);
132 132 break;
133 133 default:
134 134 return -1;
135 135 break;
136 136 }
137 137 return 1;
138 138 }
139 139
140 140 int uartsetpins(uart_t uart,uint32_t TXpin,uint32_t RXpin,uint32_t RTSpin,uint32_t CTSpin)
141 141 {
142 142 if(uart >5)return -1;
143 143 if(uart <0)return -1;
144 144 gpio_t TX,RX,CTS,RTS;
145 145 TX = gpioopen(TXpin);
146 146 RX = gpioopen(RXpin);
147 147 TX |= gpiolowspeed | gpioaf | gpiopushpulltype | gpionopulltype;
148 148 RX |= gpiolowspeed | gpioaf | gpiopushpulltype | gpionopulltype;
149 149 gpiosetconfig(&TX);
150 150 gpiosetconfig(&RX);
151 151 uint8_t gpioAFuartx = GPIO_AF_USART1;
152 152 switch(uart)
153 153 {
154 154 case uart1:
155 155 gpioAFuartx = GPIO_AF_USART1;
156 156 break;
157 157 case uart2:
158 158 gpioAFuartx = GPIO_AF_USART2;
159 159 break;
160 160 case uart3:
161 161 gpioAFuartx = GPIO_AF_USART3;
162 162 break;
163 163 case uart4:
164 164 gpioAFuartx = GPIO_AF_UART4;
165 165 break;
166 166 case uart5:
167 167 gpioAFuartx = GPIO_AF_UART5;
168 168 break;
169 169 case uart6:
170 170 gpioAFuartx = GPIO_AF_USART6;
171 171 break;
172 172 default:
173 173 return -1;
174 174 break;
175 175 }
176 176 GPIO_PinAFConfig(GPIOGETPORT(TX), (uint8_t)(TX & 0xF), gpioAFuartx);
177 177 GPIO_PinAFConfig(GPIOGETPORT(RX), (uint8_t)(RX & 0xF), gpioAFuartx);
178 178 if((gpioAFuartx!=GPIO_AF_UART5) && (gpioAFuartx!=GPIO_AF_UART4))
179 179 {
180 180 if(CTSpin!=-1)
181 181 {
182 182 CTS = gpioopen(CTSpin);
183 183 CTS |= gpiolowspeed | gpioaf | gpiopushpulltype | gpionopulltype;
184 184 gpiosetconfig(&CTS);
185 185 GPIO_PinAFConfig(GPIOGETPORT(CTS), (uint8_t)(CTS & 0xF), gpioAFuartx);
186 186 }
187 187
188 188 if(RTSpin!=-1)
189 189 {
190 190 RTS = gpioopen(RTSpin);
191 191 RTS |= gpiolowspeed | gpioaf | gpiopushpulltype | gpionopulltype;
192 192 gpiosetconfig(&RTS);
193 193 GPIO_PinAFConfig(GPIOGETPORT(RTS), (uint8_t)(RTS & 0xF), gpioAFuartx);
194 194 }
195 195 }
196 196 return 1;
197 197 }
198 198
199 199 int uartsetconfig(uart_t uart, uint32_t cfg, uint32_t speed)
200 200 {
201 201 int res=1;
202 202 uartdisable(uart);
203 203 uartsetspeed(uart,speed);
204 204 uartsetparity(uart,cfg & UARTPARITYMASK);
205 205 uartsetdatabits(uart,cfg & UARTBITSMASK);
206 206 uartsetstopbits(uart,cfg & UARTSTOPBITSMASK);
207 207 uartenable(uart);
208 208 return res;
209 209 }
210 210
211 211 int uartenable(uart_t uart)
212 212 {
213 213 if((uart<6)&&(uart>=0))
214 214 {
215 215 USART_TypeDef* _dev_ = _uart_dev_table[(int)uart];
216 216 _dev_->CR1 |= (1<<13);
217 217 _dev_->CR1 |= (1<<2) + (1<<3);
218 218 _dev_->DR = ' ';
219 219 return 1;
220 220 }
221 221 return -1;
222 222 }
223 223
224 224 int uartdisable(uart_t uart)
225 225 {
226 226 if((uart<6)&&(uart>=0))
227 227 {
228 228 USART_TypeDef* _dev_ = _uart_dev_table[(int)uart];
229 229 if((_dev_->CR1 & ((1<<3) +(1<<13)))==((1<<3) +(1<<13)))
230 230 {
231 231 while((_dev_->SR & (uint16_t)(1<<7))!=(uint16_t)(1<<7));
232 232 }
233 233 _dev_->CR1 &= ~((1<<2) + (1<<3) +(1<<13));
234 234 return 1;
235 235 }
236 236 return -1;
237 237 }
238 238
239 239 int uartsetspeed(uart_t uart,uint32_t speed)
240 240 {
241 241 if((uart<6)&&(uart>=0))
242 242 {
243 243 USART_TypeDef* _dev_ = _uart_dev_table[(int)uart];
244 244 uint32_t tmpreg = 0x00, apbclock = 0x00;
245 245 uint32_t integerdivider = 0x00;
246 246 uint32_t fractionaldivider = 0x00;
247 247 RCC_ClocksTypeDef RCC_ClocksStatus;
248 248 RCC_GetClocksFreq(&RCC_ClocksStatus);
249 249
250 250 if ((_dev_ == USART1) || ((_dev_ == USART6)))
251 251 {
252 252 apbclock = RCC_ClocksStatus.PCLK2_Frequency;
253 253 }
254 254 else
255 255 {
256 256 apbclock = RCC_ClocksStatus.PCLK1_Frequency;
257 257 }
258 258 if (((_dev_->CR1) & USART_CR1_OVER8) != (uint16_t)0)
259 259 {
260 260 integerdivider = ((25 * apbclock) / (2 * (speed)));
261 261 }
262 262 else
263 263 {
264 264 integerdivider = ((25 * apbclock) / (4 * (speed)));
265 265 }
266 266 tmpreg = (integerdivider / 100) << 4;
267 267 fractionaldivider = integerdivider - (100 * (tmpreg >> 4));
268 268 if ((_dev_->CR1 & USART_CR1_OVER8) != (uint16_t)0)
269 269 {
270 270 tmpreg |= ((((fractionaldivider * 8) + 50) / 100)) & ((uint8_t)0x07);
271 271 }
272 272 else
273 273 {
274 274 tmpreg |= ((((fractionaldivider * 16) + 50) / 100)) & ((uint8_t)0x0F);
275 275 }
276 276 _dev_->BRR = (uint16_t)tmpreg;
277 277 return 1;
278 278 }
279 279 return -1;
280 280 }
281 281
282 282 int uartsetparity(uart_t uart,uartparity_t parity)
283 283 {
284 284 if((uart<6)&&(uart>=0))
285 285 {
286 286 USART_TypeDef* _dev_ = _uart_dev_table[(int)uart];
287 287 _dev_->CR1 &= ~(((1<<9)+(1<<10)));
288 288 switch(parity)
289 289 {
290 290 case uartparityeven:
291 291 _dev_->CR1 |= (1<<10);
292 292 break;
293 293 case uartparityodd:
294 294 _dev_->CR1 |= (1<<10) + (1<<9);
295 295 break;
296 296 case uartparitynone:
297 297 break;
298 298 default :
299 299 return 0;
300 300 break;
301 301 }
302 302 return 1;
303 303 }
304 304 return -1;
305 305 }
306 306
307 307 int uartsetdatabits(uart_t uart,uartbits_t databits)
308 308 {
309 309 if((uart<6)&&(uart>=0))
310 310 {
311 311 USART_TypeDef* _dev_ = _uart_dev_table[(int)uart];
312 312 _dev_->CR1 &= ~(((1<<12)));
313 313 switch(databits)
314 314 {
315 315 case uart7bits:
316 316 return 0;
317 317 break;
318 318 case uart8bits:
319 319 break;
320 320 case uart9bits:
321 321 _dev_->CR1 |= (1<<12);
322 322 break;
323 323 default :
324 324 return 0;
325 325 break;
326 326 }
327 327 return 1;
328 328 }
329 329 return -1;
330 330 }
331 331
332 332 int uartsetstopbits(uart_t uart,uartstopbits_t stopbits)
333 333 {
334 334 if((uart<6)&&(uart>=0))
335 335 {
336 336 USART_TypeDef* _dev_ = _uart_dev_table[(int)uart];
337 337 _dev_->CR2 &= ~(((1<<12)+(1<<13)));
338 338 switch(stopbits)
339 339 {
340 340 case uarthalfstop:
341 341 _dev_->CR2 |= (1<<12);
342 342 break;
343 343 case uartonestop:
344 344 break;
345 345 case uartonehalfstop:
346 346 _dev_->CR2 |= (1<<12) + (1<<13);
347 347 break;
348 348 case uarttwostop:
349 349 _dev_->CR2 |= (1<<13);
350 350 break;
351 351 default :
352 352 return 0;
353 353 break;
354 354 }
355 355 return 1;
356 356 }
357 357 return -1;
358 358 }
359 359
360 360 int uartputc(uart_t uart,char c)
361 361 {
362 362 if((uart<6)&&(uart>=0))
363 363 {
364 364 USART_TypeDef* _dev_ = _uart_dev_table[(int)uart];
365 365 while((_dev_->SR & (uint16_t)(1<<7))!=(uint16_t)(1<<7));
366 366 _dev_->DR = c;
367 367 return 1;
368 368 }
369 369 return -1;
370 370 }
371 371
372 372 char uartgetc(uart_t uart)
373 373 {
374 374 if((uart<6)&&(uart>=0))
375 375 {
376 376 USART_TypeDef* _dev_ = _uart_dev_table[(int)uart];
377 377 while(!(_dev_->SR & (1<<5)));
378 378 return (char)_dev_->DR;
379 379 }
380 380 return -1;
381 381 }
382 382
383 383 int uartputs(uart_t uart,char* s)
384 384 {
385 385 while (*s) uartputc(uart,*s++);
386 386 return 1;
387 387 }
388 388
389 389 int uartgets(uart_t uart,char* s)
390 390 {
391 391 do
392 392 {
393 393 (*s) = uartgetc(uart);
394 394 }
395 395 while(*s++);
396 396 return 1;
397 397 }
398 398
399 399 int uartputnc(uart_t uart,char* c,int n)
400 400 {
401 401 int l=0;
402 402 while(l<n)
403 403 {
404 404 uartputc(uart,*c++);
405 405 l++;
406 406 }
407 407 return n;
408 408 }
409 409
410 410 int uartgetnc(uart_t uart,char* c,int n)
411 411 {
412 412 int l=0;
413 413 while(l<n)
414 414 {
415 415 *c++=uartgetc(uart);
416 416 l++;
417 417 }
418 418 return n;
419 419 }
420 420
421 421 int uartavailiabledata(uart_t uart)
422 422 {
423 423 if((uart<6)&&(uart>=0))
424 424 {
425 425 USART_TypeDef* _dev_ = _uart_dev_table[(int)uart];
426 426 if(!(_dev_->SR & (1<<5)))
427 427 return 0;
428 428 else
429 429 return 1;
430 430 }
431 431 return -1;
432 432 }
433 433
434 434
435 435 int _uartstrwrite(streamdevice* device,void* data,int size, int n)
436 436 {
437 437 return uartputnc((uart_t) device->_stream,(char*) data,size*n);
438 438 }
439 439
440 440 int _uartstrread(streamdevice* device,void* data,int size, int n)
441 441 {
442 442 return uartgetnc((uart_t) device->_stream,(char*) data,size*n);
443 443 }
444 444
445 445 int _uartstrsetpos(streamdevice* device,int pos)
446 446 {
447 447 return 1;
448 448 }
449 449
450 450 int uartmkstreamdev(uart_t uart,streamdevice* strdev)
451 451 {
452 452 strdev->_stream = (UHANDLE)uart;/*
453 453 strdev->write = (write_t)&_uartstrwrite;
454 454 strdev->read = (read_t)&_uartstrread;
455 455 strdev->setpos = (setpos_t)&_uartstrsetpos;*/
456 456 strdev->ops = &UART_OPS;
457 457 strdev->streamPt = 0;
458 458 return 1;
459 459 }
460 460
461 461
462 462
463 463
464 464
465 465
General Comments 0
You need to be logged in to leave comments. Login now