@@ -0,0 +1,20 | |||
|
1 | TEMPLATE = lib | |
|
2 | ||
|
3 | TARGET=bsp | |
|
4 | CONFIG += bsp gui fs | |
|
5 | ||
|
6 | ||
|
7 | BSP = SIMULATOR | |
|
8 | ||
|
9 | UCMODEL=simulator | |
|
10 | ||
|
11 | SOURCES += bsp.c | |
|
12 | ||
|
13 | HEADERS += bsp.h | |
|
14 | ||
|
15 | LIBS+= -lgpio -luart -li2c -lspi | |
|
16 | BSPFILE = bsp.pri | |
|
17 | ||
|
18 | OTHER_FILES += bsp.pri | |
|
19 | ||
|
20 |
@@ -0,0 +1,332 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the libuc, microcontroler library | |
|
3 | -- Copyright (C) 2011, Alexis Jeandet | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | ------------------------------------------------------------------------------- | |
|
19 | -- Author : Alexis Jeandet | |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
|
21 | -------------------------------------------------------------------------------*/ | |
|
22 | #include "bsp.h" | |
|
23 | #include <streamdevices.h> | |
|
24 | #include <malloc.h> | |
|
25 | #include <stdio.h> | |
|
26 | ||
|
27 | ||
|
28 | uint32_t OSC0 =8000000; | |
|
29 | uint32_t INTOSC =16000000; | |
|
30 | uint32_t RTCOSC =32768; | |
|
31 | uint32_t currentCpuFreq=0; | |
|
32 | extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__]; | |
|
33 | ||
|
34 | ||
|
35 | LCD_IF_t lcdIF0={ | |
|
36 | .init = &SDLCD_init, | |
|
37 | .writereg = &SDLCD_writereg, | |
|
38 | .readreg = &SDLCD_readreg, | |
|
39 | .writeGRAM = &SDLCD_writeGRAM_16bpp, | |
|
40 | .readGRAM = &SDLCD_readGRAM_16bpp | |
|
41 | }; | |
|
42 | ||
|
43 | LCD_t lcd0={ | |
|
44 | .interface = &lcdIF0, | |
|
45 | .init = &ili9328init, | |
|
46 | .paint = &ili9328paint, | |
|
47 | .paintText = &ili9328paintText, | |
|
48 | .paintFilRect = &ili9328paintFilRect, | |
|
49 | .getPix = &ili9328getPix, | |
|
50 | .refreshenable = &ili9328refreshenable, | |
|
51 | .width= 240, | |
|
52 | .height = 320 | |
|
53 | }; | |
|
54 | ||
|
55 | terminal_t terminal0; | |
|
56 | ||
|
57 | volatile int8_t* lcd0_CMD=(volatile int8_t*) 0x60000000; | |
|
58 | volatile int8_t* lcd0_DATA=(volatile int8_t*)(0x61FFFFF0); | |
|
59 | ||
|
60 | float VREF0 =(float)3.3; | |
|
61 | volatile vs10XXDev audioCodec0; | |
|
62 | ||
|
63 | sdcardDev sdcard2; | |
|
64 | blkdevice sdcard2blkdev; | |
|
65 | dikpartition sdcard2Part1; | |
|
66 | FAT32fs sdcard2FAT32part1; | |
|
67 | dikpartition sdcard2Part2; | |
|
68 | FAT32fs sdcard2FAT32part2; | |
|
69 | dikpartition sdcard2Part3; | |
|
70 | FAT32fs sdcard2FAT32part3; | |
|
71 | dikpartition sdcard2Part4; | |
|
72 | FAT32fs sdcard2FAT32part4; | |
|
73 | ||
|
74 | int bsp_init() | |
|
75 | { | |
|
76 | int i=0; | |
|
77 | for(i=0;i<__MAX_OPENED_FILES__;i++) | |
|
78 | { | |
|
79 | __opnfiles__[i] = NULL; | |
|
80 | } | |
|
81 | bsp_GPIO_init(); | |
|
82 | bsp_uart_init(); | |
|
83 | bsp_iic_init(); | |
|
84 | bsp_FSMC_init(); | |
|
85 | bsp_GTerm_init(); | |
|
86 | bsp_spi_init(); | |
|
87 | bsp_SD_init(); | |
|
88 | bsp_Audio_init(); | |
|
89 | printf("\r=====================\n\r"); | |
|
90 | printf( "=====================\n\r"); | |
|
91 | printf(BSP); | |
|
92 | printf(" initialised\n\r"); | |
|
93 | printf( "=====================\n\r"); | |
|
94 | return 1; | |
|
95 | } | |
|
96 | ||
|
97 | void bsp_GPIO_init() | |
|
98 | { | |
|
99 | ||
|
100 | } | |
|
101 | ||
|
102 | void bsp_uart_init() | |
|
103 | { | |
|
104 | ||
|
105 | } | |
|
106 | ||
|
107 | /* | |
|
108 | D0 PD14 D1 PD15 D2 PD0 D3 PD1 D4 PE7 | |
|
109 | D5 PE8 D6 PE9 D7 PE10 | |
|
110 | A20 PE4 = RS FSMC_NE1 PD7 CS FSMC_NWE PD5 W/S | |
|
111 | FSMC_NOE PD4 RD | |
|
112 | */ | |
|
113 | ||
|
114 | int bsp_FSMC_init() | |
|
115 | { | |
|
116 | ||
|
117 | return 1; | |
|
118 | } | |
|
119 | ||
|
120 | void bsp_spi_init() | |
|
121 | { | |
|
122 | ||
|
123 | } | |
|
124 | ||
|
125 | ||
|
126 | void bsp_iic_init() | |
|
127 | { | |
|
128 | ||
|
129 | } | |
|
130 | ||
|
131 | ||
|
132 | void bsp_Audio_init() | |
|
133 | { | |
|
134 | ||
|
135 | } | |
|
136 | ||
|
137 | void bsp_SD_init() | |
|
138 | { | |
|
139 | sdcardspimakeblkdev(&sdcard2blkdev,&sdcard2, bspsdcardselect,bsppowersdcard,bspsdcardpresent,bspsdcardwriteprotected); | |
|
140 | if(sdcard2blkdev.initialize(&sdcard2blkdev)!=STA_NOINIT) | |
|
141 | { | |
|
142 | if(mbropen(&sdcard2blkdev,&sdcard2Part1,1)==MBRnoErr) | |
|
143 | { | |
|
144 | if(FATnoErr!=fat32open(&sdcard2FAT32part1,&sdcard2Part1)) | |
|
145 | printf("Can't open fat32 partition 1\n"); | |
|
146 | } | |
|
147 | else | |
|
148 | { | |
|
149 | printf("Can't open or read MBR\n"); | |
|
150 | } | |
|
151 | delay_100us(1000); | |
|
152 | if(mbropen(&sdcard2blkdev,&sdcard2Part2,2)==MBRnoErr) | |
|
153 | { | |
|
154 | if(FATnoErr!=fat32open(&sdcard2FAT32part2,&sdcard2Part2)) | |
|
155 | printf("Can't open fat32 partition 2\n"); | |
|
156 | } | |
|
157 | else | |
|
158 | { | |
|
159 | printf("Can't open or read MBR\n"); | |
|
160 | } | |
|
161 | delay_100us(1000); | |
|
162 | if(mbropen(&sdcard2blkdev,&sdcard2Part3,3)==MBRnoErr) | |
|
163 | { | |
|
164 | if(FATnoErr!=fat32open(&sdcard2FAT32part3,&sdcard2Part3)) | |
|
165 | printf("Can't open fat32 partition 3\n"); | |
|
166 | } | |
|
167 | else | |
|
168 | { | |
|
169 | printf("Can't open or read MBR\n"); | |
|
170 | } | |
|
171 | delay_100us(1000); | |
|
172 | if(mbropen(&sdcard2blkdev,&sdcard2Part4,4)==MBRnoErr) | |
|
173 | { | |
|
174 | if(FATnoErr!=fat32open(&sdcard2FAT32part4,&sdcard2Part4)) | |
|
175 | printf("Can't open fat32 partition 4\n"); | |
|
176 | } | |
|
177 | else | |
|
178 | { | |
|
179 | printf("Can't open or read MBR\n"); | |
|
180 | } | |
|
181 | } | |
|
182 | else | |
|
183 | { | |
|
184 | printf("Can't initialize SDCARD\n"); | |
|
185 | } | |
|
186 | ||
|
187 | delay_100us(2000); | |
|
188 | } | |
|
189 | ||
|
190 | void vs1052setXCS(char val) | |
|
191 | { | |
|
192 | } | |
|
193 | ||
|
194 | void vs1052setXDCS(char val) | |
|
195 | { | |
|
196 | } | |
|
197 | ||
|
198 | void vs1052setRST(char val) | |
|
199 | { | |
|
200 | } | |
|
201 | ||
|
202 | int vs10XXDREQ() | |
|
203 | { | |
|
204 | return 1; | |
|
205 | } | |
|
206 | ||
|
207 | ||
|
208 | void bsppowersdcard(char onoff) //always ON | |
|
209 | { | |
|
210 | ||
|
211 | } | |
|
212 | ||
|
213 | char bspsdcardpresent() | |
|
214 | { | |
|
215 | return 1; | |
|
216 | } | |
|
217 | ||
|
218 | char bspsdcardwriteprotected() | |
|
219 | { | |
|
220 | return 0; | |
|
221 | } | |
|
222 | ||
|
223 | void bspsdcardselect(char YESNO) | |
|
224 | { | |
|
225 | ||
|
226 | } | |
|
227 | ||
|
228 | ||
|
229 | void bsp_lcd0_write_reg(uint32_t reg,uint32_t data) | |
|
230 | { | |
|
231 | ||
|
232 | } | |
|
233 | ||
|
234 | uint32_t bsp_lcd0_read_reg(uint32_t reg) | |
|
235 | { | |
|
236 | return 0; | |
|
237 | } | |
|
238 | ||
|
239 | void bsp_lcd0_writeGRAM(void* buffer,uint32_t count) | |
|
240 | { | |
|
241 | ||
|
242 | } | |
|
243 | ||
|
244 | void bsp_lcd0_readGRAM(void* buffer,uint32_t count) | |
|
245 | { | |
|
246 | ||
|
247 | } | |
|
248 | ||
|
249 | void bsp_GTerm_init() | |
|
250 | { | |
|
251 | SDLCD_mkscreen(240,320,16,LCDILI9328); | |
|
252 | ||
|
253 | if(__opnfiles__[1]==NULL) | |
|
254 | { | |
|
255 | streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice)); | |
|
256 | terminal_init(&terminal0 ,&lcd0,&ComicSansMS_18,fd1); | |
|
257 | lcd0.paintFilRect(&lcd0,0,0,240,320,0,0,0x0f0f); | |
|
258 | __opnfiles__[1] = fd1; | |
|
259 | } | |
|
260 | else | |
|
261 | { | |
|
262 | ||
|
263 | } | |
|
264 | } | |
|
265 | ||
|
266 | ||
|
267 | ||
|
268 | ||
|
269 | ||
|
270 | ||
|
271 | ||
|
272 | void putpixel(SDL_Surface *surface, int x, int y, Uint32 pixel) | |
|
273 | { | |
|
274 | int bpp = surface->format->BytesPerPixel; | |
|
275 | /* Here p is the address to the pixel we want to set */ | |
|
276 | Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp; | |
|
277 | switch(bpp) { | |
|
278 | case 1: | |
|
279 | *p = pixel; | |
|
280 | break; | |
|
281 | case 2: | |
|
282 | *(Uint16 *)p = pixel; | |
|
283 | break; | |
|
284 | case 3: | |
|
285 | if(SDL_BYTEORDER == SDL_BIG_ENDIAN) { | |
|
286 | p[0] = (pixel >> 16) & 0xff; | |
|
287 | p[1] = (pixel >> 8) & 0xff; | |
|
288 | p[2] = pixel & 0xff; | |
|
289 | } else { | |
|
290 | p[0] = pixel & 0xff; | |
|
291 | p[1] = (pixel >> 8) & 0xff; | |
|
292 | p[2] = (pixel >> 16) & 0xff; | |
|
293 | } | |
|
294 | break; | |
|
295 | case 4: | |
|
296 | *(Uint32 *)p = pixel; | |
|
297 | break; | |
|
298 | } | |
|
299 | } | |
|
300 | ||
|
301 | Uint32 getpixel(SDL_Surface *surface, int x, int y) | |
|
302 | { | |
|
303 | int bpp = surface->format->BytesPerPixel; | |
|
304 | /* Here p is the address to the pixel we want to retrieve */ | |
|
305 | Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp; | |
|
306 | switch(bpp) { | |
|
307 | case 1: | |
|
308 | return *p; | |
|
309 | case 2: | |
|
310 | return *(Uint16 *)p; | |
|
311 | case 3: | |
|
312 | if(SDL_BYTEORDER == SDL_BIG_ENDIAN) | |
|
313 | return p[0] << 16 | p[1] << 8 | p[2]; | |
|
314 | else | |
|
315 | return p[0] | p[1] << 8 | p[2] << 16; | |
|
316 | case 4: | |
|
317 | return *(Uint32 *)p; | |
|
318 | default: | |
|
319 | return 0; | |
|
320 | } | |
|
321 | /* shouldn’t happen, but avoids warnings */ | |
|
322 | } | |
|
323 | ||
|
324 | ||
|
325 | ||
|
326 | ||
|
327 | ||
|
328 | ||
|
329 | ||
|
330 | ||
|
331 | ||
|
332 |
@@ -0,0 +1,139 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the libuc, microcontroler library | |
|
3 | -- Copyright (C) 2011, Alexis Jeandet | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | ------------------------------------------------------------------------------- | |
|
19 | -- Author : Alexis Jeandet | |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
|
21 | -------------------------------------------------------------------------------*/ | |
|
22 | #ifndef BSP_H | |
|
23 | #define BSP_H | |
|
24 | #include <gpio.h> | |
|
25 | #include <spi.h> | |
|
26 | #include <ili9328.h> | |
|
27 | #include <genericLCD_Controler.h> | |
|
28 | #include <sdcard-spi.h> | |
|
29 | #include <terminal.h> | |
|
30 | #include <sdcard.h> | |
|
31 | #include <mbr.h> | |
|
32 | #include <VS10XX.h> | |
|
33 | #include <fat32.h> | |
|
34 | #include <SDL.h> | |
|
35 | #include <stdint.h> | |
|
36 | #include <SDLCD.h> | |
|
37 | ||
|
38 | ||
|
39 | #define __MAX_OPENED_FILES__ 4 | |
|
40 | #define __FS_ROOT_SIZE__ 4 | |
|
41 | ||
|
42 | ||
|
43 | #define LED1 PC15 | |
|
44 | #define LED2 PC14 | |
|
45 | ||
|
46 | #define BP3 PA0 | |
|
47 | ||
|
48 | #define LCD_RESET PD10 | |
|
49 | #define LCD_BACKL PE11 | |
|
50 | ||
|
51 | #define VS1053SPI spi1 | |
|
52 | #define VS1053xCS PA3 | |
|
53 | #define VS1053xRESET PA2 | |
|
54 | #define VS1053xDCS PA4 | |
|
55 | #define VS1053DREQ PA1 | |
|
56 | #define VS1053MISO PA6 | |
|
57 | #define VS1053MOSI PA7 | |
|
58 | #define VS1053SCK PA5 | |
|
59 | ||
|
60 | ||
|
61 | ||
|
62 | #define SDCARD2SPI spi3 | |
|
63 | #define SDCARD2CS PB8 | |
|
64 | #define SDCARD2CD PB9 | |
|
65 | #define SDCARD2MISO PB4 | |
|
66 | #define SDCARD2MOSI PB5 | |
|
67 | #define SDCARD2SCK PB3 | |
|
68 | ||
|
69 | extern float VREF0; | |
|
70 | ||
|
71 | extern uint32_t currentCpuFreq; | |
|
72 | extern LCD_t lcd0; | |
|
73 | ||
|
74 | extern volatile vs10XXDev audioCodec0; | |
|
75 | ||
|
76 | extern sdcardDev sdcard2; | |
|
77 | extern blkdevice sdcard2blkdev; | |
|
78 | extern dikpartition sdcard2Part1; | |
|
79 | extern FAT32fs sdcard2FAT32part1; | |
|
80 | extern dikpartition sdcard2Part2; | |
|
81 | extern FAT32fs sdcard2FAT32part2; | |
|
82 | extern dikpartition sdcard2Part3; | |
|
83 | extern FAT32fs sdcard2FAT32part3; | |
|
84 | extern dikpartition sdcard2Part4; | |
|
85 | extern FAT32fs sdcard2FAT32part4; | |
|
86 | ||
|
87 | extern int bsp_init(); | |
|
88 | ||
|
89 | extern void bsp_GPIO_init(); | |
|
90 | extern void bsp_uart_init(); | |
|
91 | extern void bsp_iic_init(); | |
|
92 | extern void bsp_spi_init(); | |
|
93 | extern void bsp_SD_init(); | |
|
94 | extern void bsp_Audio_init(); | |
|
95 | extern void bsp_GTerm_init(); | |
|
96 | extern int bsp_FSMC_init(); | |
|
97 | ||
|
98 | /* VS1053 */ | |
|
99 | extern void vs1052setXCS(char val); | |
|
100 | extern void vs1052setXDCS(char val); | |
|
101 | extern void vs1052setRST(char val); | |
|
102 | extern int vs10XXDREQ(); | |
|
103 | ||
|
104 | /* SD CARD */ | |
|
105 | void bsppowersdcard(char onoff); | |
|
106 | char bspsdcardpresent(); | |
|
107 | void bspsdcardselect(char YESNO); | |
|
108 | char bspsdcardwriteprotected(); | |
|
109 | ||
|
110 | ||
|
111 | void bsp_lcd0_write_reg(uint32_t reg,uint32_t data); | |
|
112 | uint32_t bsp_lcd0_read_reg(uint32_t reg); | |
|
113 | void bsp_lcd0_writeGRAM(void *buffer, uint32_t count); | |
|
114 | void bsp_lcd0_readGRAM(void *buffer, uint32_t count); | |
|
115 | ||
|
116 | ||
|
117 | extern void putpixel(SDL_Surface *surface, int x, int y, Uint32 pixel); | |
|
118 | extern Uint32 getpixel(SDL_Surface *surface, int x, int y); | |
|
119 | ||
|
120 | #endif | |
|
121 | ||
|
122 | ||
|
123 | ||
|
124 | ||
|
125 | ||
|
126 | ||
|
127 | ||
|
128 | ||
|
129 | ||
|
130 | ||
|
131 | ||
|
132 | ||
|
133 | ||
|
134 | ||
|
135 | ||
|
136 | ||
|
137 | ||
|
138 | ||
|
139 |
@@ -0,0 +1,6 | |||
|
1 | CPU=simultor | |
|
2 | DEFINES+=BSP=\\\"SIMULATOR\\\" | |
|
3 | ||
|
4 | UCMODEL=simulator | |
|
5 | ||
|
6 | LIBS+=-lSDLCD |
@@ -0,0 +1,22 | |||
|
1 | TEMPLATE = lib | |
|
2 | ||
|
3 | TARGET=bsp | |
|
4 | ||
|
5 | CONFIG += bsp | |
|
6 | CONFIG += gui power | |
|
7 | ||
|
8 | BSP = BEAGLESYNTH | |
|
9 | ||
|
10 | UCMODEL=stm32f4 | |
|
11 | ||
|
12 | SOURCES += bsp.c | |
|
13 | ||
|
14 | HEADERS += bsp.h | |
|
15 | ||
|
16 | LIBS+= -lgpio -luart -li2c -lspi | |
|
17 | ||
|
18 | ||
|
19 | BSPFILE = bsp.pri | |
|
20 | ||
|
21 | ||
|
22 |
@@ -0,0 +1,313 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the libuc, microcontroler library | |
|
3 | -- Copyright (C) 2011, Alexis Jeandet | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | ------------------------------------------------------------------------------- | |
|
19 | -- Author : Alexis Jeandet | |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
|
21 | -------------------------------------------------------------------------------*/ | |
|
22 | #include "bsp.h" | |
|
23 | #include <streamdevices.h> | |
|
24 | #include <malloc.h> | |
|
25 | #include <gpio.h> | |
|
26 | #include <uart.h> | |
|
27 | #include <stdio.h> | |
|
28 | #include <stm32f4xx_gpio.h> | |
|
29 | #include <stm32f4xx_fsmc.h> | |
|
30 | #include <i2c.h> | |
|
31 | #include <core.h> | |
|
32 | #include <terminal.h> | |
|
33 | ||
|
34 | uint32_t OSC0 =8000000; | |
|
35 | uint32_t INTOSC =16000000; | |
|
36 | uint32_t RTCOSC =32768; | |
|
37 | uint32_t currentCpuFreq=0; | |
|
38 | extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__]; | |
|
39 | ||
|
40 | LCD_IF_t lcdIF0={ | |
|
41 | .init = &bsp_FSMC_init, | |
|
42 | .writereg = &bsp_lcd0_write_reg, | |
|
43 | .readreg = &bsp_lcd0_read_reg, | |
|
44 | .writeGRAM = &bsp_lcd0_writeGRAM, | |
|
45 | .readGRAM = &bsp_lcd0_readGRAM | |
|
46 | }; | |
|
47 | ||
|
48 | LCD_t lcd0={ | |
|
49 | .interface = &lcdIF0, | |
|
50 | .init = &ili9328init, | |
|
51 | .paint = &ili9328paint, | |
|
52 | .paintText = &ili9328paintText, | |
|
53 | .paintFilRect = &ili9328paintFilRect, | |
|
54 | .getPix = &ili9328getPix, | |
|
55 | .refreshenable = &ili9328refreshenable, | |
|
56 | .width= 240, | |
|
57 | .height = 320 | |
|
58 | }; | |
|
59 | ||
|
60 | terminal_t terminal0; | |
|
61 | ||
|
62 | volatile int16_t* lcd0_CMD=(volatile int16_t*)0x60000000; | |
|
63 | volatile int16_t* lcd0_DATA=(volatile int16_t*)0x61FFFFF0; | |
|
64 | ||
|
65 | float VREF0 =(float)3.3; | |
|
66 | ||
|
67 | int bsp_init() | |
|
68 | { | |
|
69 | int i=0; | |
|
70 | for(i=0;i<32;i++) | |
|
71 | { | |
|
72 | __opnfiles__[i] = NULL; | |
|
73 | } | |
|
74 | bsp_GPIO_init(); | |
|
75 | bsp_uart_init(); | |
|
76 | bsp_iic_init(); | |
|
77 | bsp_FSMC_init(); | |
|
78 | bsp_GTerm_init(); | |
|
79 | printf("\r=====================\n\r"); | |
|
80 | printf( "=====================\n\r"); | |
|
81 | printf(BSP); | |
|
82 | printf(" initialised\n\r"); | |
|
83 | printf( "=====================\n\r"); | |
|
84 | return 1; | |
|
85 | } | |
|
86 | ||
|
87 | void bsp_GPIO_init() | |
|
88 | { | |
|
89 | gpio_t gpio1 = gpioopen(LED1); | |
|
90 | gpio_t gpio2 = gpioopen(LED2); | |
|
91 | gpio_t gpio3 = gpioopen(LED3); | |
|
92 | gpio_t gpio4 = gpioopen(PSU_DISABLE); | |
|
93 | gpio_t gpio5 = gpioopen(PSU_ALERT_5V); | |
|
94 | gpio_t gpio6 = gpioopen(PSU_ALERT_1_5V); | |
|
95 | gpio_t gpio7 = gpioopen(PSU_ALERT_3_3V); | |
|
96 | gpiosetspeed(&gpio1,gpiohighspeed); | |
|
97 | gpiosetspeed(&gpio2,gpiohighspeed); | |
|
98 | gpiosetspeed(&gpio3,gpiohighspeed); | |
|
99 | gpiosetspeed(&gpio4,gpiohighspeed); | |
|
100 | gpiosetspeed(&gpio5,gpiohighspeed); | |
|
101 | gpiosetspeed(&gpio6,gpiohighspeed); | |
|
102 | gpiosetspeed(&gpio7,gpiohighspeed); | |
|
103 | gpioclr(PSU_DISABLE); | |
|
104 | gpiosetdir(&gpio1,gpiooutdir); | |
|
105 | gpiosetdir(&gpio3,gpiooutdir); | |
|
106 | gpiosetdir(&gpio2,gpiooutdir); | |
|
107 | gpiosetdir(&gpio4,gpiooutdir); | |
|
108 | gpiosetdir(&gpio5,gpioindir); | |
|
109 | gpiosetdir(&gpio6,gpioindir); | |
|
110 | gpiosetdir(&gpio7,gpioindir); | |
|
111 | gpioclr(PSU_DISABLE); | |
|
112 | } | |
|
113 | ||
|
114 | void bsp_uart_init() | |
|
115 | { | |
|
116 | //if(__opnfiles__[1]==NULL) | |
|
117 | //{ | |
|
118 | //uart_t* uart1 = (uart_t*)malloc(sizeof(uart_t)); | |
|
119 | // streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice)); | |
|
120 | // uart_t uart = uartopenandconfig(uart1,uartparitynone | uart8bits | uartonestop,115200,PA9,PA10,-1,-1); | |
|
121 | //uartmkstreamdev(uart,fd1); | |
|
122 | //__opnfiles__[1] = fd1; | |
|
123 | //} | |
|
124 | //else | |
|
125 | //{ | |
|
126 | uartopenandconfig(0,uartparitynone | uart8bits | uartonestop,115200,PA9,PA10,-1,-1); | |
|
127 | //} | |
|
128 | } | |
|
129 | ||
|
130 | ||
|
131 | ||
|
132 | int bsp_FSMC_init() | |
|
133 | { | |
|
134 | #define GPIOGETPORT(gpio) ((GPIO_TypeDef*)(((((uint32_t)gpio) & (uint32_t)0x0000FF00)*(uint32_t)4) + (uint32_t)GPIOA)) | |
|
135 | #define GPIOPORTNUM(gpio) (((uint32_t)(gpio) & (uint32_t)0x0000FF00)>>(uint32_t)8) | |
|
136 | ||
|
137 | gpio_t gpio1 = gpioopen(LCD_RESET); | |
|
138 | gpiosetspeed(&gpio1,gpiohighspeed); | |
|
139 | gpiosetdir(&gpio1,gpiooutdir); | |
|
140 | gpioclr(LCD_RESET); | |
|
141 | ||
|
142 | gpio_t LCD_DBxList[]={PD14,PD15,PD0,PD1,PE7,PE8,PE9,PE10,PE11,PE12,PE13,PE14,PE15\ | |
|
143 | ,PD8,PD9,PD10,PD4,PD5,PD7,PE4}; | |
|
144 | for(int i=0;i<20;i++) | |
|
145 | { | |
|
146 | gpio_t LCD_DBx = gpioopen(LCD_DBxList[i]); | |
|
147 | LCD_DBx |= gpiohighspeed | gpioaf | gpiopushpulltype | gpionopulltype; | |
|
148 | gpiosetconfig(&LCD_DBx); | |
|
149 | GPIO_PinAFConfig(GPIOGETPORT(LCD_DBx), (uint8_t)(LCD_DBx & 0xF), GPIO_AF_FSMC); | |
|
150 | } | |
|
151 | ||
|
152 | FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure; | |
|
153 | FSMC_NORSRAMTimingInitTypeDef p; | |
|
154 | ||
|
155 | /* Enable FSMC clock */ | |
|
156 | RCC_AHB3PeriphClockCmd(RCC_AHB3Periph_FSMC, ENABLE); | |
|
157 | ||
|
158 | /*-- FSMC Configuration ------------------------------------------------------*/ | |
|
159 | /*----------------------- SRAM Bank 3 ----------------------------------------*/ | |
|
160 | /* FSMC_Bank1_NORSRAM4 configuration */ | |
|
161 | //p.FSMC_AddressSetupTime = 5; | |
|
162 | p.FSMC_AddressSetupTime = 1; | |
|
163 | p.FSMC_AddressHoldTime = 0; | |
|
164 | //p.FSMC_DataSetupTime = 9; | |
|
165 | p.FSMC_DataSetupTime = getCpuFreq()/14545450 ;// 11; | |
|
166 | p.FSMC_BusTurnAroundDuration = 0; | |
|
167 | p.FSMC_CLKDivision = 0; | |
|
168 | p.FSMC_DataLatency = 0; | |
|
169 | p.FSMC_AccessMode = FSMC_AccessMode_A; | |
|
170 | /* Color LCD configuration ------------------------------------ | |
|
171 | LCD configured as follow: | |
|
172 | - Data/Address MUX = Disable | |
|
173 | - Memory Type = SRAM | |
|
174 | - Data Width = 16bit | |
|
175 | - Write Operation = Enable | |
|
176 | - Extended Mode = Enable | |
|
177 | - Asynchronous Wait = Disable */ | |
|
178 | ||
|
179 | FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM1; | |
|
180 | FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable; | |
|
181 | FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM; | |
|
182 | FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b; | |
|
183 | FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable; | |
|
184 | FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable; | |
|
185 | FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low; | |
|
186 | FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable; | |
|
187 | FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState; | |
|
188 | FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable; | |
|
189 | FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable; | |
|
190 | FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable; | |
|
191 | FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable; | |
|
192 | FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p; | |
|
193 | FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p; | |
|
194 | ||
|
195 | FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure); | |
|
196 | ||
|
197 | /* Enable FSMC NOR/SRAM Bank1 */ | |
|
198 | FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM1, ENABLE); | |
|
199 | gpioset(LCD_RESET); | |
|
200 | lcd0.init(&lcd0); | |
|
201 | return 1; | |
|
202 | } | |
|
203 | ||
|
204 | void bsp_spi_init() | |
|
205 | { | |
|
206 | ||
|
207 | } | |
|
208 | ||
|
209 | ||
|
210 | void bsp_iic_init() | |
|
211 | { | |
|
212 | i2copenandconfig(i2c2,0,10000,PF0,PF1); | |
|
213 | } | |
|
214 | ||
|
215 | void bsp_SD_init() | |
|
216 | { | |
|
217 | ||
|
218 | } | |
|
219 | ||
|
220 | void vs10XXclearXCS(){} | |
|
221 | void vs10XXsetXCS(){} | |
|
222 | int vs10XXDREQ() | |
|
223 | { | |
|
224 | return 1; | |
|
225 | } | |
|
226 | ||
|
227 | ||
|
228 | void bsppowersdcard(char onoff) //always ON | |
|
229 | { | |
|
230 | ||
|
231 | } | |
|
232 | ||
|
233 | char bspsdcardpresent() | |
|
234 | { | |
|
235 | return 0; | |
|
236 | } | |
|
237 | ||
|
238 | char bspsdcardwriteprotected() | |
|
239 | { | |
|
240 | return 0; | |
|
241 | } | |
|
242 | ||
|
243 | void bspsdcardselect(char YESNO) | |
|
244 | { | |
|
245 | ||
|
246 | } | |
|
247 | ||
|
248 | ||
|
249 | void bsp_lcd0_write_reg(uint32_t reg,uint32_t data) | |
|
250 | { | |
|
251 | *lcd0_CMD=(uint16_t)reg; | |
|
252 | *lcd0_DATA=(uint16_t)data; | |
|
253 | } | |
|
254 | ||
|
255 | uint32_t bsp_lcd0_read_reg(uint32_t reg) | |
|
256 | { | |
|
257 | *lcd0_CMD=(uint16_t)reg; | |
|
258 | return (uint16_t)*lcd0_DATA; | |
|
259 | } | |
|
260 | ||
|
261 | void bsp_lcd0_writeGRAM(void* buffer,uint32_t count) | |
|
262 | { | |
|
263 | *lcd0_CMD=(uint16_t)ILI9328_REGISTER_WRITEDATATOGRAM; | |
|
264 | uint16_t* castedBuff=(uint16_t*)buffer; | |
|
265 | for(int i=0;i<(int)count;i++) | |
|
266 | { | |
|
267 | *lcd0_DATA=castedBuff[i]; | |
|
268 | } | |
|
269 | } | |
|
270 | ||
|
271 | void bsp_lcd0_readGRAM(void* buffer,uint32_t count) | |
|
272 | { | |
|
273 | *lcd0_CMD=(uint16_t)ILI9328_REGISTER_WRITEDATATOGRAM; | |
|
274 | uint16_t* castedBuff=(uint16_t*)buffer; | |
|
275 | castedBuff[0]=*lcd0_DATA; | |
|
276 | for(int i=0;i<(int)count;i++) | |
|
277 | { | |
|
278 | castedBuff[i]=*lcd0_DATA; | |
|
279 | } | |
|
280 | } | |
|
281 | ||
|
282 | ||
|
283 | void bsp_GTerm_init() | |
|
284 | { | |
|
285 | if(__opnfiles__[1]==NULL) | |
|
286 | { | |
|
287 | //uart_t* uart1 = (uart_t*)malloc(sizeof(uart_t)); | |
|
288 | streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice)); | |
|
289 | terminal_init(&terminal0 ,&lcd0,&ComicSansMS_8,fd1); | |
|
290 | __opnfiles__[1] = fd1; | |
|
291 | } | |
|
292 | else | |
|
293 | { | |
|
294 | ||
|
295 | } | |
|
296 | } | |
|
297 | ||
|
298 | ||
|
299 | ||
|
300 | ||
|
301 | ||
|
302 | ||
|
303 | ||
|
304 | ||
|
305 | ||
|
306 | ||
|
307 | ||
|
308 | ||
|
309 | ||
|
310 | ||
|
311 | ||
|
312 | ||
|
313 |
@@ -0,0 +1,106 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the libuc, microcontroler library | |
|
3 | -- Copyright (C) 2011, Alexis Jeandet | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | ------------------------------------------------------------------------------- | |
|
19 | -- Author : Alexis Jeandet | |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
|
21 | -------------------------------------------------------------------------------*/ | |
|
22 | #ifndef BSP_H | |
|
23 | #define BSP_H | |
|
24 | #include <stm32f4xx.h> | |
|
25 | #include <stm32f4xx_gpio.h> | |
|
26 | #include <stm32f4xx_rcc.h> | |
|
27 | #include <gpio.h> | |
|
28 | #include <ili9328.h> | |
|
29 | #include <genericLCD_Controler.h> | |
|
30 | ||
|
31 | #define __MAX_OPENED_FILES__ 4 | |
|
32 | #define __FS_ROOT_SIZE__ 4 | |
|
33 | /* | |
|
34 | #ifndef PD8 | |
|
35 | #define PD8 | |
|
36 | #endif | |
|
37 | #ifndef PD9 | |
|
38 | #define PD9 | |
|
39 | #endif | |
|
40 | */ | |
|
41 | ||
|
42 | ||
|
43 | #define LED1 PF6 | |
|
44 | #define LED2 PF7 | |
|
45 | #define LED3 PF8 | |
|
46 | ||
|
47 | #define PSU_DISABLE PH2 | |
|
48 | #define PSU_ALERT_5V PF2 | |
|
49 | #define PSU_ALERT_1_5V PF3 | |
|
50 | #define PSU_ALERT_3_3V PF4 | |
|
51 | ||
|
52 | #define LCD_RESET PE2 | |
|
53 | ||
|
54 | extern float VREF0; | |
|
55 | ||
|
56 | extern uint32_t currentCpuFreq; | |
|
57 | extern LCD_t lcd0; | |
|
58 | ||
|
59 | ||
|
60 | extern int bsp_init(); | |
|
61 | ||
|
62 | extern void bsp_GPIO_init(); | |
|
63 | extern void bsp_uart_init(); | |
|
64 | extern void bsp_iic_init(); | |
|
65 | extern void bsp_spi_init(); | |
|
66 | extern void bsp_SD_init(); | |
|
67 | extern void bsp_GTerm_init(); | |
|
68 | extern int bsp_FSMC_init(); | |
|
69 | ||
|
70 | /* VS1053 */ | |
|
71 | extern void clearXCS(); | |
|
72 | extern void setXCS(); | |
|
73 | extern int vs10XXDREQ(); | |
|
74 | ||
|
75 | /* SD CARD */ | |
|
76 | void bsppowersdcard(char onoff); | |
|
77 | char bspsdcardpresent(); | |
|
78 | void bspsdcardselect(char YESNO); | |
|
79 | char bspsdcardwriteprotected(); | |
|
80 | ||
|
81 | ||
|
82 | void bsp_lcd0_write_reg(uint32_t reg,uint32_t data); | |
|
83 | uint32_t bsp_lcd0_read_reg(uint32_t reg); | |
|
84 | void bsp_lcd0_writeGRAM(void *buffer, uint32_t count); | |
|
85 | void bsp_lcd0_readGRAM(void *buffer, uint32_t count); | |
|
86 | ||
|
87 | #endif | |
|
88 | ||
|
89 | ||
|
90 | ||
|
91 | ||
|
92 | ||
|
93 | ||
|
94 | ||
|
95 | ||
|
96 | ||
|
97 | ||
|
98 | ||
|
99 | ||
|
100 | ||
|
101 | ||
|
102 | ||
|
103 | ||
|
104 | ||
|
105 | ||
|
106 |
@@ -0,0 +1,9 | |||
|
1 | CPU=stm32f4xxxG | |
|
2 | DEFINES+=BSP=\\\"BEAGLESYNTH\\\" | |
|
3 | beagleCp.target = beagleCp | |
|
4 | beagleCp.commands = cd bin && scp $(QMAKE_TARGET).bin root@192.168.7.2://opt/stm32flashAje/hello.bin | |
|
5 | beagleCp131.target = beagleCp131 | |
|
6 | beagleCp131.commands = cd bin && scp $(QMAKE_TARGET).bin root@129.104.27.131://opt/stm32flashAje/hello.bin | |
|
7 | QMAKE_EXTRA_TARGETS += beagleCp beagleCp131 | |
|
8 | ||
|
9 | UCMODEL=stm32f4 |
@@ -0,0 +1,18 | |||
|
1 | TEMPLATE = lib | |
|
2 | ||
|
3 | TARGET=bsp | |
|
4 | ||
|
5 | CONFIG += bsp | |
|
6 | BSP=M4Stick | |
|
7 | ||
|
8 | UCMODEL=stm32f4 | |
|
9 | ||
|
10 | SOURCES += bsp.c | |
|
11 | ||
|
12 | HEADERS += bsp.h | |
|
13 | LIBS+= -lgpio -luart -li2c -lspi | |
|
14 | ||
|
15 | BSPFILE = bsp.pri | |
|
16 | ||
|
17 | ||
|
18 |
@@ -0,0 +1,126 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the libuc, microcontroler library | |
|
3 | -- Copyright (C) 2011, Alexis Jeandet | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | ------------------------------------------------------------------------------- | |
|
19 | -- Author : Alexis Jeandet | |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
|
21 | -------------------------------------------------------------------------------*/ | |
|
22 | #include "bsp.h" | |
|
23 | #include <streamdevices.h> | |
|
24 | #include <malloc.h> | |
|
25 | #include <gpio.h> | |
|
26 | #include <uart.h> | |
|
27 | #include <stdio.h> | |
|
28 | uint32_t OSC0 =8000000; | |
|
29 | uint32_t INTOSC =16000000; | |
|
30 | uint32_t RTCOSC =32768; | |
|
31 | uint32_t currentCpuFreq=0; | |
|
32 | extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__]; | |
|
33 | ||
|
34 | float VREF0 =(float)3.3; | |
|
35 | ||
|
36 | int bsp_init() | |
|
37 | { | |
|
38 | int i=0; | |
|
39 | for(i=0;i<32;i++) | |
|
40 | { | |
|
41 | __opnfiles__[i] = NULL; | |
|
42 | } | |
|
43 | bsp_GPIO_init(); | |
|
44 | bsp_uart_init(); | |
|
45 | printf("\r================================================================\n\r"); | |
|
46 | printf("================================================================\n\r"); | |
|
47 | printf(BSP); | |
|
48 | printf(" initialised\n\r"); | |
|
49 | printf("================================================================\n\r"); | |
|
50 | return 1; | |
|
51 | } | |
|
52 | ||
|
53 | void bsp_GPIO_init() | |
|
54 | { | |
|
55 | gpio_t gpio1 = gpioopen(PC6);//gpioopen(LED1); //PD9 D=> 0x0300 9 => 0x0009 | |
|
56 | gpio_t gpio2 = gpioopen(PC7);//gpioopen(LED2); | |
|
57 | gpiosetspeed(&gpio1,gpiohighspeed); | |
|
58 | gpiosetspeed(&gpio2,gpiohighspeed); | |
|
59 | gpiosetdir(&gpio1,gpiooutdir); | |
|
60 | gpiosetdir(&gpio2,gpiooutdir); | |
|
61 | } | |
|
62 | ||
|
63 | void bsp_uart_init() | |
|
64 | { | |
|
65 | if(__opnfiles__[1]==NULL) | |
|
66 | { | |
|
67 | //uart_t* uart1 = (uart_t*)malloc(sizeof(uart_t)); | |
|
68 | streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice)); | |
|
69 | uart_t uart = uartopenandconfig(uart3,uartparitynone | uart8bits | uartonestop,115200,LED2,LED1,-1,-1); | |
|
70 | uartmkstreamdev(uart,fd1); | |
|
71 | __opnfiles__[1] = fd1; | |
|
72 | } | |
|
73 | else | |
|
74 | { | |
|
75 | uartopenandconfig(uart3,uartparitynone | uart8bits | uartonestop,115200,LED2,LED1,-1,-1); | |
|
76 | } | |
|
77 | } | |
|
78 | ||
|
79 | void bsp_spi_init() | |
|
80 | { | |
|
81 | ||
|
82 | } | |
|
83 | ||
|
84 | ||
|
85 | void bsp_iic_init() | |
|
86 | { | |
|
87 | ||
|
88 | } | |
|
89 | ||
|
90 | void bsp_SD_init() | |
|
91 | { | |
|
92 | ||
|
93 | } | |
|
94 | ||
|
95 | void vs10XXclearXCS(){} | |
|
96 | void vs10XXsetXCS(){} | |
|
97 | int vs10XXDREQ() | |
|
98 | { | |
|
99 | return 1; | |
|
100 | } | |
|
101 | ||
|
102 | ||
|
103 | void bsppowersdcard(char onoff) //always ON | |
|
104 | { | |
|
105 | ||
|
106 | } | |
|
107 | ||
|
108 | char bspsdcardpresent() | |
|
109 | { | |
|
110 | return 0; | |
|
111 | } | |
|
112 | ||
|
113 | char bspsdcardwriteprotected() | |
|
114 | { | |
|
115 | return 0; | |
|
116 | } | |
|
117 | ||
|
118 | void bspsdcardselect(char YESNO) | |
|
119 | { | |
|
120 | ||
|
121 | } | |
|
122 | ||
|
123 | ||
|
124 | ||
|
125 | ||
|
126 |
@@ -0,0 +1,86 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the libuc, microcontroler library | |
|
3 | -- Copyright (C) 2011, Alexis Jeandet | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | ------------------------------------------------------------------------------- | |
|
19 | -- Author : Alexis Jeandet | |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
|
21 | -------------------------------------------------------------------------------*/ | |
|
22 | #ifndef BSP_H | |
|
23 | #define BSP_H | |
|
24 | #include <stm32f4xx.h> | |
|
25 | #include <stm32f4xx_gpio.h> | |
|
26 | #include <stm32f4xx_rcc.h> | |
|
27 | #include <gpio.h> | |
|
28 | ||
|
29 | ||
|
30 | #define __MAX_OPENED_FILES__ 32 | |
|
31 | #define __FS_ROOT_SIZE__ 32 | |
|
32 | ||
|
33 | #define LED1 PD8 | |
|
34 | #define LED2 PD9 | |
|
35 | ||
|
36 | #define LED3ON GPIOB->BSRRH = GPIO_Pin_15 | |
|
37 | #define LED2ON GPIOD->BSRRH = GPIO_Pin_8 | |
|
38 | #define LED1ON GPIOD->BSRRH = GPIO_Pin_9 | |
|
39 | ||
|
40 | #define LED3OFF GPIOB->BSRRL = GPIO_Pin_15 | |
|
41 | #define LED2OFF GPIOD->BSRRL = GPIO_Pin_8 | |
|
42 | #define LED1OFF GPIOD->BSRRL = GPIO_Pin_9 | |
|
43 | ||
|
44 | extern float VREF0; | |
|
45 | ||
|
46 | extern uint32_t currentCpuFreq; | |
|
47 | ||
|
48 | extern int bsp_init(); | |
|
49 | ||
|
50 | extern void bsp_GPIO_init(); | |
|
51 | extern void bsp_uart_init(); | |
|
52 | extern void bsp_iic_init(); | |
|
53 | extern void bsp_spi_init(); | |
|
54 | extern void bsp_SD_init(); | |
|
55 | ||
|
56 | /* VS1053 */ | |
|
57 | extern void clearXCS(); | |
|
58 | extern void setXCS(); | |
|
59 | extern int vs10XXDREQ(); | |
|
60 | ||
|
61 | /* SD CARD */ | |
|
62 | void bsppowersdcard(char onoff); | |
|
63 | char bspsdcardpresent(); | |
|
64 | void bspsdcardselect(char YESNO); | |
|
65 | char bspsdcardwriteprotected(); | |
|
66 | ||
|
67 | #endif | |
|
68 | ||
|
69 | ||
|
70 | ||
|
71 | ||
|
72 | ||
|
73 | ||
|
74 | ||
|
75 | ||
|
76 | ||
|
77 | ||
|
78 | ||
|
79 | ||
|
80 | ||
|
81 | ||
|
82 | ||
|
83 | ||
|
84 | ||
|
85 | ||
|
86 |
@@ -0,0 +1,35 | |||
|
1 | TEMPLATE = lib | |
|
2 | ||
|
3 | TARGET=bsp | |
|
4 | CONFIG += bsp | |
|
5 | ||
|
6 | BSP=M4StickV2 | |
|
7 | ||
|
8 | ||
|
9 | UCMODEL=stm32f4 | |
|
10 | ||
|
11 | SOURCES += bsp.c | |
|
12 | ||
|
13 | HEADERS += bsp.h | |
|
14 | ||
|
15 | ||
|
16 | BSPFILE = bsp.pri | |
|
17 | ||
|
18 | ||
|
19 | LIBS+= -lgpio -luart -li2c -lspi | |
|
20 | ||
|
21 | INCLUDEPATH += $${PWD} | |
|
22 | ||
|
23 | SOURCES += bsp.c | |
|
24 | contains(CONFIG , USB){ | |
|
25 | SOURCES += usbd_usr.c \ | |
|
26 | usbd_desc.c \ | |
|
27 | usbd_cdc_vcp.c \ | |
|
28 | usb_bsp.c | |
|
29 | } | |
|
30 | ||
|
31 | HEADERS += $$libuc2/bsp/includes/$$BSP/bsp.h \ | |
|
32 | usbd_desc.h \ | |
|
33 | usbd_conf.h \ | |
|
34 | usbd_cdc_vcp.h \ | |
|
35 | usb_conf.h |
@@ -0,0 +1,143 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the libuc, microcontroler library | |
|
3 | -- Copyright (C) 2011, Alexis Jeandet | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | ------------------------------------------------------------------------------- | |
|
19 | -- Author : Alexis Jeandet | |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
|
21 | -------------------------------------------------------------------------------*/ | |
|
22 | #include "bsp.h" | |
|
23 | #include <streamdevices.h> | |
|
24 | #include <malloc.h> | |
|
25 | #include <gpio.h> | |
|
26 | #include <uart.h> | |
|
27 | #include <spi.h> | |
|
28 | #include <stdio.h> | |
|
29 | #include <core.h> | |
|
30 | uint32_t OSC0 =8000000; | |
|
31 | uint32_t INTOSC =16000000; | |
|
32 | uint32_t RTCOSC =32768; | |
|
33 | uint32_t currentCpuFreq=0; | |
|
34 | extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__]; | |
|
35 | ||
|
36 | float VREF0 =(float)3.3; | |
|
37 | ||
|
38 | int bsp_init() | |
|
39 | { | |
|
40 | int i=0; | |
|
41 | for(i=0;i<32;i++) | |
|
42 | { | |
|
43 | __opnfiles__[i] = NULL; | |
|
44 | } | |
|
45 | bsp_GPIO_init(); | |
|
46 | bsp_uart_init(); | |
|
47 | bsp_spi_init(); | |
|
48 | printf("\r================================================================\n\r"); | |
|
49 | printf("================================================================\n\r"); | |
|
50 | printf(BSP); | |
|
51 | printf(" initialised\n\r"); | |
|
52 | printf("================================================================\n\r"); | |
|
53 | return 1; | |
|
54 | } | |
|
55 | ||
|
56 | void bsp_GPIO_init() | |
|
57 | { | |
|
58 | gpio_t GPIOList[]={LED1,LED2,LED3,ADC_MODE0,ADC_MODE1,ADC_FSYNC | |
|
59 | ,ADC_SYNC,ADC_CLKDIV}; | |
|
60 | gpio_t GPIOx; | |
|
61 | for(int i=0;i<8;i++) | |
|
62 | { | |
|
63 | GPIOx = gpioopen(GPIOList[i]); | |
|
64 | gpiosetspeed(&GPIOx,gpiohighspeed); | |
|
65 | gpiosetdir(&GPIOx,gpiooutdir); | |
|
66 | gpiosetouttype(&GPIOx,gpiopushpulltype); | |
|
67 | } | |
|
68 | gpioset(ADC_CLKDIV); | |
|
69 | gpioset(ADC_MODE0); | |
|
70 | gpioset(ADC_MODE1); | |
|
71 | gpioclr(ADC_SYNC); | |
|
72 | gpioclr(ADC_FSYNC); | |
|
73 | delay_100us(10); | |
|
74 | gpioset(ADC_SYNC); | |
|
75 | ||
|
76 | } | |
|
77 | ||
|
78 | void bsp_uart_init() | |
|
79 | { | |
|
80 | if(__opnfiles__[1]==NULL) | |
|
81 | { | |
|
82 | //uart_t* uart1 = (uart_t*)malloc(sizeof(uart_t)); | |
|
83 | streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice)); | |
|
84 | //uart_t uart = uartopenandconfig(uart1,uartparitynone | uart8bits | uartonestop,230400,PA9,PA10,-1,-1); | |
|
85 | uart_t uart = uartopenandconfig(uart1,uartparitynone | uart8bits | uartonestop,115200,PA9,PA10,-1,-1); | |
|
86 | uartmkstreamdev(uart,fd1); | |
|
87 | __opnfiles__[1] = fd1; | |
|
88 | } | |
|
89 | else | |
|
90 | { | |
|
91 | // uartopenandconfig(uart1,uartparitynone | uart8bits | uartonestop,230400,PA9,PA10,-1,-1); | |
|
92 | uartopenandconfig(uart1,uartparitynone | uart8bits | uartonestop,115200,PA9,PA10,-1,-1); | |
|
93 | } | |
|
94 | } | |
|
95 | ||
|
96 | void bsp_spi_init() | |
|
97 | { | |
|
98 | spiopenandconfig(spi1,spi8bits | spimaster |spiclkinhlow | spiclkfirstedge | spimsbfirst,4000000,DAC_DIN,ADC_DOUT1,ADC_SCLK,-1); | |
|
99 | } | |
|
100 | ||
|
101 | ||
|
102 | void bsp_iic_init() | |
|
103 | { | |
|
104 | ||
|
105 | } | |
|
106 | ||
|
107 | void bsp_SD_init() | |
|
108 | { | |
|
109 | ||
|
110 | } | |
|
111 | ||
|
112 | void vs10XXclearXCS(){} | |
|
113 | void vs10XXsetXCS(){} | |
|
114 | int vs10XXDREQ() | |
|
115 | { | |
|
116 | return 1; | |
|
117 | } | |
|
118 | ||
|
119 | ||
|
120 | void bsppowersdcard(char onoff) //always ON | |
|
121 | { | |
|
122 | ||
|
123 | } | |
|
124 | ||
|
125 | char bspsdcardpresent() | |
|
126 | { | |
|
127 | return 0; | |
|
128 | } | |
|
129 | ||
|
130 | char bspsdcardwriteprotected() | |
|
131 | { | |
|
132 | return 0; | |
|
133 | } | |
|
134 | ||
|
135 | void bspsdcardselect(char YESNO) | |
|
136 | { | |
|
137 | ||
|
138 | } | |
|
139 | ||
|
140 | ||
|
141 | ||
|
142 | ||
|
143 |
@@ -0,0 +1,92 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the libuc, microcontroler library | |
|
3 | -- Copyright (C) 2011, Alexis Jeandet | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | ------------------------------------------------------------------------------- | |
|
19 | -- Author : Alexis Jeandet | |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
|
21 | -------------------------------------------------------------------------------*/ | |
|
22 | #ifndef BSP_H | |
|
23 | #define BSP_H | |
|
24 | #include <stm32f4xx.h> | |
|
25 | #include <stm32f4xx_gpio.h> | |
|
26 | #include <stm32f4xx_rcc.h> | |
|
27 | #include <gpio.h> | |
|
28 | ||
|
29 | ||
|
30 | #define __MAX_OPENED_FILES__ 32 | |
|
31 | #define __FS_ROOT_SIZE__ 32 | |
|
32 | ||
|
33 | #define LED1 PD9 | |
|
34 | #define LED2 PD8 | |
|
35 | #define LED3 PB15 | |
|
36 | ||
|
37 | #define DAC_CS PA1 | |
|
38 | #define DAC_DIN PA7 | |
|
39 | ||
|
40 | #define ADC_MODE0 PA2 | |
|
41 | #define ADC_MODE1 PA3 | |
|
42 | #define ADC_FSYNC PA4 | |
|
43 | #define ADC_SCLK PA5 | |
|
44 | #define ADC_DOUT1 PA6 | |
|
45 | ||
|
46 | #define ADC_SYNC PB10 | |
|
47 | #define ADC_CLKDIV PB11 | |
|
48 | ||
|
49 | ||
|
50 | extern float VREF0; | |
|
51 | ||
|
52 | extern uint32_t currentCpuFreq; | |
|
53 | ||
|
54 | extern int bsp_init(); | |
|
55 | ||
|
56 | extern void bsp_GPIO_init(); | |
|
57 | extern void bsp_uart_init(); | |
|
58 | extern void bsp_iic_init(); | |
|
59 | extern void bsp_spi_init(); | |
|
60 | extern void bsp_SD_init(); | |
|
61 | ||
|
62 | /* VS1053 */ | |
|
63 | extern void clearXCS(); | |
|
64 | extern void setXCS(); | |
|
65 | extern int vs10XXDREQ(); | |
|
66 | ||
|
67 | /* SD CARD */ | |
|
68 | void bsppowersdcard(char onoff); | |
|
69 | char bspsdcardpresent(); | |
|
70 | void bspsdcardselect(char YESNO); | |
|
71 | char bspsdcardwriteprotected(); | |
|
72 | ||
|
73 | #endif | |
|
74 | ||
|
75 | ||
|
76 | ||
|
77 | ||
|
78 | ||
|
79 | ||
|
80 | ||
|
81 | ||
|
82 | ||
|
83 | ||
|
84 | ||
|
85 | ||
|
86 | ||
|
87 | ||
|
88 | ||
|
89 | ||
|
90 | ||
|
91 | ||
|
92 |
@@ -0,0 +1,7 | |||
|
1 | CPU=stm32f4xxxG | |
|
2 | DEFINES+=BSP=\\\"M4StickV2\\\" | |
|
3 | #CONFIG += USB | |
|
4 | USB += cdc | |
|
5 | DEFINES+= USE_USB_OTG_FS | |
|
6 | DEFINES+=stm32f4 | |
|
7 | UCMODEL=stm32f4 |
@@ -0,0 +1,320 | |||
|
1 | /** | |
|
2 | ****************************************************************************** | |
|
3 | * @file usb_bsp.c | |
|
4 | * @author MCD Application Team | |
|
5 | * @version V1.1.0 | |
|
6 | * @date 19-March-2012 | |
|
7 | * @brief This file is responsible to offer board support package and is | |
|
8 | * configurable by user. | |
|
9 | ****************************************************************************** | |
|
10 | * @attention | |
|
11 | * | |
|
12 | * <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2> | |
|
13 | * | |
|
14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); | |
|
15 | * You may not use this file except in compliance with the License. | |
|
16 | * You may obtain a copy of the License at: | |
|
17 | * | |
|
18 | * http://www.st.com/software_license_agreement_liberty_v2 | |
|
19 | * | |
|
20 | * Unless required by applicable law or agreed to in writing, software | |
|
21 | * distributed under the License is distributed on an "AS IS" BASIS, | |
|
22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
|
23 | * See the License for the specific language governing permissions and | |
|
24 | * limitations under the License. | |
|
25 | * | |
|
26 | ****************************************************************************** | |
|
27 | */ | |
|
28 | ||
|
29 | /* Includes ------------------------------------------------------------------*/ | |
|
30 | #include "usb_bsp.h" | |
|
31 | #include "usbd_conf.h" | |
|
32 | ||
|
33 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY | |
|
34 | * @{ | |
|
35 | */ | |
|
36 | ||
|
37 | /** @defgroup USB_BSP | |
|
38 | * @brief This file is responsible to offer board support package | |
|
39 | * @{ | |
|
40 | */ | |
|
41 | ||
|
42 | /** @defgroup USB_BSP_Private_Defines | |
|
43 | * @{ | |
|
44 | */ | |
|
45 | /** | |
|
46 | * @} | |
|
47 | */ | |
|
48 | ||
|
49 | ||
|
50 | /** @defgroup USB_BSP_Private_TypesDefinitions | |
|
51 | * @{ | |
|
52 | */ | |
|
53 | /** | |
|
54 | * @} | |
|
55 | */ | |
|
56 | ||
|
57 | ||
|
58 | ||
|
59 | ||
|
60 | ||
|
61 | /** @defgroup USB_BSP_Private_Macros | |
|
62 | * @{ | |
|
63 | */ | |
|
64 | /** | |
|
65 | * @} | |
|
66 | */ | |
|
67 | ||
|
68 | /** @defgroup USBH_BSP_Private_Variables | |
|
69 | * @{ | |
|
70 | */ | |
|
71 | ||
|
72 | /** | |
|
73 | * @} | |
|
74 | */ | |
|
75 | ||
|
76 | /** @defgroup USBH_BSP_Private_FunctionPrototypes | |
|
77 | * @{ | |
|
78 | */ | |
|
79 | /** | |
|
80 | * @} | |
|
81 | */ | |
|
82 | ||
|
83 | /** @defgroup USB_BSP_Private_Functions | |
|
84 | * @{ | |
|
85 | */ | |
|
86 | ||
|
87 | ||
|
88 | /** | |
|
89 | * @brief USB_OTG_BSP_Init | |
|
90 | * Initilizes BSP configurations | |
|
91 | * @param None | |
|
92 | * @retval None | |
|
93 | */ | |
|
94 | ||
|
95 | void USB_OTG_BSP_Init(USB_OTG_CORE_HANDLE *pdev) | |
|
96 | { | |
|
97 | #ifdef USE_STM3210C_EVAL | |
|
98 | ||
|
99 | RCC_OTGFSCLKConfig(RCC_OTGFSCLKSource_PLLVCO_Div3); | |
|
100 | RCC_AHBPeriphClockCmd(RCC_AHBPeriph_OTG_FS, ENABLE) ; | |
|
101 | ||
|
102 | #else // USE_STM322xG_EVAL | |
|
103 | GPIO_InitTypeDef GPIO_InitStructure; | |
|
104 | #ifdef USE_USB_OTG_FS | |
|
105 | RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_GPIOA , ENABLE); | |
|
106 | ||
|
107 | /* Configure SOF ID DM DP Pins */ | |
|
108 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | | |
|
109 | GPIO_Pin_11 | | |
|
110 | GPIO_Pin_12; | |
|
111 | ||
|
112 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; | |
|
113 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; | |
|
114 | GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; | |
|
115 | GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ; | |
|
116 | GPIO_Init(GPIOA, &GPIO_InitStructure); | |
|
117 | ||
|
118 | GPIO_PinAFConfig(GPIOA,GPIO_PinSource8,GPIO_AF_OTG1_FS) ; | |
|
119 | GPIO_PinAFConfig(GPIOA,GPIO_PinSource11,GPIO_AF_OTG1_FS) ; | |
|
120 | GPIO_PinAFConfig(GPIOA,GPIO_PinSource12,GPIO_AF_OTG1_FS) ; | |
|
121 | ||
|
122 | /* Configure VBUS Pin */ | |
|
123 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; | |
|
124 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; | |
|
125 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; | |
|
126 | GPIO_InitStructure.GPIO_OType = GPIO_OType_OD; | |
|
127 | GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ; | |
|
128 | GPIO_Init(GPIOA, &GPIO_InitStructure); | |
|
129 | ||
|
130 | /* Configure ID pin */ | |
|
131 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; | |
|
132 | GPIO_InitStructure.GPIO_OType = GPIO_OType_OD; | |
|
133 | GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP ; | |
|
134 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; | |
|
135 | GPIO_Init(GPIOA, &GPIO_InitStructure); | |
|
136 | GPIO_PinAFConfig(GPIOA,GPIO_PinSource10,GPIO_AF_OTG1_FS) ; | |
|
137 | ||
|
138 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE); | |
|
139 | RCC_AHB2PeriphClockCmd(RCC_AHB2Periph_OTG_FS, ENABLE) ; | |
|
140 | #else // USE_USB_OTG_HS | |
|
141 | ||
|
142 | #ifdef USE_ULPI_PHY // ULPI | |
|
143 | RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOB | | |
|
144 | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOH | | |
|
145 | RCC_AHB1Periph_GPIOI, ENABLE); | |
|
146 | ||
|
147 | ||
|
148 | GPIO_PinAFConfig(GPIOA,GPIO_PinSource3, GPIO_AF_OTG2_HS) ; // D0 | |
|
149 | GPIO_PinAFConfig(GPIOA,GPIO_PinSource5, GPIO_AF_OTG2_HS) ; // CLK | |
|
150 | GPIO_PinAFConfig(GPIOB,GPIO_PinSource0, GPIO_AF_OTG2_HS) ; // D1 | |
|
151 | GPIO_PinAFConfig(GPIOB,GPIO_PinSource1, GPIO_AF_OTG2_HS) ; // D2 | |
|
152 | GPIO_PinAFConfig(GPIOB,GPIO_PinSource5, GPIO_AF_OTG2_HS) ; // D7 | |
|
153 | GPIO_PinAFConfig(GPIOB,GPIO_PinSource10,GPIO_AF_OTG2_HS) ; // D3 | |
|
154 | GPIO_PinAFConfig(GPIOB,GPIO_PinSource11,GPIO_AF_OTG2_HS) ; // D4 | |
|
155 | GPIO_PinAFConfig(GPIOB,GPIO_PinSource12,GPIO_AF_OTG2_HS) ; // D5 | |
|
156 | GPIO_PinAFConfig(GPIOB,GPIO_PinSource13,GPIO_AF_OTG2_HS) ; // D6 | |
|
157 | GPIO_PinAFConfig(GPIOH,GPIO_PinSource4, GPIO_AF_OTG2_HS) ; // NXT | |
|
158 | GPIO_PinAFConfig(GPIOI,GPIO_PinSource11,GPIO_AF_OTG2_HS) ; // DIR | |
|
159 | GPIO_PinAFConfig(GPIOC,GPIO_PinSource0, GPIO_AF_OTG2_HS) ; // STP | |
|
160 | ||
|
161 | // CLK | |
|
162 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5 ; | |
|
163 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; | |
|
164 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; | |
|
165 | GPIO_Init(GPIOA, &GPIO_InitStructure); | |
|
166 | ||
|
167 | // D0 | |
|
168 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 ; | |
|
169 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; | |
|
170 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; | |
|
171 | GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; | |
|
172 | GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ; | |
|
173 | GPIO_Init(GPIOA, &GPIO_InitStructure); | |
|
174 | ||
|
175 | ||
|
176 | ||
|
177 | // D1 D2 D3 D4 D5 D6 D7 | |
|
178 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | | |
|
179 | GPIO_Pin_5 | GPIO_Pin_10 | | |
|
180 | GPIO_Pin_11| GPIO_Pin_12 | | |
|
181 | GPIO_Pin_13 ; | |
|
182 | ||
|
183 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; | |
|
184 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; | |
|
185 | GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; | |
|
186 | GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ; | |
|
187 | GPIO_Init(GPIOB, &GPIO_InitStructure); | |
|
188 | ||
|
189 | ||
|
190 | // STP | |
|
191 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 ; | |
|
192 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; | |
|
193 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; | |
|
194 | GPIO_Init(GPIOC, &GPIO_InitStructure); | |
|
195 | ||
|
196 | //NXT | |
|
197 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4; | |
|
198 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; | |
|
199 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; | |
|
200 | GPIO_Init(GPIOH, &GPIO_InitStructure); | |
|
201 | ||
|
202 | ||
|
203 | //DIR | |
|
204 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11 ; | |
|
205 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; | |
|
206 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; | |
|
207 | GPIO_Init(GPIOI, &GPIO_InitStructure); | |
|
208 | ||
|
209 | ||
|
210 | RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_OTG_HS | | |
|
211 | RCC_AHB1Periph_OTG_HS_ULPI, ENABLE) ; | |
|
212 | ||
|
213 | #else | |
|
214 | ||
|
215 | RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB , ENABLE); | |
|
216 | ||
|
217 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12 | | |
|
218 | GPIO_Pin_14 | | |
|
219 | GPIO_Pin_15; | |
|
220 | ||
|
221 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; | |
|
222 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; | |
|
223 | GPIO_Init(GPIOB, &GPIO_InitStructure); | |
|
224 | ||
|
225 | GPIO_PinAFConfig(GPIOB,GPIO_PinSource12, GPIO_AF_OTG2_FS) ; | |
|
226 | GPIO_PinAFConfig(GPIOB,GPIO_PinSource14,GPIO_AF_OTG2_FS) ; | |
|
227 | GPIO_PinAFConfig(GPIOB,GPIO_PinSource15,GPIO_AF_OTG2_FS) ; | |
|
228 | ||
|
229 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13; | |
|
230 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; | |
|
231 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; | |
|
232 | GPIO_Init(GPIOB, &GPIO_InitStructure); | |
|
233 | ||
|
234 | ||
|
235 | RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_OTG_HS, ENABLE) ; | |
|
236 | ||
|
237 | #endif | |
|
238 | #endif //USB_OTG_HS | |
|
239 | #endif //USE_STM322xG_EVAL | |
|
240 | } | |
|
241 | /** | |
|
242 | * @brief USB_OTG_BSP_EnableInterrupt | |
|
243 | * Enabele USB Global interrupt | |
|
244 | * @param None | |
|
245 | * @retval None | |
|
246 | */ | |
|
247 | void USB_OTG_BSP_EnableInterrupt(USB_OTG_CORE_HANDLE *pdev) | |
|
248 | { | |
|
249 | NVIC_InitTypeDef NVIC_InitStructure; | |
|
250 | ||
|
251 | NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); | |
|
252 | #ifdef USE_USB_OTG_HS | |
|
253 | NVIC_InitStructure.NVIC_IRQChannel = OTG_HS_IRQn; | |
|
254 | #else | |
|
255 | NVIC_InitStructure.NVIC_IRQChannel = OTG_FS_IRQn; | |
|
256 | #endif | |
|
257 | NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; | |
|
258 | NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3; | |
|
259 | NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; | |
|
260 | NVIC_Init(&NVIC_InitStructure); | |
|
261 | #ifdef USB_OTG_HS_DEDICATED_EP1_ENABLED | |
|
262 | NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); | |
|
263 | NVIC_InitStructure.NVIC_IRQChannel = OTG_HS_EP1_OUT_IRQn; | |
|
264 | NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; | |
|
265 | NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2; | |
|
266 | NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; | |
|
267 | NVIC_Init(&NVIC_InitStructure); | |
|
268 | ||
|
269 | NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); | |
|
270 | NVIC_InitStructure.NVIC_IRQChannel = OTG_HS_EP1_IN_IRQn; | |
|
271 | NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; | |
|
272 | NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; | |
|
273 | NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; | |
|
274 | NVIC_Init(&NVIC_InitStructure); | |
|
275 | #endif | |
|
276 | } | |
|
277 | /** | |
|
278 | * @brief USB_OTG_BSP_uDelay | |
|
279 | * This function provides delay time in micro sec | |
|
280 | * @param usec : Value of delay required in micro sec | |
|
281 | * @retval None | |
|
282 | */ | |
|
283 | void USB_OTG_BSP_uDelay (const uint32_t usec) | |
|
284 | { | |
|
285 | uint32_t count = 0; | |
|
286 | const uint32_t utime = (120 * usec / 7); | |
|
287 | do | |
|
288 | { | |
|
289 | if ( ++count > utime ) | |
|
290 | { | |
|
291 | return ; | |
|
292 | } | |
|
293 | } | |
|
294 | while (1); | |
|
295 | } | |
|
296 | ||
|
297 | ||
|
298 | /** | |
|
299 | * @brief USB_OTG_BSP_mDelay | |
|
300 | * This function provides delay time in milli sec | |
|
301 | * @param msec : Value of delay required in milli sec | |
|
302 | * @retval None | |
|
303 | */ | |
|
304 | void USB_OTG_BSP_mDelay (const uint32_t msec) | |
|
305 | { | |
|
306 | USB_OTG_BSP_uDelay(msec * 1000); | |
|
307 | } | |
|
308 | /** | |
|
309 | * @} | |
|
310 | */ | |
|
311 | ||
|
312 | /** | |
|
313 | * @} | |
|
314 | */ | |
|
315 | ||
|
316 | /** | |
|
317 | * @} | |
|
318 | */ | |
|
319 | ||
|
320 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,310 | |||
|
1 | /** | |
|
2 | ****************************************************************************** | |
|
3 | * @file usb_conf.h | |
|
4 | * @author MCD Application Team | |
|
5 | * @version V1.1.0 | |
|
6 | * @date 19-March-2012 | |
|
7 | * @brief General low level driver configuration | |
|
8 | ****************************************************************************** | |
|
9 | * @attention | |
|
10 | * | |
|
11 | * <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2> | |
|
12 | * | |
|
13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); | |
|
14 | * You may not use this file except in compliance with the License. | |
|
15 | * You may obtain a copy of the License at: | |
|
16 | * | |
|
17 | * http://www.st.com/software_license_agreement_liberty_v2 | |
|
18 | * | |
|
19 | * Unless required by applicable law or agreed to in writing, software | |
|
20 | * distributed under the License is distributed on an "AS IS" BASIS, | |
|
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
|
22 | * See the License for the specific language governing permissions and | |
|
23 | * limitations under the License. | |
|
24 | * | |
|
25 | ****************************************************************************** | |
|
26 | */ | |
|
27 | ||
|
28 | /* Define to prevent recursive inclusion -------------------------------------*/ | |
|
29 | #ifndef __USB_CONF__H__ | |
|
30 | #define __USB_CONF__H__ | |
|
31 | ||
|
32 | /* Includes ------------------------------------------------------------------*/ | |
|
33 | #if defined (USE_STM322xG_EVAL) | |
|
34 | #include "stm322xg_eval.h" | |
|
35 | #include "stm322xg_eval_lcd.h" | |
|
36 | #include "stm322xg_eval_ioe.h" | |
|
37 | #include "stm322xg_eval_sdio_sd.h" | |
|
38 | #elif defined(USE_STM324xG_EVAL) | |
|
39 | #include "stm32f4xx.h" | |
|
40 | #include "stm324xg_eval.h" | |
|
41 | #include "stm324xg_eval_lcd.h" | |
|
42 | #include "stm324xg_eval_ioe.h" | |
|
43 | #include "stm324xg_eval_sdio_sd.h" | |
|
44 | #elif defined (USE_STM3210C_EVAL) | |
|
45 | #include "stm32f10x.h" | |
|
46 | #include "stm3210c_eval.h" | |
|
47 | #include "stm3210c_eval_lcd.h" | |
|
48 | #include "stm3210c_eval_ioe.h" | |
|
49 | #include "stm3210c_eval_spi_sd.h" | |
|
50 | #elif defined (stm32f4) | |
|
51 | #include "stm32f4xx.h" | |
|
52 | #else | |
|
53 | #error "Missing define: Evaluation board (ie. USE_STM322xG_EVAL)" | |
|
54 | #endif | |
|
55 | ||
|
56 | ||
|
57 | /** @addtogroup USB_OTG_DRIVER | |
|
58 | * @{ | |
|
59 | */ | |
|
60 | ||
|
61 | /** @defgroup USB_CONF | |
|
62 | * @brief USB low level driver configuration file | |
|
63 | * @{ | |
|
64 | */ | |
|
65 | ||
|
66 | /** @defgroup USB_CONF_Exported_Defines | |
|
67 | * @{ | |
|
68 | */ | |
|
69 | ||
|
70 | /* USB Core and PHY interface configuration. | |
|
71 | Tip: To avoid modifying these defines each time you need to change the USB | |
|
72 | configuration, you can declare the needed define in your toolchain | |
|
73 | compiler preprocessor. | |
|
74 | */ | |
|
75 | /****************** USB OTG FS PHY CONFIGURATION ******************************* | |
|
76 | * The USB OTG FS Core supports one on-chip Full Speed PHY. | |
|
77 | * | |
|
78 | * The USE_EMBEDDED_PHY symbol is defined in the project compiler preprocessor | |
|
79 | * when FS core is used. | |
|
80 | *******************************************************************************/ | |
|
81 | #ifndef USE_USB_OTG_FS | |
|
82 | //#define USE_USB_OTG_FS | |
|
83 | #endif /* USE_USB_OTG_FS */ | |
|
84 | ||
|
85 | #ifdef USE_USB_OTG_FS | |
|
86 | #define USB_OTG_FS_CORE | |
|
87 | #endif | |
|
88 | ||
|
89 | /****************** USB OTG HS PHY CONFIGURATION ******************************* | |
|
90 | * The USB OTG HS Core supports two PHY interfaces: | |
|
91 | * (i) An ULPI interface for the external High Speed PHY: the USB HS Core will | |
|
92 | * operate in High speed mode | |
|
93 | * (ii) An on-chip Full Speed PHY: the USB HS Core will operate in Full speed mode | |
|
94 | * | |
|
95 | * You can select the PHY to be used using one of these two defines: | |
|
96 | * (i) USE_ULPI_PHY: if the USB OTG HS Core is to be used in High speed mode | |
|
97 | * (ii) USE_EMBEDDED_PHY: if the USB OTG HS Core is to be used in Full speed mode | |
|
98 | * | |
|
99 | * Notes: | |
|
100 | * - The USE_ULPI_PHY symbol is defined in the project compiler preprocessor as | |
|
101 | * default PHY when HS core is used. | |
|
102 | * - On STM322xG-EVAL and STM324xG-EVAL boards, only configuration(i) is available. | |
|
103 | * Configuration (ii) need a different hardware, for more details refer to your | |
|
104 | * STM32 device datasheet. | |
|
105 | *******************************************************************************/ | |
|
106 | #ifndef USE_USB_OTG_HS | |
|
107 | //#define USE_USB_OTG_HS | |
|
108 | #endif /* USE_USB_OTG_HS */ | |
|
109 | ||
|
110 | #ifndef USE_ULPI_PHY | |
|
111 | //#define USE_ULPI_PHY | |
|
112 | #endif /* USE_ULPI_PHY */ | |
|
113 | ||
|
114 | #ifndef USE_EMBEDDED_PHY | |
|
115 | //#define USE_EMBEDDED_PHY | |
|
116 | #endif /* USE_EMBEDDED_PHY */ | |
|
117 | ||
|
118 | #ifdef USE_USB_OTG_HS | |
|
119 | #define USB_OTG_HS_CORE | |
|
120 | #endif | |
|
121 | ||
|
122 | /******************************************************************************* | |
|
123 | * FIFO Size Configuration in Device mode | |
|
124 | * | |
|
125 | * (i) Receive data FIFO size = RAM for setup packets + | |
|
126 | * OUT endpoint control information + | |
|
127 | * data OUT packets + miscellaneous | |
|
128 | * Space = ONE 32-bits words | |
|
129 | * --> RAM for setup packets = 10 spaces | |
|
130 | * (n is the nbr of CTRL EPs the device core supports) | |
|
131 | * --> OUT EP CTRL info = 1 space | |
|
132 | * (one space for status information written to the FIFO along with each | |
|
133 | * received packet) | |
|
134 | * --> data OUT packets = (Largest Packet Size / 4) + 1 spaces | |
|
135 | * (MINIMUM to receive packets) | |
|
136 | * --> OR data OUT packets = at least 2*(Largest Packet Size / 4) + 1 spaces | |
|
137 | * (if high-bandwidth EP is enabled or multiple isochronous EPs) | |
|
138 | * --> miscellaneous = 1 space per OUT EP | |
|
139 | * (one space for transfer complete status information also pushed to the | |
|
140 | * FIFO with each endpoint's last packet) | |
|
141 | * | |
|
142 | * (ii)MINIMUM RAM space required for each IN EP Tx FIFO = MAX packet size for | |
|
143 | * that particular IN EP. More space allocated in the IN EP Tx FIFO results | |
|
144 | * in a better performance on the USB and can hide latencies on the AHB. | |
|
145 | * | |
|
146 | * (iii) TXn min size = 16 words. (n : Transmit FIFO index) | |
|
147 | * (iv) When a TxFIFO is not used, the Configuration should be as follows: | |
|
148 | * case 1 : n > m and Txn is not used (n,m : Transmit FIFO indexes) | |
|
149 | * --> Txm can use the space allocated for Txn. | |
|
150 | * case2 : n < m and Txn is not used (n,m : Transmit FIFO indexes) | |
|
151 | * --> Txn should be configured with the minimum space of 16 words | |
|
152 | * (v) The FIFO is used optimally when used TxFIFOs are allocated in the top | |
|
153 | * of the FIFO.Ex: use EP1 and EP2 as IN instead of EP1 and EP3 as IN ones. | |
|
154 | * (vi) In HS case 12 FIFO locations should be reserved for internal DMA registers | |
|
155 | * so total FIFO size should be 1012 Only instead of 1024 | |
|
156 | *******************************************************************************/ | |
|
157 | ||
|
158 | /****************** USB OTG HS CONFIGURATION **********************************/ | |
|
159 | #ifdef USB_OTG_HS_CORE | |
|
160 | #define RX_FIFO_HS_SIZE 512 | |
|
161 | #define TX0_FIFO_HS_SIZE 64 | |
|
162 | #define TX1_FIFO_HS_SIZE 372 | |
|
163 | #define TX2_FIFO_HS_SIZE 64 | |
|
164 | #define TX3_FIFO_HS_SIZE 0 | |
|
165 | #define TX4_FIFO_HS_SIZE 0 | |
|
166 | #define TX5_FIFO_HS_SIZE 0 | |
|
167 | ||
|
168 | // #define USB_OTG_HS_SOF_OUTPUT_ENABLED | |
|
169 | ||
|
170 | #ifdef USE_ULPI_PHY | |
|
171 | #define USB_OTG_ULPI_PHY_ENABLED | |
|
172 | #endif | |
|
173 | #ifdef USE_EMBEDDED_PHY | |
|
174 | #define USB_OTG_EMBEDDED_PHY_ENABLED | |
|
175 | /* wakeup is working only when HS core is configured in FS mode */ | |
|
176 | #define USB_OTG_HS_LOW_PWR_MGMT_SUPPORT | |
|
177 | #endif | |
|
178 | /* #define USB_OTG_HS_INTERNAL_DMA_ENABLED */ /* Be aware that enabling DMA mode will result in data being sent only by | |
|
179 | multiple of 4 packet sizes. This is due to the fact that USB DMA does | |
|
180 | not allow sending data from non word-aligned addresses. | |
|
181 | For this specific application, it is advised to not enable this option | |
|
182 | unless required. */ | |
|
183 | #define USB_OTG_HS_DEDICATED_EP1_ENABLED | |
|
184 | #endif | |
|
185 | ||
|
186 | /****************** USB OTG FS CONFIGURATION **********************************/ | |
|
187 | #ifdef USB_OTG_FS_CORE | |
|
188 | #define RX_FIFO_FS_SIZE 128 | |
|
189 | #define TX0_FIFO_FS_SIZE 32 | |
|
190 | #define TX1_FIFO_FS_SIZE 128 | |
|
191 | #define TX2_FIFO_FS_SIZE 32 | |
|
192 | #define TX3_FIFO_FS_SIZE 0 | |
|
193 | ||
|
194 | // #define USB_OTG_FS_LOW_PWR_MGMT_SUPPORT | |
|
195 | // #define USB_OTG_FS_SOF_OUTPUT_ENABLED | |
|
196 | #endif | |
|
197 | ||
|
198 | /****************** USB OTG MISC CONFIGURATION ********************************/ | |
|
199 | #define VBUS_SENSING_ENABLED | |
|
200 | ||
|
201 | /****************** USB OTG MODE CONFIGURATION ********************************/ | |
|
202 | //#define USE_HOST_MODE | |
|
203 | #define USE_DEVICE_MODE | |
|
204 | //#define USE_OTG_MODE | |
|
205 | ||
|
206 | #ifndef USB_OTG_FS_CORE | |
|
207 | #ifndef USB_OTG_HS_CORE | |
|
208 | #error "USB_OTG_HS_CORE or USB_OTG_FS_CORE should be defined" | |
|
209 | #endif | |
|
210 | #endif | |
|
211 | ||
|
212 | #ifndef USE_DEVICE_MODE | |
|
213 | #ifndef USE_HOST_MODE | |
|
214 | #error "USE_DEVICE_MODE or USE_HOST_MODE should be defined" | |
|
215 | #endif | |
|
216 | #endif | |
|
217 | ||
|
218 | #ifndef USE_USB_OTG_HS | |
|
219 | #ifndef USE_USB_OTG_FS | |
|
220 | #error "USE_USB_OTG_HS or USE_USB_OTG_FS should be defined" | |
|
221 | #endif | |
|
222 | #else //USE_USB_OTG_HS | |
|
223 | #ifndef USE_ULPI_PHY | |
|
224 | #ifndef USE_EMBEDDED_PHY | |
|
225 | #error "USE_ULPI_PHY or USE_EMBEDDED_PHY should be defined" | |
|
226 | #endif | |
|
227 | #endif | |
|
228 | #endif | |
|
229 | ||
|
230 | /****************** C Compilers dependant keywords ****************************/ | |
|
231 | /* In HS mode and when the DMA is used, all variables and data structures dealing | |
|
232 | with the DMA during the transaction process should be 4-bytes aligned */ | |
|
233 | #ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED | |
|
234 | #if defined (__GNUC__) /* GNU Compiler */ | |
|
235 | #define __ALIGN_END __attribute__ ((aligned (4))) | |
|
236 | #define __ALIGN_BEGIN | |
|
237 | #else | |
|
238 | #define __ALIGN_END | |
|
239 | #if defined (__CC_ARM) /* ARM Compiler */ | |
|
240 | #define __ALIGN_BEGIN __align(4) | |
|
241 | #elif defined (__ICCARM__) /* IAR Compiler */ | |
|
242 | #define __ALIGN_BEGIN | |
|
243 | #elif defined (__TASKING__) /* TASKING Compiler */ | |
|
244 | #define __ALIGN_BEGIN __align(4) | |
|
245 | #endif /* __CC_ARM */ | |
|
246 | #endif /* __GNUC__ */ | |
|
247 | #else | |
|
248 | #define __ALIGN_BEGIN | |
|
249 | #define __ALIGN_END | |
|
250 | #endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */ | |
|
251 | ||
|
252 | /* __packed keyword used to decrease the data type alignment to 1-byte */ | |
|
253 | #if defined (__CC_ARM) /* ARM Compiler */ | |
|
254 | #define __packed __packed | |
|
255 | #elif defined (__ICCARM__) /* IAR Compiler */ | |
|
256 | #define __packed __packed | |
|
257 | #elif defined ( __GNUC__ ) /* GNU Compiler */ | |
|
258 | #define __packed __attribute__ ((__packed__)) | |
|
259 | #elif defined (__TASKING__) /* TASKING Compiler */ | |
|
260 | #define __packed __unaligned | |
|
261 | #endif /* __CC_ARM */ | |
|
262 | ||
|
263 | /** | |
|
264 | * @} | |
|
265 | */ | |
|
266 | ||
|
267 | ||
|
268 | /** @defgroup USB_CONF_Exported_Types | |
|
269 | * @{ | |
|
270 | */ | |
|
271 | /** | |
|
272 | * @} | |
|
273 | */ | |
|
274 | ||
|
275 | ||
|
276 | /** @defgroup USB_CONF_Exported_Macros | |
|
277 | * @{ | |
|
278 | */ | |
|
279 | /** | |
|
280 | * @} | |
|
281 | */ | |
|
282 | ||
|
283 | /** @defgroup USB_CONF_Exported_Variables | |
|
284 | * @{ | |
|
285 | */ | |
|
286 | /** | |
|
287 | * @} | |
|
288 | */ | |
|
289 | ||
|
290 | /** @defgroup USB_CONF_Exported_FunctionsPrototype | |
|
291 | * @{ | |
|
292 | */ | |
|
293 | /** | |
|
294 | * @} | |
|
295 | */ | |
|
296 | ||
|
297 | ||
|
298 | #endif //__USB_CONF__H__ | |
|
299 | ||
|
300 | ||
|
301 | /** | |
|
302 | * @} | |
|
303 | */ | |
|
304 | ||
|
305 | /** | |
|
306 | * @} | |
|
307 | */ | |
|
308 | ||
|
309 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |
|
310 |
@@ -0,0 +1,381 | |||
|
1 | /** | |
|
2 | ****************************************************************************** | |
|
3 | * @file usbd_cdc_vcp.c | |
|
4 | * @author MCD Application Team | |
|
5 | * @version V1.1.0 | |
|
6 | * @date 19-March-2012 | |
|
7 | * @brief Generic media access Layer. | |
|
8 | ****************************************************************************** | |
|
9 | * @attention | |
|
10 | * | |
|
11 | * <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2> | |
|
12 | * | |
|
13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); | |
|
14 | * You may not use this file except in compliance with the License. | |
|
15 | * You may obtain a copy of the License at: | |
|
16 | * | |
|
17 | * http://www.st.com/software_license_agreement_liberty_v2 | |
|
18 | * | |
|
19 | * Unless required by applicable law or agreed to in writing, software | |
|
20 | * distributed under the License is distributed on an "AS IS" BASIS, | |
|
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
|
22 | * See the License for the specific language governing permissions and | |
|
23 | * limitations under the License. | |
|
24 | * | |
|
25 | ****************************************************************************** | |
|
26 | */ | |
|
27 | ||
|
28 | #ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED | |
|
29 | #pragma data_alignment = 4 | |
|
30 | #endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */ | |
|
31 | ||
|
32 | /* Includes ------------------------------------------------------------------*/ | |
|
33 | #include "usbd_cdc_vcp.h" | |
|
34 | #include "usb_conf.h" | |
|
35 | ||
|
36 | /* Private typedef -----------------------------------------------------------*/ | |
|
37 | /* Private define ------------------------------------------------------------*/ | |
|
38 | /* Private macro -------------------------------------------------------------*/ | |
|
39 | /* Private variables ---------------------------------------------------------*/ | |
|
40 | LINE_CODING linecoding = | |
|
41 | { | |
|
42 | 115200, /* baud rate*/ | |
|
43 | 0x00, /* stop bits-1*/ | |
|
44 | 0x00, /* parity - none*/ | |
|
45 | 0x08 /* nb. of bits 8*/ | |
|
46 | }; | |
|
47 | ||
|
48 | ||
|
49 | USART_InitTypeDef USART_InitStructure; | |
|
50 | ||
|
51 | /* These are external variables imported from CDC core to be used for IN | |
|
52 | transfer management. */ | |
|
53 | extern uint8_t APP_Rx_Buffer []; /* Write CDC received data in this buffer. | |
|
54 | These data will be sent over USB IN endpoint | |
|
55 | in the CDC core functions. */ | |
|
56 | extern uint32_t APP_Rx_ptr_in; /* Increment this pointer or roll it back to | |
|
57 | start address when writing received data | |
|
58 | in the buffer APP_Rx_Buffer. */ | |
|
59 | ||
|
60 | /* Private function prototypes -----------------------------------------------*/ | |
|
61 | static uint16_t VCP_Init (void); | |
|
62 | static uint16_t VCP_DeInit (void); | |
|
63 | static uint16_t VCP_Ctrl (uint32_t Cmd, uint8_t* Buf, uint32_t Len); | |
|
64 | static uint16_t VCP_DataTx (uint8_t* Buf, uint32_t Len); | |
|
65 | static uint16_t VCP_DataRx (uint8_t* Buf, uint32_t Len); | |
|
66 | ||
|
67 | static uint16_t VCP_COMConfig(uint8_t Conf); | |
|
68 | ||
|
69 | CDC_IF_Prop_TypeDef VCP_fops = | |
|
70 | { | |
|
71 | VCP_Init, | |
|
72 | VCP_DeInit, | |
|
73 | VCP_Ctrl, | |
|
74 | VCP_DataTx, | |
|
75 | VCP_DataRx | |
|
76 | }; | |
|
77 | ||
|
78 | /* Private functions ---------------------------------------------------------*/ | |
|
79 | /** | |
|
80 | * @brief VCP_Init | |
|
81 | * Initializes the Media on the STM32 | |
|
82 | * @param None | |
|
83 | * @retval Result of the opeartion (USBD_OK in all cases) | |
|
84 | */ | |
|
85 | static uint16_t VCP_Init(void) | |
|
86 | { | |
|
87 | NVIC_InitTypeDef NVIC_InitStructure; | |
|
88 | ||
|
89 | /* EVAL_COM1 default configuration */ | |
|
90 | /* EVAL_COM1 configured as follow: | |
|
91 | - BaudRate = 115200 baud | |
|
92 | - Word Length = 8 Bits | |
|
93 | - One Stop Bit | |
|
94 | - Parity Odd | |
|
95 | - Hardware flow control disabled | |
|
96 | - Receive and transmit enabled | |
|
97 | */ | |
|
98 | USART_InitStructure.USART_BaudRate = 115200; | |
|
99 | USART_InitStructure.USART_WordLength = USART_WordLength_8b; | |
|
100 | USART_InitStructure.USART_StopBits = USART_StopBits_1; | |
|
101 | USART_InitStructure.USART_Parity = USART_Parity_Odd; | |
|
102 | USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; | |
|
103 | USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; | |
|
104 | ||
|
105 | /* Configure and enable the USART */ | |
|
106 | STM_EVAL_COMInit(COM1, &USART_InitStructure); | |
|
107 | ||
|
108 | /* Enable the USART Receive interrupt */ | |
|
109 | USART_ITConfig(EVAL_COM1, USART_IT_RXNE, ENABLE); | |
|
110 | ||
|
111 | /* Enable USART Interrupt */ | |
|
112 | NVIC_InitStructure.NVIC_IRQChannel = EVAL_COM1_IRQn; | |
|
113 | NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; | |
|
114 | NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; | |
|
115 | NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; | |
|
116 | NVIC_Init(&NVIC_InitStructure); | |
|
117 | ||
|
118 | return USBD_OK; | |
|
119 | } | |
|
120 | ||
|
121 | /** | |
|
122 | * @brief VCP_DeInit | |
|
123 | * DeInitializes the Media on the STM32 | |
|
124 | * @param None | |
|
125 | * @retval Result of the opeartion (USBD_OK in all cases) | |
|
126 | */ | |
|
127 | static uint16_t VCP_DeInit(void) | |
|
128 | { | |
|
129 | ||
|
130 | return USBD_OK; | |
|
131 | } | |
|
132 | ||
|
133 | ||
|
134 | /** | |
|
135 | * @brief VCP_Ctrl | |
|
136 | * Manage the CDC class requests | |
|
137 | * @param Cmd: Command code | |
|
138 | * @param Buf: Buffer containing command data (request parameters) | |
|
139 | * @param Len: Number of data to be sent (in bytes) | |
|
140 | * @retval Result of the opeartion (USBD_OK in all cases) | |
|
141 | */ | |
|
142 | static uint16_t VCP_Ctrl (uint32_t Cmd, uint8_t* Buf, uint32_t Len) | |
|
143 | { | |
|
144 | switch (Cmd) | |
|
145 | { | |
|
146 | case SEND_ENCAPSULATED_COMMAND: | |
|
147 | /* Not needed for this driver */ | |
|
148 | break; | |
|
149 | ||
|
150 | case GET_ENCAPSULATED_RESPONSE: | |
|
151 | /* Not needed for this driver */ | |
|
152 | break; | |
|
153 | ||
|
154 | case SET_COMM_FEATURE: | |
|
155 | /* Not needed for this driver */ | |
|
156 | break; | |
|
157 | ||
|
158 | case GET_COMM_FEATURE: | |
|
159 | /* Not needed for this driver */ | |
|
160 | break; | |
|
161 | ||
|
162 | case CLEAR_COMM_FEATURE: | |
|
163 | /* Not needed for this driver */ | |
|
164 | break; | |
|
165 | ||
|
166 | case SET_LINE_CODING: | |
|
167 | linecoding.bitrate = (uint32_t)(Buf[0] | (Buf[1] << 8) | (Buf[2] << 16) | (Buf[3] << 24)); | |
|
168 | linecoding.format = Buf[4]; | |
|
169 | linecoding.paritytype = Buf[5]; | |
|
170 | linecoding.datatype = Buf[6]; | |
|
171 | /* Set the new configuration */ | |
|
172 | VCP_COMConfig(OTHER_CONFIG); | |
|
173 | break; | |
|
174 | ||
|
175 | case GET_LINE_CODING: | |
|
176 | Buf[0] = (uint8_t)(linecoding.bitrate); | |
|
177 | Buf[1] = (uint8_t)(linecoding.bitrate >> 8); | |
|
178 | Buf[2] = (uint8_t)(linecoding.bitrate >> 16); | |
|
179 | Buf[3] = (uint8_t)(linecoding.bitrate >> 24); | |
|
180 | Buf[4] = linecoding.format; | |
|
181 | Buf[5] = linecoding.paritytype; | |
|
182 | Buf[6] = linecoding.datatype; | |
|
183 | break; | |
|
184 | ||
|
185 | case SET_CONTROL_LINE_STATE: | |
|
186 | /* Not needed for this driver */ | |
|
187 | break; | |
|
188 | ||
|
189 | case SEND_BREAK: | |
|
190 | /* Not needed for this driver */ | |
|
191 | break; | |
|
192 | ||
|
193 | default: | |
|
194 | break; | |
|
195 | } | |
|
196 | ||
|
197 | return USBD_OK; | |
|
198 | } | |
|
199 | ||
|
200 | /** | |
|
201 | * @brief VCP_DataTx | |
|
202 | * CDC received data to be send over USB IN endpoint are managed in | |
|
203 | * this function. | |
|
204 | * @param Buf: Buffer of data to be sent | |
|
205 | * @param Len: Number of data to be sent (in bytes) | |
|
206 | * @retval Result of the opeartion: USBD_OK if all operations are OK else VCP_FAIL | |
|
207 | */ | |
|
208 | static uint16_t VCP_DataTx (uint8_t* Buf, uint32_t Len) | |
|
209 | { | |
|
210 | if (linecoding.datatype == 7) | |
|
211 | { | |
|
212 | APP_Rx_Buffer[APP_Rx_ptr_in] = USART_ReceiveData(EVAL_COM1) & 0x7F; | |
|
213 | } | |
|
214 | else if (linecoding.datatype == 8) | |
|
215 | { | |
|
216 | APP_Rx_Buffer[APP_Rx_ptr_in] = USART_ReceiveData(EVAL_COM1); | |
|
217 | } | |
|
218 | ||
|
219 | APP_Rx_ptr_in++; | |
|
220 | ||
|
221 | /* To avoid buffer overflow */ | |
|
222 | if(APP_Rx_ptr_in == APP_RX_DATA_SIZE) | |
|
223 | { | |
|
224 | APP_Rx_ptr_in = 0; | |
|
225 | } | |
|
226 | ||
|
227 | return USBD_OK; | |
|
228 | } | |
|
229 | ||
|
230 | /** | |
|
231 | * @brief VCP_DataRx | |
|
232 | * Data received over USB OUT endpoint are sent over CDC interface | |
|
233 | * through this function. | |
|
234 | * | |
|
235 | * @note | |
|
236 | * This function will block any OUT packet reception on USB endpoint | |
|
237 | * untill exiting this function. If you exit this function before transfer | |
|
238 | * is complete on CDC interface (ie. using DMA controller) it will result | |
|
239 | * in receiving more data while previous ones are still not sent. | |
|
240 | * | |
|
241 | * @param Buf: Buffer of data to be received | |
|
242 | * @param Len: Number of data received (in bytes) | |
|
243 | * @retval Result of the opeartion: USBD_OK if all operations are OK else VCP_FAIL | |
|
244 | */ | |
|
245 | static uint16_t VCP_DataRx (uint8_t* Buf, uint32_t Len) | |
|
246 | { | |
|
247 | uint32_t i; | |
|
248 | ||
|
249 | for (i = 0; i < Len; i++) | |
|
250 | { | |
|
251 | USART_SendData(EVAL_COM1, *(Buf + i) ); | |
|
252 | while(USART_GetFlagStatus(EVAL_COM1, USART_FLAG_TXE) == RESET); | |
|
253 | } | |
|
254 | ||
|
255 | return USBD_OK; | |
|
256 | } | |
|
257 | ||
|
258 | /** | |
|
259 | * @brief VCP_COMConfig | |
|
260 | * Configure the COM Port with default values or values received from host. | |
|
261 | * @param Conf: can be DEFAULT_CONFIG to set the default configuration or OTHER_CONFIG | |
|
262 | * to set a configuration received from the host. | |
|
263 | * @retval None. | |
|
264 | */ | |
|
265 | static uint16_t VCP_COMConfig(uint8_t Conf) | |
|
266 | { | |
|
267 | if (Conf == DEFAULT_CONFIG) | |
|
268 | { | |
|
269 | /* EVAL_COM1 default configuration */ | |
|
270 | /* EVAL_COM1 configured as follow: | |
|
271 | - BaudRate = 115200 baud | |
|
272 | - Word Length = 8 Bits | |
|
273 | - One Stop Bit | |
|
274 | - Parity Odd | |
|
275 | - Hardware flow control disabled | |
|
276 | - Receive and transmit enabled | |
|
277 | */ | |
|
278 | USART_InitStructure.USART_BaudRate = 115200; | |
|
279 | USART_InitStructure.USART_WordLength = USART_WordLength_8b; | |
|
280 | USART_InitStructure.USART_StopBits = USART_StopBits_1; | |
|
281 | USART_InitStructure.USART_Parity = USART_Parity_Odd; | |
|
282 | USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; | |
|
283 | USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; | |
|
284 | ||
|
285 | /* Configure and enable the USART */ | |
|
286 | STM_EVAL_COMInit(COM1, &USART_InitStructure); | |
|
287 | ||
|
288 | /* Enable the USART Receive interrupt */ | |
|
289 | USART_ITConfig(EVAL_COM1, USART_IT_RXNE, ENABLE); | |
|
290 | } | |
|
291 | else | |
|
292 | { | |
|
293 | /* set the Stop bit*/ | |
|
294 | switch (linecoding.format) | |
|
295 | { | |
|
296 | case 0: | |
|
297 | USART_InitStructure.USART_StopBits = USART_StopBits_1; | |
|
298 | break; | |
|
299 | case 1: | |
|
300 | USART_InitStructure.USART_StopBits = USART_StopBits_1_5; | |
|
301 | break; | |
|
302 | case 2: | |
|
303 | USART_InitStructure.USART_StopBits = USART_StopBits_2; | |
|
304 | break; | |
|
305 | default : | |
|
306 | VCP_COMConfig(DEFAULT_CONFIG); | |
|
307 | return (USBD_FAIL); | |
|
308 | } | |
|
309 | ||
|
310 | /* set the parity bit*/ | |
|
311 | switch (linecoding.paritytype) | |
|
312 | { | |
|
313 | case 0: | |
|
314 | USART_InitStructure.USART_Parity = USART_Parity_No; | |
|
315 | break; | |
|
316 | case 1: | |
|
317 | USART_InitStructure.USART_Parity = USART_Parity_Even; | |
|
318 | break; | |
|
319 | case 2: | |
|
320 | USART_InitStructure.USART_Parity = USART_Parity_Odd; | |
|
321 | break; | |
|
322 | default : | |
|
323 | VCP_COMConfig(DEFAULT_CONFIG); | |
|
324 | return (USBD_FAIL); | |
|
325 | } | |
|
326 | ||
|
327 | /*set the data type : only 8bits and 9bits is supported */ | |
|
328 | switch (linecoding.datatype) | |
|
329 | { | |
|
330 | case 0x07: | |
|
331 | /* With this configuration a parity (Even or Odd) should be set */ | |
|
332 | USART_InitStructure.USART_WordLength = USART_WordLength_8b; | |
|
333 | break; | |
|
334 | case 0x08: | |
|
335 | if (USART_InitStructure.USART_Parity == USART_Parity_No) | |
|
336 | { | |
|
337 | USART_InitStructure.USART_WordLength = USART_WordLength_8b; | |
|
338 | } | |
|
339 | else | |
|
340 | { | |
|
341 | USART_InitStructure.USART_WordLength = USART_WordLength_9b; | |
|
342 | } | |
|
343 | ||
|
344 | break; | |
|
345 | default : | |
|
346 | VCP_COMConfig(DEFAULT_CONFIG); | |
|
347 | return (USBD_FAIL); | |
|
348 | } | |
|
349 | ||
|
350 | USART_InitStructure.USART_BaudRate = linecoding.bitrate; | |
|
351 | USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; | |
|
352 | USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; | |
|
353 | ||
|
354 | /* Configure and enable the USART */ | |
|
355 | STM_EVAL_COMInit(COM1, &USART_InitStructure); | |
|
356 | } | |
|
357 | return USBD_OK; | |
|
358 | } | |
|
359 | ||
|
360 | /** | |
|
361 | * @brief EVAL_COM_IRQHandler | |
|
362 | * | |
|
363 | * @param None. | |
|
364 | * @retval None. | |
|
365 | */ | |
|
366 | void EVAL_COM_IRQHandler(void) | |
|
367 | { | |
|
368 | if (USART_GetITStatus(EVAL_COM1, USART_IT_RXNE) != RESET) | |
|
369 | { | |
|
370 | /* Send the received data to the PC Host*/ | |
|
371 | VCP_DataTx (0,0); | |
|
372 | } | |
|
373 | ||
|
374 | /* If overrun condition occurs, clear the ORE flag and recover communication */ | |
|
375 | if (USART_GetFlagStatus(EVAL_COM1, USART_FLAG_ORE) != RESET) | |
|
376 | { | |
|
377 | (void)USART_ReceiveData(EVAL_COM1); | |
|
378 | } | |
|
379 | } | |
|
380 | ||
|
381 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,74 | |||
|
1 | /** | |
|
2 | ****************************************************************************** | |
|
3 | * @file usbd_cdc_vcp.h | |
|
4 | * @author MCD Application Team | |
|
5 | * @version V1.1.0 | |
|
6 | * @date 19-March-2012 | |
|
7 | * @brief Header for usbd_cdc_vcp.c file. | |
|
8 | ****************************************************************************** | |
|
9 | * @attention | |
|
10 | * | |
|
11 | * <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2> | |
|
12 | * | |
|
13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); | |
|
14 | * You may not use this file except in compliance with the License. | |
|
15 | * You may obtain a copy of the License at: | |
|
16 | * | |
|
17 | * http://www.st.com/software_license_agreement_liberty_v2 | |
|
18 | * | |
|
19 | * Unless required by applicable law or agreed to in writing, software | |
|
20 | * distributed under the License is distributed on an "AS IS" BASIS, | |
|
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
|
22 | * See the License for the specific language governing permissions and | |
|
23 | * limitations under the License. | |
|
24 | * | |
|
25 | ****************************************************************************** | |
|
26 | */ | |
|
27 | ||
|
28 | /* Define to prevent recursive inclusion -------------------------------------*/ | |
|
29 | #ifndef __USBD_CDC_VCP_H | |
|
30 | #define __USBD_CDC_VCP_H | |
|
31 | ||
|
32 | /* Includes ------------------------------------------------------------------*/ | |
|
33 | #ifdef STM32F2XX | |
|
34 | #include "stm32f2xx.h" | |
|
35 | #elif defined(STM32F10X_CL) | |
|
36 | #include "stm32f10x.h" | |
|
37 | #endif /* STM32F2XX */ | |
|
38 | ||
|
39 | #include "usbd_cdc_core.h" | |
|
40 | #include "usbd_conf.h" | |
|
41 | ||
|
42 | ||
|
43 | /* Exported typef ------------------------------------------------------------*/ | |
|
44 | /* The following structures groups all needed parameters to be configured for the | |
|
45 | ComPort. These parameters can modified on the fly by the host through CDC class | |
|
46 | command class requests. */ | |
|
47 | typedef struct | |
|
48 | { | |
|
49 | uint32_t bitrate; | |
|
50 | uint8_t format; | |
|
51 | uint8_t paritytype; | |
|
52 | uint8_t datatype; | |
|
53 | }LINE_CODING; | |
|
54 | ||
|
55 | /* Exported constants --------------------------------------------------------*/ | |
|
56 | /* The following define is used to route the USART IRQ handler to be used. | |
|
57 | The IRQ handler function is implemented in the usbd_cdc_vcp.c file. */ | |
|
58 | ||
|
59 | #ifdef USE_STM3210C_EVAL | |
|
60 | #define EVAL_COM_IRQHandler USART2_IRQHandler | |
|
61 | #else | |
|
62 | #define EVAL_COM_IRQHandler USART3_IRQHandler | |
|
63 | #endif /* USE_STM322xG_EVAL */ | |
|
64 | ||
|
65 | ||
|
66 | #define DEFAULT_CONFIG 0 | |
|
67 | #define OTHER_CONFIG 1 | |
|
68 | ||
|
69 | /* Exported macro ------------------------------------------------------------*/ | |
|
70 | /* Exported functions ------------------------------------------------------- */ | |
|
71 | ||
|
72 | #endif /* __USBD_CDC_VCP_H */ | |
|
73 | ||
|
74 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,107 | |||
|
1 | /** | |
|
2 | ****************************************************************************** | |
|
3 | * @file usbd_conf.h | |
|
4 | * @author MCD Application Team | |
|
5 | * @version V1.1.0 | |
|
6 | * @date 19-March-2012 | |
|
7 | * @brief USB Device configuration file | |
|
8 | ****************************************************************************** | |
|
9 | * @attention | |
|
10 | * | |
|
11 | * <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2> | |
|
12 | * | |
|
13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); | |
|
14 | * You may not use this file except in compliance with the License. | |
|
15 | * You may obtain a copy of the License at: | |
|
16 | * | |
|
17 | * http://www.st.com/software_license_agreement_liberty_v2 | |
|
18 | * | |
|
19 | * Unless required by applicable law or agreed to in writing, software | |
|
20 | * distributed under the License is distributed on an "AS IS" BASIS, | |
|
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
|
22 | * See the License for the specific language governing permissions and | |
|
23 | * limitations under the License. | |
|
24 | * | |
|
25 | ****************************************************************************** | |
|
26 | */ | |
|
27 | ||
|
28 | /* Define to prevent recursive inclusion -------------------------------------*/ | |
|
29 | #ifndef __USBD_CONF__H__ | |
|
30 | #define __USBD_CONF__H__ | |
|
31 | ||
|
32 | /* Includes ------------------------------------------------------------------*/ | |
|
33 | #include "usb_conf.h" | |
|
34 | ||
|
35 | /** @defgroup USB_CONF_Exported_Defines | |
|
36 | * @{ | |
|
37 | */ | |
|
38 | #define USBD_CFG_MAX_NUM 1 | |
|
39 | #define USBD_ITF_MAX_NUM 1 | |
|
40 | ||
|
41 | #define USBD_SELF_POWERED | |
|
42 | ||
|
43 | #define USB_MAX_STR_DESC_SIZ 255 | |
|
44 | ||
|
45 | /** @defgroup USB_VCP_Class_Layer_Parameter | |
|
46 | * @{ | |
|
47 | */ | |
|
48 | #define CDC_IN_EP 0x81 /* EP1 for data IN */ | |
|
49 | #define CDC_OUT_EP 0x01 /* EP1 for data OUT */ | |
|
50 | #define CDC_CMD_EP 0x82 /* EP2 for CDC commands */ | |
|
51 | ||
|
52 | /* CDC Endpoints parameters: you can fine tune these values depending on the needed baudrates and performance. */ | |
|
53 | #ifdef USE_USB_OTG_HS | |
|
54 | #define CDC_DATA_MAX_PACKET_SIZE 512 /* Endpoint IN & OUT Packet size */ | |
|
55 | #define CDC_CMD_PACKET_SZE 8 /* Control Endpoint Packet size */ | |
|
56 | ||
|
57 | #define CDC_IN_FRAME_INTERVAL 40 /* Number of micro-frames between IN transfers */ | |
|
58 | #define APP_RX_DATA_SIZE 2048 /* Total size of IN buffer: | |
|
59 | APP_RX_DATA_SIZE*8/MAX_BAUDARATE*1000 should be > CDC_IN_FRAME_INTERVAL*8 */ | |
|
60 | #else | |
|
61 | #define CDC_DATA_MAX_PACKET_SIZE 64 /* Endpoint IN & OUT Packet size */ | |
|
62 | #define CDC_CMD_PACKET_SZE 8 /* Control Endpoint Packet size */ | |
|
63 | ||
|
64 | #define CDC_IN_FRAME_INTERVAL 5 /* Number of frames between IN transfers */ | |
|
65 | #define APP_RX_DATA_SIZE 2048 /* Total size of IN buffer: | |
|
66 | APP_RX_DATA_SIZE*8/MAX_BAUDARATE*1000 should be > CDC_IN_FRAME_INTERVAL */ | |
|
67 | #endif /* USE_USB_OTG_HS */ | |
|
68 | ||
|
69 | #define APP_FOPS VCP_fops | |
|
70 | /** | |
|
71 | * @} | |
|
72 | */ | |
|
73 | ||
|
74 | /** @defgroup USB_CONF_Exported_Types | |
|
75 | * @{ | |
|
76 | */ | |
|
77 | /** | |
|
78 | * @} | |
|
79 | */ | |
|
80 | ||
|
81 | ||
|
82 | /** @defgroup USB_CONF_Exported_Macros | |
|
83 | * @{ | |
|
84 | */ | |
|
85 | /** | |
|
86 | * @} | |
|
87 | */ | |
|
88 | ||
|
89 | /** @defgroup USB_CONF_Exported_Variables | |
|
90 | * @{ | |
|
91 | */ | |
|
92 | /** | |
|
93 | * @} | |
|
94 | */ | |
|
95 | ||
|
96 | /** @defgroup USB_CONF_Exported_FunctionsPrototype | |
|
97 | * @{ | |
|
98 | */ | |
|
99 | /** | |
|
100 | * @} | |
|
101 | */ | |
|
102 | ||
|
103 | ||
|
104 | #endif //__USBD_CONF__H__ | |
|
105 | ||
|
106 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |
|
107 |
@@ -0,0 +1,322 | |||
|
1 | /** | |
|
2 | ****************************************************************************** | |
|
3 | * @file usbd_desc.c | |
|
4 | * @author MCD Application Team | |
|
5 | * @version V1.1.0 | |
|
6 | * @date 19-March-2012 | |
|
7 | * @brief This file provides the USBD descriptors and string formating method. | |
|
8 | ****************************************************************************** | |
|
9 | * @attention | |
|
10 | * | |
|
11 | * <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2> | |
|
12 | * | |
|
13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); | |
|
14 | * You may not use this file except in compliance with the License. | |
|
15 | * You may obtain a copy of the License at: | |
|
16 | * | |
|
17 | * http://www.st.com/software_license_agreement_liberty_v2 | |
|
18 | * | |
|
19 | * Unless required by applicable law or agreed to in writing, software | |
|
20 | * distributed under the License is distributed on an "AS IS" BASIS, | |
|
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
|
22 | * See the License for the specific language governing permissions and | |
|
23 | * limitations under the License. | |
|
24 | * | |
|
25 | ****************************************************************************** | |
|
26 | */ | |
|
27 | ||
|
28 | /* Includes ------------------------------------------------------------------*/ | |
|
29 | #include "usbd_core.h" | |
|
30 | #include "usbd_desc.h" | |
|
31 | #include "usbd_req.h" | |
|
32 | #include "usbd_conf.h" | |
|
33 | #include "usb_regs.h" | |
|
34 | ||
|
35 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY | |
|
36 | * @{ | |
|
37 | */ | |
|
38 | ||
|
39 | ||
|
40 | /** @defgroup USBD_DESC | |
|
41 | * @brief USBD descriptors module | |
|
42 | * @{ | |
|
43 | */ | |
|
44 | ||
|
45 | /** @defgroup USBD_DESC_Private_TypesDefinitions | |
|
46 | * @{ | |
|
47 | */ | |
|
48 | /** | |
|
49 | * @} | |
|
50 | */ | |
|
51 | ||
|
52 | ||
|
53 | /** @defgroup USBD_DESC_Private_Defines | |
|
54 | * @{ | |
|
55 | */ | |
|
56 | #define USBD_VID 0x0483 | |
|
57 | ||
|
58 | #define USBD_PID 0x5740 | |
|
59 | ||
|
60 | /** @defgroup USB_String_Descriptors | |
|
61 | * @{ | |
|
62 | */ | |
|
63 | #define USBD_LANGID_STRING 0x409 | |
|
64 | #define USBD_MANUFACTURER_STRING "STMicroelectronics" | |
|
65 | ||
|
66 | #define USBD_PRODUCT_HS_STRING "STM32 Virtual ComPort in HS mode" | |
|
67 | #define USBD_SERIALNUMBER_HS_STRING "00000000050B" | |
|
68 | ||
|
69 | #define USBD_PRODUCT_FS_STRING "STM32 Virtual ComPort in FS Mode" | |
|
70 | #define USBD_SERIALNUMBER_FS_STRING "00000000050C" | |
|
71 | ||
|
72 | #define USBD_CONFIGURATION_HS_STRING "VCP Config" | |
|
73 | #define USBD_INTERFACE_HS_STRING "VCP Interface" | |
|
74 | ||
|
75 | #define USBD_CONFIGURATION_FS_STRING "VCP Config" | |
|
76 | #define USBD_INTERFACE_FS_STRING "VCP Interface" | |
|
77 | /** | |
|
78 | * @} | |
|
79 | */ | |
|
80 | ||
|
81 | ||
|
82 | /** @defgroup USBD_DESC_Private_Macros | |
|
83 | * @{ | |
|
84 | */ | |
|
85 | /** | |
|
86 | * @} | |
|
87 | */ | |
|
88 | ||
|
89 | ||
|
90 | /** @defgroup USBD_DESC_Private_Variables | |
|
91 | * @{ | |
|
92 | */ | |
|
93 | ||
|
94 | USBD_DEVICE USR_desc = | |
|
95 | { | |
|
96 | USBD_USR_DeviceDescriptor, | |
|
97 | USBD_USR_LangIDStrDescriptor, | |
|
98 | USBD_USR_ManufacturerStrDescriptor, | |
|
99 | USBD_USR_ProductStrDescriptor, | |
|
100 | USBD_USR_SerialStrDescriptor, | |
|
101 | USBD_USR_ConfigStrDescriptor, | |
|
102 | USBD_USR_InterfaceStrDescriptor, | |
|
103 | ||
|
104 | }; | |
|
105 | ||
|
106 | #ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED | |
|
107 | #if defined ( __ICCARM__ ) /*!< IAR Compiler */ | |
|
108 | #pragma data_alignment=4 | |
|
109 | #endif | |
|
110 | #endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */ | |
|
111 | /* USB Standard Device Descriptor */ | |
|
112 | __ALIGN_BEGIN uint8_t USBD_DeviceDesc[USB_SIZ_DEVICE_DESC] __ALIGN_END = | |
|
113 | { | |
|
114 | 0x12, /*bLength */ | |
|
115 | USB_DEVICE_DESCRIPTOR_TYPE, /*bDescriptorType*/ | |
|
116 | 0x00, /*bcdUSB */ | |
|
117 | 0x02, | |
|
118 | 0x00, /*bDeviceClass*/ | |
|
119 | 0x00, /*bDeviceSubClass*/ | |
|
120 | 0x00, /*bDeviceProtocol*/ | |
|
121 | USB_OTG_MAX_EP0_SIZE, /*bMaxPacketSize*/ | |
|
122 | LOBYTE(USBD_VID), /*idVendor*/ | |
|
123 | HIBYTE(USBD_VID), /*idVendor*/ | |
|
124 | LOBYTE(USBD_PID), /*idVendor*/ | |
|
125 | HIBYTE(USBD_PID), /*idVendor*/ | |
|
126 | 0x00, /*bcdDevice rel. 2.00*/ | |
|
127 | 0x02, | |
|
128 | USBD_IDX_MFC_STR, /*Index of manufacturer string*/ | |
|
129 | USBD_IDX_PRODUCT_STR, /*Index of product string*/ | |
|
130 | USBD_IDX_SERIAL_STR, /*Index of serial number string*/ | |
|
131 | USBD_CFG_MAX_NUM /*bNumConfigurations*/ | |
|
132 | } ; /* USB_DeviceDescriptor */ | |
|
133 | ||
|
134 | #ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED | |
|
135 | #if defined ( __ICCARM__ ) /*!< IAR Compiler */ | |
|
136 | #pragma data_alignment=4 | |
|
137 | #endif | |
|
138 | #endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */ | |
|
139 | /* USB Standard Device Descriptor */ | |
|
140 | __ALIGN_BEGIN uint8_t USBD_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_DESC] __ALIGN_END = | |
|
141 | { | |
|
142 | USB_LEN_DEV_QUALIFIER_DESC, | |
|
143 | USB_DESC_TYPE_DEVICE_QUALIFIER, | |
|
144 | 0x00, | |
|
145 | 0x02, | |
|
146 | 0x00, | |
|
147 | 0x00, | |
|
148 | 0x00, | |
|
149 | 0x40, | |
|
150 | 0x01, | |
|
151 | 0x00, | |
|
152 | }; | |
|
153 | ||
|
154 | #ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED | |
|
155 | #if defined ( __ICCARM__ ) /*!< IAR Compiler */ | |
|
156 | #pragma data_alignment=4 | |
|
157 | #endif | |
|
158 | #endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */ | |
|
159 | /* USB Standard Device Descriptor */ | |
|
160 | __ALIGN_BEGIN uint8_t USBD_LangIDDesc[USB_SIZ_STRING_LANGID] __ALIGN_END = | |
|
161 | { | |
|
162 | USB_SIZ_STRING_LANGID, | |
|
163 | USB_DESC_TYPE_STRING, | |
|
164 | LOBYTE(USBD_LANGID_STRING), | |
|
165 | HIBYTE(USBD_LANGID_STRING), | |
|
166 | }; | |
|
167 | /** | |
|
168 | * @} | |
|
169 | */ | |
|
170 | ||
|
171 | ||
|
172 | /** @defgroup USBD_DESC_Private_FunctionPrototypes | |
|
173 | * @{ | |
|
174 | */ | |
|
175 | /** | |
|
176 | * @} | |
|
177 | */ | |
|
178 | ||
|
179 | ||
|
180 | /** @defgroup USBD_DESC_Private_Functions | |
|
181 | * @{ | |
|
182 | */ | |
|
183 | ||
|
184 | /** | |
|
185 | * @brief USBD_USR_DeviceDescriptor | |
|
186 | * return the device descriptor | |
|
187 | * @param speed : current device speed | |
|
188 | * @param length : pointer to data length variable | |
|
189 | * @retval pointer to descriptor buffer | |
|
190 | */ | |
|
191 | uint8_t * USBD_USR_DeviceDescriptor( uint8_t speed , uint16_t *length) | |
|
192 | { | |
|
193 | *length = sizeof(USBD_DeviceDesc); | |
|
194 | return USBD_DeviceDesc; | |
|
195 | } | |
|
196 | ||
|
197 | /** | |
|
198 | * @brief USBD_USR_LangIDStrDescriptor | |
|
199 | * return the LangID string descriptor | |
|
200 | * @param speed : current device speed | |
|
201 | * @param length : pointer to data length variable | |
|
202 | * @retval pointer to descriptor buffer | |
|
203 | */ | |
|
204 | uint8_t * USBD_USR_LangIDStrDescriptor( uint8_t speed , uint16_t *length) | |
|
205 | { | |
|
206 | *length = sizeof(USBD_LangIDDesc); | |
|
207 | return USBD_LangIDDesc; | |
|
208 | } | |
|
209 | ||
|
210 | ||
|
211 | /** | |
|
212 | * @brief USBD_USR_ProductStrDescriptor | |
|
213 | * return the product string descriptor | |
|
214 | * @param speed : current device speed | |
|
215 | * @param length : pointer to data length variable | |
|
216 | * @retval pointer to descriptor buffer | |
|
217 | */ | |
|
218 | uint8_t * USBD_USR_ProductStrDescriptor( uint8_t speed , uint16_t *length) | |
|
219 | { | |
|
220 | ||
|
221 | ||
|
222 | if(speed == 0) | |
|
223 | { | |
|
224 | USBD_GetString (USBD_PRODUCT_HS_STRING, USBD_StrDesc, length); | |
|
225 | } | |
|
226 | else | |
|
227 | { | |
|
228 | USBD_GetString (USBD_PRODUCT_FS_STRING, USBD_StrDesc, length); | |
|
229 | } | |
|
230 | return USBD_StrDesc; | |
|
231 | } | |
|
232 | ||
|
233 | /** | |
|
234 | * @brief USBD_USR_ManufacturerStrDescriptor | |
|
235 | * return the manufacturer string descriptor | |
|
236 | * @param speed : current device speed | |
|
237 | * @param length : pointer to data length variable | |
|
238 | * @retval pointer to descriptor buffer | |
|
239 | */ | |
|
240 | uint8_t * USBD_USR_ManufacturerStrDescriptor( uint8_t speed , uint16_t *length) | |
|
241 | { | |
|
242 | USBD_GetString (USBD_MANUFACTURER_STRING, USBD_StrDesc, length); | |
|
243 | return USBD_StrDesc; | |
|
244 | } | |
|
245 | ||
|
246 | /** | |
|
247 | * @brief USBD_USR_SerialStrDescriptor | |
|
248 | * return the serial number string descriptor | |
|
249 | * @param speed : current device speed | |
|
250 | * @param length : pointer to data length variable | |
|
251 | * @retval pointer to descriptor buffer | |
|
252 | */ | |
|
253 | uint8_t * USBD_USR_SerialStrDescriptor( uint8_t speed , uint16_t *length) | |
|
254 | { | |
|
255 | if(speed == USB_OTG_SPEED_HIGH) | |
|
256 | { | |
|
257 | USBD_GetString (USBD_SERIALNUMBER_HS_STRING, USBD_StrDesc, length); | |
|
258 | } | |
|
259 | else | |
|
260 | { | |
|
261 | USBD_GetString (USBD_SERIALNUMBER_FS_STRING, USBD_StrDesc, length); | |
|
262 | } | |
|
263 | return USBD_StrDesc; | |
|
264 | } | |
|
265 | ||
|
266 | /** | |
|
267 | * @brief USBD_USR_ConfigStrDescriptor | |
|
268 | * return the configuration string descriptor | |
|
269 | * @param speed : current device speed | |
|
270 | * @param length : pointer to data length variable | |
|
271 | * @retval pointer to descriptor buffer | |
|
272 | */ | |
|
273 | uint8_t * USBD_USR_ConfigStrDescriptor( uint8_t speed , uint16_t *length) | |
|
274 | { | |
|
275 | if(speed == USB_OTG_SPEED_HIGH) | |
|
276 | { | |
|
277 | USBD_GetString (USBD_CONFIGURATION_HS_STRING, USBD_StrDesc, length); | |
|
278 | } | |
|
279 | else | |
|
280 | { | |
|
281 | USBD_GetString (USBD_CONFIGURATION_FS_STRING, USBD_StrDesc, length); | |
|
282 | } | |
|
283 | return USBD_StrDesc; | |
|
284 | } | |
|
285 | ||
|
286 | ||
|
287 | /** | |
|
288 | * @brief USBD_USR_InterfaceStrDescriptor | |
|
289 | * return the interface string descriptor | |
|
290 | * @param speed : current device speed | |
|
291 | * @param length : pointer to data length variable | |
|
292 | * @retval pointer to descriptor buffer | |
|
293 | */ | |
|
294 | uint8_t * USBD_USR_InterfaceStrDescriptor( uint8_t speed , uint16_t *length) | |
|
295 | { | |
|
296 | if(speed == 0) | |
|
297 | { | |
|
298 | USBD_GetString (USBD_INTERFACE_HS_STRING, USBD_StrDesc, length); | |
|
299 | } | |
|
300 | else | |
|
301 | { | |
|
302 | USBD_GetString (USBD_INTERFACE_FS_STRING, USBD_StrDesc, length); | |
|
303 | } | |
|
304 | return USBD_StrDesc; | |
|
305 | } | |
|
306 | ||
|
307 | /** | |
|
308 | * @} | |
|
309 | */ | |
|
310 | ||
|
311 | ||
|
312 | /** | |
|
313 | * @} | |
|
314 | */ | |
|
315 | ||
|
316 | ||
|
317 | /** | |
|
318 | * @} | |
|
319 | */ | |
|
320 | ||
|
321 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | |
|
322 |
@@ -0,0 +1,120 | |||
|
1 | /** | |
|
2 | ****************************************************************************** | |
|
3 | * @file usbd_desc.h | |
|
4 | * @author MCD Application Team | |
|
5 | * @version V1.1.0 | |
|
6 | * @date 19-March-2012 | |
|
7 | * @brief header file for the usbd_desc.c file | |
|
8 | ****************************************************************************** | |
|
9 | * @attention | |
|
10 | * | |
|
11 | * <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2> | |
|
12 | * | |
|
13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); | |
|
14 | * You may not use this file except in compliance with the License. | |
|
15 | * You may obtain a copy of the License at: | |
|
16 | * | |
|
17 | * http://www.st.com/software_license_agreement_liberty_v2 | |
|
18 | * | |
|
19 | * Unless required by applicable law or agreed to in writing, software | |
|
20 | * distributed under the License is distributed on an "AS IS" BASIS, | |
|
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
|
22 | * See the License for the specific language governing permissions and | |
|
23 | * limitations under the License. | |
|
24 | * | |
|
25 | ****************************************************************************** | |
|
26 | */ | |
|
27 | ||
|
28 | /* Define to prevent recursive inclusion -------------------------------------*/ | |
|
29 | ||
|
30 | #ifndef __USB_DESC_H | |
|
31 | #define __USB_DESC_H | |
|
32 | ||
|
33 | /* Includes ------------------------------------------------------------------*/ | |
|
34 | #include "usbd_def.h" | |
|
35 | ||
|
36 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY | |
|
37 | * @{ | |
|
38 | */ | |
|
39 | ||
|
40 | /** @defgroup USB_DESC | |
|
41 | * @brief general defines for the usb device library file | |
|
42 | * @{ | |
|
43 | */ | |
|
44 | ||
|
45 | /** @defgroup USB_DESC_Exported_Defines | |
|
46 | * @{ | |
|
47 | */ | |
|
48 | #define USB_DEVICE_DESCRIPTOR_TYPE 0x01 | |
|
49 | #define USB_CONFIGURATION_DESCRIPTOR_TYPE 0x02 | |
|
50 | #define USB_STRING_DESCRIPTOR_TYPE 0x03 | |
|
51 | #define USB_INTERFACE_DESCRIPTOR_TYPE 0x04 | |
|
52 | #define USB_ENDPOINT_DESCRIPTOR_TYPE 0x05 | |
|
53 | #define USB_SIZ_DEVICE_DESC 18 | |
|
54 | #define USB_SIZ_STRING_LANGID 4 | |
|
55 | ||
|
56 | /** | |
|
57 | * @} | |
|
58 | */ | |
|
59 | ||
|
60 | ||
|
61 | /** @defgroup USBD_DESC_Exported_TypesDefinitions | |
|
62 | * @{ | |
|
63 | */ | |
|
64 | /** | |
|
65 | * @} | |
|
66 | */ | |
|
67 | ||
|
68 | ||
|
69 | ||
|
70 | /** @defgroup USBD_DESC_Exported_Macros | |
|
71 | * @{ | |
|
72 | */ | |
|
73 | /** | |
|
74 | * @} | |
|
75 | */ | |
|
76 | ||
|
77 | /** @defgroup USBD_DESC_Exported_Variables | |
|
78 | * @{ | |
|
79 | */ | |
|
80 | extern uint8_t USBD_DeviceDesc [USB_SIZ_DEVICE_DESC]; | |
|
81 | extern uint8_t USBD_StrDesc[USB_MAX_STR_DESC_SIZ]; | |
|
82 | extern uint8_t USBD_OtherSpeedCfgDesc[USB_LEN_CFG_DESC]; | |
|
83 | extern uint8_t USBD_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_DESC]; | |
|
84 | extern uint8_t USBD_LangIDDesc[USB_SIZ_STRING_LANGID]; | |
|
85 | extern USBD_DEVICE USR_desc; | |
|
86 | /** | |
|
87 | * @} | |
|
88 | */ | |
|
89 | ||
|
90 | /** @defgroup USBD_DESC_Exported_FunctionsPrototype | |
|
91 | * @{ | |
|
92 | */ | |
|
93 | ||
|
94 | ||
|
95 | uint8_t * USBD_USR_DeviceDescriptor( uint8_t speed , uint16_t *length); | |
|
96 | uint8_t * USBD_USR_LangIDStrDescriptor( uint8_t speed , uint16_t *length); | |
|
97 | uint8_t * USBD_USR_ManufacturerStrDescriptor ( uint8_t speed , uint16_t *length); | |
|
98 | uint8_t * USBD_USR_ProductStrDescriptor ( uint8_t speed , uint16_t *length); | |
|
99 | uint8_t * USBD_USR_SerialStrDescriptor( uint8_t speed , uint16_t *length); | |
|
100 | uint8_t * USBD_USR_ConfigStrDescriptor( uint8_t speed , uint16_t *length); | |
|
101 | uint8_t * USBD_USR_InterfaceStrDescriptor( uint8_t speed , uint16_t *length); | |
|
102 | ||
|
103 | #ifdef USB_SUPPORT_USER_STRING_DESC | |
|
104 | uint8_t * USBD_USR_USRStringDesc (uint8_t speed, uint8_t idx , uint16_t *length); | |
|
105 | #endif /* USB_SUPPORT_USER_STRING_DESC */ | |
|
106 | ||
|
107 | /** | |
|
108 | * @} | |
|
109 | */ | |
|
110 | ||
|
111 | #endif /* __USBD_DESC_H */ | |
|
112 | ||
|
113 | /** | |
|
114 | * @} | |
|
115 | */ | |
|
116 | ||
|
117 | /** | |
|
118 | * @} | |
|
119 | */ | |
|
120 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,203 | |||
|
1 | /** | |
|
2 | ****************************************************************************** | |
|
3 | * @file usbd_usr.c | |
|
4 | * @author MCD Application Team | |
|
5 | * @version V1.1.0 | |
|
6 | * @date 19-March-2012 | |
|
7 | * @brief This file includes the user application layer | |
|
8 | ****************************************************************************** | |
|
9 | * @attention | |
|
10 | * | |
|
11 | * <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2> | |
|
12 | * | |
|
13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); | |
|
14 | * You may not use this file except in compliance with the License. | |
|
15 | * You may obtain a copy of the License at: | |
|
16 | * | |
|
17 | * http://www.st.com/software_license_agreement_liberty_v2 | |
|
18 | * | |
|
19 | * Unless required by applicable law or agreed to in writing, software | |
|
20 | * distributed under the License is distributed on an "AS IS" BASIS, | |
|
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
|
22 | * See the License for the specific language governing permissions and | |
|
23 | * limitations under the License. | |
|
24 | * | |
|
25 | ****************************************************************************** | |
|
26 | */ | |
|
27 | ||
|
28 | /* Includes ------------------------------------------------------------------*/ | |
|
29 | #include "usbd_usr.h" | |
|
30 | #include "usbd_ioreq.h" | |
|
31 | //#include "lcd_log.h" | |
|
32 | ||
|
33 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY | |
|
34 | * @{ | |
|
35 | */ | |
|
36 | ||
|
37 | /** @defgroup USBD_USR | |
|
38 | * @brief This file includes the user application layer | |
|
39 | * @{ | |
|
40 | */ | |
|
41 | ||
|
42 | /** @defgroup USBD_USR_Private_TypesDefinitions | |
|
43 | * @{ | |
|
44 | */ | |
|
45 | /** | |
|
46 | * @} | |
|
47 | */ | |
|
48 | ||
|
49 | ||
|
50 | /** @defgroup USBD_USR_Private_Defines | |
|
51 | * @{ | |
|
52 | */ | |
|
53 | /** | |
|
54 | * @} | |
|
55 | */ | |
|
56 | ||
|
57 | ||
|
58 | /** @defgroup USBD_USR_Private_Macros | |
|
59 | * @{ | |
|
60 | */ | |
|
61 | /** | |
|
62 | * @} | |
|
63 | */ | |
|
64 | ||
|
65 | ||
|
66 | /** @defgroup USBD_USR_Private_Variables | |
|
67 | * @{ | |
|
68 | */ | |
|
69 | ||
|
70 | USBD_Usr_cb_TypeDef USR_cb = | |
|
71 | { | |
|
72 | USBD_USR_Init, | |
|
73 | USBD_USR_DeviceReset, | |
|
74 | USBD_USR_DeviceConfigured, | |
|
75 | USBD_USR_DeviceSuspended, | |
|
76 | USBD_USR_DeviceResumed, | |
|
77 | ||
|
78 | ||
|
79 | USBD_USR_DeviceConnected, | |
|
80 | USBD_USR_DeviceDisconnected, | |
|
81 | }; | |
|
82 | ||
|
83 | /** | |
|
84 | * @} | |
|
85 | */ | |
|
86 | ||
|
87 | /** @defgroup USBD_USR_Private_Constants | |
|
88 | * @{ | |
|
89 | */ | |
|
90 | ||
|
91 | /** | |
|
92 | * @} | |
|
93 | */ | |
|
94 | ||
|
95 | ||
|
96 | ||
|
97 | /** @defgroup USBD_USR_Private_FunctionPrototypes | |
|
98 | * @{ | |
|
99 | */ | |
|
100 | /** | |
|
101 | * @} | |
|
102 | */ | |
|
103 | ||
|
104 | ||
|
105 | /** @defgroup USBD_USR_Private_Functions | |
|
106 | * @{ | |
|
107 | */ | |
|
108 | ||
|
109 | /** | |
|
110 | * @brief USBD_USR_Init | |
|
111 | * Displays the message on LCD for host lib initialization | |
|
112 | * @param None | |
|
113 | * @retval None | |
|
114 | */ | |
|
115 | void USBD_USR_Init(void) | |
|
116 | { | |
|
117 | /* Initialize LEDs */ | |
|
118 | //STM_EVAL_LEDInit(LED1); | |
|
119 | //STM_EVAL_LEDInit(LED2); | |
|
120 | //STM_EVAL_LEDInit(LED3); | |
|
121 | //STM_EVAL_LEDInit(LED4); | |
|
122 | ||
|
123 | } | |
|
124 | ||
|
125 | /** | |
|
126 | * @brief USBD_USR_DeviceReset | |
|
127 | * Displays the message on LCD on device Reset Event | |
|
128 | * @param speed : device speed | |
|
129 | * @retval None | |
|
130 | */ | |
|
131 | void USBD_USR_DeviceReset(uint8_t speed ) | |
|
132 | { | |
|
133 | ||
|
134 | } | |
|
135 | ||
|
136 | ||
|
137 | /** | |
|
138 | * @brief USBD_USR_DeviceConfigured | |
|
139 | * Displays the message on LCD on device configuration Event | |
|
140 | * @param None | |
|
141 | * @retval Staus | |
|
142 | */ | |
|
143 | void USBD_USR_DeviceConfigured (void) | |
|
144 | { | |
|
145 | } | |
|
146 | ||
|
147 | /** | |
|
148 | * @brief USBD_USR_DeviceSuspended | |
|
149 | * Displays the message on LCD on device suspend Event | |
|
150 | * @param None | |
|
151 | * @retval None | |
|
152 | */ | |
|
153 | void USBD_USR_DeviceSuspended(void) | |
|
154 | { | |
|
155 | ||
|
156 | /* Users can do their application actions here for the USB-Reset */ | |
|
157 | } | |
|
158 | ||
|
159 | ||
|
160 | /** | |
|
161 | * @brief USBD_USR_DeviceResumed | |
|
162 | * Displays the message on LCD on device resume Event | |
|
163 | * @param None | |
|
164 | * @retval None | |
|
165 | */ | |
|
166 | void USBD_USR_DeviceResumed(void) | |
|
167 | { | |
|
168 | ||
|
169 | /* Users can do their application actions here for the USB-Reset */ | |
|
170 | } | |
|
171 | ||
|
172 | ||
|
173 | /** | |
|
174 | * @brief USBD_USR_DeviceConnected | |
|
175 | * Displays the message on LCD on device connection Event | |
|
176 | * @param None | |
|
177 | * @retval Staus | |
|
178 | */ | |
|
179 | void USBD_USR_DeviceConnected (void) | |
|
180 | { | |
|
181 | ||
|
182 | } | |
|
183 | ||
|
184 | ||
|
185 | /** | |
|
186 | * @brief USBD_USR_DeviceDisonnected | |
|
187 | * Displays the message on LCD on device disconnection Event | |
|
188 | * @param None | |
|
189 | * @retval Staus | |
|
190 | */ | |
|
191 | void USBD_USR_DeviceDisconnected (void) | |
|
192 | { | |
|
193 | ||
|
194 | } | |
|
195 | /** | |
|
196 | * @} | |
|
197 | */ | |
|
198 | ||
|
199 | /** | |
|
200 | * @} | |
|
201 | */ | |
|
202 | ||
|
203 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@@ -0,0 +1,28 | |||
|
1 | TEMPLATE = lib | |
|
2 | ||
|
3 | TARGET=bsp | |
|
4 | CONFIG += bsp gui audio fs | |
|
5 | ||
|
6 | BSP = OPLAYER | |
|
7 | ||
|
8 | UCMODEL=stm32f4 | |
|
9 | ||
|
10 | SOURCES += bsp.c \ | |
|
11 | bsp_spi.c \ | |
|
12 | bsp_lcd.c \ | |
|
13 | bsp_sdcard.c \ | |
|
14 | bsp_audio.c | |
|
15 | ||
|
16 | HEADERS += bsp.h \ | |
|
17 | ../../common/bsp_spi.h \ | |
|
18 | ../../common/bsp_i2c.h \ | |
|
19 | ../../common/bsp_gpio.h | |
|
20 | ||
|
21 | INCLUDEPATH += ../../common/ | |
|
22 | ||
|
23 | LIBS+= -lgpio -luart -li2c -lspi | |
|
24 | ||
|
25 | BSPFILE = bsp.pri | |
|
26 | ||
|
27 | ||
|
28 |
@@ -0,0 +1,204 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the libuc, microcontroler library | |
|
3 | -- Copyright (C) 2013, Alexis Jeandet | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | ------------------------------------------------------------------------------- | |
|
19 | -- Author : Alexis Jeandet | |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
|
21 | -------------------------------------------------------------------------------*/ | |
|
22 | #include "bsp.h" | |
|
23 | #include <streamdevices.h> | |
|
24 | #include <malloc.h> | |
|
25 | #include <gpio.h> | |
|
26 | #include <uart.h> | |
|
27 | #include <stdio.h> | |
|
28 | #include <stm32f4xx_gpio.h> | |
|
29 | #include <stm32f4xx_fsmc.h> | |
|
30 | #include <i2c.h> | |
|
31 | #include <core.h> | |
|
32 | #include <terminal.h> | |
|
33 | #include "bsp_gpio.h" | |
|
34 | #include "bsp_i2c.h" | |
|
35 | #include "bsp_i2c.h" | |
|
36 | ||
|
37 | uint32_t OSC0 =8000000; | |
|
38 | uint32_t INTOSC =16000000; | |
|
39 | uint32_t RTCOSC =32768; | |
|
40 | uint32_t currentCpuFreq=0; | |
|
41 | extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__]; | |
|
42 | ||
|
43 | ||
|
44 | ||
|
45 | LCD_IF_t lcdIF0={ | |
|
46 | .init = &bsp_FSMC_init, | |
|
47 | .writereg = &bsp_lcd0_write_reg, | |
|
48 | .readreg = &bsp_lcd0_read_reg, | |
|
49 | .writeGRAM = &bsp_lcd0_writeGRAM, | |
|
50 | .readGRAM = &bsp_lcd0_readGRAM | |
|
51 | }; | |
|
52 | ||
|
53 | LCD_t lcd0={ | |
|
54 | .interface = &lcdIF0, | |
|
55 | .init = &ili9328init, | |
|
56 | .paint = &ili9328paint, | |
|
57 | .paintText = &ili9328paintText, | |
|
58 | .paintFilRect = &ili9328paintFilRect, | |
|
59 | .getPix = &ili9328getPix, | |
|
60 | .refreshenable = &ili9328refreshenable, | |
|
61 | .width= 240, | |
|
62 | .height = 320 | |
|
63 | }; | |
|
64 | ||
|
65 | terminal_t terminal0; | |
|
66 | ||
|
67 | ||
|
68 | ||
|
69 | float VREF0 =(float)3.3; | |
|
70 | volatile vs10XXDev audioCodec0; | |
|
71 | ||
|
72 | ADS7843_t TC0; | |
|
73 | ||
|
74 | sdcardDev sdcard2; | |
|
75 | blkdevice sdcard2blkdev; | |
|
76 | dikpartition sdcard2Part1; | |
|
77 | FAT32fs sdcard2FAT32part1; | |
|
78 | dikpartition sdcard2Part2; | |
|
79 | FAT32fs sdcard2FAT32part2; | |
|
80 | dikpartition sdcard2Part3; | |
|
81 | FAT32fs sdcard2FAT32part3; | |
|
82 | dikpartition sdcard2Part4; | |
|
83 | FAT32fs sdcard2FAT32part4; | |
|
84 | ||
|
85 | int bsp_init() | |
|
86 | { | |
|
87 | int i=0; | |
|
88 | for(i=0;i<__MAX_OPENED_FILES__;i++) | |
|
89 | { | |
|
90 | __opnfiles__[i] = NULL; | |
|
91 | } | |
|
92 | bsp_GPIO_init(); | |
|
93 | bsp_uart_init(); | |
|
94 | bsp_iic_init(); | |
|
95 | bsp_FSMC_init(); | |
|
96 | bsp_GTerm_init(); | |
|
97 | bsp_spi_init(); | |
|
98 | bsp_SD_init(); | |
|
99 | bsp_Audio_init(); | |
|
100 | bsp_TC_init(); | |
|
101 | printf("\r=====================\n\r"); | |
|
102 | printf( "=====================\n\r"); | |
|
103 | printf(BSP); | |
|
104 | printf(" initialised\n\r"); | |
|
105 | printf( "=====================\n\r"); | |
|
106 | #if __BYTE_ORDER__==__ORDER_BIG_ENDIAN__ | |
|
107 | printf( "BIG ENDIAN MACHINE\n\r"); | |
|
108 | #else | |
|
109 | printf( "LITLE ENDIAN MACHINE\n\r"); | |
|
110 | #endif | |
|
111 | return 1; | |
|
112 | } | |
|
113 | ||
|
114 | void bsp_GPIO_init() | |
|
115 | { | |
|
116 | gpio_t GPIO_Out_init_List[]={LED1,LED2,LCD_RESET,LCD_BACKL,VS1053xCS,VS1053xDCS,\ | |
|
117 | VS1053xRESET,SDCARD2CS,LCD_RS,LCD_CS,TC_CS}; | |
|
118 | ||
|
119 | gpio_t GPIO_In_init_List[]={VS1053DREQ,SDCARD2CD,BP3,TC_BUSY}; | |
|
120 | ||
|
121 | bsp_gpio_set_outputs(GPIO_Out_init_List,11); | |
|
122 | bsp_gpio_set_inputs(GPIO_In_init_List,4); | |
|
123 | ||
|
124 | gpioclr(VS1053xRESET); | |
|
125 | gpioset(VS1053xCS); | |
|
126 | gpioset(VS1053xDCS); | |
|
127 | gpioset(SDCARD2CS); | |
|
128 | gpioclr(LCD_RESET); | |
|
129 | gpioclr(LCD_BACKL); | |
|
130 | } | |
|
131 | ||
|
132 | void bsp_uart_init() | |
|
133 | { | |
|
134 | ||
|
135 | } | |
|
136 | ||
|
137 | ||
|
138 | ||
|
139 | ||
|
140 | ||
|
141 | int bsp_TC_init() | |
|
142 | { | |
|
143 | ads7843init(&TC0,TC_SPI,tcsetncs,tcbusy); | |
|
144 | } | |
|
145 | ||
|
146 | ||
|
147 | ||
|
148 | ||
|
149 | void bsp_iic_init() | |
|
150 | { | |
|
151 | // i2copenandconfig(i2c2,0,10000,PF0,PF1); | |
|
152 | } | |
|
153 | ||
|
154 | ||
|
155 | ||
|
156 | ||
|
157 | void tcsetncs(char val) | |
|
158 | { | |
|
159 | if(val) | |
|
160 | gpioset(TC_CS); | |
|
161 | else | |
|
162 | gpioclr(TC_CS); | |
|
163 | } | |
|
164 | ||
|
165 | int tcbusy() | |
|
166 | { | |
|
167 | return gpiogetval(TC_BUSY); | |
|
168 | } | |
|
169 | ||
|
170 | ||
|
171 | ||
|
172 | ||
|
173 | ||
|
174 | void bsp_GTerm_init() | |
|
175 | { | |
|
176 | if(__opnfiles__[1]==NULL) | |
|
177 | { | |
|
178 | streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice)); | |
|
179 | terminal_init(&terminal0 ,&lcd0,&ComicSansMS_8,fd1); | |
|
180 | terminal_settextColor(&terminal0,0); | |
|
181 | __opnfiles__[1] = fd1; | |
|
182 | } | |
|
183 | else | |
|
184 | { | |
|
185 | ||
|
186 | } | |
|
187 | } | |
|
188 | ||
|
189 | ||
|
190 | ||
|
191 | ||
|
192 | ||
|
193 | ||
|
194 | ||
|
195 | ||
|
196 | ||
|
197 | ||
|
198 | ||
|
199 | ||
|
200 | ||
|
201 | ||
|
202 | ||
|
203 | ||
|
204 |
@@ -0,0 +1,151 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the libuc, microcontroler library | |
|
3 | -- Copyright (C) 2011, Alexis Jeandet | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | ------------------------------------------------------------------------------- | |
|
19 | -- Author : Alexis Jeandet | |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
|
21 | -------------------------------------------------------------------------------*/ | |
|
22 | #ifndef BSP_H | |
|
23 | #define BSP_H | |
|
24 | #include <stm32f4xx.h> | |
|
25 | #include <stm32f4xx_gpio.h> | |
|
26 | #include <stm32f4xx_rcc.h> | |
|
27 | #include <gpio.h> | |
|
28 | #include <spi.h> | |
|
29 | #include <ili9328.h> | |
|
30 | #include <genericLCD_Controler.h> | |
|
31 | #include <sdcard-spi.h> | |
|
32 | #include <sdcard.h> | |
|
33 | #include <mbr.h> | |
|
34 | #include <VS10XX.h> | |
|
35 | #include <fat32.h> | |
|
36 | #include <ADS7843.h> | |
|
37 | ||
|
38 | #define GPIOGETPORT(gpio) ((GPIO_TypeDef*)(((((uint32_t)gpio) & (uint32_t)0x0000FF00)*(uint32_t)4) + (uint32_t)GPIOA)) | |
|
39 | #define GPIOPORTNUM(gpio) (((uint32_t)(gpio) & (uint32_t)0x0000FF00)>>(uint32_t)8) | |
|
40 | ||
|
41 | ||
|
42 | #define __MAX_OPENED_FILES__ 4 | |
|
43 | #define __FS_ROOT_SIZE__ 4 | |
|
44 | ||
|
45 | ||
|
46 | #define LED1 PC15 | |
|
47 | #define LED2 PC14 | |
|
48 | ||
|
49 | #define BP3 PA0 | |
|
50 | ||
|
51 | #define LCD_RESET PD10 | |
|
52 | #define LCD_BACKL PE11 | |
|
53 | #define LCD_RS PE4 | |
|
54 | #define LCD_CS PD7 | |
|
55 | ||
|
56 | #define TC_SPI spi2 | |
|
57 | #define TC_PEN PC4 | |
|
58 | #define TC_BUSY PC5 | |
|
59 | #define TC_CS PB12 | |
|
60 | #define TC_CLK PB13 | |
|
61 | #define TC_DOUT PB14 | |
|
62 | #define TC_DIN PB15 | |
|
63 | ||
|
64 | #define VS1053SPI spi1 | |
|
65 | #define VS1053xCS PA3 | |
|
66 | #define VS1053xRESET PA2 | |
|
67 | #define VS1053xDCS PA4 | |
|
68 | #define VS1053DREQ PA1 | |
|
69 | #define VS1053MISO PA6 | |
|
70 | #define VS1053MOSI PA7 | |
|
71 | #define VS1053SCK PA5 | |
|
72 | ||
|
73 | ||
|
74 | ||
|
75 | #define SDCARD2SPI spi3 | |
|
76 | #define SDCARD2CS PB8 | |
|
77 | #define SDCARD2CD PB9 | |
|
78 | #define SDCARD2MISO PB4 | |
|
79 | #define SDCARD2MOSI PB5 | |
|
80 | #define SDCARD2SCK PB3 | |
|
81 | ||
|
82 | extern float VREF0; | |
|
83 | ||
|
84 | extern uint32_t currentCpuFreq; | |
|
85 | extern LCD_t lcd0; | |
|
86 | extern ADS7843_t TC0; | |
|
87 | ||
|
88 | extern volatile vs10XXDev audioCodec0; | |
|
89 | ||
|
90 | extern sdcardDev sdcard2; | |
|
91 | extern blkdevice sdcard2blkdev; | |
|
92 | extern dikpartition sdcard2Part1; | |
|
93 | extern FAT32fs sdcard2FAT32part1; | |
|
94 | extern dikpartition sdcard2Part2; | |
|
95 | extern FAT32fs sdcard2FAT32part2; | |
|
96 | extern dikpartition sdcard2Part3; | |
|
97 | extern FAT32fs sdcard2FAT32part3; | |
|
98 | extern dikpartition sdcard2Part4; | |
|
99 | extern FAT32fs sdcard2FAT32part4; | |
|
100 | ||
|
101 | extern int bsp_init(); | |
|
102 | ||
|
103 | extern void bsp_GPIO_init(); | |
|
104 | extern void bsp_uart_init(); | |
|
105 | extern void bsp_iic_init(); | |
|
106 | extern void bsp_spi_init(); | |
|
107 | extern void bsp_SD_init(); | |
|
108 | extern void bsp_Audio_init(); | |
|
109 | extern void bsp_GTerm_init(); | |
|
110 | extern int bsp_FSMC_init(); | |
|
111 | extern int bsp_TC_init(); | |
|
112 | extern void tcsetncs(char val); | |
|
113 | extern int tcbusy(); | |
|
114 | /* VS1053 */ | |
|
115 | extern void vs1052setXCS(char val); | |
|
116 | extern void vs1052setXDCS(char val); | |
|
117 | extern void vs1052setRST(char val); | |
|
118 | extern int vs10XXDREQ(); | |
|
119 | ||
|
120 | /* SD CARD */ | |
|
121 | void bsppowersdcard(char onoff); | |
|
122 | char bspsdcardpresent(); | |
|
123 | void bspsdcardselect(char YESNO); | |
|
124 | char bspsdcardwriteprotected(); | |
|
125 | ||
|
126 | ||
|
127 | void bsp_lcd0_write_reg(uint32_t reg,uint32_t data); | |
|
128 | uint32_t bsp_lcd0_read_reg(uint32_t reg); | |
|
129 | void bsp_lcd0_writeGRAM(void *buffer, uint32_t count); | |
|
130 | void bsp_lcd0_readGRAM(void *buffer, uint32_t count); | |
|
131 | ||
|
132 | #endif | |
|
133 | ||
|
134 | ||
|
135 | ||
|
136 | ||
|
137 | ||
|
138 | ||
|
139 | ||
|
140 | ||
|
141 | ||
|
142 | ||
|
143 | ||
|
144 | ||
|
145 | ||
|
146 | ||
|
147 | ||
|
148 | ||
|
149 | ||
|
150 | ||
|
151 |
@@ -0,0 +1,94 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the libuc, microcontroler library | |
|
3 | -- Copyright (C) 2013, Alexis Jeandet | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | ------------------------------------------------------------------------------- | |
|
19 | -- Author : Alexis Jeandet | |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
|
21 | -------------------------------------------------------------------------------*/ | |
|
22 | #include "bsp.h" | |
|
23 | #include <streamdevices.h> | |
|
24 | #include <malloc.h> | |
|
25 | #include <gpio.h> | |
|
26 | #include <uart.h> | |
|
27 | #include <stdio.h> | |
|
28 | #include <stm32f4xx_gpio.h> | |
|
29 | #include <stm32f4xx_fsmc.h> | |
|
30 | #include <i2c.h> | |
|
31 | #include <core.h> | |
|
32 | #include <terminal.h> | |
|
33 | ||
|
34 | void bsp_Audio_init() | |
|
35 | { | |
|
36 | vs10XXopen(&audioCodec0,VS1053SPI,vs1052setXCS,vs1052setRST,vs1052setXDCS,vs10XXDREQ); | |
|
37 | if(audioCodec0.VERSION!=UNKNOWN) | |
|
38 | { | |
|
39 | printf("detected Audio codec "); | |
|
40 | switch (audioCodec0.VERSION) { | |
|
41 | case VS1001: | |
|
42 | printf("VS1001\n"); | |
|
43 | break; | |
|
44 | case VS1011: | |
|
45 | printf("VS1011\n"); | |
|
46 | break; | |
|
47 | case VS1002: | |
|
48 | printf("VS1002\n"); | |
|
49 | break; | |
|
50 | case VS1003: | |
|
51 | printf("VS1003\n"); | |
|
52 | break; | |
|
53 | case VS1053: | |
|
54 | printf("VS1053\n"); | |
|
55 | break; | |
|
56 | case VS1033: | |
|
57 | printf("VS1033\n"); | |
|
58 | break; | |
|
59 | case VS1103: | |
|
60 | printf("VS1103\n"); | |
|
61 | break; | |
|
62 | default: | |
|
63 | printf("Unknown device\n"); | |
|
64 | break; | |
|
65 | } | |
|
66 | } | |
|
67 | } | |
|
68 | ||
|
69 | ||
|
70 | ||
|
71 | void vs1052setXCS(char val) | |
|
72 | { | |
|
73 | gpiosetval(VS1053xCS,(int)val); | |
|
74 | } | |
|
75 | ||
|
76 | void vs1052setXDCS(char val) | |
|
77 | { | |
|
78 | //gpiosetval(LED1,(int)val); | |
|
79 | gpiosetval(VS1053xDCS,(int)val); | |
|
80 | } | |
|
81 | ||
|
82 | void vs1052setRST(char val) | |
|
83 | { | |
|
84 | if(val) | |
|
85 | gpioset(VS1053xRESET); | |
|
86 | else | |
|
87 | gpioclr(VS1053xRESET); | |
|
88 | } | |
|
89 | ||
|
90 | ||
|
91 | int vs10XXDREQ() | |
|
92 | { | |
|
93 | return gpiogetval(VS1053DREQ); | |
|
94 | } |
@@ -0,0 +1,266 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the libuc, microcontroler library | |
|
3 | -- Copyright (C) 2013, Alexis Jeandet | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | ------------------------------------------------------------------------------- | |
|
19 | -- Author : Alexis Jeandet | |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
|
21 | -------------------------------------------------------------------------------*/ | |
|
22 | #include "bsp.h" | |
|
23 | #include <streamdevices.h> | |
|
24 | #include <malloc.h> | |
|
25 | #include <gpio.h> | |
|
26 | #include <uart.h> | |
|
27 | #include <stdio.h> | |
|
28 | #include <stm32f4xx_gpio.h> | |
|
29 | #include <stm32f4xx_fsmc.h> | |
|
30 | #include <i2c.h> | |
|
31 | #include <core.h> | |
|
32 | #include <terminal.h> | |
|
33 | ||
|
34 | ||
|
35 | #define clr_RS gpioclr(LCD_RS) | |
|
36 | #define set_RS gpioset(LCD_RS) | |
|
37 | ||
|
38 | #define clr_CS gpioclr(LCD_CS) | |
|
39 | #define set_CS gpioset(LCD_CS) | |
|
40 | ||
|
41 | volatile int8_t* lcd0_CMD=(volatile int8_t*)0x60000000; | |
|
42 | volatile int16_t* lcd0_CMD16=(volatile int16_t*)0x60000000; | |
|
43 | volatile int8_t* lcd0_DATA=(volatile int8_t*)0x61FFFFF0; | |
|
44 | volatile int16_t* lcd0_DATA16=(volatile int16_t*)0x61FFFFF0; | |
|
45 | ||
|
46 | /* | |
|
47 | D0 PD14 D1 PD15 D2 PD0 D3 PD1 D4 PE7 | |
|
48 | D5 PE8 D6 PE9 D7 PE10 | |
|
49 | A20 PE4 = RS FSMC_NE1 PD7 CS FSMC_NWE PD5 W/S | |
|
50 | FSMC_NOE PD4 RD | |
|
51 | */ | |
|
52 | ||
|
53 | int bsp_FSMC_init() | |
|
54 | { | |
|
55 | ||
|
56 | gpio_t LCD_DBxList[]={PD14,PD15,PD0,PD1,PE7,PE8,PE9,PE10\ | |
|
57 | ,PD4,PD5}; | |
|
58 | // gpio_t LCD_DBxList[]={PD14,PD15,PD0,PD1,PE7,PE8,PE9,PE10\ | |
|
59 | // ,PD4,PD5,PD7,PE4}; | |
|
60 | for(int i=0;i<10;i++) | |
|
61 | { | |
|
62 | gpio_t LCD_DBx = gpioopen(LCD_DBxList[i]); | |
|
63 | LCD_DBx |= gpiohighspeed | gpioaf | gpiopushpulltype | gpionopulltype; | |
|
64 | gpiosetconfig(&LCD_DBx); | |
|
65 | GPIO_PinAFConfig(GPIOGETPORT(LCD_DBx), (uint8_t)(LCD_DBx & 0xF), GPIO_AF_FSMC); | |
|
66 | } | |
|
67 | ||
|
68 | FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure; | |
|
69 | FSMC_NORSRAMTimingInitTypeDef p; | |
|
70 | ||
|
71 | /* Enable FSMC clock */ | |
|
72 | RCC_AHB3PeriphClockCmd(RCC_AHB3Periph_FSMC, ENABLE); | |
|
73 | ||
|
74 | /*-- FSMC Configuration ------------------------------------------------------*/ | |
|
75 | /*----------------------- SRAM Bank 3 ----------------------------------------*/ | |
|
76 | /* FSMC_Bank1_NORSRAM4 configuration */ | |
|
77 | p.FSMC_AddressSetupTime = 1;//3 | |
|
78 | p.FSMC_AddressHoldTime = 1;//3 | |
|
79 | //ili9328 -> data setup time > 10ns | |
|
80 | p.FSMC_DataSetupTime = 6; | |
|
81 | p.FSMC_CLKDivision = 3; | |
|
82 | if(getCpuFreq()>=100*1000*1000) | |
|
83 | { | |
|
84 | p.FSMC_CLKDivision = 3; | |
|
85 | p.FSMC_DataSetupTime = 6;// 11; | |
|
86 | } | |
|
87 | p.FSMC_BusTurnAroundDuration = 0; | |
|
88 | p.FSMC_DataLatency = 3; | |
|
89 | //ili9328 -> data hold time > 15ns | |
|
90 | if(getCpuFreq()>66*1000*1000) | |
|
91 | p.FSMC_DataLatency = 3; | |
|
92 | p.FSMC_AccessMode = FSMC_AccessMode_D; | |
|
93 | ||
|
94 | ||
|
95 | FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM1; | |
|
96 | FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable; | |
|
97 | FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_NOR; | |
|
98 | FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_8b; | |
|
99 | FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable; | |
|
100 | FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable; | |
|
101 | FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low; | |
|
102 | FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable; | |
|
103 | FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState; | |
|
104 | FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable; | |
|
105 | FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable; | |
|
106 | FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Enable; //Dis | |
|
107 | FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable; | |
|
108 | FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p; | |
|
109 | FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p; | |
|
110 | ||
|
111 | FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure); | |
|
112 | ||
|
113 | FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM1, ENABLE); | |
|
114 | gpioset(LCD_RESET); | |
|
115 | gpioclr(LCD_RESET); | |
|
116 | delay_100us(500); | |
|
117 | gpioset(LCD_RESET); | |
|
118 | delay_100us(500); | |
|
119 | lcd0.init(&lcd0); | |
|
120 | gpioset(LCD_BACKL); | |
|
121 | return 1; | |
|
122 | } | |
|
123 | ||
|
124 | ||
|
125 | ||
|
126 | void bsp_lcd0_write_reg(uint32_t reg,uint32_t data) | |
|
127 | { | |
|
128 | uint8_t* pt8 = (uint8_t*)(void*)(®); | |
|
129 | #if __BYTE_ORDER__==__ORDER_BIG_ENDIAN__ | |
|
130 | *lcd0_CMD=pt8[3]; | |
|
131 | *lcd0_CMD=pt8[2]; | |
|
132 | pt8 = (uint8_t*)(void*)&data; | |
|
133 | *lcd0_DATA=pt8[3]; | |
|
134 | *lcd0_DATA=pt8[2]; | |
|
135 | #else | |
|
136 | clr_CS; | |
|
137 | clr_RS; | |
|
138 | *lcd0_CMD=pt8[1]; | |
|
139 | *lcd0_CMD=pt8[0]; | |
|
140 | set_RS; | |
|
141 | pt8 = (uint8_t*)(void*)&data; | |
|
142 | *lcd0_DATA=pt8[1]; | |
|
143 | *lcd0_DATA=pt8[0]; | |
|
144 | set_CS; | |
|
145 | #endif | |
|
146 | ||
|
147 | } | |
|
148 | ||
|
149 | uint32_t bsp_lcd0_read_reg(uint32_t reg) | |
|
150 | { | |
|
151 | uint8_t* pt8 = (uint8_t*)(void*)(®); | |
|
152 | uint32_t DATA=0; | |
|
153 | ||
|
154 | #if __BYTE_ORDER__==__ORDER_BIG_ENDIAN__ | |
|
155 | *lcd0_CMD=pt8[3]; | |
|
156 | *lcd0_CMD=pt8[2]; | |
|
157 | pt8 = (uint8_t*)(void*)&DATA; | |
|
158 | pt8[3]=*lcd0_DATA; | |
|
159 | pt8[2]=*lcd0_DATA; | |
|
160 | #else | |
|
161 | clr_CS; | |
|
162 | clr_RS; | |
|
163 | *lcd0_CMD=pt8[1]; | |
|
164 | *lcd0_CMD=pt8[0]; | |
|
165 | set_RS; | |
|
166 | pt8 = (uint8_t*)(void*)&DATA; | |
|
167 | pt8[1]=*lcd0_DATA; | |
|
168 | pt8[0]=*lcd0_DATA; | |
|
169 | set_CS; | |
|
170 | #endif | |
|
171 | ||
|
172 | return DATA; | |
|
173 | } | |
|
174 | ||
|
175 | void bsp_lcd0_writeGRAM(void* buffer,uint32_t count) | |
|
176 | { | |
|
177 | uint32_t reg =ILI9328_REGISTER_WRITEDATATOGRAM; | |
|
178 | uint8_t* pt8 = (uint8_t*)(void*)(®); | |
|
179 | #if __BYTE_ORDER__==__ORDER_BIG_ENDIAN__ | |
|
180 | *lcd0_CMD=pt8[3]; | |
|
181 | *lcd0_CMD=pt8[2]; | |
|
182 | pt8 = (uint8_t*)(void*)buffer; | |
|
183 | for(int i=0;i<(int)count;i++) | |
|
184 | { | |
|
185 | *lcd0_DATA=pt8[(2*i) +1]; | |
|
186 | *lcd0_DATA=pt8[2*i]; | |
|
187 | } | |
|
188 | #else | |
|
189 | clr_CS; | |
|
190 | clr_RS; | |
|
191 | *lcd0_CMD=pt8[1]; | |
|
192 | *lcd0_CMD=pt8[0]; | |
|
193 | set_RS; | |
|
194 | pt8 = (uint8_t*)(void*)buffer; | |
|
195 | for(int i=0;i<(int)count;i++) | |
|
196 | { | |
|
197 | ||
|
198 | *lcd0_DATA=pt8[(2*i) +1]; | |
|
199 | *lcd0_DATA=pt8[2*i]; | |
|
200 | } | |
|
201 | set_CS; | |
|
202 | #endif | |
|
203 | } | |
|
204 | ||
|
205 | ||
|
206 | void bsp_lcd0_readGRAM(void* buffer,uint32_t count) | |
|
207 | { | |
|
208 | //uint32_t reg =ILI9328_REGISTER_WRITEDATATOGRAM; | |
|
209 | volatile uint8_t* pt8;// = (uint8_t*)(void*)® | |
|
210 | /* #if __BYTE_ORDER__==__ORDER_BIG_ENDIAN__ | |
|
211 | *lcd0_CMD=pt8[3]; | |
|
212 | *lcd0_CMD=pt8[2]; | |
|
213 | pt8 = (uint8_t*)(void*)buffer; | |
|
214 | for(int i=0;i<(int)count;i++) | |
|
215 | { | |
|
216 | pt8[(2*i) +1]=*lcd0_DATA; | |
|
217 | pt8[2*i]=*lcd0_DATA; | |
|
218 | } | |
|
219 | #else | |
|
220 | *lcd0_CMD=(uint8_t)0; | |
|
221 | *lcd0_CMD=(uint8_t)0; | |
|
222 | *lcd0_CMD=(uint8_t)0; | |
|
223 | *lcd0_CMD=(uint8_t)0; | |
|
224 | *lcd0_CMD=pt8[1]; | |
|
225 | *lcd0_CMD=pt8[0]; | |
|
226 | pt8 = (uint8_t*)buffer;*/ | |
|
227 | /* | |
|
228 | * x dummy reads Cf ili9328 datasheet p79! | |
|
229 | */ | |
|
230 | /* pt8[0]=*lcd0_DATA; | |
|
231 | pt8[1]=*lcd0_DATA; | |
|
232 | ||
|
233 | for(int i=0;i<(int)count;i++) | |
|
234 | { | |
|
235 | pt8[(2*i) +1]=*lcd0_DATA; | |
|
236 | pt8[2*i]=*lcd0_DATA; | |
|
237 | pt8[(2*i) +1]=*lcd0_DATA; | |
|
238 | pt8[2*i]=*lcd0_DATA; | |
|
239 | } | |
|
240 | #endif*/ | |
|
241 | //clr_CS; | |
|
242 | //clr_RS; | |
|
243 | //*lcd0_CMD=(int8_t)0; | |
|
244 | //*lcd0_CMD=(int8_t)0x22; | |
|
245 | // *lcd0_CMD=(int8_t)0x00; | |
|
246 | //set_RS; | |
|
247 | pt8 = (uint8_t*)buffer; | |
|
248 | //pt8[1]=*lcd0_DATA; | |
|
249 | //pt8[0]=*lcd0_DATA; | |
|
250 | pt8[0]=0xFF; | |
|
251 | pt8[1]=0xFF; | |
|
252 | /* for(int i=0;i<(int)count;i++) | |
|
253 | { | |
|
254 | pt8[(2*i)+1]= *lcd0_DATA; | |
|
255 | pt8[2*i]= *lcd0_DATA; | |
|
256 | }*/ | |
|
257 | set_CS; | |
|
258 | } | |
|
259 | ||
|
260 | ||
|
261 | ||
|
262 | ||
|
263 | ||
|
264 | ||
|
265 | ||
|
266 |
@@ -0,0 +1,116 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the libuc, microcontroler library | |
|
3 | -- Copyright (C) 2013, Alexis Jeandet | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | ------------------------------------------------------------------------------- | |
|
19 | -- Author : Alexis Jeandet | |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
|
21 | -------------------------------------------------------------------------------*/ | |
|
22 | #include "bsp.h" | |
|
23 | #include <streamdevices.h> | |
|
24 | #include <malloc.h> | |
|
25 | #include <gpio.h> | |
|
26 | #include <uart.h> | |
|
27 | #include <stdio.h> | |
|
28 | #include <stm32f4xx_gpio.h> | |
|
29 | #include <stm32f4xx_fsmc.h> | |
|
30 | #include <i2c.h> | |
|
31 | #include <core.h> | |
|
32 | #include <terminal.h> | |
|
33 | ||
|
34 | ||
|
35 | void bsp_SD_init() | |
|
36 | { | |
|
37 | if(bspsdcardpresent()) | |
|
38 | { | |
|
39 | sdcardspimake(&sdcard2,(UHANDLE)SDCARD2SPI,spigetnc,spiputnc,spisetspeed,spigetspeed); | |
|
40 | sdcardspimakeblkdev(&sdcard2blkdev,&sdcard2,bspsdcardselect,bsppowersdcard,bspsdcardpresent,bspsdcardwriteprotected); | |
|
41 | if(sdcard2blkdev.initialize(&sdcard2blkdev)!=STA_NOINIT) | |
|
42 | { | |
|
43 | if(mbropen(&sdcard2blkdev,&sdcard2Part1,1)==MBRnoErr) | |
|
44 | { | |
|
45 | if(FATnoErr!=fat32open(&sdcard2FAT32part1,&sdcard2Part1)) | |
|
46 | printf("Can't open fat32 partition 1\n"); | |
|
47 | } | |
|
48 | else | |
|
49 | { | |
|
50 | printf("Can't open or read MBR\n"); | |
|
51 | } | |
|
52 | if(mbropen(&sdcard2blkdev,&sdcard2Part2,2)==MBRnoErr) | |
|
53 | { | |
|
54 | if(FATnoErr!=fat32open(&sdcard2FAT32part2,&sdcard2Part2)) | |
|
55 | printf("Can't open fat32 partition 2\n"); | |
|
56 | } | |
|
57 | else | |
|
58 | { | |
|
59 | printf("Can't open or read MBR\n"); | |
|
60 | } | |
|
61 | if(mbropen(&sdcard2blkdev,&sdcard2Part3,3)==MBRnoErr) | |
|
62 | { | |
|
63 | if(FATnoErr!=fat32open(&sdcard2FAT32part3,&sdcard2Part3)) | |
|
64 | printf("Can't open fat32 partition 3\n"); | |
|
65 | } | |
|
66 | else | |
|
67 | { | |
|
68 | printf("Can't open or read MBR\n"); | |
|
69 | } | |
|
70 | if(mbropen(&sdcard2blkdev,&sdcard2Part4,4)==MBRnoErr) | |
|
71 | { | |
|
72 | if(FATnoErr!=fat32open(&sdcard2FAT32part4,&sdcard2Part4)) | |
|
73 | printf("Can't open fat32 partition 4\n"); | |
|
74 | } | |
|
75 | else | |
|
76 | { | |
|
77 | printf("Can't open or read MBR\n"); | |
|
78 | } | |
|
79 | } | |
|
80 | else | |
|
81 | { | |
|
82 | printf("Can't initialize SDCARD\n"); | |
|
83 | } | |
|
84 | } | |
|
85 | } | |
|
86 | ||
|
87 | ||
|
88 | ||
|
89 | ||
|
90 | ||
|
91 | ||
|
92 | ||
|
93 | void bsppowersdcard(char onoff) //always ON | |
|
94 | { | |
|
95 | ||
|
96 | } | |
|
97 | ||
|
98 | char bspsdcardpresent() | |
|
99 | { | |
|
100 | return gpiogetval(SDCARD2CD); | |
|
101 | } | |
|
102 | ||
|
103 | char bspsdcardwriteprotected() | |
|
104 | { | |
|
105 | return 0; | |
|
106 | } | |
|
107 | ||
|
108 | void bspsdcardselect(char YESNO) | |
|
109 | { | |
|
110 | // gpiosetval(LED1,(int)YESNO); | |
|
111 | if(YESNO) | |
|
112 | gpioclr(SDCARD2CS); | |
|
113 | else | |
|
114 | gpioset(SDCARD2CS); | |
|
115 | } | |
|
116 |
@@ -0,0 +1,70 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the libuc, microcontroler library | |
|
3 | -- Copyright (C) 2013, Alexis Jeandet | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | ------------------------------------------------------------------------------- | |
|
19 | -- Author : Alexis Jeandet | |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
|
21 | -------------------------------------------------------------------------------*/ | |
|
22 | #include "bsp.h" | |
|
23 | #include <streamdevices.h> | |
|
24 | #include <malloc.h> | |
|
25 | #include <gpio.h> | |
|
26 | #include <uart.h> | |
|
27 | #include <stdio.h> | |
|
28 | #include <stm32f4xx_gpio.h> | |
|
29 | #include <stm32f4xx_fsmc.h> | |
|
30 | #include <i2c.h> | |
|
31 | #include <core.h> | |
|
32 | #include <terminal.h> | |
|
33 | ||
|
34 | #define GPIOGETPORT(gpio) ((GPIO_TypeDef*)(((((uint32_t)gpio) & (uint32_t)0x0000FF00)*(uint32_t)4) + (uint32_t)GPIOA)) | |
|
35 | #define GPIOPORTNUM(gpio) (((uint32_t)(gpio) & (uint32_t)0x0000FF00)>>(uint32_t)8) | |
|
36 | ||
|
37 | ||
|
38 | void bsp_spi_init() | |
|
39 | { | |
|
40 | gpio_t VSSPI_DBxList[]={VS1053SCK,VS1053MOSI,VS1053MISO}; | |
|
41 | for(int i=0;i<3;i++) | |
|
42 | { | |
|
43 | gpio_t SPI_DBx = gpioopen(VSSPI_DBxList[i]); | |
|
44 | SPI_DBx |= gpiohighspeed | gpioaf | gpiopushpulltype | gpionopulltype; | |
|
45 | gpiosetconfig(&SPI_DBx); | |
|
46 | GPIO_PinAFConfig(GPIOGETPORT(SPI_DBx), (uint8_t)(SPI_DBx & 0xF), GPIO_AF_SPI1); | |
|
47 | } | |
|
48 | spiopenandconfig(VS1053SPI,spi8bits|spimaster|spimsbfirst,2*1000*1000,VS1053MOSI,VS1053MISO,VS1053SCK,-1); | |
|
49 | ||
|
50 | gpio_t SDSPI_DBxList[]={SDCARD2SCK,SDCARD2MOSI,SDCARD2MISO}; | |
|
51 | for(int i=0;i<3;i++) | |
|
52 | { | |
|
53 | gpio_t SPI_DBx = gpioopen(SDSPI_DBxList[i]); | |
|
54 | SPI_DBx |= gpiohighspeed | gpioaf | gpiopushpulltype | gpionopulltype; | |
|
55 | gpiosetconfig(&SPI_DBx); | |
|
56 | GPIO_PinAFConfig(GPIOGETPORT(SPI_DBx), (uint8_t)(SPI_DBx & 0xF), GPIO_AF_SPI3); | |
|
57 | } | |
|
58 | spiopenandconfig(SDCARD2SPI,spi8bits|spimaster|spimsbfirst,400*1000,SDCARD2MOSI,SDCARD2MISO,SDCARD2SCK,-1); | |
|
59 | ||
|
60 | gpio_t TCSPI_DBxList[]={TC_CLK,TC_DIN,TC_DOUT}; | |
|
61 | for(int i=0;i<3;i++) | |
|
62 | { | |
|
63 | gpio_t SPI_DBx = gpioopen(TCSPI_DBxList[i]); | |
|
64 | SPI_DBx |= gpiohighspeed | gpioaf | gpiopushpulltype | gpionopulltype; | |
|
65 | gpiosetconfig(&SPI_DBx); | |
|
66 | GPIO_PinAFConfig(GPIOGETPORT(SPI_DBx), (uint8_t)(SPI_DBx & 0xF), GPIO_AF_SPI2); | |
|
67 | } | |
|
68 | spiopenandconfig(TC_SPI,spi8bits|spimaster|spimsbfirst,500*1000,TC_DIN,TC_DOUT,TC_CLK,-1); | |
|
69 | ||
|
70 | } |
@@ -0,0 +1,19 | |||
|
1 | TEMPLATE = lib | |
|
2 | ||
|
3 | TARGET=bsp | |
|
4 | CONFIG += bsp | |
|
5 | ||
|
6 | BSP=SOLAR_LFR_PSU | |
|
7 | ||
|
8 | UCMODEL=stm32f4 | |
|
9 | ||
|
10 | SOURCES += bsp.c | |
|
11 | ||
|
12 | HEADERS += bsp.h | |
|
13 | ||
|
14 | LIBS+= -lgpio -luart -li2c -lspi | |
|
15 | ||
|
16 | BSPFILE = bsp.pri | |
|
17 | ||
|
18 | ||
|
19 |
@@ -0,0 +1,140 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the libuc, microcontroler library | |
|
3 | -- Copyright (C) 2011, Alexis Jeandet | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | ------------------------------------------------------------------------------- | |
|
19 | -- Author : Alexis Jeandet | |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
|
21 | -------------------------------------------------------------------------------*/ | |
|
22 | #include "bsp.h" | |
|
23 | #include <streamdevices.h> | |
|
24 | #include <malloc.h> | |
|
25 | #include <gpio.h> | |
|
26 | #include <uart.h> | |
|
27 | #include <stdio.h> | |
|
28 | #include <i2c.h> | |
|
29 | ||
|
30 | uint32_t OSC0 =8000000; | |
|
31 | uint32_t INTOSC =16000000; | |
|
32 | uint32_t RTCOSC =32768; | |
|
33 | uint32_t currentCpuFreq=0; | |
|
34 | extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__]; | |
|
35 | ||
|
36 | float VREF0 =(float)3.3; | |
|
37 | ||
|
38 | int bsp_init() | |
|
39 | { | |
|
40 | int i=0; | |
|
41 | for(i=0;i<32;i++) | |
|
42 | { | |
|
43 | __opnfiles__[i] = NULL; | |
|
44 | } | |
|
45 | bsp_GPIO_init(); | |
|
46 | bsp_uart_init(); | |
|
47 | bsp_iic_init(); | |
|
48 | printf("\r================================================================\n\r"); | |
|
49 | printf("================================================================\n\r"); | |
|
50 | printf(BSP); | |
|
51 | printf(" initialised\n\r"); | |
|
52 | printf("================================================================\n\r"); | |
|
53 | return 1; | |
|
54 | } | |
|
55 | ||
|
56 | void bsp_GPIO_init() | |
|
57 | { | |
|
58 | gpio_t gpio1 = gpioopen(PD12);//gpioopen(LED1); //PD9 D=> 0x0300 9 => 0x0009 | |
|
59 | gpio_t gpio2 = gpioopen(PD13);//gpioopen(LED2); | |
|
60 | gpio_t gpio3 = gpioopen(PD14);//gpioopen(LED2); | |
|
61 | gpio_t gpio4 = gpioopen(PD15);//gpioopen(LED2); | |
|
62 | gpio_t dacRst=gpioopen(PD4); | |
|
63 | gpiosetspeed(&gpio1,gpiohighspeed); | |
|
64 | gpiosetspeed(&gpio2,gpiohighspeed); | |
|
65 | gpiosetspeed(&gpio3,gpiohighspeed); | |
|
66 | gpiosetspeed(&gpio4,gpiohighspeed); | |
|
67 | gpiosetspeed(&dacRst,gpiohighspeed); | |
|
68 | gpiosetdir(&gpio1,gpiooutdir); | |
|
69 | gpiosetdir(&gpio3,gpiooutdir); | |
|
70 | gpiosetdir(&gpio2,gpiooutdir); | |
|
71 | gpiosetdir(&gpio4,gpiooutdir); | |
|
72 | gpiosetdir(&dacRst,gpiooutdir); | |
|
73 | gpioset(dacRst); | |
|
74 | } | |
|
75 | ||
|
76 | void bsp_uart_init() | |
|
77 | { | |
|
78 | if(__opnfiles__[1]==NULL) | |
|
79 | { | |
|
80 | //uart_t* uart1 = (uart_t*)malloc(sizeof(uart_t)); | |
|
81 | streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice)); | |
|
82 | uart_t uart = uartopenandconfig(uart3,uartparitynone | uart8bits | uartonestop,115200,PB10,PB11,-1,-1); | |
|
83 | uartmkstreamdev(uart,fd1); | |
|
84 | __opnfiles__[1] = fd1; | |
|
85 | } | |
|
86 | else | |
|
87 | { | |
|
88 | uartopenandconfig(uart3,uartparitynone | uart8bits | uartonestop,115200,PB10,PB11,-1,-1); | |
|
89 | } | |
|
90 | } | |
|
91 | ||
|
92 | void bsp_spi_init() | |
|
93 | { | |
|
94 | ||
|
95 | } | |
|
96 | ||
|
97 | ||
|
98 | void bsp_iic_init() | |
|
99 | { | |
|
100 | i2copenandconfig(i2c1,0,400000,PB9,PB6); | |
|
101 | i2copenandconfig(i2c3,0,400000,PC9,PA8); | |
|
102 | } | |
|
103 | ||
|
104 | void bsp_SD_init() | |
|
105 | { | |
|
106 | ||
|
107 | } | |
|
108 | ||
|
109 | void vs10XXclearXCS(){} | |
|
110 | void vs10XXsetXCS(){} | |
|
111 | int vs10XXDREQ() | |
|
112 | { | |
|
113 | return 1; | |
|
114 | } | |
|
115 | ||
|
116 | ||
|
117 | void bsppowersdcard(char onoff) //always ON | |
|
118 | { | |
|
119 | ||
|
120 | } | |
|
121 | ||
|
122 | char bspsdcardpresent() | |
|
123 | { | |
|
124 | return 0; | |
|
125 | } | |
|
126 | ||
|
127 | char bspsdcardwriteprotected() | |
|
128 | { | |
|
129 | return 0; | |
|
130 | } | |
|
131 | ||
|
132 | void bspsdcardselect(char YESNO) | |
|
133 | { | |
|
134 | ||
|
135 | } | |
|
136 | ||
|
137 | ||
|
138 | ||
|
139 | ||
|
140 |
@@ -0,0 +1,87 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the libuc, microcontroler library | |
|
3 | -- Copyright (C) 2011, Alexis Jeandet | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | ------------------------------------------------------------------------------- | |
|
19 | -- Author : Alexis Jeandet | |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
|
21 | -------------------------------------------------------------------------------*/ | |
|
22 | #ifndef BSP_H | |
|
23 | #define BSP_H | |
|
24 | #include <stm32f4xx.h> | |
|
25 | #include <stm32f4xx_gpio.h> | |
|
26 | #include <stm32f4xx_rcc.h> | |
|
27 | #include <gpio.h> | |
|
28 | ||
|
29 | #define __MAX_OPENED_FILES__ 32 | |
|
30 | #define __FS_ROOT_SIZE__ 32 | |
|
31 | /* | |
|
32 | #ifndef PD8 | |
|
33 | #define PD8 | |
|
34 | #endif | |
|
35 | #ifndef PD9 | |
|
36 | #define PD9 | |
|
37 | #endif | |
|
38 | */ | |
|
39 | ||
|
40 | #define LED1 PD12 | |
|
41 | #define LED2 PD13 | |
|
42 | #define LED3 PD14 | |
|
43 | #define LED4 PD15 | |
|
44 | ||
|
45 | extern float VREF0; | |
|
46 | ||
|
47 | extern uint32_t currentCpuFreq; | |
|
48 | ||
|
49 | extern int bsp_init(); | |
|
50 | ||
|
51 | extern void bsp_GPIO_init(); | |
|
52 | extern void bsp_uart_init(); | |
|
53 | extern void bsp_iic_init(); | |
|
54 | extern void bsp_spi_init(); | |
|
55 | extern void bsp_SD_init(); | |
|
56 | ||
|
57 | /* VS1053 */ | |
|
58 | extern void clearXCS(); | |
|
59 | extern void setXCS(); | |
|
60 | extern int vs10XXDREQ(); | |
|
61 | ||
|
62 | /* SD CARD */ | |
|
63 | void bsppowersdcard(char onoff); | |
|
64 | char bspsdcardpresent(); | |
|
65 | void bspsdcardselect(char YESNO); | |
|
66 | char bspsdcardwriteprotected(); | |
|
67 | ||
|
68 | #endif | |
|
69 | ||
|
70 | ||
|
71 | ||
|
72 | ||
|
73 | ||
|
74 | ||
|
75 | ||
|
76 | ||
|
77 | ||
|
78 | ||
|
79 | ||
|
80 | ||
|
81 | ||
|
82 | ||
|
83 | ||
|
84 | ||
|
85 | ||
|
86 | ||
|
87 |
@@ -0,0 +1,26 | |||
|
1 | TEMPLATE = lib | |
|
2 | ||
|
3 | TARGET=bsp | |
|
4 | CONFIG += bsp | |
|
5 | ||
|
6 | BSP = STM32-E407 | |
|
7 | ||
|
8 | UCMODEL=stm32f4 | |
|
9 | ||
|
10 | SOURCES += bsp.c \ | |
|
11 | bsp_spi.c \ | |
|
12 | bsp_sdcard.c | |
|
13 | ||
|
14 | HEADERS += bsp.h \ | |
|
15 | ../../common/bsp_spi.h \ | |
|
16 | ../../common/bsp_i2c.h \ | |
|
17 | ../../common/bsp_gpio.h | |
|
18 | ||
|
19 | INCLUDEPATH += ../../common/ | |
|
20 | ||
|
21 | LIBS+= -lgpio -luart -li2c -lspi | |
|
22 | ||
|
23 | BSPFILE = bsp.pri | |
|
24 | ||
|
25 | ||
|
26 |
@@ -0,0 +1,139 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the libuc, microcontroler library | |
|
3 | -- Copyright (C) 2013, Alexis Jeandet | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | ------------------------------------------------------------------------------- | |
|
19 | -- Author : Alexis Jeandet | |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
|
21 | -------------------------------------------------------------------------------*/ | |
|
22 | #include "bsp.h" | |
|
23 | #include <streamdevices.h> | |
|
24 | #include <malloc.h> | |
|
25 | #include <gpio.h> | |
|
26 | #include <uart.h> | |
|
27 | #include <stdio.h> | |
|
28 | #include <stm32f4xx_gpio.h> | |
|
29 | #include <stm32f4xx_fsmc.h> | |
|
30 | #include <i2c.h> | |
|
31 | #include <core.h> | |
|
32 | #include <terminal.h> | |
|
33 | #include "bsp_gpio.h" | |
|
34 | #include "bsp_i2c.h" | |
|
35 | #include "bsp_i2c.h" | |
|
36 | ||
|
37 | uint32_t OSC0 =12000000; | |
|
38 | uint32_t INTOSC =16000000; | |
|
39 | uint32_t RTCOSC =32768; | |
|
40 | uint32_t currentCpuFreq=0; | |
|
41 | extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__]; | |
|
42 | ||
|
43 | ||
|
44 | float VREF0 =(float)3.3; | |
|
45 | ||
|
46 | sdcardDev sdcard2; | |
|
47 | blkdevice sdcard2blkdev; | |
|
48 | dikpartition sdcard2Part1; | |
|
49 | FAT32fs sdcard2FAT32part1; | |
|
50 | dikpartition sdcard2Part2; | |
|
51 | FAT32fs sdcard2FAT32part2; | |
|
52 | dikpartition sdcard2Part3; | |
|
53 | FAT32fs sdcard2FAT32part3; | |
|
54 | dikpartition sdcard2Part4; | |
|
55 | FAT32fs sdcard2FAT32part4; | |
|
56 | ||
|
57 | int bsp_init() | |
|
58 | { | |
|
59 | int i=0; | |
|
60 | for(i=0;i<__MAX_OPENED_FILES__;i++) | |
|
61 | { | |
|
62 | __opnfiles__[i] = NULL; | |
|
63 | } | |
|
64 | bsp_GPIO_init(); | |
|
65 | bsp_uart_init(); | |
|
66 | bsp_iic_init(); | |
|
67 | bsp_spi_init(); | |
|
68 | bsp_SD_init(); | |
|
69 | printf("\r=====================\n\r"); | |
|
70 | printf( "=====================\n\r"); | |
|
71 | printf(BSP); | |
|
72 | printf(" initialised\n\r"); | |
|
73 | printf( "=====================\n\r"); | |
|
74 | #if __BYTE_ORDER__==__ORDER_BIG_ENDIAN__ | |
|
75 | printf( "BIG ENDIAN MACHINE\n\r"); | |
|
76 | #else | |
|
77 | printf( "LITLE ENDIAN MACHINE\n\r"); | |
|
78 | #endif | |
|
79 | return 1; | |
|
80 | } | |
|
81 | ||
|
82 | void bsp_GPIO_init() | |
|
83 | { | |
|
84 | gpio_t GPIO_Out_init_List[]={LED1}; | |
|
85 | ||
|
86 | gpio_t GPIO_In_init_List[]={BP1}; | |
|
87 | ||
|
88 | bsp_gpio_set_outputs(GPIO_Out_init_List,1); | |
|
89 | bsp_gpio_set_inputs(GPIO_In_init_List,1); | |
|
90 | ||
|
91 | } | |
|
92 | ||
|
93 | void bsp_uart_init() | |
|
94 | { | |
|
95 | if(__opnfiles__[1]==NULL) | |
|
96 | { | |
|
97 | streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice)); | |
|
98 | uart_t uart = uartopenandconfig(uart6,uartparitynone | uart8bits | uartonestop,115200,PC6,PC7,-1,-1); | |
|
99 | uartmkstreamdev(uart,fd1); | |
|
100 | __opnfiles__[1] = fd1; | |
|
101 | } | |
|
102 | else | |
|
103 | { | |
|
104 | uartopenandconfig(uart6,uartparitynone | uart8bits | uartonestop,115200,PC6,PC7,-1,-1); | |
|
105 | } | |
|
106 | } | |
|
107 | ||
|
108 | ||
|
109 | ||
|
110 | ||
|
111 | void bsp_iic_init() | |
|
112 | { | |
|
113 | // i2copenandconfig(i2c2,0,10000,PF0,PF1); | |
|
114 | } | |
|
115 | ||
|
116 | ||
|
117 | ||
|
118 | ||
|
119 | void bsp_GTerm_init() | |
|
120 | { | |
|
121 | ||
|
122 | } | |
|
123 | ||
|
124 | ||
|
125 | ||
|
126 | ||
|
127 | ||
|
128 | ||
|
129 | ||
|
130 | ||
|
131 | ||
|
132 | ||
|
133 | ||
|
134 | ||
|
135 | ||
|
136 | ||
|
137 | ||
|
138 | ||
|
139 |
@@ -0,0 +1,98 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the libuc, microcontroler library | |
|
3 | -- Copyright (C) 2011, Alexis Jeandet | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | ------------------------------------------------------------------------------- | |
|
19 | -- Author : Alexis Jeandet | |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
|
21 | -------------------------------------------------------------------------------*/ | |
|
22 | #ifndef BSP_H | |
|
23 | #define BSP_H | |
|
24 | #include <stm32f4xx.h> | |
|
25 | #include <stm32f4xx_gpio.h> | |
|
26 | #include <stm32f4xx_rcc.h> | |
|
27 | #include <gpio.h> | |
|
28 | #include <spi.h> | |
|
29 | #include <ili9328.h> | |
|
30 | #include <genericLCD_Controler.h> | |
|
31 | #include <sdcard-spi.h> | |
|
32 | #include <sdcard.h> | |
|
33 | #include <mbr.h> | |
|
34 | #include <VS10XX.h> | |
|
35 | #include <fat32.h> | |
|
36 | #include <ADS7843.h> | |
|
37 | ||
|
38 | #define __MAX_OPENED_FILES__ 4 | |
|
39 | #define __FS_ROOT_SIZE__ 4 | |
|
40 | ||
|
41 | ||
|
42 | #define LED1 PC13 | |
|
43 | #define LED2 PC13 | |
|
44 | ||
|
45 | #define BP1 PA0 | |
|
46 | ||
|
47 | ||
|
48 | extern float VREF0; | |
|
49 | ||
|
50 | extern uint32_t currentCpuFreq; | |
|
51 | ||
|
52 | ||
|
53 | extern sdcardDev sdcard2; | |
|
54 | extern blkdevice sdcard2blkdev; | |
|
55 | extern dikpartition sdcard2Part1; | |
|
56 | extern FAT32fs sdcard2FAT32part1; | |
|
57 | extern dikpartition sdcard2Part2; | |
|
58 | extern FAT32fs sdcard2FAT32part2; | |
|
59 | extern dikpartition sdcard2Part3; | |
|
60 | extern FAT32fs sdcard2FAT32part3; | |
|
61 | extern dikpartition sdcard2Part4; | |
|
62 | extern FAT32fs sdcard2FAT32part4; | |
|
63 | ||
|
64 | extern int bsp_init(); | |
|
65 | ||
|
66 | extern void bsp_GPIO_init(); | |
|
67 | extern void bsp_uart_init(); | |
|
68 | extern void bsp_iic_init(); | |
|
69 | extern void bsp_spi_init(); | |
|
70 | extern void bsp_SD_init(); | |
|
71 | ||
|
72 | /* SD CARD */ | |
|
73 | void bsppowersdcard(char onoff); | |
|
74 | char bspsdcardpresent(); | |
|
75 | void bspsdcardselect(char YESNO); | |
|
76 | char bspsdcardwriteprotected(); | |
|
77 | ||
|
78 | ||
|
79 | #endif | |
|
80 | ||
|
81 | ||
|
82 | ||
|
83 | ||
|
84 | ||
|
85 | ||
|
86 | ||
|
87 | ||
|
88 | ||
|
89 | ||
|
90 | ||
|
91 | ||
|
92 | ||
|
93 | ||
|
94 | ||
|
95 | ||
|
96 | ||
|
97 | ||
|
98 |
@@ -0,0 +1,60 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the libuc, microcontroler library | |
|
3 | -- Copyright (C) 2013, Alexis Jeandet | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | ------------------------------------------------------------------------------- | |
|
19 | -- Author : Alexis Jeandet | |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
|
21 | -------------------------------------------------------------------------------*/ | |
|
22 | #include "bsp.h" | |
|
23 | #include <streamdevices.h> | |
|
24 | #include <malloc.h> | |
|
25 | #include <gpio.h> | |
|
26 | #include <uart.h> | |
|
27 | #include <stdio.h> | |
|
28 | #include <stm32f4xx_gpio.h> | |
|
29 | #include <stm32f4xx_fsmc.h> | |
|
30 | #include <i2c.h> | |
|
31 | #include <core.h> | |
|
32 | #include <terminal.h> | |
|
33 | ||
|
34 | ||
|
35 | void bsp_SD_init() | |
|
36 | { | |
|
37 | ||
|
38 | } | |
|
39 | ||
|
40 | ||
|
41 | void bsppowersdcard(char onoff) //always ON | |
|
42 | { | |
|
43 | ||
|
44 | } | |
|
45 | ||
|
46 | char bspsdcardpresent() | |
|
47 | { | |
|
48 | ||
|
49 | } | |
|
50 | ||
|
51 | char bspsdcardwriteprotected() | |
|
52 | { | |
|
53 | return 0; | |
|
54 | } | |
|
55 | ||
|
56 | void bspsdcardselect(char YESNO) | |
|
57 | { | |
|
58 | ||
|
59 | } | |
|
60 |
@@ -0,0 +1,38 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the libuc, microcontroler library | |
|
3 | -- Copyright (C) 2013, Alexis Jeandet | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | ------------------------------------------------------------------------------- | |
|
19 | -- Author : Alexis Jeandet | |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
|
21 | -------------------------------------------------------------------------------*/ | |
|
22 | #include "bsp.h" | |
|
23 | #include <streamdevices.h> | |
|
24 | #include <malloc.h> | |
|
25 | #include <gpio.h> | |
|
26 | #include <uart.h> | |
|
27 | #include <stdio.h> | |
|
28 | #include <stm32f4xx_gpio.h> | |
|
29 | #include <stm32f4xx_fsmc.h> | |
|
30 | #include <i2c.h> | |
|
31 | #include <core.h> | |
|
32 | #include <terminal.h> | |
|
33 | ||
|
34 | void bsp_spi_init() | |
|
35 | { | |
|
36 | ||
|
37 | ||
|
38 | } |
@@ -0,0 +1,19 | |||
|
1 | TEMPLATE = lib | |
|
2 | ||
|
3 | TARGET=bsp | |
|
4 | CONFIG += bsp | |
|
5 | ||
|
6 | BSP=STM32F429Discovery | |
|
7 | ||
|
8 | UCMODEL=stm32f4 | |
|
9 | ||
|
10 | SOURCES += bsp.c | |
|
11 | ||
|
12 | HEADERS += bsp.h | |
|
13 | ||
|
14 | LIBS+= -lgpio -luart -li2c -lspi | |
|
15 | ||
|
16 | BSPFILE = bsp.pri | |
|
17 | ||
|
18 | ||
|
19 |
@@ -0,0 +1,131 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the libuc, microcontroler library | |
|
3 | -- Copyright (C) 2011, Alexis Jeandet | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | ------------------------------------------------------------------------------- | |
|
19 | -- Author : Alexis Jeandet | |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
|
21 | -------------------------------------------------------------------------------*/ | |
|
22 | #include "bsp.h" | |
|
23 | #include <streamdevices.h> | |
|
24 | #include <malloc.h> | |
|
25 | #include <gpio.h> | |
|
26 | #include <uart.h> | |
|
27 | #include <stdio.h> | |
|
28 | uint32_t OSC0 =8000000; | |
|
29 | uint32_t INTOSC =16000000; | |
|
30 | uint32_t RTCOSC =32768; | |
|
31 | uint32_t currentCpuFreq=0; | |
|
32 | extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__]; | |
|
33 | ||
|
34 | float VREF0 =(float)3.3; | |
|
35 | ||
|
36 | int bsp_init() | |
|
37 | { | |
|
38 | int i=0; | |
|
39 | for(i=0;i<32;i++) | |
|
40 | { | |
|
41 | __opnfiles__[i] = NULL; | |
|
42 | } | |
|
43 | bsp_GPIO_init(); | |
|
44 | bsp_uart_init(); | |
|
45 | printf("\r================================================================\n\r"); | |
|
46 | printf("================================================================\n\r"); | |
|
47 | printf(BSP); | |
|
48 | printf(" initialised\n\r"); | |
|
49 | printf("================================================================\n\r"); | |
|
50 | return 1; | |
|
51 | } | |
|
52 | ||
|
53 | void bsp_GPIO_init() | |
|
54 | { | |
|
55 | gpio_t gpio1 = gpioopen(LED1); | |
|
56 | gpio_t gpio2 = gpioopen(LED2); | |
|
57 | gpio_t gpio3 = gpioopen(BP0); | |
|
58 | gpiosetspeed(&gpio1,gpiohighspeed); | |
|
59 | gpiosetspeed(&gpio2,gpiohighspeed); | |
|
60 | gpiosetspeed(&gpio3,gpiohighspeed); | |
|
61 | gpiosetdir(&gpio1,gpiooutdir); | |
|
62 | gpiosetdir(&gpio2,gpiooutdir); | |
|
63 | gpiosetdir(&gpio3,gpioindir); | |
|
64 | } | |
|
65 | ||
|
66 | void bsp_uart_init() | |
|
67 | { | |
|
68 | if(__opnfiles__[1]==NULL) | |
|
69 | { | |
|
70 | //uart_t* uart1 = (uart_t*)malloc(sizeof(uart_t)); | |
|
71 | streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice)); | |
|
72 | uart_t uart = uartopenandconfig(uart1,uartparitynone | uart8bits | uartonestop,115200,PA9,PA10,-1,-1); | |
|
73 | uartmkstreamdev(uart,fd1); | |
|
74 | __opnfiles__[1] = fd1; //stdo | |
|
75 | __opnfiles__[0] = fd1; //stdi | |
|
76 | } | |
|
77 | else | |
|
78 | { | |
|
79 | uartopenandconfig(uart1,uartparitynone | uart8bits | uartonestop,115200,PA9,PA10,-1,-1); | |
|
80 | } | |
|
81 | } | |
|
82 | ||
|
83 | void bsp_spi_init() | |
|
84 | { | |
|
85 | ||
|
86 | } | |
|
87 | ||
|
88 | ||
|
89 | void bsp_iic_init() | |
|
90 | { | |
|
91 | ||
|
92 | } | |
|
93 | ||
|
94 | void bsp_SD_init() | |
|
95 | { | |
|
96 | ||
|
97 | } | |
|
98 | ||
|
99 | ||
|
100 | void vs10XXclearXCS(){} | |
|
101 | void vs10XXsetXCS(){} | |
|
102 | int vs10XXDREQ() | |
|
103 | { | |
|
104 | return 1; | |
|
105 | } | |
|
106 | ||
|
107 | ||
|
108 | void bsppowersdcard(char onoff) //always ON | |
|
109 | { | |
|
110 | ||
|
111 | } | |
|
112 | ||
|
113 | char bspsdcardpresent() | |
|
114 | { | |
|
115 | return 0; | |
|
116 | } | |
|
117 | ||
|
118 | char bspsdcardwriteprotected() | |
|
119 | { | |
|
120 | return 0; | |
|
121 | } | |
|
122 | ||
|
123 | void bspsdcardselect(char YESNO) | |
|
124 | { | |
|
125 | ||
|
126 | } | |
|
127 | ||
|
128 | ||
|
129 | ||
|
130 | ||
|
131 |
@@ -0,0 +1,80 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the libuc, microcontroler library | |
|
3 | -- Copyright (C) 2011, Alexis Jeandet | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | ------------------------------------------------------------------------------- | |
|
19 | -- Author : Alexis Jeandet | |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
|
21 | -------------------------------------------------------------------------------*/ | |
|
22 | #ifndef BSP_H | |
|
23 | #define BSP_H | |
|
24 | #include <stm32f4xx.h> | |
|
25 | #include <gpio.h> | |
|
26 | ||
|
27 | #define __MAX_OPENED_FILES__ 32 | |
|
28 | #define __FS_ROOT_SIZE__ 32 | |
|
29 | ||
|
30 | #define LED1 PG13 | |
|
31 | #define LED2 PG14 | |
|
32 | ||
|
33 | #define BP0 PA0 | |
|
34 | ||
|
35 | extern float VREF0; | |
|
36 | ||
|
37 | extern uint32_t OSC0; | |
|
38 | extern uint32_t currentCpuFreq; | |
|
39 | ||
|
40 | ||
|
41 | ||
|
42 | extern int bsp_init(); | |
|
43 | ||
|
44 | extern void bsp_GPIO_init(); | |
|
45 | extern void bsp_uart_init(); | |
|
46 | extern void bsp_iic_init(); | |
|
47 | extern void bsp_spi_init(); | |
|
48 | extern void bsp_SD_init(); | |
|
49 | ||
|
50 | /* VS1053 */ | |
|
51 | extern void clearXCS(); | |
|
52 | extern void setXCS(); | |
|
53 | extern int vs10XXDREQ(); | |
|
54 | ||
|
55 | /* SD CARD */ | |
|
56 | void bsppowersdcard(char onoff); | |
|
57 | char bspsdcardpresent(); | |
|
58 | void bspsdcardselect(char YESNO); | |
|
59 | char bspsdcardwriteprotected(); | |
|
60 | ||
|
61 | #endif | |
|
62 | ||
|
63 | ||
|
64 | ||
|
65 | ||
|
66 | ||
|
67 | ||
|
68 | ||
|
69 | ||
|
70 | ||
|
71 | ||
|
72 | ||
|
73 | ||
|
74 | ||
|
75 | ||
|
76 | ||
|
77 | ||
|
78 | ||
|
79 | ||
|
80 |
@@ -0,0 +1,18 | |||
|
1 | TEMPLATE = lib | |
|
2 | ||
|
3 | TARGET=bsp | |
|
4 | CONFIG += bsp gui | |
|
5 | ||
|
6 | BSP=STM32F4Discovery-EXT | |
|
7 | ||
|
8 | UCMODEL=stm32f4 | |
|
9 | ||
|
10 | SOURCES += bsp.c | |
|
11 | ||
|
12 | HEADERS += bsp.h | |
|
13 | LIBS+= -lgpio -luart -li2c -lspi | |
|
14 | ||
|
15 | BSPFILE = bsp.pri | |
|
16 | ||
|
17 | ||
|
18 |
@@ -0,0 +1,311 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the libuc, microcontroler library | |
|
3 | -- Copyright (C) 2011, Alexis Jeandet | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | ------------------------------------------------------------------------------- | |
|
19 | -- Author : Alexis Jeandet | |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
|
21 | -------------------------------------------------------------------------------*/ | |
|
22 | #include "bsp.h" | |
|
23 | #include <streamdevices.h> | |
|
24 | #include <malloc.h> | |
|
25 | #include <gpio.h> | |
|
26 | #include <uart.h> | |
|
27 | #include <stdio.h> | |
|
28 | #include <stm32f4xx_gpio.h> | |
|
29 | #include <stm32f4xx_fsmc.h> | |
|
30 | #include <stm32f4xx_gpio.h> | |
|
31 | #include <stm32f4xx_rcc.h> | |
|
32 | #include <core.h> | |
|
33 | ||
|
34 | uint32_t OSC0 =8000000; | |
|
35 | uint32_t INTOSC =16000000; | |
|
36 | uint32_t RTCOSC =32768; | |
|
37 | uint32_t currentCpuFreq=0; | |
|
38 | extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__]; | |
|
39 | ||
|
40 | float VREF0 =(float)3.3; | |
|
41 | ||
|
42 | LCD_IF_t lcdIF0={ | |
|
43 | .init = &bsp_FSMC_init, | |
|
44 | .writereg = &bsp_lcd0_write_reg, | |
|
45 | .readreg = &bsp_lcd0_read_reg, | |
|
46 | .writeGRAM = &bsp_lcd0_writeGRAM, | |
|
47 | .readGRAM = &bsp_lcd0_readGRAM | |
|
48 | }; | |
|
49 | ||
|
50 | LCD_t lcd0={ | |
|
51 | .interface = &lcdIF0, | |
|
52 | .init = &ssd2119init, | |
|
53 | .paint = &ssd2119paint, | |
|
54 | .paintText = &ssd2119paintText, | |
|
55 | .paintFilRect = &ssd2119paintFilRect, | |
|
56 | .refreshenable = &ssd2119refreshenable, | |
|
57 | .width= 320, | |
|
58 | .height = 240 | |
|
59 | }; | |
|
60 | ||
|
61 | ||
|
62 | volatile int16_t* lcd0_CMD=(volatile int16_t*) 0x60000000; | |
|
63 | volatile int16_t* lcd0_DATA=(volatile int16_t*)(0x60FFFFF0); | |
|
64 | ||
|
65 | int bsp_init() | |
|
66 | { | |
|
67 | int i=0; | |
|
68 | for(i=0;i<32;i++) | |
|
69 | { | |
|
70 | __opnfiles__[i] = NULL; | |
|
71 | } | |
|
72 | bsp_GPIO_init(); | |
|
73 | bsp_uart_init(); | |
|
74 | bsp_FSMC_init(); | |
|
75 | printf("\r================================================================\n\r"); | |
|
76 | printf("================================================================\n\r"); | |
|
77 | printf(BSP); | |
|
78 | printf(" initialised\n\r"); | |
|
79 | printf("================================================================\n\r"); | |
|
80 | return 1; | |
|
81 | } | |
|
82 | ||
|
83 | void bsp_GPIO_init() | |
|
84 | { | |
|
85 | gpio_t gpio1 = gpioopen(PD12);//gpioopen(LED1); //PD9 D=> 0x0300 9 => 0x0009 | |
|
86 | // gpio_t gpio2 = gpioopen(PD13);//gpioopen(LED2); | |
|
87 | gpio_t gpio3 = gpioopen(PD14);//gpioopen(LED2); | |
|
88 | // gpio_t gpio4 = gpioopen(PD15);//gpioopen(LED2); | |
|
89 | gpiosetspeed(&gpio1,gpiohighspeed); | |
|
90 | //gpiosetspeed(&gpio2,gpiohighspeed); | |
|
91 | gpiosetspeed(&gpio3,gpiohighspeed); | |
|
92 | //gpiosetspeed(&gpio4,gpiohighspeed); | |
|
93 | gpiosetdir(&gpio1,gpiooutdir); | |
|
94 | gpiosetdir(&gpio3,gpiooutdir); | |
|
95 | // gpiosetdir(&gpio2,gpiooutdir); | |
|
96 | //gpiosetdir(&gpio4,gpiooutdir); | |
|
97 | } | |
|
98 | ||
|
99 | void bsp_uart_init() | |
|
100 | { | |
|
101 | if(__opnfiles__[1]==NULL) | |
|
102 | { | |
|
103 | //uart_t* uart1 = (uart_t*)malloc(sizeof(uart_t)); | |
|
104 | streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice)); | |
|
105 | uart_t uart = uartopenandconfig(uart6,uartparitynone | uart8bits | uartonestop,9600,PC6,PC7,-1,-1); | |
|
106 | uartmkstreamdev(uart,fd1); | |
|
107 | __opnfiles__[1] = fd1; //stdo | |
|
108 | __opnfiles__[0] = fd1; //stdi | |
|
109 | } | |
|
110 | else | |
|
111 | { | |
|
112 | uartopenandconfig(uart6,uartparitynone | uart8bits | uartonestop,9600,PC6,PC7,-1,-1); | |
|
113 | } | |
|
114 | } | |
|
115 | ||
|
116 | ||
|
117 | /* | |
|
118 | D0 PD14 D1 PD15 D2 PD0 D3 PD1 D4 PE7 | |
|
119 | D5 PE8 D6 PE9 D7 PE10 D8 PE11 D9 PE12 | |
|
120 | D10 PE13 D11 PE14 D12 PE15 D13 PD8 D14 PD9 | |
|
121 | D15 PD10 | |
|
122 | A0 PF0 = RS FSMC_NE3 PG10 CS FSMC_NWE PD5 W/S | |
|
123 | FSMC_NOE PD4 RD | |
|
124 | */ | |
|
125 | /*-- GPIOs Configuration -----------------------------------------------------*/ | |
|
126 | /* | |
|
127 | +-------------------+--------------------+------------------+------------------+ | |
|
128 | + SRAM pins assignment + | |
|
129 | +-------------------+--------------------+------------------+------------------+ | |
|
130 | | PD0 <-> FSMC_D2 | PE0 <-> FSMC_NBL0 | PF0 <-> FSMC_A0 | PG0 <-> FSMC_A10 | | |
|
131 | | PD1 <-> FSMC_D3 | PE1 <-> FSMC_NBL1 | PF1 <-> FSMC_A1 | PG1 <-> FSMC_A11 | | |
|
132 | | PD4 <-> FSMC_NOE | PE3 <-> FSMC_A19 | PF2 <-> FSMC_A2 | PG2 <-> FSMC_A12 | | |
|
133 | | PD5 <-> FSMC_NWE | PE4 <-> FSMC_A20 | PF3 <-> FSMC_A3 | PG3 <-> FSMC_A13 | | |
|
134 | | PD8 <-> FSMC_D13 | PE7 <-> FSMC_D4 | PF4 <-> FSMC_A4 | PG4 <-> FSMC_A14 | | |
|
135 | | PD9 <-> FSMC_D14 | PE8 <-> FSMC_D5 | PF5 <-> FSMC_A5 | PG5 <-> FSMC_A15 | | |
|
136 | | PD10 <-> FSMC_D15 | PE9 <-> FSMC_D6 | PF12 <-> FSMC_A6 | PG9 <-> FSMC_NE2 | | |
|
137 | | PD11 <-> FSMC_A16 | PE10 <-> FSMC_D7 | PF13 <-> FSMC_A7 |------------------+ | |
|
138 | | PD12 <-> FSMC_A17 | PE11 <-> FSMC_D8 | PF14 <-> FSMC_A8 | | |
|
139 | | PD13 <-> FSMC_A18 | PE12 <-> FSMC_D9 | PF15 <-> FSMC_A9 | | |
|
140 | | PD14 <-> FSMC_D0 | PE13 <-> FSMC_D10 |------------------+ | |
|
141 | | PD15 <-> FSMC_D1 | PE14 <-> FSMC_D11 | | |
|
142 | | | PE15 <-> FSMC_D12 | | |
|
143 | +-------------------+--------------------+ | |
|
144 | */ | |
|
145 | int bsp_FSMC_init() | |
|
146 | { | |
|
147 | #define GPIOGETPORT(gpio) ((GPIO_TypeDef*)(((((uint32_t)gpio) & (uint32_t)0x0000FF00)*(uint32_t)4) + (uint32_t)GPIOA)) | |
|
148 | #define GPIOPORTNUM(gpio) (((uint32_t)(gpio) & (uint32_t)0x0000FF00)>>(uint32_t)8) | |
|
149 | ||
|
150 | gpio_t gpio1 = gpioopen(LCD_RESET); | |
|
151 | gpiosetspeed(&gpio1,gpiohighspeed); | |
|
152 | gpiosetdir(&gpio1,gpiooutdir); | |
|
153 | gpioclr(LCD_RESET); | |
|
154 | gpio1 = gpioopen(LCD_CS); | |
|
155 | gpiosetspeed(&gpio1,gpiohighspeed); | |
|
156 | gpiosetdir(&gpio1,gpiooutdir); | |
|
157 | gpioset(LCD_CS); | |
|
158 | gpio_t LCD_DBxList[]={ | |
|
159 | PD0 ,PD1 ,PD4 ,PD5 ,PD8 ,PD9 ,PD10,PD14,PD15, | |
|
160 | PE3 ,PE7 ,PE8 ,PE9 ,PE10,PE11,PE12,PE13,PE14, | |
|
161 | PE15 }; | |
|
162 | ||
|
163 | for(int i=0;i<19;i++) | |
|
164 | { | |
|
165 | gpio_t LCD_DBx = gpioopen(LCD_DBxList[i]); | |
|
166 | LCD_DBx |= gpiohighspeed | gpioaf | gpiopushpulltype | gpionopulltype; | |
|
167 | gpiosetconfig(&LCD_DBx); | |
|
168 | GPIO_PinAFConfig(GPIOGETPORT(LCD_DBx), (uint8_t)(LCD_DBx & 0xF), GPIO_AF_FSMC); | |
|
169 | } | |
|
170 | ||
|
171 | FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure; | |
|
172 | FSMC_NORSRAMTimingInitTypeDef p; | |
|
173 | ||
|
174 | /* Enable FSMC clock */ | |
|
175 | RCC_AHB3PeriphClockCmd(RCC_AHB3Periph_FSMC, ENABLE); | |
|
176 | ||
|
177 | /*-- FSMC Configuration ------------------------------------------------------*/ | |
|
178 | /*----------------------- SRAM Bank 3 ----------------------------------------*/ | |
|
179 | /* FSMC_Bank1_NORSRAM3 configuration */ | |
|
180 | p.FSMC_AddressSetupTime = 1; | |
|
181 | p.FSMC_AddressHoldTime = 0; | |
|
182 | p.FSMC_DataSetupTime = getCpuFreq()/14545450 ;// 11; | |
|
183 | p.FSMC_BusTurnAroundDuration = 0; | |
|
184 | p.FSMC_CLKDivision = 0; | |
|
185 | p.FSMC_DataLatency = 0; | |
|
186 | p.FSMC_AccessMode = FSMC_AccessMode_A; | |
|
187 | /* Color LCD configuration ------------------------------------ | |
|
188 | LCD configured as follow: | |
|
189 | - Data/Address MUX = Disable | |
|
190 | - Memory Type = SRAM | |
|
191 | - Data Width = 16bit | |
|
192 | - Write Operation = Enable | |
|
193 | - Extended Mode = Enable | |
|
194 | - Asynchronous Wait = Disable */ | |
|
195 | ||
|
196 | FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM3; | |
|
197 | FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable; | |
|
198 | FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM; | |
|
199 | FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b; | |
|
200 | FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable; | |
|
201 | FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable; | |
|
202 | FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low; | |
|
203 | FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable; | |
|
204 | FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState; | |
|
205 | FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable; | |
|
206 | FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable; | |
|
207 | FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable; | |
|
208 | FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable; | |
|
209 | FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p; | |
|
210 | FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p; | |
|
211 | ||
|
212 | FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure); | |
|
213 | ||
|
214 | /* Enable FSMC NOR/SRAM Bank1 */ | |
|
215 | FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM3, ENABLE); | |
|
216 | gpioset(LCD_RESET); | |
|
217 | gpioclr(LCD_CS); | |
|
218 | lcd0.init(&lcd0); | |
|
219 | return 1; | |
|
220 | } | |
|
221 | ||
|
222 | void bsp_spi_init() | |
|
223 | { | |
|
224 | ||
|
225 | } | |
|
226 | ||
|
227 | ||
|
228 | void bsp_iic_init() | |
|
229 | { | |
|
230 | ||
|
231 | } | |
|
232 | ||
|
233 | void bsp_SD_init() | |
|
234 | { | |
|
235 | ||
|
236 | } | |
|
237 | ||
|
238 | ||
|
239 | void vs10XXclearXCS(){} | |
|
240 | void vs10XXsetXCS(){} | |
|
241 | int vs10XXDREQ() | |
|
242 | { | |
|
243 | return 1; | |
|
244 | } | |
|
245 | ||
|
246 | ||
|
247 | void bsppowersdcard(char onoff) //always ON | |
|
248 | { | |
|
249 | ||
|
250 | } | |
|
251 | ||
|
252 | char bspsdcardpresent() | |
|
253 | { | |
|
254 | return 0; | |
|
255 | } | |
|
256 | ||
|
257 | char bspsdcardwriteprotected() | |
|
258 | { | |
|
259 | return 0; | |
|
260 | } | |
|
261 | ||
|
262 | void bspsdcardselect(char YESNO) | |
|
263 | { | |
|
264 | ||
|
265 | } | |
|
266 | ||
|
267 | ||
|
268 | ||
|
269 | void bsp_lcd0_write_reg(uint32_t reg,uint32_t data) | |
|
270 | { | |
|
271 | gpioclr(LCD_CS); | |
|
272 | *lcd0_CMD=(uint16_t)reg; | |
|
273 | *lcd0_DATA=(uint16_t)data; | |
|
274 | gpioset(LCD_CS); | |
|
275 | } | |
|
276 | ||
|
277 | uint32_t bsp_lcd0_read_reg(uint32_t reg) | |
|
278 | { | |
|
279 | gpioclr(LCD_CS); | |
|
280 | *lcd0_CMD=(uint16_t)reg; | |
|
281 | uint32_t data=(uint16_t)*lcd0_DATA; | |
|
282 | gpioset(LCD_CS); | |
|
283 | return data; | |
|
284 | } | |
|
285 | ||
|
286 | void bsp_lcd0_writeGRAM(void* buffer,uint32_t count) | |
|
287 | { | |
|
288 | gpioclr(LCD_CS); | |
|
289 | *lcd0_CMD=(uint16_t)ILI9328_REGISTER_WRITEDATATOGRAM; | |
|
290 | uint16_t* castedBuff=(uint16_t*)buffer; | |
|
291 | for(int i=0;i<(int)count;i++) | |
|
292 | { | |
|
293 | *lcd0_DATA=castedBuff[i]; | |
|
294 | } | |
|
295 | gpioset(LCD_CS); | |
|
296 | } | |
|
297 | ||
|
298 | void bsp_lcd0_readGRAM(void* buffer,uint32_t count) | |
|
299 | { | |
|
300 | gpioclr(LCD_CS); | |
|
301 | *lcd0_CMD=(uint16_t)ILI9328_REGISTER_WRITEDATATOGRAM; | |
|
302 | uint16_t* castedBuff=(uint16_t*)buffer; | |
|
303 | castedBuff[0]=*lcd0_DATA; | |
|
304 | for(int i=0;i<(int)count;i++) | |
|
305 | { | |
|
306 | castedBuff[i]=*lcd0_DATA; | |
|
307 | } | |
|
308 | gpioset(LCD_CS); | |
|
309 | } | |
|
310 | ||
|
311 |
@@ -0,0 +1,108 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the libuc, microcontroler library | |
|
3 | -- Copyright (C) 2011, Alexis Jeandet | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | ------------------------------------------------------------------------------- | |
|
19 | -- Author : Alexis Jeandet | |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
|
21 | -------------------------------------------------------------------------------*/ | |
|
22 | #ifndef BSP_H | |
|
23 | #define BSP_H | |
|
24 | #include <stm32f4xx.h> | |
|
25 | #include <gpio.h> | |
|
26 | #include <ili9328.h> | |
|
27 | #include <ssd2119.h> | |
|
28 | #include <genericLCD_Controler.h> | |
|
29 | /* | |
|
30 | #ifndef PD12 | |
|
31 | #define PD12 | |
|
32 | #endif | |
|
33 | #ifndef PD13 | |
|
34 | #define PD13 | |
|
35 | #endif | |
|
36 | */ | |
|
37 | #define __MAX_OPENED_FILES__ 32 | |
|
38 | #define __FS_ROOT_SIZE__ 32 | |
|
39 | ||
|
40 | #define LED1 PD12 | |
|
41 | #define LED2 PD13 | |
|
42 | #define LCD_RESET PD3 | |
|
43 | #define LCD_CS PD7 | |
|
44 | #define LCD_BACKL PD13 | |
|
45 | ||
|
46 | #define GREENLEDON (GPIOD->BSRRL = 1<<12) | |
|
47 | #define ORANGELEDON (GPIOD->BSRRL = 1<<13) | |
|
48 | #define REDLEDON (GPIOD->BSRRL = 1<<14) | |
|
49 | #define BLUELEDON (GPIOD->BSRRL = 1<<15) | |
|
50 | ||
|
51 | #define GREENLEDOFF (GPIOD->BSRRH = 1<<12) | |
|
52 | #define ORANGELEDOFF (GPIOD->BSRRH = 1<<13) | |
|
53 | #define REDLEDOFF (GPIOD->BSRRH = 1<<14) | |
|
54 | #define BLUELEDOFF (GPIOD->BSRRH = 1<<15) | |
|
55 | ||
|
56 | extern float VREF0; | |
|
57 | ||
|
58 | extern uint32_t OSC0; | |
|
59 | extern uint32_t currentCpuFreq; | |
|
60 | ||
|
61 | ||
|
62 | ||
|
63 | extern int bsp_init(); | |
|
64 | ||
|
65 | extern void bsp_GPIO_init(); | |
|
66 | extern void bsp_uart_init(); | |
|
67 | extern void bsp_iic_init(); | |
|
68 | extern void bsp_spi_init(); | |
|
69 | extern void bsp_SD_init(); | |
|
70 | extern int bsp_FSMC_init(); | |
|
71 | ||
|
72 | /* VS1053 */ | |
|
73 | extern void clearXCS(); | |
|
74 | extern void setXCS(); | |
|
75 | extern int vs10XXDREQ(); | |
|
76 | ||
|
77 | /* SD CARD */ | |
|
78 | void bsppowersdcard(char onoff); | |
|
79 | char bspsdcardpresent(); | |
|
80 | void bspsdcardselect(char YESNO); | |
|
81 | char bspsdcardwriteprotected(); | |
|
82 | ||
|
83 | ||
|
84 | void bsp_lcd0_write_reg(uint32_t reg,uint32_t data); | |
|
85 | uint32_t bsp_lcd0_read_reg(uint32_t reg); | |
|
86 | void bsp_lcd0_writeGRAM(void *buffer, uint32_t count); | |
|
87 | void bsp_lcd0_readGRAM(void *buffer, uint32_t count); | |
|
88 | ||
|
89 | #endif | |
|
90 | ||
|
91 | ||
|
92 | ||
|
93 | ||
|
94 | ||
|
95 | ||
|
96 | ||
|
97 | ||
|
98 | ||
|
99 | ||
|
100 | ||
|
101 | ||
|
102 | ||
|
103 | ||
|
104 | ||
|
105 | ||
|
106 | ||
|
107 | ||
|
108 |
@@ -0,0 +1,19 | |||
|
1 | TEMPLATE = lib | |
|
2 | ||
|
3 | TARGET=bsp | |
|
4 | CONFIG += bsp gui | |
|
5 | ||
|
6 | BSP=STM32F4Discovery-ILI9328-8bits | |
|
7 | ||
|
8 | UCMODEL=stm32f4 | |
|
9 | ||
|
10 | SOURCES += bsp.c | |
|
11 | ||
|
12 | HEADERS += bsp.h | |
|
13 | ||
|
14 | LIBS+= -lgpio -luart -li2c -lspi | |
|
15 | ||
|
16 | BSPFILE = bsp.pri | |
|
17 | ||
|
18 | ||
|
19 |
@@ -0,0 +1,378 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the libuc, microcontroler library | |
|
3 | -- Copyright (C) 2011, Alexis Jeandet | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | ------------------------------------------------------------------------------- | |
|
19 | -- Author : Alexis Jeandet | |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
|
21 | -------------------------------------------------------------------------------*/ | |
|
22 | #include "bsp.h" | |
|
23 | #include <streamdevices.h> | |
|
24 | #include <malloc.h> | |
|
25 | #include <gpio.h> | |
|
26 | #include <uart.h> | |
|
27 | #include <stdio.h> | |
|
28 | #include <ili9328.h> | |
|
29 | #include <genericLCD_Controler.h> | |
|
30 | #include <stm32f4xx.h> | |
|
31 | #include <stm32f4xx_gpio.h> | |
|
32 | #include <stm32f4xx_rcc.h> | |
|
33 | #include <stm32f4xx_gpio.h> | |
|
34 | #include <stm32f4xx_fsmc.h> | |
|
35 | #include <terminal.h> | |
|
36 | uint32_t OSC0 =8000000; | |
|
37 | uint32_t INTOSC =16000000; | |
|
38 | uint32_t RTCOSC =32768; | |
|
39 | uint32_t currentCpuFreq=0; | |
|
40 | extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__]; | |
|
41 | ||
|
42 | volatile uint8_t* lcd0_CMD=(volatile uint8_t*)0x60000000; | |
|
43 | volatile uint8_t* lcd0_DATA=(volatile uint8_t*)0x61FFFFF0; | |
|
44 | terminal_t terminal0; | |
|
45 | volatile vs10XXDev audioCodec0; | |
|
46 | sdcardDev sdcard2; | |
|
47 | blkdevice sdcard2blkdev; | |
|
48 | dikpartition sdcard2Part1; | |
|
49 | FAT32fs sdcard2FAT32part1; | |
|
50 | dikpartition sdcard2Part2; | |
|
51 | FAT32fs sdcard2FAT32part2; | |
|
52 | dikpartition sdcard2Part3; | |
|
53 | FAT32fs sdcard2FAT32part3; | |
|
54 | dikpartition sdcard2Part4; | |
|
55 | FAT32fs sdcard2FAT32part4; | |
|
56 | ||
|
57 | LCD_IF_t lcdIF0={ | |
|
58 | .init = &bsp_FSMC_init, | |
|
59 | .writereg = &bsp_lcd0_write_reg, | |
|
60 | .readreg = &bsp_lcd0_read_reg, | |
|
61 | .writeGRAM = &bsp_lcd0_writeGRAM, | |
|
62 | .readGRAM = &bsp_lcd0_readGRAM | |
|
63 | }; | |
|
64 | ||
|
65 | LCD_t lcd0={ | |
|
66 | .interface = &lcdIF0, | |
|
67 | .init = &ili9328init, | |
|
68 | .paint = &ili9328paint, | |
|
69 | .paintText = &ili9328paintText, | |
|
70 | .paintFilRect = &ili9328paintFilRect, | |
|
71 | .refreshenable = &ili9328refreshenable, | |
|
72 | .width= 240, | |
|
73 | .height = 320 | |
|
74 | }; | |
|
75 | ||
|
76 | ||
|
77 | float VREF0 =(float)3.3; | |
|
78 | ||
|
79 | int bsp_init() | |
|
80 | { | |
|
81 | int i=0; | |
|
82 | for(i=0;i<32;i++) | |
|
83 | { | |
|
84 | __opnfiles__[i] = NULL; | |
|
85 | } | |
|
86 | bsp_GPIO_init(); | |
|
87 | bsp_uart_init(); | |
|
88 | bsp_FSMC_init(); | |
|
89 | bsp_GTerm_init(); | |
|
90 | printf("\r================================================================\n\r"); | |
|
91 | printf("================================================================\n\r"); | |
|
92 | printf(BSP); | |
|
93 | printf(" initialised\n\r"); | |
|
94 | printf("================================================================\n\r"); | |
|
95 | return 1; | |
|
96 | } | |
|
97 | ||
|
98 | void bsp_GPIO_init() | |
|
99 | { | |
|
100 | gpio_t gpio1 = gpioopen(PD12);//gpioopen(LED1); //PD9 D=> 0x0300 9 => 0x0009 | |
|
101 | gpio_t gpio2 = gpioopen(PD13);//gpioopen(LED2); | |
|
102 | gpio_t gpio3 = gpioopen(PD14);//gpioopen(LED2); | |
|
103 | gpio_t gpio4 = gpioopen(PD15);//gpioopen(LED2); | |
|
104 | gpiosetspeed(&gpio1,gpiohighspeed); | |
|
105 | gpiosetspeed(&gpio2,gpiohighspeed); | |
|
106 | gpiosetspeed(&gpio3,gpiohighspeed); | |
|
107 | gpiosetspeed(&gpio4,gpiohighspeed); | |
|
108 | gpiosetdir(&gpio1,gpiooutdir); | |
|
109 | gpiosetdir(&gpio3,gpiooutdir); | |
|
110 | gpiosetdir(&gpio2,gpiooutdir); | |
|
111 | gpiosetdir(&gpio4,gpiooutdir); | |
|
112 | } | |
|
113 | ||
|
114 | void bsp_uart_init() | |
|
115 | { | |
|
116 | // if(__opnfiles__[1]==NULL) | |
|
117 | // { | |
|
118 | // //uart_t* uart1 = (uart_t*)malloc(sizeof(uart_t)); | |
|
119 | // streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice)); | |
|
120 | // uart_t uart = uartopenandconfig(uart3,uartparitynone | uart8bits | uartonestop,19200,PB10,PB11,-1,-1); | |
|
121 | // uartmkstreamdev(uart,fd1); | |
|
122 | // __opnfiles__[1] = fd1; //stdo | |
|
123 | // __opnfiles__[0] = fd1; //stdi | |
|
124 | // } | |
|
125 | // else | |
|
126 | // { | |
|
127 | // uartopenandconfig(2,uartparitynone | uart8bits | uartonestop,115200,PB10,PB11,-1,-1); | |
|
128 | // } | |
|
129 | } | |
|
130 | ||
|
131 | void bsp_spi_init() | |
|
132 | { | |
|
133 | ||
|
134 | } | |
|
135 | ||
|
136 | ||
|
137 | int bsp_FSMC_init() | |
|
138 | { | |
|
139 | #define GPIOGETPORT(gpio) ((GPIO_TypeDef*)(((((uint32_t)gpio) & (uint32_t)0x0000FF00)*(uint32_t)4) + (uint32_t)GPIOA)) | |
|
140 | #define GPIOPORTNUM(gpio) (((uint32_t)(gpio) & (uint32_t)0x0000FF00)>>(uint32_t)8) | |
|
141 | ||
|
142 | gpio_t LCD_DBxList[]={PD14,PD15,PD0,PD1,PE7,PE8,PE9,PE10\ | |
|
143 | ,PD4,PD5,PD7,PE4}; | |
|
144 | for(int i=0;i<12;i++) | |
|
145 | { | |
|
146 | gpio_t LCD_DBx = gpioopen(LCD_DBxList[i]); | |
|
147 | LCD_DBx |= gpiohighspeed | gpioaf | gpiopushpulltype | gpionopulltype; | |
|
148 | gpiosetconfig(&LCD_DBx); | |
|
149 | GPIO_PinAFConfig(GPIOGETPORT(LCD_DBx), (uint8_t)(LCD_DBx & 0xF), GPIO_AF_FSMC); | |
|
150 | } | |
|
151 | ||
|
152 | FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure; | |
|
153 | FSMC_NORSRAMTimingInitTypeDef p,readtim; | |
|
154 | ||
|
155 | /* Enable FSMC clock */ | |
|
156 | RCC_AHB3PeriphClockCmd(RCC_AHB3Periph_FSMC, ENABLE); | |
|
157 | ||
|
158 | /*-- FSMC Configuration ------------------------------------------------------*/ | |
|
159 | /*----------------------- SRAM Bank 3 ----------------------------------------*/ | |
|
160 | /* FSMC_Bank1_NORSRAM4 configuration */ | |
|
161 | p.FSMC_AddressSetupTime = 3; | |
|
162 | p.FSMC_AddressHoldTime = 3; | |
|
163 | //ili9328 -> data setup time > 10ns | |
|
164 | p.FSMC_DataSetupTime = 1; | |
|
165 | if(getCpuFreq()>100*1000*1000) | |
|
166 | p.FSMC_DataSetupTime = 2;// 11; | |
|
167 | p.FSMC_BusTurnAroundDuration = 0; | |
|
168 | p.FSMC_CLKDivision = 0; | |
|
169 | p.FSMC_DataLatency = 0; | |
|
170 | //ili9328 -> data hold time > 15ns | |
|
171 | if(getCpuFreq()>66*1000*1000) | |
|
172 | p.FSMC_DataLatency = 1; | |
|
173 | p.FSMC_AccessMode = FSMC_AccessMode_A; | |
|
174 | ||
|
175 | readtim.FSMC_AddressSetupTime = 0xF; | |
|
176 | readtim.FSMC_AddressHoldTime = 0xF; | |
|
177 | //p.FSMC_DataSetupTime = 9; | |
|
178 | readtim.FSMC_DataSetupTime = 0xF ;// 11; | |
|
179 | if(getCpuFreq()>100*1000*1000) | |
|
180 | readtim.FSMC_DataSetupTime = 0xF;// 11; | |
|
181 | readtim.FSMC_BusTurnAroundDuration = 0xf; | |
|
182 | readtim.FSMC_CLKDivision = 0; | |
|
183 | readtim.FSMC_DataLatency = 0xF; | |
|
184 | if(getCpuFreq()>66*1000*1000) | |
|
185 | readtim.FSMC_DataLatency = 0xF; | |
|
186 | readtim.FSMC_AccessMode = FSMC_AccessMode_A; | |
|
187 | ||
|
188 | ||
|
189 | FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM1; | |
|
190 | FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable; | |
|
191 | FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM; | |
|
192 | FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_8b; | |
|
193 | FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable; | |
|
194 | FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable; | |
|
195 | FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low; | |
|
196 | FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable; | |
|
197 | FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState; | |
|
198 | FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable; | |
|
199 | FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable; | |
|
200 | FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable; | |
|
201 | FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable; | |
|
202 | FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &readtim; | |
|
203 | FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p; | |
|
204 | ||
|
205 | FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure); | |
|
206 | ||
|
207 | FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM1, ENABLE); | |
|
208 | gpioset(LCD_RESET); | |
|
209 | gpioclr(LCD_RESET); | |
|
210 | delay_100us(500); | |
|
211 | gpioset(LCD_RESET); | |
|
212 | delay_100us(500); | |
|
213 | lcd0.init(&lcd0); | |
|
214 | gpioset(LCD_BACKL); | |
|
215 | return 1; | |
|
216 | } | |
|
217 | ||
|
218 | ||
|
219 | void bsp_iic_init() | |
|
220 | { | |
|
221 | ||
|
222 | } | |
|
223 | ||
|
224 | void bsp_SD_init() | |
|
225 | { | |
|
226 | ||
|
227 | } | |
|
228 | ||
|
229 | ||
|
230 | void vs10XXclearXCS(){} | |
|
231 | void vs10XXsetXCS(){} | |
|
232 | int vs10XXDREQ() | |
|
233 | { | |
|
234 | return 1; | |
|
235 | } | |
|
236 | ||
|
237 | ||
|
238 | void bsppowersdcard(char onoff) //always ON | |
|
239 | { | |
|
240 | ||
|
241 | } | |
|
242 | ||
|
243 | char bspsdcardpresent() | |
|
244 | { | |
|
245 | return 0; | |
|
246 | } | |
|
247 | ||
|
248 | char bspsdcardwriteprotected() | |
|
249 | { | |
|
250 | return 0; | |
|
251 | } | |
|
252 | ||
|
253 | void bspsdcardselect(char YESNO) | |
|
254 | { | |
|
255 | ||
|
256 | } | |
|
257 | ||
|
258 | ||
|
259 | ||
|
260 | void bsp_lcd0_write_reg(uint32_t reg,uint32_t data) | |
|
261 | { | |
|
262 | uint8_t* pt8 = (uint8_t*)(void*)® | |
|
263 | #if __BYTE_ORDER__==__ORDER_BIG_ENDIAN__ | |
|
264 | *lcd0_CMD=pt8[3]; | |
|
265 | *lcd0_CMD=pt8[2]; | |
|
266 | pt8 = (uint8_t*)(void*)&data; | |
|
267 | *lcd0_DATA=pt8[3]; | |
|
268 | *lcd0_DATA=pt8[2]; | |
|
269 | #else | |
|
270 | *lcd0_CMD=pt8[1]; | |
|
271 | *lcd0_CMD=pt8[0]; | |
|
272 | pt8 = (uint8_t*)(void*)&data; | |
|
273 | *lcd0_DATA=pt8[1]; | |
|
274 | *lcd0_DATA=pt8[0]; | |
|
275 | #endif | |
|
276 | ||
|
277 | } | |
|
278 | ||
|
279 | uint32_t bsp_lcd0_read_reg(uint32_t reg) | |
|
280 | { | |
|
281 | uint8_t* pt8 = (uint8_t*)(void*)® | |
|
282 | uint32_t DATA=0; | |
|
283 | #if __BYTE_ORDER__==__ORDER_BIG_ENDIAN__ | |
|
284 | *lcd0_CMD=pt8[3]; | |
|
285 | *lcd0_CMD=pt8[2]; | |
|
286 | pt8 = (uint8_t*)(void*)&DATA; | |
|
287 | pt8[3]=*lcd0_DATA; | |
|
288 | pt8[2]=*lcd0_DATA; | |
|
289 | #else | |
|
290 | ||
|
291 | *lcd0_CMD=pt8[1]; | |
|
292 | *lcd0_CMD=pt8[0]; | |
|
293 | pt8 = (uint8_t*)(void*)&DATA; | |
|
294 | pt8[1]=*lcd0_DATA; | |
|
295 | pt8[0]=*lcd0_DATA; | |
|
296 | #endif | |
|
297 | ||
|
298 | return DATA; | |
|
299 | } | |
|
300 | ||
|
301 | void bsp_lcd0_writeGRAM(void* buffer,uint32_t count) | |
|
302 | { | |
|
303 | uint32_t reg =ILI9328_REGISTER_WRITEDATATOGRAM; | |
|
304 | uint8_t* pt8 = (uint8_t*)(void*)(®); | |
|
305 | #if __BYTE_ORDER__==__ORDER_BIG_ENDIAN__ | |
|
306 | *lcd0_CMD=pt8[3]; | |
|
307 | *lcd0_CMD=pt8[2]; | |
|
308 | pt8 = (uint8_t*)(void*)buffer; | |
|
309 | for(int i=0;i<(int)count;i++) | |
|
310 | { | |
|
311 | *lcd0_DATA=pt8[(2*i) +1]; | |
|
312 | *lcd0_DATA=pt8[2*i]; | |
|
313 | } | |
|
314 | #else | |
|
315 | ||
|
316 | *lcd0_CMD=pt8[1]; | |
|
317 | *lcd0_CMD=pt8[0]; | |
|
318 | pt8 = (uint8_t*)(void*)buffer; | |
|
319 | for(int i=0;i<(int)count;i++) | |
|
320 | { | |
|
321 | ||
|
322 | *lcd0_DATA=pt8[(2*i) +1]; | |
|
323 | *lcd0_DATA=pt8[2*i]; | |
|
324 | } | |
|
325 | #endif | |
|
326 | } | |
|
327 | ||
|
328 | void bsp_lcd0_readGRAM(void* buffer,uint32_t count) | |
|
329 | { | |
|
330 | uint32_t reg =ILI9328_REGISTER_WRITEDATATOGRAM; | |
|
331 | uint8_t* pt8 = (uint8_t*)(void*)® | |
|
332 | #if __BYTE_ORDER__==__ORDER_BIG_ENDIAN__ | |
|
333 | *lcd0_CMD=pt8[3]; | |
|
334 | *lcd0_CMD=pt8[2]; | |
|
335 | pt8 = (uint8_t*)(void*)buffer; | |
|
336 | for(int i=0;i<(int)count;i++) | |
|
337 | { | |
|
338 | pt8[(2*i) +1]=*lcd0_DATA; | |
|
339 | pt8[2*i]=*lcd0_DATA; | |
|
340 | } | |
|
341 | #else | |
|
342 | *lcd0_CMD=pt8[1]; | |
|
343 | *lcd0_CMD=pt8[0]; | |
|
344 | pt8 = (uint8_t*)(void*)buffer; | |
|
345 | /* | |
|
346 | * x dummy reads Cf ili9328 datasheet p79! | |
|
347 | */ | |
|
348 | pt8[0]=*lcd0_DATA; | |
|
349 | pt8[0]=*lcd0_DATA; | |
|
350 | ||
|
351 | for(int i=0;i<(int)count;i++) | |
|
352 | { | |
|
353 | pt8[(2*i) +1]=*lcd0_DATA; | |
|
354 | pt8[2*i]=*lcd0_DATA; | |
|
355 | // pt8[(2*i) +1]=(uint8_t)0; | |
|
356 | // pt8[(2*i)]=(uint8_t)0; | |
|
357 | } | |
|
358 | #endif | |
|
359 | } | |
|
360 | ||
|
361 | void bsp_GTerm_init() | |
|
362 | { | |
|
363 | if(__opnfiles__[1]==NULL) | |
|
364 | { | |
|
365 | streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice)); | |
|
366 | terminal_init(&terminal0 ,&lcd0,&ComicSansMS_8,fd1); | |
|
367 | __opnfiles__[1] = fd1; | |
|
368 | } | |
|
369 | else | |
|
370 | { | |
|
371 | ||
|
372 | } | |
|
373 | } | |
|
374 | ||
|
375 | ||
|
376 | ||
|
377 | ||
|
378 |
@@ -0,0 +1,127 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the libuc, microcontroler library | |
|
3 | -- Copyright (C) 2011, Alexis Jeandet | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | ------------------------------------------------------------------------------- | |
|
19 | -- Author : Alexis Jeandet | |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
|
21 | -------------------------------------------------------------------------------*/ | |
|
22 | #ifndef BSP_H | |
|
23 | #define BSP_H | |
|
24 | #include <stm32f4xx.h> | |
|
25 | #include <stm32f4xx_gpio.h> | |
|
26 | #include <stm32f4xx_rcc.h> | |
|
27 | #include <gpio.h> | |
|
28 | #include <spi.h> | |
|
29 | #include <ili9328.h> | |
|
30 | #include <genericLCD_Controler.h> | |
|
31 | #include <sdcard-spi.h> | |
|
32 | #include <sdcard.h> | |
|
33 | #include <mbr.h> | |
|
34 | #include <VS10XX.h> | |
|
35 | #include <fat32.h> | |
|
36 | ||
|
37 | /* | |
|
38 | #ifndef PD12 | |
|
39 | #define PD12 | |
|
40 | #endif | |
|
41 | #ifndef PD13 | |
|
42 | #define PD13 | |
|
43 | #endif | |
|
44 | */ | |
|
45 | #define __MAX_OPENED_FILES__ 32 | |
|
46 | #define __FS_ROOT_SIZE__ 32 | |
|
47 | ||
|
48 | #define LED1 PD12 | |
|
49 | #define LED2 PD13 | |
|
50 | #define BP3 PA0 | |
|
51 | ||
|
52 | #define LCD_RESET PD10 | |
|
53 | #define LCD_BACKL PE11 | |
|
54 | ||
|
55 | #define GREENLEDON (GPIOD->BSRRL = 1<<12) | |
|
56 | #define ORANGELEDON (GPIOD->BSRRL = 1<<13) | |
|
57 | #define REDLEDON (GPIOD->BSRRL = 1<<14) | |
|
58 | #define BLUELEDON (GPIOD->BSRRL = 1<<15) | |
|
59 | ||
|
60 | #define GREENLEDOFF (GPIOD->BSRRH = 1<<12) | |
|
61 | #define ORANGELEDOFF (GPIOD->BSRRH = 1<<13) | |
|
62 | #define REDLEDOFF (GPIOD->BSRRH = 1<<14) | |
|
63 | #define BLUELEDOFF (GPIOD->BSRRH = 1<<15) | |
|
64 | ||
|
65 | extern float VREF0; | |
|
66 | extern LCD_t lcd0; | |
|
67 | extern uint32_t OSC0; | |
|
68 | extern uint32_t currentCpuFreq; | |
|
69 | extern volatile vs10XXDev audioCodec0; | |
|
70 | extern sdcardDev sdcard2; | |
|
71 | extern blkdevice sdcard2blkdev; | |
|
72 | extern dikpartition sdcard2Part1; | |
|
73 | extern FAT32fs sdcard2FAT32part1; | |
|
74 | extern dikpartition sdcard2Part2; | |
|
75 | extern FAT32fs sdcard2FAT32part2; | |
|
76 | extern dikpartition sdcard2Part3; | |
|
77 | extern FAT32fs sdcard2FAT32part3; | |
|
78 | extern dikpartition sdcard2Part4; | |
|
79 | extern FAT32fs sdcard2FAT32part4; | |
|
80 | ||
|
81 | ||
|
82 | extern int bsp_init(); | |
|
83 | ||
|
84 | extern void bsp_GPIO_init(); | |
|
85 | extern void bsp_uart_init(); | |
|
86 | extern void bsp_iic_init(); | |
|
87 | extern void bsp_spi_init(); | |
|
88 | extern void bsp_SD_init(); | |
|
89 | extern void bsp_GTerm_init(); | |
|
90 | extern int bsp_FSMC_init(); | |
|
91 | ||
|
92 | void bsp_lcd0_write_reg(uint32_t reg,uint32_t data); | |
|
93 | uint32_t bsp_lcd0_read_reg(uint32_t reg); | |
|
94 | void bsp_lcd0_writeGRAM(void *buffer, uint32_t count); | |
|
95 | void bsp_lcd0_readGRAM(void *buffer, uint32_t count); | |
|
96 | ||
|
97 | /* VS1053 */ | |
|
98 | extern void clearXCS(); | |
|
99 | extern void setXCS(); | |
|
100 | extern int vs10XXDREQ(); | |
|
101 | ||
|
102 | /* SD CARD */ | |
|
103 | void bsppowersdcard(char onoff); | |
|
104 | char bspsdcardpresent(); | |
|
105 | void bspsdcardselect(char YESNO); | |
|
106 | char bspsdcardwriteprotected(); | |
|
107 | ||
|
108 | #endif | |
|
109 | ||
|
110 | ||
|
111 | ||
|
112 | ||
|
113 | ||
|
114 | ||
|
115 | ||
|
116 | ||
|
117 | ||
|
118 | ||
|
119 | ||
|
120 | ||
|
121 | ||
|
122 | ||
|
123 | ||
|
124 | ||
|
125 | ||
|
126 | ||
|
127 |
@@ -0,0 +1,3 | |||
|
1 | CPU=stm32f4xxxG | |
|
2 | DEFINES+=BSP=\\\"STM32F4Discovery-ILI9328-8bits\\\" | |
|
3 | UCMODEL=stm32f4 |
@@ -0,0 +1,19 | |||
|
1 | TEMPLATE = lib | |
|
2 | ||
|
3 | TARGET=bsp | |
|
4 | CONFIG += bsp | |
|
5 | ||
|
6 | BSP=STM32F4Discovery | |
|
7 | ||
|
8 | UCMODEL=stm32f4 | |
|
9 | ||
|
10 | SOURCES += bsp.c | |
|
11 | ||
|
12 | HEADERS += bsp.h | |
|
13 | ||
|
14 | LIBS+= -lgpio -luart -li2c -lspi | |
|
15 | ||
|
16 | BSPFILE = bsp.pri | |
|
17 | ||
|
18 | ||
|
19 |
@@ -0,0 +1,134 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the libuc, microcontroler library | |
|
3 | -- Copyright (C) 2011, Alexis Jeandet | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | ------------------------------------------------------------------------------- | |
|
19 | -- Author : Alexis Jeandet | |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
|
21 | -------------------------------------------------------------------------------*/ | |
|
22 | #include "bsp.h" | |
|
23 | #include <streamdevices.h> | |
|
24 | #include <malloc.h> | |
|
25 | #include <gpio.h> | |
|
26 | #include <uart.h> | |
|
27 | #include <stdio.h> | |
|
28 | uint32_t OSC0 =8000000; | |
|
29 | uint32_t INTOSC =16000000; | |
|
30 | uint32_t RTCOSC =32768; | |
|
31 | uint32_t currentCpuFreq=0; | |
|
32 | extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__]; | |
|
33 | ||
|
34 | float VREF0 =(float)3.3; | |
|
35 | ||
|
36 | int bsp_init() | |
|
37 | { | |
|
38 | int i=0; | |
|
39 | for(i=0;i<32;i++) | |
|
40 | { | |
|
41 | __opnfiles__[i] = NULL; | |
|
42 | } | |
|
43 | bsp_GPIO_init(); | |
|
44 | bsp_uart_init(); | |
|
45 | printf("\r================================================================\n\r"); | |
|
46 | printf("================================================================\n\r"); | |
|
47 | printf(BSP); | |
|
48 | printf(" initialised\n\r"); | |
|
49 | printf("================================================================\n\r"); | |
|
50 | return 1; | |
|
51 | } | |
|
52 | ||
|
53 | void bsp_GPIO_init() | |
|
54 | { | |
|
55 | gpio_t gpio1 = gpioopen(PD12);//gpioopen(LED1); //PD9 D=> 0x0300 9 => 0x0009 | |
|
56 | gpio_t gpio2 = gpioopen(PD13);//gpioopen(LED2); | |
|
57 | gpio_t gpio3 = gpioopen(PD14);//gpioopen(LED2); | |
|
58 | gpio_t gpio4 = gpioopen(PD15);//gpioopen(LED2); | |
|
59 | gpiosetspeed(&gpio1,gpiohighspeed); | |
|
60 | gpiosetspeed(&gpio2,gpiohighspeed); | |
|
61 | gpiosetspeed(&gpio3,gpiohighspeed); | |
|
62 | gpiosetspeed(&gpio4,gpiohighspeed); | |
|
63 | gpiosetdir(&gpio1,gpiooutdir); | |
|
64 | gpiosetdir(&gpio3,gpiooutdir); | |
|
65 | gpiosetdir(&gpio2,gpiooutdir); | |
|
66 | gpiosetdir(&gpio4,gpiooutdir); | |
|
67 | } | |
|
68 | ||
|
69 | void bsp_uart_init() | |
|
70 | { | |
|
71 | if(__opnfiles__[1]==NULL) | |
|
72 | { | |
|
73 | //uart_t* uart1 = (uart_t*)malloc(sizeof(uart_t)); | |
|
74 | streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice)); | |
|
75 | uart_t uart = uartopenandconfig(uart3,uartparitynone | uart8bits | uartonestop,19200,PB10,PB11,-1,-1); | |
|
76 | uartmkstreamdev(uart,fd1); | |
|
77 | __opnfiles__[1] = fd1; //stdo | |
|
78 | __opnfiles__[0] = fd1; //stdi | |
|
79 | } | |
|
80 | else | |
|
81 | { | |
|
82 | uartopenandconfig(2,uartparitynone | uart8bits | uartonestop,115200,PB10,PB11,-1,-1); | |
|
83 | } | |
|
84 | } | |
|
85 | ||
|
86 | void bsp_spi_init() | |
|
87 | { | |
|
88 | ||
|
89 | } | |
|
90 | ||
|
91 | ||
|
92 | void bsp_iic_init() | |
|
93 | { | |
|
94 | ||
|
95 | } | |
|
96 | ||
|
97 | void bsp_SD_init() | |
|
98 | { | |
|
99 | ||
|
100 | } | |
|
101 | ||
|
102 | ||
|
103 | void vs10XXclearXCS(){} | |
|
104 | void vs10XXsetXCS(){} | |
|
105 | int vs10XXDREQ() | |
|
106 | { | |
|
107 | return 1; | |
|
108 | } | |
|
109 | ||
|
110 | ||
|
111 | void bsppowersdcard(char onoff) //always ON | |
|
112 | { | |
|
113 | ||
|
114 | } | |
|
115 | ||
|
116 | char bspsdcardpresent() | |
|
117 | { | |
|
118 | return 0; | |
|
119 | } | |
|
120 | ||
|
121 | char bspsdcardwriteprotected() | |
|
122 | { | |
|
123 | return 0; | |
|
124 | } | |
|
125 | ||
|
126 | void bspsdcardselect(char YESNO) | |
|
127 | { | |
|
128 | ||
|
129 | } | |
|
130 | ||
|
131 | ||
|
132 | ||
|
133 | ||
|
134 |
@@ -0,0 +1,95 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the libuc, microcontroler library | |
|
3 | -- Copyright (C) 2011, Alexis Jeandet | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | ------------------------------------------------------------------------------- | |
|
19 | -- Author : Alexis Jeandet | |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
|
21 | -------------------------------------------------------------------------------*/ | |
|
22 | #ifndef BSP_H | |
|
23 | #define BSP_H | |
|
24 | #include <stm32f4xx.h> | |
|
25 | #include <gpio.h> | |
|
26 | /* | |
|
27 | #ifndef PD12 | |
|
28 | #define PD12 | |
|
29 | #endif | |
|
30 | #ifndef PD13 | |
|
31 | #define PD13 | |
|
32 | #endif | |
|
33 | */ | |
|
34 | #define __MAX_OPENED_FILES__ 32 | |
|
35 | #define __FS_ROOT_SIZE__ 32 | |
|
36 | ||
|
37 | #define LED1 PD12 | |
|
38 | #define LED2 PD13 | |
|
39 | ||
|
40 | #define GREENLEDON (GPIOD->BSRRL = 1<<12) | |
|
41 | #define ORANGELEDON (GPIOD->BSRRL = 1<<13) | |
|
42 | #define REDLEDON (GPIOD->BSRRL = 1<<14) | |
|
43 | #define BLUELEDON (GPIOD->BSRRL = 1<<15) | |
|
44 | ||
|
45 | #define GREENLEDOFF (GPIOD->BSRRH = 1<<12) | |
|
46 | #define ORANGELEDOFF (GPIOD->BSRRH = 1<<13) | |
|
47 | #define REDLEDOFF (GPIOD->BSRRH = 1<<14) | |
|
48 | #define BLUELEDOFF (GPIOD->BSRRH = 1<<15) | |
|
49 | ||
|
50 | extern float VREF0; | |
|
51 | ||
|
52 | extern uint32_t OSC0; | |
|
53 | extern uint32_t currentCpuFreq; | |
|
54 | ||
|
55 | ||
|
56 | ||
|
57 | extern int bsp_init(); | |
|
58 | ||
|
59 | extern void bsp_GPIO_init(); | |
|
60 | extern void bsp_uart_init(); | |
|
61 | extern void bsp_iic_init(); | |
|
62 | extern void bsp_spi_init(); | |
|
63 | extern void bsp_SD_init(); | |
|
64 | ||
|
65 | /* VS1053 */ | |
|
66 | extern void clearXCS(); | |
|
67 | extern void setXCS(); | |
|
68 | extern int vs10XXDREQ(); | |
|
69 | ||
|
70 | /* SD CARD */ | |
|
71 | void bsppowersdcard(char onoff); | |
|
72 | char bspsdcardpresent(); | |
|
73 | void bspsdcardselect(char YESNO); | |
|
74 | char bspsdcardwriteprotected(); | |
|
75 | ||
|
76 | #endif | |
|
77 | ||
|
78 | ||
|
79 | ||
|
80 | ||
|
81 | ||
|
82 | ||
|
83 | ||
|
84 | ||
|
85 | ||
|
86 | ||
|
87 | ||
|
88 | ||
|
89 | ||
|
90 | ||
|
91 | ||
|
92 | ||
|
93 | ||
|
94 | ||
|
95 |
@@ -0,0 +1,18 | |||
|
1 | TEMPLATE = lib | |
|
2 | ||
|
3 | TARGET=bsp | |
|
4 | CONFIG += bsp gui | |
|
5 | ||
|
6 | BSP=STM32F4Eval | |
|
7 | ||
|
8 | UCMODEL=stm32f4 | |
|
9 | ||
|
10 | SOURCES += bsp.c | |
|
11 | ||
|
12 | HEADERS += bsp.h | |
|
13 | LIBS+= -lgpio -luart -li2c -lspi | |
|
14 | ||
|
15 | BSPFILE = bsp.pri | |
|
16 | ||
|
17 | ||
|
18 |
@@ -0,0 +1,363 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the libuc, microcontroler library | |
|
3 | -- Copyright (C) 2011, Alexis Jeandet | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | ------------------------------------------------------------------------------- | |
|
19 | -- Author : Alexis Jeandet | |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
|
21 | -------------------------------------------------------------------------------*/ | |
|
22 | #include "bsp.h" | |
|
23 | #include <streamdevices.h> | |
|
24 | #include <malloc.h> | |
|
25 | #include <gpio.h> | |
|
26 | #include <uart.h> | |
|
27 | #include <stdio.h> | |
|
28 | #include <stm32f4xx_gpio.h> | |
|
29 | #include <stm32f4xx_fsmc.h> | |
|
30 | #include <i2c.h> | |
|
31 | #include <core.h> | |
|
32 | #include <terminal.h> | |
|
33 | uint32_t OSC0 =8000000; | |
|
34 | uint32_t INTOSC =16000000; | |
|
35 | uint32_t RTCOSC =32768; | |
|
36 | uint32_t currentCpuFreq=0; | |
|
37 | extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__]; | |
|
38 | ||
|
39 | LCD_IF_t lcdIF0={ | |
|
40 | .init = &bsp_FSMC_init, | |
|
41 | .writereg = &bsp_lcd0_write_reg, | |
|
42 | .readreg = &bsp_lcd0_read_reg, | |
|
43 | .writeGRAM = &bsp_lcd0_writeGRAM, | |
|
44 | .readGRAM = &bsp_lcd0_readGRAM | |
|
45 | }; | |
|
46 | ||
|
47 | LCD_t lcd0={ | |
|
48 | .interface = &lcdIF0, | |
|
49 | .init = &ili9328init, | |
|
50 | .paint = &ili9328paint, | |
|
51 | .paintText = &ili9328paintText, | |
|
52 | .paintFilRect = &ili9328paintFilRect, | |
|
53 | .getPix = &ili9328getPix, | |
|
54 | .refreshenable = &ili9328refreshenable, | |
|
55 | .width= 240, | |
|
56 | .height = 320 | |
|
57 | }; | |
|
58 | ||
|
59 | terminal_t terminal0; | |
|
60 | ||
|
61 | ||
|
62 | volatile int16_t* lcd0_CMD=(volatile int16_t*) (0x60000000 | 0x08000000); | |
|
63 | volatile int16_t* lcd0_DATA=((volatile int16_t*)(0x60000000 | 0x08000002)); | |
|
64 | ||
|
65 | float VREF0 =(float)3.3; | |
|
66 | ||
|
67 | int bsp_init() | |
|
68 | { | |
|
69 | int i=0; | |
|
70 | for(i=0;i<32;i++) | |
|
71 | { | |
|
72 | __opnfiles__[i] = NULL; | |
|
73 | } | |
|
74 | bsp_GPIO_init(); | |
|
75 | bsp_uart_init(); | |
|
76 | bsp_iic_init(); | |
|
77 | bsp_FSMC_init(); | |
|
78 | bsp_GTerm_init(); | |
|
79 | printf("\r=====================\n\r"); | |
|
80 | printf( "=====================\n\r"); | |
|
81 | printf(BSP); | |
|
82 | printf(" initialised\n\r"); | |
|
83 | printf( "=====================\n\r"); | |
|
84 | return 1; | |
|
85 | } | |
|
86 | ||
|
87 | void bsp_GPIO_init() | |
|
88 | { | |
|
89 | gpio_t gpio1 = gpioopen(LED1); | |
|
90 | gpio_t gpio2 = gpioopen(LED2); | |
|
91 | gpio_t gpio3 = gpioopen(LED3); | |
|
92 | gpiosetspeed(&gpio1,gpiohighspeed); | |
|
93 | gpiosetspeed(&gpio2,gpiohighspeed); | |
|
94 | gpiosetspeed(&gpio3,gpiohighspeed); | |
|
95 | gpiosetdir(&gpio1,gpiooutdir); | |
|
96 | gpiosetdir(&gpio2,gpiooutdir); | |
|
97 | gpiosetdir(&gpio3,gpiooutdir); | |
|
98 | } | |
|
99 | ||
|
100 | void bsp_uart_init() | |
|
101 | { | |
|
102 | //if(__opnfiles__[1]==NULL) | |
|
103 | //{ | |
|
104 | //uart_t* uart1 = (uart_t*)malloc(sizeof(uart_t)); | |
|
105 | // streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice)); | |
|
106 | // uart_t uart = uartopenandconfig(uart1,uartparitynone | uart8bits | uartonestop,115200,PA9,PA10,-1,-1); | |
|
107 | //uartmkstreamdev(uart,fd1); | |
|
108 | //__opnfiles__[1] = fd1; | |
|
109 | //} | |
|
110 | //else | |
|
111 | //{ | |
|
112 | uartopenandconfig(0,uartparitynone | uart8bits | uartonestop,115200,PA9,PA10,-1,-1); | |
|
113 | //} | |
|
114 | } | |
|
115 | ||
|
116 | /* | |
|
117 | D0 PD14 D1 PD15 D2 PD0 D3 PD1 D4 PE7 | |
|
118 | D5 PE8 D6 PE9 D7 PE10 D8 PE11 D9 PE12 | |
|
119 | D10 PE13 D11 PE14 D12 PE15 D13 PD8 D14 PD9 | |
|
120 | D15 PD10 | |
|
121 | A0 PF0 = RS FSMC_NE3 PG10 CS FSMC_NWE PD5 W/S | |
|
122 | FSMC_NOE PD4 RD | |
|
123 | */ | |
|
124 | /*-- GPIOs Configuration -----------------------------------------------------*/ | |
|
125 | /* | |
|
126 | +-------------------+--------------------+------------------+------------------+ | |
|
127 | + SRAM pins assignment + | |
|
128 | +-------------------+--------------------+------------------+------------------+ | |
|
129 | | PD0 <-> FSMC_D2 | PE0 <-> FSMC_NBL0 | PF0 <-> FSMC_A0 | PG0 <-> FSMC_A10 | | |
|
130 | | PD1 <-> FSMC_D3 | PE1 <-> FSMC_NBL1 | PF1 <-> FSMC_A1 | PG1 <-> FSMC_A11 | | |
|
131 | | PD4 <-> FSMC_NOE | PE3 <-> FSMC_A19 | PF2 <-> FSMC_A2 | PG2 <-> FSMC_A12 | | |
|
132 | | PD5 <-> FSMC_NWE | PE4 <-> FSMC_A20 | PF3 <-> FSMC_A3 | PG3 <-> FSMC_A13 | | |
|
133 | | PD8 <-> FSMC_D13 | PE7 <-> FSMC_D4 | PF4 <-> FSMC_A4 | PG4 <-> FSMC_A14 | | |
|
134 | | PD9 <-> FSMC_D14 | PE8 <-> FSMC_D5 | PF5 <-> FSMC_A5 | PG5 <-> FSMC_A15 | | |
|
135 | | PD10 <-> FSMC_D15 | PE9 <-> FSMC_D6 | PF12 <-> FSMC_A6 | PG9 <-> FSMC_NE2 | | |
|
136 | | PD11 <-> FSMC_A16 | PE10 <-> FSMC_D7 | PF13 <-> FSMC_A7 |------------------+ | |
|
137 | | PD12 <-> FSMC_A17 | PE11 <-> FSMC_D8 | PF14 <-> FSMC_A8 | | |
|
138 | | PD13 <-> FSMC_A18 | PE12 <-> FSMC_D9 | PF15 <-> FSMC_A9 | | |
|
139 | | PD14 <-> FSMC_D0 | PE13 <-> FSMC_D10 |------------------+ | |
|
140 | | PD15 <-> FSMC_D1 | PE14 <-> FSMC_D11 | | |
|
141 | | | PE15 <-> FSMC_D12 | | |
|
142 | +-------------------+--------------------+ | |
|
143 | */ | |
|
144 | int bsp_FSMC_init() | |
|
145 | { | |
|
146 | #define GPIOGETPORT(gpio) ((GPIO_TypeDef*)(((((uint32_t)gpio) & (uint32_t)0x0000FF00)*(uint32_t)4) + (uint32_t)GPIOA)) | |
|
147 | #define GPIOPORTNUM(gpio) (((uint32_t)(gpio) & (uint32_t)0x0000FF00)>>(uint32_t)8) | |
|
148 | ||
|
149 | gpio_t LCD_DBxList[]={ | |
|
150 | PD0 ,PD1 ,PD4 ,PD5 ,PD8 ,PD9 ,PD10,PD11,PD12,PD13,PD14,PD15, | |
|
151 | PE0 ,PE1 ,PE3 ,PE4 ,PE7 ,PE8 ,PE9 ,PE10,PE11,PE12,PE13,PE14, | |
|
152 | PE15,PF0 ,PF1 ,PF2 ,PF3 ,PF4 ,PF5 ,PF12,PF13,PF14,PF15,PG0 , | |
|
153 | PG1 ,PG2 ,PG3 ,PG4 ,PG5 ,PG9 ,PG10 | |
|
154 | }; | |
|
155 | ||
|
156 | for(int i=0;i<43;i++) | |
|
157 | { | |
|
158 | gpio_t LCD_DBx = gpioopen(LCD_DBxList[i]); | |
|
159 | LCD_DBx |= gpiohighspeed | gpioaf | gpiopushpulltype | gpionopulltype; | |
|
160 | gpiosetconfig(&LCD_DBx); | |
|
161 | GPIO_PinAFConfig(GPIOGETPORT(LCD_DBx), (uint8_t)(LCD_DBx & 0xF), GPIO_AF_FSMC); | |
|
162 | } | |
|
163 | ||
|
164 | FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure; | |
|
165 | FSMC_NORSRAMTimingInitTypeDef p,readtim; | |
|
166 | ||
|
167 | /* Enable FSMC clock */ | |
|
168 | RCC_AHB3PeriphClockCmd(RCC_AHB3Periph_FSMC, ENABLE); | |
|
169 | ||
|
170 | /*-- FSMC Configuration ------------------------------------------------------*/ | |
|
171 | /*----------------------- SRAM Bank 3 ----------------------------------------*/ | |
|
172 | /* FSMC_Bank1_NORSRAM3 configuration */ | |
|
173 | p.FSMC_AddressSetupTime = 0xf; | |
|
174 | p.FSMC_AddressHoldTime = 0xf; | |
|
175 | //ili9328 -> data setup time > 10ns | |
|
176 | p.FSMC_DataSetupTime = 0xf; | |
|
177 | if(getCpuFreq()>100*1000*1000) | |
|
178 | p.FSMC_DataSetupTime = 0xf;// 11; | |
|
179 | p.FSMC_BusTurnAroundDuration = 0xf; | |
|
180 | p.FSMC_CLKDivision = 0; | |
|
181 | p.FSMC_DataLatency = 0xf; | |
|
182 | //ili9328 -> data hold time > 15ns | |
|
183 | if(getCpuFreq()>66*1000*1000) | |
|
184 | p.FSMC_DataLatency = 0xf; | |
|
185 | p.FSMC_AccessMode = FSMC_AccessMode_A; | |
|
186 | ||
|
187 | readtim.FSMC_AddressSetupTime = 0xf; | |
|
188 | readtim.FSMC_AddressHoldTime = 0xf; | |
|
189 | //p.FSMC_DataSetupTime = 9; | |
|
190 | readtim.FSMC_DataSetupTime = 0xf ;// 11; | |
|
191 | if(getCpuFreq()>100*1000*1000) | |
|
192 | readtim.FSMC_DataSetupTime = 0xf;// 11; | |
|
193 | readtim.FSMC_BusTurnAroundDuration = 0xf; | |
|
194 | readtim.FSMC_CLKDivision = 0; | |
|
195 | readtim.FSMC_DataLatency = 0xf; | |
|
196 | if(getCpuFreq()>66*1000*1000) | |
|
197 | readtim.FSMC_DataLatency = 0xf; | |
|
198 | readtim.FSMC_AccessMode = FSMC_AccessMode_A; | |
|
199 | /* Color LCD configuration ------------------------------------ | |
|
200 | LCD configured as follow: | |
|
201 | - Data/Address MUX = Disable | |
|
202 | - Memory Type = SRAM | |
|
203 | - Data Width = 16bit | |
|
204 | - Write Operation = Enable | |
|
205 | - Extended Mode = Enable | |
|
206 | - Asynchronous Wait = Disable */ | |
|
207 | ||
|
208 | FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM3; | |
|
209 | FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable; | |
|
210 | FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM; | |
|
211 | FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b; | |
|
212 | FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable; | |
|
213 | FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable; | |
|
214 | FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low; | |
|
215 | FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable; | |
|
216 | FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState; | |
|
217 | FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable; | |
|
218 | FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable; | |
|
219 | FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable; | |
|
220 | FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable; | |
|
221 | FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &readtim; | |
|
222 | FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p; | |
|
223 | ||
|
224 | FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure); | |
|
225 | ||
|
226 | /* Enable FSMC NOR/SRAM Bank1 */ | |
|
227 | FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM3, ENABLE); | |
|
228 | ||
|
229 | ||
|
230 | p.FSMC_AddressSetupTime = getCpuFreq()/50000000; | |
|
231 | p.FSMC_AddressHoldTime = 0; | |
|
232 | p.FSMC_DataSetupTime = getCpuFreq()/25000000; | |
|
233 | p.FSMC_BusTurnAroundDuration = 1; | |
|
234 | p.FSMC_CLKDivision = 0; | |
|
235 | p.FSMC_DataLatency = 0; | |
|
236 | p.FSMC_AccessMode = FSMC_AccessMode_A; | |
|
237 | ||
|
238 | FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM2; | |
|
239 | FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable; | |
|
240 | FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_PSRAM; | |
|
241 | FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b; | |
|
242 | FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable; | |
|
243 | FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable; | |
|
244 | FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low; | |
|
245 | FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable; | |
|
246 | FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState; | |
|
247 | FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable; | |
|
248 | FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable; | |
|
249 | FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable; | |
|
250 | FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable; | |
|
251 | FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p; | |
|
252 | FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p; | |
|
253 | ||
|
254 | FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure); | |
|
255 | ||
|
256 | /*!< Enable FSMC Bank1_SRAM2 Bank */ | |
|
257 | FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM2, ENABLE); | |
|
258 | lcd0.init(&lcd0); | |
|
259 | return 1; | |
|
260 | } | |
|
261 | ||
|
262 | void bsp_spi_init() | |
|
263 | { | |
|
264 | ||
|
265 | } | |
|
266 | ||
|
267 | ||
|
268 | void bsp_iic_init() | |
|
269 | { | |
|
270 | i2copenandconfig(i2c1,0,10000,PB9,PB6); | |
|
271 | } | |
|
272 | ||
|
273 | void bsp_SD_init() | |
|
274 | { | |
|
275 | gpio_t SDIO_DBxList[]={PC8 ,PC9 ,PC10 ,PC11 ,PC12,PD2}; | |
|
276 | for(int i=0;i<6;i++) | |
|
277 | { | |
|
278 | gpio_t SDIO_DBx = gpioopen(SDIO_DBxList[i]); | |
|
279 | SDIO_DBx |= gpiohighspeed | gpioaf | gpiopushpulltype | gpionopulltype; | |
|
280 | gpiosetconfig(&SDIO_DBx); | |
|
281 | GPIO_PinAFConfig(GPIOGETPORT(SDIO_DBx), (uint8_t)(SDIO_DBx & 0xF), GPIO_AF_SDIO); | |
|
282 | } | |
|
283 | } | |
|
284 | ||
|
285 | void vs10XXclearXCS(){} | |
|
286 | void vs10XXsetXCS(){} | |
|
287 | int vs10XXDREQ() | |
|
288 | { | |
|
289 | return 1; | |
|
290 | } | |
|
291 | ||
|
292 | ||
|
293 | void bsppowersdcard(char onoff) //always ON | |
|
294 | { | |
|
295 | ||
|
296 | } | |
|
297 | ||
|
298 | char bspsdcardpresent() | |
|
299 | { | |
|
300 | return 0; | |
|
301 | } | |
|
302 | ||
|
303 | char bspsdcardwriteprotected() | |
|
304 | { | |
|
305 | return 0; | |
|
306 | } | |
|
307 | ||
|
308 | void bspsdcardselect(char YESNO) | |
|
309 | { | |
|
310 | ||
|
311 | } | |
|
312 | ||
|
313 | ||
|
314 | void bsp_lcd0_write_reg(uint32_t reg,uint32_t data) | |
|
315 | { | |
|
316 | *lcd0_CMD=(uint16_t)reg; | |
|
317 | *lcd0_DATA=(uint16_t)data; | |
|
318 | } | |
|
319 | ||
|
320 | uint32_t bsp_lcd0_read_reg(uint32_t reg) | |
|
321 | { | |
|
322 | *lcd0_CMD=(uint16_t)reg; | |
|
323 | return (uint16_t)*lcd0_DATA; | |
|
324 | } | |
|
325 | ||
|
326 | void bsp_lcd0_writeGRAM(void* buffer,uint32_t count) | |
|
327 | { | |
|
328 | *lcd0_CMD=(uint16_t)ILI9328_REGISTER_WRITEDATATOGRAM; | |
|
329 | uint16_t* castedBuff=(uint16_t*)buffer; | |
|
330 | for(int i=0;i<(int)count;i++) | |
|
331 | { | |
|
332 | *lcd0_DATA=castedBuff[i]; | |
|
333 | } | |
|
334 | } | |
|
335 | ||
|
336 | void bsp_lcd0_readGRAM(void* buffer,uint32_t count) | |
|
337 | { | |
|
338 | *lcd0_CMD=(uint16_t)ILI9328_REGISTER_WRITEDATATOGRAM; | |
|
339 | uint16_t* castedBuff=(uint16_t*)buffer; | |
|
340 | castedBuff[0]=*lcd0_DATA; | |
|
341 | for(int i=0;i<(int)count;i++) | |
|
342 | { | |
|
343 | castedBuff[i]=*lcd0_DATA; | |
|
344 | } | |
|
345 | } | |
|
346 | ||
|
347 | void bsp_GTerm_init() | |
|
348 | { | |
|
349 | if(__opnfiles__[1]==NULL) | |
|
350 | { | |
|
351 | streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice)); | |
|
352 | ili9328paintFilRect(&lcd0,0,0,240,320,0x7FFF,5,0); | |
|
353 | terminal_init(&terminal0,&lcd0,&ComicSansMS_8,fd1); | |
|
354 | __opnfiles__[1] = fd1; | |
|
355 | } | |
|
356 | else | |
|
357 | { | |
|
358 | ||
|
359 | } | |
|
360 | } | |
|
361 | ||
|
362 | ||
|
363 |
@@ -0,0 +1,94 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the libuc, microcontroler library | |
|
3 | -- Copyright (C) 2011, Alexis Jeandet | |
|
4 | -- | |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
|
6 | -- it under the terms of the GNU General Public License as published by | |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
|
8 | -- (at your option) any later version. | |
|
9 | -- | |
|
10 | -- This program is distributed in the hope that it will be useful, | |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
13 | -- GNU General Public License for more details. | |
|
14 | -- | |
|
15 | -- You should have received a copy of the GNU General Public License | |
|
16 | -- along with this program; if not, write to the Free Software | |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
|
18 | ------------------------------------------------------------------------------- | |
|
19 | -- Author : Alexis Jeandet | |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
|
21 | -------------------------------------------------------------------------------*/ | |
|
22 | #ifndef BSP_H | |
|
23 | #define BSP_H | |
|
24 | #include <stm32f4xx.h> | |
|
25 | #include <stm32f4xx_gpio.h> | |
|
26 | #include <stm32f4xx_rcc.h> | |
|
27 | #include <gpio.h> | |
|
28 | #include <ili9328.h> | |
|
29 | #include <genericLCD_Controler.h> | |
|
30 | ||
|
31 | #define __MAX_OPENED_FILES__ 4 | |
|
32 | #define __FS_ROOT_SIZE__ 4 | |
|
33 | ||
|
34 | ||
|
35 | ||
|
36 | #define LED1 PG6 | |
|
37 | #define LED2 PG8 | |
|
38 | #define LED3 PI9 | |
|
39 | #define LED4 PC7 | |
|
40 | ||
|
41 | ||
|
42 | extern float VREF0; | |
|
43 | ||
|
44 | extern uint32_t currentCpuFreq; | |
|
45 | extern LCD_t lcd0; | |
|
46 | ||
|
47 | ||
|
48 | extern int bsp_init(); | |
|
49 | ||
|
50 | extern void bsp_GPIO_init(); | |
|
51 | extern void bsp_uart_init(); | |
|
52 | extern void bsp_iic_init(); | |
|
53 | extern void bsp_spi_init(); | |
|
54 | extern void bsp_SD_init(); | |
|
55 | extern void bsp_GTerm_init(); | |
|
56 | extern int bsp_FSMC_init(); | |
|
57 | ||
|
58 | /* VS1053 */ | |
|
59 | extern void clearXCS(); | |
|
60 | extern void setXCS(); | |
|
61 | extern int vs10XXDREQ(); | |
|
62 | ||
|
63 | /* SD CARD */ | |
|
64 | void bsppowersdcard(char onoff); | |
|
65 | char bspsdcardpresent(); | |
|
66 | void bspsdcardselect(char YESNO); | |
|
67 | char bspsdcardwriteprotected(); | |
|
68 | ||
|
69 | ||
|
70 | void bsp_lcd0_write_reg(uint32_t reg,uint32_t data); | |
|
71 | uint32_t bsp_lcd0_read_reg(uint32_t reg); | |
|
72 | void bsp_lcd0_writeGRAM(void *buffer, uint32_t count); | |
|
73 | void bsp_lcd0_readGRAM(void *buffer, uint32_t count); | |
|
74 | ||
|
75 | #endif | |
|
76 | ||
|
77 | ||
|
78 | ||
|
79 | ||
|
80 | ||
|
81 | ||
|
82 | ||
|
83 | ||
|
84 | ||
|
85 | ||
|
86 | ||
|
87 | ||
|
88 | ||
|
89 | ||
|
90 | ||
|
91 | ||
|
92 | ||
|
93 | ||
|
94 |
@@ -0,0 +1,20 | |||
|
1 | TEMPLATE = subdirs | |
|
2 | CONFIG += ordered | |
|
3 | SUBDIRS += STM32F4Discovery \ | |
|
4 | M4Stick \ | |
|
5 | M4StickV2 \ | |
|
6 | SOLAR_LFR_PSU \ | |
|
7 | BEAGLESYNTH \ | |
|
8 | STM32F4Eval \ | |
|
9 | STM32F4Discovery-EXT \ | |
|
10 | STM32F4Discovery-ILI9328-8bits \ | |
|
11 | OPLAYER \ | |
|
12 | STM32-E407 \ | |
|
13 | STM32F429Discovery | |
|
14 | ||
|
15 | ||
|
16 | ||
|
17 | ||
|
18 | ||
|
19 | ||
|
20 |
@@ -29,10 +29,17 own licence. If you reconize any of your | |||
|
29 | 29 | ____________ |
|
30 | 30 | Intallation: |
|
31 | 31 | ~~~~~~~~~~~~ |
|
32 | To install the libuc2 you just need to copy the libuc2 folder where you whant then you need to: | |
|
33 | -set the libuc2 environement varriable, with linux you can append this to the end of your /etc/bashrc file: | |
|
34 | libuc2=/opt/libuc2 | |
|
35 | replace /opt/ by the path where is installed the libuc2. | |
|
32 | -On linux you must copy the libuc2 folder to /opt/libuc2. Then you will be able to use /opt/libuc2/bin/qmake-libuc2 to generate Makefiles et build it. | |
|
33 | ||
|
34 | ________________ | |
|
35 | Building libuc2: | |
|
36 | ~~~~~~~~~~~~~~~~ | |
|
37 | Usualy you work on one architecture at time, when you build the libuc2 you build it for one architecture at time but you can sequencially build it for | |
|
38 | several architectures. First you have to generate Makefiles with qmake, call qmake in the libuc2 root folder with your target architecture as argument: | |
|
39 | /opt/libuc2/bin/qmake-libuc2 UCMODEL=stm32f4 # Building for stm32f4 | |
|
40 | make -j 4 # 4 if you have 4 core | |
|
41 | ||
|
42 | You can also work with QtCreator, just remember to set UCMODEL variable in your prject configuration. | |
|
36 | 43 | |
|
37 | 44 | ______________ |
|
38 | 45 | Contributions: |
@@ -1,21 +1,17 | |||
|
1 | 1 | TEMPLATE = subdirs |
|
2 | 2 | CONFIG += ordered |
|
3 | SUBDIRS += STM32F4Discovery \ | |
|
4 | M4Stick \ | |
|
5 | M4StickV2 \ | |
|
6 | SOLAR_LFR_PSU \ | |
|
7 | BEAGLESYNTH \ | |
|
8 | STM32F4Eval \ | |
|
9 | STM32F4Discovery-EXT \ | |
|
10 | STM32F4Discovery-ILI9328-8bits \ | |
|
11 | OPLAYER \ | |
|
12 | SIMULATOR \ | |
|
13 | STM32-E407 \ | |
|
14 | STM32F429Discovery | |
|
3 | ||
|
4 | !isEmpty( UCMODEL ) { | |
|
5 | contains( UCMODEL, stm32f4 ){ | |
|
6 | SUBDIRS += stm32f4 | |
|
7 | } | |
|
8 | contains( UCMODEL, simulator ){ | |
|
9 | SUBDIRS += simulator | |
|
10 | } | |
|
11 | } | |
|
15 | 12 | |
|
16 | 13 | |
|
17 | 14 | |
|
18 | 15 | |
|
19 | 16 | |
|
20 | 17 | |
|
21 |
@@ -1,12 +1,15 | |||
|
1 | TEMPLATE = app | |
|
1 | !isEmpty( UCMODEL ) { | |
|
2 | contains( UCMODEL, stm32f4 ){ | |
|
3 | TEMPLATE = app | |
|
4 | BSP = BEAGLESYNTH | |
|
5 | #BSP = SOLAR_LFR_PSU | |
|
6 | ||
|
7 | SOURCES += \ | |
|
8 | main.c | |
|
9 | } | |
|
10 | } | |
|
2 | 11 | |
|
3 | 12 | |
|
4 | 13 | |
|
5 | UCMODEL=stm32f4 | |
|
6 | 14 | |
|
7 | BSP = BEAGLESYNTH | |
|
8 | #BSP = SOLAR_LFR_PSU | |
|
9 | 15 | |
|
10 | SOURCES += \ | |
|
11 | main.c | |
|
12 |
@@ -1,22 +1,18 | |||
|
1 | TEMPLATE = app | |
|
2 | ||
|
1 | !isEmpty( UCMODEL ) { | |
|
2 | contains( UCMODEL, stm32f4 ){ | |
|
3 | TEMPLATE = app | |
|
3 | 4 | |
|
4 | UCMODEL=stm32f4 | |
|
5 | DEFINES += CPUFREQ=80000000 | |
|
5 | DEFINES += CPUFREQ=80000000 | |
|
6 | 6 | |
|
7 | BSP = BEAGLESYNTH | |
|
8 | #BSP = SOLAR_LFR_PSU | |
|
9 | #BSP = STM32F4Eval | |
|
7 | BSP = BEAGLESYNTH | |
|
8 | #BSP = SOLAR_LFR_PSU | |
|
9 | #BSP = STM32F4Eval | |
|
10 | 10 | |
|
11 | SOURCES += \ | |
|
12 | main.c | |
|
11 | SOURCES += \ | |
|
12 | main.c | |
|
13 | } | |
|
14 | } | |
|
13 | 15 | |
|
14 | 16 | |
|
15 | 17 | |
|
16 | 18 | |
|
17 | ||
|
18 | #beagleCp.target = beagleCp | |
|
19 | #beagleCp.commands = cd bin && scp $(QMAKE_TARGET).bin root@192.168.7.2://opt/stm32flashAje/hello.bin | |
|
20 | #beagleCp131.target = beagleCp131 | |
|
21 | #beagleCp131.commands = cd bin && scp $(QMAKE_TARGET).bin root@129.104.27.131://opt/stm32flashAje/hello.bin | |
|
22 | #QMAKE_EXTRA_TARGETS += beagleCp beagleCp131 |
@@ -1,12 +1,15 | |||
|
1 | TEMPLATE = app | |
|
1 | !isEmpty( UCMODEL ) { | |
|
2 | contains( UCMODEL, stm32f4 ){ | |
|
3 | TEMPLATE = app | |
|
4 | ||
|
5 | BSP=M4StickV2 | |
|
2 | 6 | |
|
3 | UCMODEL=stm32f4 | |
|
7 | DEFINES += CPUFREQ=80000000 | |
|
4 | 8 | |
|
5 | BSP=M4StickV2 | |
|
9 | SOURCES += \ | |
|
10 | main.c | |
|
11 | ||
|
12 | } | |
|
13 | } | |
|
6 | 14 | |
|
7 | 15 | |
|
8 | DEFINES += CPUFREQ=80000000 | |
|
9 | ||
|
10 | SOURCES += \ | |
|
11 | main.c | |
|
12 |
@@ -1,11 +1,16 | |||
|
1 | TEMPLATE = app | |
|
1 | !isEmpty( UCMODEL ) { | |
|
2 | contains( UCMODEL, stm32f4 ){ | |
|
3 | TEMPLATE = app | |
|
4 | ||
|
5 | BSP = SOLAR_LFR_PSU | |
|
6 | ||
|
7 | LIBS += -lN25Q128 | |
|
8 | ||
|
9 | SOURCES += \ | |
|
10 | main.c | |
|
11 | ||
|
12 | } | |
|
13 | } | |
|
2 | 14 | |
|
3 | 15 | |
|
4 | UCMODEL=stm32f4 | |
|
5 | BSP = SOLAR_LFR_PSU | |
|
6 | 16 | |
|
7 | LIBS += -lN25Q128 | |
|
8 | ||
|
9 | SOURCES += \ | |
|
10 | main.c | |
|
11 |
@@ -1,9 +1,13 | |||
|
1 | TEMPLATE = app | |
|
1 | !isEmpty( UCMODEL ) { | |
|
2 | contains( UCMODEL, stm32f4 ){ | |
|
3 | TEMPLATE = app | |
|
2 | 4 | |
|
3 | UCMODEL=stm32f4 | |
|
5 | BSP = SOLAR_LFR_PSU | |
|
4 | 6 | |
|
5 | BSP = SOLAR_LFR_PSU | |
|
7 | SOURCES += \ | |
|
8 | main.c | |
|
9 | } | |
|
10 | } | |
|
6 | 11 | |
|
7 | SOURCES += \ | |
|
8 | main.c | |
|
9 | 12 | |
|
13 |
@@ -1,9 +1,15 | |||
|
1 | TEMPLATE = app | |
|
1 | !isEmpty( UCMODEL ) { | |
|
2 | contains( UCMODEL, stm32f4 ){ | |
|
3 | TEMPLATE = app | |
|
2 | 4 | |
|
3 | UCMODEL=stm32f4 | |
|
4 | BSP = STM32F4Discovery | |
|
5 | BSP = STM32F4Discovery | |
|
5 | 6 | |
|
6 | SOURCES += \ | |
|
7 | main.c | |
|
7 | SOURCES += \ | |
|
8 | main.c | |
|
9 | } | |
|
10 | } | |
|
8 | 11 | |
|
9 | 12 | |
|
13 | ||
|
14 | ||
|
15 |
@@ -1,15 +1,19 | |||
|
1 | TEMPLATE = app | |
|
2 | CONFIG += cpu | |
|
1 | !isEmpty( UCMODEL ) { | |
|
2 | contains( UCMODEL, stm32f4 ){ | |
|
3 | TEMPLATE = app | |
|
4 | CONFIG += cpu | |
|
5 | ||
|
6 | BSP = OPLAYER | |
|
7 | #BSP = STM32F4Discovery-ILI9328-8bits | |
|
8 | ||
|
9 | DEFINES += CPUFREQ=40000000 | |
|
3 | 10 | |
|
4 | 11 | |
|
5 | UCMODEL=stm32f4 | |
|
6 | BSP = OPLAYER | |
|
7 | #BSP = STM32F4Discovery-ILI9328-8bits | |
|
12 | SOURCES += \ | |
|
13 | main.c \ | |
|
14 | test_lcd.c | |
|
8 | 15 | |
|
9 | DEFINES += CPUFREQ=40000000 | |
|
16 | } | |
|
17 | } | |
|
10 | 18 | |
|
11 | 19 | |
|
12 | SOURCES += \ | |
|
13 | main.c \ | |
|
14 | test_lcd.c | |
|
15 |
@@ -1,10 +1,13 | |||
|
1 | TEMPLATE = app | |
|
2 | ||
|
3 | UCMODEL=stm32f4 | |
|
1 | !isEmpty( UCMODEL ) { | |
|
2 | contains( UCMODEL, stm32f4 ){ | |
|
3 | TEMPLATE = app | |
|
4 | 4 | |
|
5 | BSP = STM32F4Discovery | |
|
5 | BSP = STM32F4Discovery | |
|
6 | 6 | |
|
7 | SOURCES += \ | |
|
8 | main.c | |
|
7 | SOURCES += \ | |
|
8 | main.c | |
|
9 | } | |
|
10 | } | |
|
9 | 11 | |
|
10 | 12 | |
|
13 |
@@ -1,13 +1,21 | |||
|
1 | TEMPLATE = app | |
|
1 | !isEmpty( UCMODEL ) { | |
|
2 | contains( UCMODEL, stm32f4 ){ | |
|
3 | TEMPLATE = app | |
|
2 | 4 | |
|
3 | UCMODEL=stm32f4 | |
|
4 | DEFINES += CPUFREQ=160000000 | |
|
5 | DEFINES += CPUFREQ=160000000 | |
|
6 | ||
|
7 | #BSP = BEAGLESYNTH | |
|
8 | #BSP = SOLAR_LFR_PSU | |
|
9 | ||
|
10 | BSP = STM32F4Eval | |
|
5 | 11 | |
|
6 | #BSP = BEAGLESYNTH | |
|
7 | #BSP = SOLAR_LFR_PSU | |
|
12 | SOURCES += \ | |
|
13 | main.c | |
|
14 | } | |
|
15 | } | |
|
8 | 16 | |
|
9 | BSP = STM32F4Eval | |
|
17 | ||
|
18 | ||
|
10 | 19 | |
|
11 | SOURCES += \ | |
|
12 | main.c | |
|
13 | 20 | |
|
21 |
@@ -1,12 +1,15 | |||
|
1 | TEMPLATE = app | |
|
1 | !isEmpty( UCMODEL ) { | |
|
2 | contains( UCMODEL, simulator ){ | |
|
3 | TEMPLATE = app | |
|
4 | BSP = SIMULATOR | |
|
2 | 5 | |
|
3 | UCMODEL=simulator | |
|
4 | BSP = SIMULATOR | |
|
6 | DEFINES += CPUFREQ=100000000 | |
|
5 | 7 | |
|
6 | DEFINES += CPUFREQ=100000000 | |
|
8 | SOURCES += \ | |
|
9 | main.c \ | |
|
10 | test_lcd.c \ | |
|
11 | test_SDCARD.c | |
|
12 | } | |
|
13 | } | |
|
7 | 14 | |
|
8 | SOURCES += \ | |
|
9 | main.c \ | |
|
10 | test_lcd.c \ | |
|
11 | test_SDCARD.c | |
|
12 | 15 |
@@ -1,22 +1,30 | |||
|
1 | 1 | TEMPLATE = subdirs |
|
2 | 2 | CONFIG += ordered |
|
3 | SUBDIRS += QtTest/test.pro \ | |
|
3 | ||
|
4 | ||
|
5 | !isEmpty( UCMODEL ) { | |
|
6 | contains( UCMODEL, stm32f4 ){ | |
|
7 | SUBDIRS += \ | |
|
8 | QtTest/test.pro \ | |
|
4 | 9 | SOLAR_PSU_HELLO/hello.pro \ |
|
5 | 10 | SDCARD \ |
|
6 | 11 | STM32F4IT \ |
|
7 | 12 | M4StickV2 \ |
|
8 | 13 | lcdHello \ |
|
9 | 14 | BeagleSynthHello \ |
|
10 | lcdTerminal \ | |
|
15 | lcdTerminal \ | |
|
11 | 16 | BeagleSynthHelloSupMon \ |
|
12 | 17 | TEST_CMSIS_FFT \ |
|
13 | 18 | N25Q128_test \ |
|
14 |
ssd2119Tests |
|
|
19 | ssd2119Tests | |
|
20 | } | |
|
21 | contains( UCMODEL, simulator ){ | |
|
22 | SUBDIRS += \ | |
|
15 | 23 | TEST_SIMULATOR |
|
24 | } | |
|
25 | } | |
|
16 | 26 | |
|
17 | 27 | |
|
18 | 28 | |
|
19 | 29 | |
|
20 | 30 | |
|
21 | ||
|
22 |
@@ -1,11 +1,18 | |||
|
1 | TEMPLATE = app | |
|
1 | !isEmpty( UCMODEL ) { | |
|
2 | contains( UCMODEL, stm32f4 ){ | |
|
3 | TEMPLATE = app | |
|
2 | 4 | |
|
3 | UCMODEL=stm32f4 | |
|
5 | BSP = STM32F4Eval | |
|
4 | 6 | |
|
5 | BSP = STM32F4Eval | |
|
7 | DEFINES += CPUFREQ=160000000 | |
|
6 | 8 | |
|
7 | DEFINES += CPUFREQ=160000000 | |
|
9 | SOURCES += \ | |
|
10 | main.c | |
|
8 | 11 | |
|
9 | SOURCES += \ | |
|
10 | main.c | |
|
12 | } | |
|
13 | } | |
|
14 | ||
|
11 | 15 | |
|
16 | ||
|
17 | ||
|
18 |
@@ -1,11 +1,18 | |||
|
1 | TEMPLATE = app | |
|
2 | CONFIG += audio | |
|
3 | UCMODEL=stm32f4 | |
|
1 | !isEmpty( UCMODEL ) { | |
|
2 | contains( UCMODEL, stm32f4 ){ | |
|
3 | TEMPLATE = app | |
|
4 | CONFIG += audio | |
|
4 | 5 | |
|
5 | BSP = STM32F4Eval | |
|
6 | BSP = STM32F4Eval | |
|
7 | ||
|
8 | DEFINES += CPUFREQ=168000000 | |
|
6 | 9 | |
|
7 | DEFINES += CPUFREQ=168000000 | |
|
10 | SOURCES += \ | |
|
11 | main.c | |
|
8 | 12 | |
|
9 | SOURCES += \ | |
|
10 | main.c | |
|
13 | } | |
|
14 | } | |
|
11 | 15 | |
|
16 | ||
|
17 | ||
|
18 |
@@ -1,10 +1,14 | |||
|
1 | TEMPLATE = app | |
|
1 | !isEmpty( UCMODEL ) { | |
|
2 | contains( UCMODEL, stm32f4 ){ | |
|
3 | TEMPLATE = app | |
|
4 | ||
|
5 | DEFINES += CPUFREQ=120000000 | |
|
6 | ||
|
7 | BSP = STM32F4Discovery-EXT | |
|
8 | ||
|
9 | SOURCES += \ | |
|
10 | main.c | |
|
11 | } | |
|
12 | } | |
|
2 | 13 | |
|
3 | 14 | |
|
4 | UCMODEL=stm32f4 | |
|
5 | DEFINES += CPUFREQ=120000000 | |
|
6 | ||
|
7 | BSP = STM32F4Discovery-EXT | |
|
8 | ||
|
9 | SOURCES += \ | |
|
10 | main.c |
@@ -1,11 +1,8 | |||
|
1 | 1 | TEMPLATE = subdirs |
|
2 | 2 | CONFIG += ordered |
|
3 | ||
|
3 | 4 | SUBDIRS += src/lib.pro \ |
|
4 | 5 | bsp\ |
|
5 | 6 | examples |
|
6 | 7 | |
|
7 | binfiles.files = bin/dfu.py | |
|
8 | binfiles.path = $$[QT_INSTALL_BINS] | |
|
9 | 8 | |
|
10 | INSTALLS+=binfiles | |
|
11 |
@@ -30,15 +30,17 INCLUDEPATH += $$[QT_INSTALL_HEADERS] \ | |||
|
30 | 30 | $$[QT_INSTALL_HEADERS]/GRAPHIC/GUI/FONTS \ |
|
31 | 31 | $$[QT_INSTALL_HEADERS]/GRAPHIC/GUI/Widgets |
|
32 | 32 | |
|
33 | # | |
|
34 | # Microcontroler switch | |
|
35 | # | |
|
36 | # | |
|
33 | isEmpty( UCMODEL ) { | |
|
34 | message("You didn't define any target architecture, default is stm32f4") | |
|
35 | message("To define a target architecture set the UCMODEL variable to the desired architecture") | |
|
36 | #UCMODEL=stm32f4 | |
|
37 | } | |
|
38 | ||
|
37 | 39 | contains( TEMPLATE, app ) { |
|
38 | 40 | !isEmpty( BSP ) { |
|
39 | 41 | include(./boards/$$BSP/bsp.pri) |
|
40 | 42 | } |
|
41 | INCLUDEPATH+= $$[QT_INSTALL_PREFIX]/bsp/src/$$BSP | |
|
43 | INCLUDEPATH+= $$[QT_INSTALL_PREFIX]/bsp/src/$$UCMODEL/$$BSP | |
|
42 | 44 | CONFIG += link_prl |
|
43 | 45 | OBJECTS_DIR=obj-$$UCMODEL |
|
44 | 46 | DESTDIR=bin-$$UCMODEL |
@@ -1,5 +1,5 | |||
|
1 |
TEMPLATE = |
|
|
2 | CONFIG += ordered | |
|
1 | TEMPLATE = lib | |
|
2 | CONFIG += libuc2lib | |
|
3 | TARGET = CS43L22 | |
|
3 | 4 | |
|
4 | SUBDIRS += ./CS43L22_STM32F4.pro \ | |
|
5 | ./CS43L22_SIMULATOR.pro | |
|
5 | SOURCES += CS43L22.c |
@@ -1,3 +1,10 | |||
|
1 |
TEMPLATE = |
|
|
2 | SUBDIRS += ./VS10XX_STM32F4.pro \ | |
|
3 | ./VS10XX_SIMULATOR.pro | |
|
1 | TEMPLATE = lib | |
|
2 | CONFIG += libuc2lib | |
|
3 | TARGET = vs10XX | |
|
4 | ||
|
5 | SOURCES += VS10XX.c | |
|
6 | ||
|
7 | ||
|
8 | HEADERS += \ | |
|
9 | ../../../../include/AUDIO/VS10XX.h | |
|
10 |
@@ -1,3 +1,7 | |||
|
1 |
TEMPLATE = |
|
|
2 | SUBDIRS += ./24LC0X_STM32F4.pro \ | |
|
3 | ./24LC0X_SIMULATOR.pro | |
|
1 | TEMPLATE = lib | |
|
2 | CONFIG += libuc2lib | |
|
3 | ||
|
4 | SOURCES += 24LC0X.c | |
|
5 | TARGET = 24LC0X | |
|
6 | ||
|
7 |
@@ -1,5 +1,8 | |||
|
1 |
TEMPLATE = |
|
|
1 | TEMPLATE = lib | |
|
2 | CONFIG += libuc2lib | |
|
3 | ||
|
4 | SOURCES += N25Q128.c | |
|
5 | TARGET = N25Q128 | |
|
2 | 6 | |
|
3 | 7 | |
|
4 | SUBDIRS += ./N25Q128_SIMULATOR.pro \ | |
|
5 | ./N25Q128_STM32F4.pro | |
|
8 |
@@ -1,6 +1,8 | |||
|
1 |
TEMPLATE = |
|
|
2 | CONFIG += ordered | |
|
1 | TEMPLATE = lib | |
|
2 | CONFIG += libuc2lib | |
|
3 | TARGET = ucdirent | |
|
3 | 4 | |
|
4 | SUBDIRS += ./dirent_STM32F4.pro \ | |
|
5 | ./dirent_SIMULATOR.pro | |
|
5 | SOURCES += \ | |
|
6 | ucdirent.c | |
|
6 | 7 | |
|
8 |
@@ -1,5 +1,11 | |||
|
1 |
TEMPLATE = |
|
|
2 | CONFIG += ordered | |
|
1 | TEMPLATE = lib | |
|
2 | CONFIG += libuc2lib | |
|
3 | TARGET = fat32 | |
|
3 | 4 | |
|
4 | SUBDIRS += ./fat32_STM32F4.pro \ | |
|
5 | ./fat32_SIMULATOR.pro | |
|
5 | SOURCES += \ | |
|
6 | fat32.c | |
|
7 | ||
|
8 | ||
|
9 | HEADERS += \ | |
|
10 | ../../../includes/fat32.h | |
|
11 |
@@ -1,7 +1,10 | |||
|
1 | 1 | TEMPLATE = subdirs |
|
2 | 2 | CONFIG += ordered |
|
3 | 3 | |
|
4 |
SUBDIRS += |
|
|
5 | MBR \ | |
|
4 | SUBDIRS += MBR \ | |
|
6 | 5 | DIRENT \ |
|
7 | 6 | FAT32 |
|
7 | ||
|
8 | !contains( UCMODEL , simulator){ | |
|
9 | SUBDIRS += SDCARD \ | |
|
10 | } |
@@ -1,5 +1,9 | |||
|
1 |
TEMPLATE = |
|
|
2 | CONFIG += ordered | |
|
1 | TEMPLATE = lib | |
|
2 | CONFIG += libuc2lib | |
|
3 | TARGET = mbr | |
|
3 | 4 | |
|
4 | SUBDIRS += ./mbr_STM32F4.pro \ | |
|
5 | ./mbr_SIMULATOR.pro | |
|
5 | SOURCES += \ | |
|
6 | mbr.c | |
|
7 | ||
|
8 | ||
|
9 |
@@ -1,4 +1,8 | |||
|
1 | TEMPLATE = subdirs | |
|
2 | CONFIG += ordered | |
|
1 | !contains( UCMODEL , simulator){ | |
|
2 | TEMPLATE = lib | |
|
3 | CONFIG += libuc2lib | |
|
4 | TARGET = sdcard | |
|
3 | 5 | |
|
4 | SUBDIRS += ./sdcard_STM32F4.pro | |
|
6 | SOURCES += \ | |
|
7 | sdcard.c | |
|
8 | } |
@@ -1,5 +1,9 | |||
|
1 |
TEMPLATE = |
|
|
2 | CONFIG += ordered | |
|
1 | TEMPLATE = lib | |
|
2 | CONFIG += libuc2lib | |
|
3 | TARGET = ili9328 | |
|
3 | 4 | |
|
4 | SUBDIRS += ./ili9328_STM32F4.pro \ | |
|
5 | ./ili9328_SIMULATOR.pro | |
|
5 | SOURCES += \ | |
|
6 | ili9328.c | |
|
7 | ||
|
8 | ||
|
9 |
@@ -1,5 +1,8 | |||
|
1 |
TEMPLATE = |
|
|
2 | CONFIG += ordered | |
|
1 | TEMPLATE = lib | |
|
2 | CONFIG += libuc2lib | |
|
3 | TARGET = ssd2119 | |
|
3 | 4 | |
|
4 | SUBDIRS += ./ssd2119_STM32F4.pro \ | |
|
5 | ./ssd2119_SIMULATOR.pro | |
|
5 | SOURCES += \ | |
|
6 | ssd2119.c | |
|
7 | ||
|
8 |
@@ -1,10 +1,8 | |||
|
1 |
TEMPLATE = |
|
|
2 | SUBDIRS += ./FONTS_STM32F4.pro \ | |
|
3 | ./FONTS_SIMULATOR.pro | |
|
1 | TEMPLATE = lib | |
|
2 | CONFIG += libuc2lib | |
|
3 | TARGET = fonts | |
|
4 | ||
|
5 | SOURCES += \ | |
|
6 | fonts8pts.c | |
|
4 | 7 | |
|
5 | 8 | |
|
6 | ||
|
7 | ||
|
8 | ||
|
9 | ||
|
10 |
@@ -1,5 +1,7 | |||
|
1 |
TEMPLATE = |
|
|
2 | SUBDIRS += ./Terminal_STM32F4.pro \ | |
|
3 | ./Terminal_SIMULATOR.pro | |
|
1 | TEMPLATE = lib | |
|
2 | CONFIG += libuc2lib | |
|
3 | TARGET = terminal | |
|
4 | 4 | |
|
5 | SOURCES += \ | |
|
6 | Terminal.c | |
|
5 | 7 |
@@ -1,5 +1,9 | |||
|
1 |
TEMPLATE = |
|
|
2 | CONFIG += ordered | |
|
1 | TEMPLATE = lib | |
|
2 | CONFIG += libuc2lib | |
|
3 | TARGET = ADS7843 | |
|
3 | 4 | |
|
4 | SUBDIRS += ./ADS7843_STM32F4.pro \ | |
|
5 | ./ADS7843_SIMULATOR.pro | |
|
5 | SOURCES += \ | |
|
6 | ADS7843.c | |
|
7 | ||
|
8 | ||
|
9 |
@@ -1,5 +1,9 | |||
|
1 |
TEMPLATE = |
|
|
2 | CONFIG += ordered | |
|
1 | TEMPLATE = lib | |
|
2 | CONFIG += libuc2lib | |
|
3 | TARGET = STMPE811 | |
|
3 | 4 | |
|
4 | SUBDIRS += ./STMPE811_STM32F4.pro \ | |
|
5 | ./STMPE811_SIMULATOR.pro | |
|
5 | SOURCES += \ | |
|
6 | STMPE811.c | |
|
7 | ||
|
8 | ||
|
9 |
@@ -1,5 +1,10 | |||
|
1 |
TEMPLATE = |
|
|
2 | CONFIG += ordered | |
|
1 | TEMPLATE = lib | |
|
2 | CONFIG += libuc2lib | |
|
3 | TARGET = ina226 | |
|
3 | 4 | |
|
4 | SUBDIRS += ./ina226_STM32F4.pro \ | |
|
5 | ./ina226_SIMULATOR.pro | |
|
5 | SOURCES += ina226.c | |
|
6 | ||
|
7 | ||
|
8 | HEADERS += \ | |
|
9 | ../../../../include/POWER/ina226.h | |
|
10 |
@@ -1,9 +1,8 | |||
|
1 |
TEMPLATE = |
|
|
2 | CONFIG += ordered | |
|
1 | TEMPLATE = lib | |
|
2 | CONFIG += libuc2lib | |
|
3 | OBJECTS_DIR = obj | |
|
3 | 4 | |
|
4 | SUBDIRS += ./Threading_STM32F4.pro \ | |
|
5 | ./Threading_SIMULATOR.pro | |
|
5 | TARGET=Threading | |
|
6 | SOURCES += thread.c | |
|
6 | 7 | |
|
7 | 8 | |
|
8 | ||
|
9 |
@@ -1,17 +1,13 | |||
|
1 | 1 | TEMPLATE = subdirs |
|
2 | 2 | CONFIG += ordered |
|
3 | 3 | |
|
4 | SUBDIRS += stm32f4 | |
|
5 | ||
|
4 | !isEmpty( UCMODEL ) { | |
|
5 | contains( UCMODEL, stm32f4 ){ | |
|
6 | SUBDIRS += stm32f4 | |
|
7 | } | |
|
8 | contains( UCMODEL, simulator ){ | |
|
9 | SUBDIRS += simulator | |
|
10 | } | |
|
11 | } | |
|
6 | 12 | SUBDIRS += common |
|
7 | SUBDIRS += simulator | |
|
8 | ||
|
9 | headers.files = includes/*.h \ | |
|
10 | includes/GRAPHIC/CONTROLERS/*.h \ | |
|
11 | includes/GRAPHIC/TC_CONTROLERS/*.h \ | |
|
12 | includes/GRAPHIC/GUI/FONTS/*.h \ | |
|
13 | includes/GRAPHIC/GUI/Widgets/*.h | |
|
14 | ||
|
15 | headers.path = $$[QT_INSTALL_HEADERS] | |
|
16 | INSTALLS += headers | |
|
17 | 13 |
@@ -1,3 +1,5 | |||
|
1 | contains(UCMODEL,simulator) | |
|
2 | { | |
|
1 | 3 | TEMPLATE = subdirs |
|
2 | 4 | CONFIG += ordered |
|
3 | 5 | SUBDIRS = CORE/core.pro \ |
@@ -9,6 +11,4 SUBDIRS = CORE/core.pro \ | |||
|
9 | 11 | SDCARD \ |
|
10 | 12 | SDLCD |
|
11 | 13 | |
|
12 | ||
|
13 | ||
|
14 | ||
|
14 | } |
@@ -1,6 +1,7 | |||
|
1 | 1 | TEMPLATE = subdirs |
|
2 | 2 | CONFIG += ordered |
|
3 | SUBDIRS = CORE/core.pro \ | |
|
3 | ||
|
4 | SUBDIRS = CORE/core.pro \ | |
|
4 | 5 | CPU/cpu.pro \ |
|
5 | 6 | GPIO/gpio.pro \ |
|
6 | 7 | UART/uart.pro \ |
@@ -9,5 +10,4 SUBDIRS = CORE/core.pro \ | |||
|
9 | 10 | SDCARD-SDIO/sdcard-sdio.pro |
|
10 | 11 | |
|
11 | 12 | |
|
12 | ||
|
13 | 13 |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now