##// END OF EJS Templates
Added Simulator target to run code on x86 and debug functions....
jeandet -
r63:68dfbccdd813 dev_alexis
parent child
Show More
@@ -0,0 +1,19
1 TEMPLATE = lib
2
3 TARGET=bsp
4
5
6
7 BSP = SIMULATOR
8
9 UCMODEL=simulator
10
11 SOURCES += bsp.c
12
13 HEADERS += bsp.h
14
15
16 BSPFILE = bsp.pri
17
18
19
@@ -0,0 +1,282
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@gmail.com
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,
40 .readGRAM = &SDLCD_readGRAM
41 };
42
43 LCD_t lcd0={
44 .interface = &lcdIF0,
45 .init = &ili9328init,
46 .paint = &ili9328paint,
47 .paintText = &ili9328paintText,
48 .paintFilRect = &ili9328paintFilRect,
49 .refreshenable = &ili9328refreshenable,
50 .width= 240,
51 .height = 320
52 };
53
54 terminal_t terminal0;
55
56 volatile int8_t* lcd0_CMD=(volatile int8_t*) 0x60000000;
57 volatile int8_t* lcd0_DATA=(volatile int8_t*)(0x61FFFFF0);
58
59 float VREF0 =(float)3.3;
60 volatile vs10XXDev audioCodec0;
61
62 sdcardDev sdcard2;
63 blkdevice sdcard2blkdev;
64 dikpartition sdcard2Part1;
65 FAT32fs sdcard2FAT32part1;
66 dikpartition sdcard2Part2;
67 FAT32fs sdcard2FAT32part2;
68 dikpartition sdcard2Part3;
69 FAT32fs sdcard2FAT32part3;
70 dikpartition sdcard2Part4;
71 FAT32fs sdcard2FAT32part4;
72
73 int bsp_init()
74 {
75 int i=0;
76 for(i=0;i<__MAX_OPENED_FILES__;i++)
77 {
78 __opnfiles__[i] = NULL;
79 }
80 bsp_GPIO_init();
81 bsp_uart_init();
82 bsp_iic_init();
83 bsp_FSMC_init();
84 bsp_GTerm_init();
85 bsp_spi_init();
86 bsp_SD_init();
87 bsp_Audio_init();
88 printf("\r=====================\n\r");
89 printf( "=====================\n\r");
90 printf(BSP);
91 printf(" initialised\n\r");
92 printf( "=====================\n\r");
93 return 1;
94 }
95
96 void bsp_GPIO_init()
97 {
98
99 }
100
101 void bsp_uart_init()
102 {
103
104 }
105
106 /*
107 D0 PD14 D1 PD15 D2 PD0 D3 PD1 D4 PE7
108 D5 PE8 D6 PE9 D7 PE10
109 A20 PE4 = RS FSMC_NE1 PD7 CS FSMC_NWE PD5 W/S
110 FSMC_NOE PD4 RD
111 */
112
113 int bsp_FSMC_init()
114 {
115
116 return 1;
117 }
118
119 void bsp_spi_init()
120 {
121
122 }
123
124
125 void bsp_iic_init()
126 {
127
128 }
129
130
131 void bsp_Audio_init()
132 {
133
134 }
135
136 void bsp_SD_init()
137 {
138
139 }
140
141 void vs1052setXCS(char val)
142 {
143 }
144
145 void vs1052setXDCS(char val)
146 {
147 }
148
149 void vs1052setRST(char val)
150 {
151 }
152
153 int vs10XXDREQ()
154 {
155 return 1;
156 }
157
158
159 void bsppowersdcard(char onoff) //always ON
160 {
161
162 }
163
164 char bspsdcardpresent()
165 {
166 return 1;
167 }
168
169 char bspsdcardwriteprotected()
170 {
171 return 0;
172 }
173
174 void bspsdcardselect(char YESNO)
175 {
176
177 }
178
179
180 void bsp_lcd0_write_reg(uint32_t reg,uint32_t data)
181 {
182
183 }
184
185 uint32_t bsp_lcd0_read_reg(uint32_t reg)
186 {
187 return 0;
188 }
189
190 void bsp_lcd0_writeGRAM(void* buffer,uint32_t count)
191 {
192
193 }
194
195 void bsp_lcd0_readGRAM(void* buffer,uint32_t count)
196 {
197
198 }
199
200 void bsp_GTerm_init()
201 {
202 SDLCD_mkscreen(240,320,16,LCDILI9328);
203
204 if(__opnfiles__[1]==NULL)
205 {
206 streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice));
207 terminal_init(&terminal0 ,&lcd0,&ComicSansMS_18,fd1);
208 __opnfiles__[1] = fd1;
209 }
210 else
211 {
212
213 }
214 }
215
216
217
218
219
220
221
222 void putpixel(SDL_Surface *surface, int x, int y, Uint32 pixel)
223 {
224 int bpp = surface->format->BytesPerPixel;
225 /* Here p is the address to the pixel we want to set */
226 Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;
227 switch(bpp) {
228 case 1:
229 *p = pixel;
230 break;
231 case 2:
232 *(Uint16 *)p = pixel;
233 break;
234 case 3:
235 if(SDL_BYTEORDER == SDL_BIG_ENDIAN) {
236 p[0] = (pixel >> 16) & 0xff;
237 p[1] = (pixel >> 8) & 0xff;
238 p[2] = pixel & 0xff;
239 } else {
240 p[0] = pixel & 0xff;
241 p[1] = (pixel >> 8) & 0xff;
242 p[2] = (pixel >> 16) & 0xff;
243 }
244 break;
245 case 4:
246 *(Uint32 *)p = pixel;
247 break;
248 }
249 }
250
251 Uint32 getpixel(SDL_Surface *surface, int x, int y)
252 {
253 int bpp = surface->format->BytesPerPixel;
254 /* Here p is the address to the pixel we want to retrieve */
255 Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;
256 switch(bpp) {
257 case 1:
258 return *p;
259 case 2:
260 return *(Uint16 *)p;
261 case 3:
262 if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
263 return p[0] << 16 | p[1] << 8 | p[2];
264 else
265 return p[0] | p[1] << 8 | p[2] << 16;
266 case 4:
267 return *(Uint32 *)p;
268 default:
269 return 0;
270 }
271 /* shouldn’t happen, but avoids warnings */
272 }
273
274
275
276
277
278
279
280
281
282
@@ -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@gmail.com
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,23
1 #include <stdio.h>
2 #include <fat32.h>
3 #include <gpio.h>
4 #include <uart.h>
5 #include <stm32f4xx.h>
6 #include <bsp.h>
7 #include <core.h>
8 #include <VS10XX.h>
9 #include <bsp.h>
10 #include <spi.h>
11 #include <sdcard.h>
12 #include <sdcard-spi.h>
13 #include <fat32.h>
14 #include <ucdirent.h>
15 #include <string.h>
16 #include <terminal.h>
17 #include <ili9328.h>
18
19
20 void test_Block_Move(LCD_t* LCD,int x,int y,int w,int h,int color)
21 {
22 LCD->paintFilRect(LCD,x,y,w,h,0,0,color);
23 }
@@ -0,0 +1,13
1 TEMPLATE = app
2 CONFIG += cpu
3
4
5 UCMODEL=simulator
6 BSP = SIMULATOR
7
8 DEFINES += CPUFREQ=100000000
9
10 SOURCES += \
11 main.c \
12 test_lcd.c
13
@@ -0,0 +1,55
1 #include <stdio.h>
2 #include <fat32.h>
3 #include <gpio.h>
4 #include <uart.h>
5 #include <bsp.h>
6 #include <core.h>
7 #include <bsp.h>
8 #include <spi.h>
9 #include <fat32.h>
10 #include <ucdirent.h>
11 #include <string.h>
12 #include <unistd.h>
13 #include <terminal.h>
14 #include <stdarg.h>
15 #include <malloc.h>
16
17 extern streamdevice* __opnfiles__[];
18 extern void test_Block_Move(LCD_t* LCD,int x,int y,int w,int h,int color);
19 char buffer[512];
20
21 void streamdevicePrint(streamdevice* dev, const char* format,...)
22 {
23 char** str_buffer;
24 int i;
25 va_list ap;
26 va_start(ap,format);
27 vasprintf(str_buffer,format,ap);
28 va_end(ap);
29 i=strlen(*str_buffer);
30 dev->ops->write(dev,(void*)*str_buffer,1,i);
31 free(*str_buffer);
32 }
33
34 void lcd_print()
35 {
36 lcd0.paintFilRect(&lcd0,10,10,100,100,0,0,0x0F0F);
37 // __opnfiles__[1]->ops->write(__opnfiles__[1],(void*)"hello",1,5);
38 }
39
40 int libuc2_main_task()
41 {
42 char in[255];
43 lcd_print();
44 printf("hello world\n");
45 streamdevicePrint(__opnfiles__[1],"test Hello %d %f \n ",1234567,8.96);
46 // while (scanf("%c",in))
47 // {
48 sleep(3);
49 // }
50 }
51
52
53
54
55
@@ -0,0 +1,21
1 #include <stdio.h>
2 #include <fat32.h>
3 #include <gpio.h>
4 #include <uart.h>
5 #include <bsp.h>
6 #include <core.h>
7 #include <VS10XX.h>
8 #include <bsp.h>
9 #include <spi.h>
10 #include <sdcard.h>
11 #include <sdcard-spi.h>
12 #include <fat32.h>
13 #include <ucdirent.h>
14 #include <string.h>
15 #include <ili9328.h>
16
17
18 void test_Block_Move(LCD_t* LCD,int x,int y,int w,int h,int color)
19 {
20 // LCD->paintFilRect(LCD,x,y,w,h,0,0,color);
21 }
@@ -0,0 +1,15
1 TEMPLATE = lib
2 TARGET = CS43L22
3
4 SOURCES += CS43L22.c
5
6 INCLUDEPATH += ../../../includes \
7 ../../CPU/CMSIS/Include
8
9
10 UCMODEL=simulator
11
12 target.path = $$[QT_INSTALL_LIBS]/$$UCMODEL
13 INSTALLS += target
14
15
@@ -0,0 +1,14
1 TEMPLATE = lib
2 TARGET = vs10XX
3
4 SOURCES += VS10XX.c
5
6
7 HEADERS += ../../../includes/VS10XX.h
8 INCLUDEPATH += ../../../includes
9
10 UCMODEL=simulator
11
12 target.path = $$[QT_INSTALL_LIBS]/$$UCMODEL
13 INSTALLS += target
14
@@ -0,0 +1,14
1 TEMPLATE = lib
2 TARGET = vs10XX
3
4 SOURCES += VS10XX.c
5
6
7 HEADERS += ../../../includes/VS10XX.h
8 INCLUDEPATH += ../../../includes
9
10 UCMODEL=stm32f4
11
12 target.path = $$[QT_INSTALL_LIBS]/$$UCMODEL
13 INSTALLS += target
14
@@ -0,0 +1,14
1 TEMPLATE = lib
2
3 SOURCES += 24LC0X.c
4 HEADERS += ../../../includes/24LC0X.h \
5 ../../../../includes/24LC0X.h
6
7 INCLUDEPATH += ../../../includes \
8 ../../CPU/CMSIS/Include
9
10
11 UCMODEL=simulator
12
13 target.path = $$[QT_INSTALL_LIBS]/$$UCMODEL
14 INSTALLS += target
@@ -0,0 +1,15
1 TEMPLATE = lib
2
3 SOURCES += 24LC0X.c
4 HEADERS += ../../../includes/24LC0X.h \
5 ../../../../includes/24LC0X.h
6
7 INCLUDEPATH += ../../../includes \
8 ../../CPU/STM32F4xx_StdPeriph_Driver/inc \
9 ../../CPU/CMSIS/Include
10
11
12 UCMODEL=stm32f4
13
14 target.path = $$[QT_INSTALL_LIBS]/$$UCMODEL
15 INSTALLS += target
@@ -0,0 +1,13
1 TEMPLATE = lib
2
3 SOURCES += N25Q128.c
4 HEADERS += ../../../includes/N25Q128.h
5
6 INCLUDEPATH += ../../../includes \
7 ../../CPU/CMSIS/Include
8
9
10 UCMODEL=simulator
11
12 target.path = $$[QT_INSTALL_LIBS]/$$UCMODEL
13 INSTALLS += target
@@ -0,0 +1,13
1 TEMPLATE = lib
2
3 SOURCES += N25Q128.c
4 HEADERS += ../../../includes/N25Q128.h
5
6 INCLUDEPATH += ../../../includes \
7 ../../CPU/CMSIS/Include
8
9
10 UCMODEL=stm32f4
11
12 target.path = $$[QT_INSTALL_LIBS]/$$UCMODEL
13 INSTALLS += target
@@ -0,0 +1,15
1 TEMPLATE = lib
2 OBJECTS_DIR = obj
3 TARGET = ucdirent
4
5 SOURCES += \
6 ucdirent.c
7
8 INCLUDEPATH += ../../includes
9
10
11 UCMODEL=simulator
12
13 target.path = $$[QT_INSTALL_LIBS]/$$UCMODEL
14 INSTALLS += target
15
@@ -0,0 +1,17
1 TEMPLATE = lib
2 OBJECTS_DIR = obj
3 TARGET = fat32
4
5 SOURCES += \
6 fat32.c
7
8 INCLUDEPATH += ../../../includes
9
10 UCMODEL=simulator
11
12 target.path = $$[QT_INSTALL_LIBS]/$$UCMODEL
13 INSTALLS += target
14
15 HEADERS += \
16 ../../../includes/fat32.h
17
@@ -0,0 +1,17
1 TEMPLATE = lib
2 OBJECTS_DIR = obj
3 TARGET = mbr
4
5 SOURCES += \
6 mbr.c
7
8 INCLUDEPATH += ../../../includes
9
10 UCMODEL=simulator
11
12 target.path = $$[QT_INSTALL_LIBS]/$$UCMODEL
13 INSTALLS += target
14
15 HEADERS += \
16 ../../../includes/mbr.h
17
@@ -0,0 +1,18
1 TEMPLATE = lib
2 TARGET = ili9328
3
4 SOURCES += \
5 ili9328.c
6
7
8 INCLUDEPATH += ../../../../includes \
9 ../../../../includes/GRAPHIC/CONTROLERS \
10 ../../../../includes/GRAPHIC/GUI/FONTS \
11 ../../../../includes/GRAPHIC/GUI/Widgets
12
13
14 UCMODEL=simulator
15
16 target.path = $$[QT_INSTALL_LIBS]/$$UCMODEL
17 INSTALLS += target
18
@@ -0,0 +1,18
1 TEMPLATE = lib
2 TARGET = ssd2119
3
4 SOURCES += \
5 ssd2119.c
6
7
8 INCLUDEPATH += ../../../../includes \
9 ../../../../includes/GRAPHIC/CONTROLERS \
10 ../../../../includes/GRAPHIC/GUI/FONTS \
11 ../../../../includes/GRAPHIC/GUI/Widgets
12
13
14 UCMODEL=simulator
15
16 target.path = $$[QT_INSTALL_LIBS]/$$UCMODEL
17 INSTALLS += target
18
@@ -0,0 +1,18
1 TEMPLATE = lib
2 TARGET = fonts
3
4 SOURCES += \
5 fonts8pts.c
6
7
8 INCLUDEPATH += ../../../../includes \
9 ../../../../includes/GRAPHIC/CONTROLERS \
10 ../../../../includes/GRAPHIC/GUI/FONTS \
11 ../../../../includes/GRAPHIC/GUI/Widgets
12
13
14 UCMODEL=simulator
15
16 target.path = $$[QT_INSTALL_LIBS]/$$UCMODEL
17 INSTALLS += target
18
@@ -0,0 +1,20
1 TEMPLATE = lib
2 TARGET = terminal
3
4 SOURCES += \
5 Terminal.c
6
7
8 INCLUDEPATH += ../../../../includes \
9 ../../../../includes/GRAPHIC/CONTROLERS \
10 ../../../../includes/GRAPHIC/GUI/FONTS \
11 ../../../../includes/GRAPHIC/GUI/Widgets
12
13 HEADERS += \
14 ../../../../../includes/GRAPHIC/GUI/Widgets/terminal.h
15
16 UCMODEL=simulator
17
18 target.path = $$[QT_INSTALL_LIBS]/$$UCMODEL
19 INSTALLS += target
20
@@ -0,0 +1,23
1 TEMPLATE = lib
2 TARGET = STMPE811
3
4 SOURCES += \
5 STMPE811.c
6
7 INCLUDEPATH += ../../../../includes \
8 ../../../../includes/GRAPHIC/CONTROLERS \
9 ../../../../includes/GRAPHIC/TC_CONTROLERS \
10 ../../../../includes/GRAPHIC/GUI/FONTS \
11 ../../../../includes/GRAPHIC/GUI/Widgets
12
13
14 UCMODEL=simulator
15
16 target.path = $$[QT_INSTALL_LIBS]/$$UCMODEL
17 INSTALLS += target
18
19 HEADERS += \
20 ../../../../includes/GRAPHIC/TC_CONTROLERS/STMPE811.h \
21 ../../../../includes/GRAPHIC/TC_CONTROLERS/genericTC_Controler.h
22
23
@@ -0,0 +1,14
1 TEMPLATE = lib
2 TARGET = ina226
3
4 SOURCES += ina226.c
5
6 INCLUDEPATH += ../../../includes \
7 ../../CPU/CMSIS/Include
8
9
10 UCMODEL=simulator
11
12 target.path = $$[QT_INSTALL_LIBS]/$$UCMODEL
13 INSTALLS += target
14
@@ -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@gmail.com
21 -------------------------------------------------------------------------------*/
22 #include <core.h>
23 #include <stdint.h>
24 #include <stdlib.h>
25 #include <stdio.h>
26 #include <gpio.h>
27 #include <unistd.h>
28
29 extern uint32_t OSC0;
30 extern uint32_t INTOSC;
31 extern uint32_t RTCOSC;
32
33 volatile uint32_t tickCounter=0;
34
35
36 void SysTick_Handler(void)
37 {
38 tickCounter+=1;
39 // if((tickCounter&0xFFF)==0x800)
40 // gpiosetval(PC15,!gpiogetval(PC15));
41 }
42
43 void delay_us(uint32_t value)
44 {
45 usleep(value);
46 }
47
48 void delay_100us(uint32_t value)
49 {
50 usleep(value*100);
51 }
52
53 uint32_t getAPB1Freq()
54 {
55 return 0;
56 }
57
58 uint32_t getAPB2Freq()
59 {
60 return 0;
61 }
62
63
64 uint32_t getCpuFreq()
65 {
66 return 0;
67 }
68
69 void reset_AHB1()
70 {
71 }
72
73 void reset_AHB2()
74 {
75
76 }
77
78 void reset_APB1()
79 {
80
81 }
82
83 void reset_APB2()
84 {
85
86 }
87
88
89
90
91
92 int optimizePLLcfg(uint32_t freq, uint32_t srcfreq,uint32_t PLLM,uint32_t* PLLP, uint32_t* PLLN,uint8_t* AHBPRindx)
93 {
94
95 return 1;
96 }
97
98
99 int setPll(uint32_t freq)
100 {
101
102 return freq;
103 }
104
105 void configureSysTick()
106 {
107
108 }
109
110 int setCpuFreq(uint32_t freq)
111 {
112
113 return 0;
114 }
115
116
117 void enable_FPU()
118 {
119
120 }
121
122
123
124
125
126
@@ -0,0 +1,13
1 TEMPLATE = lib
2 SOURCES += \
3 core.c \
4 threads.c \
5 irq_handlers.c
6
7 INCLUDEPATH += ../../includes
8
9
10 UCMODEL=simulator
11
12 target.path = $$[QT_INSTALL_LIBS]/$$UCMODEL
13 INSTALLS += target
@@ -0,0 +1,452
1 #include <stdio.h>
2
3 void NMI_Handler(void)
4 {
5 printf("NMI_Handler\n");
6 }
7
8 void HardFault_Handler(void)
9 {
10 printf("HardFault_Handler\n");
11 }
12
13 void MemManage_Handler(void)
14 {
15 printf("MemManage_Handler\n");
16 }
17
18 void BusFault_Handler(void)
19 {
20 printf("BusFault_Handler\n");
21 }
22
23 void UsageFault_Handler(void)
24 {
25 printf("UsageFault_Handler\n");
26 }
27
28 void SVC_Handler(void)
29 {
30 printf("SVC_Handler\n");
31 }
32
33 void DebugMon_Handler(void)
34 {
35 printf("DebugMon_Handler\n");
36 }
37
38 void PendSV_Handler(void)
39 {
40 printf("PendSV_Handler\n");
41 }
42
43 void WWDG_IRQHandler(void)
44 {
45 printf("WWDG_IRQHandler\n");
46 }
47
48 void PVD_IRQHandler(void)
49 {
50 printf("PVD_IRQHandler\n");
51 }
52
53 void TAMP_STAMP_IRQHandler(void)
54 {
55 printf("TAMP_STAMP_IRQHandler\n");
56 }
57
58 void RTC_WKUP_IRQHandler(void)
59 {
60 printf("RTC_WKUP_IRQHandler\n");
61 }
62
63 void FLASH_IRQHandler(void)
64 {
65 printf("FLASH_IRQHandler\n");
66 }
67
68 void RCC_IRQHandler(void)
69 {
70 printf("RCC_IRQHandler\n");
71 }
72
73 void EXTI0_IRQHandler(void)
74 {
75 printf("EXTI0_IRQHandler\n");
76 }
77
78 void EXTI1_IRQHandler(void)
79 {
80 printf("EXTI1_IRQHandler\n");
81 }
82
83 void EXTI2_IRQHandler(void)
84 {
85 printf("EXTI2_IRQHandler\n");
86 }
87
88 void EXTI3_IRQHandler(void)
89 {
90 printf("EXTI3_IRQHandler\n");
91 }
92
93 void EXTI4_IRQHandler(void)
94 {
95 printf("EXTI4_IRQHandler\n");
96 }
97
98 void DMA1_Stream0_IRQHandler(void)
99 {
100 printf("DMA1_Stream0_IRQHandler\n");
101 }
102
103 void DMA1_Stream1_IRQHandler(void)
104 {
105 printf("DMA1_Stream1_IRQHandler\n");
106 }
107
108 void DMA1_Stream2_IRQHandler(void)
109 {
110 printf("DMA1_Stream2_IRQHandler\n");
111 }
112
113 void DMA1_Stream3_IRQHandler(void)
114 {
115 printf("DMA1_Stream3_IRQHandler\n");
116 }
117
118 void DMA1_Stream4_IRQHandler(void)
119 {
120 printf("DMA1_Stream4_IRQHandler\n");
121 }
122
123 void DMA1_Stream5_IRQHandler(void)
124 {
125 printf("DMA1_Stream5_IRQHandler\n");
126 }
127
128 void DMA1_Stream6_IRQHandler(void)
129 {
130 printf("DMA1_Stream6_IRQHandler\n");
131 }
132
133 void ADC_IRQHandler(void)
134 {
135 printf("ADC_IRQHandler\n");
136 }
137
138 void CAN1_TX_IRQHandler(void)
139 {
140 printf("CAN1_TX_IRQHandler\n");
141 }
142
143 void CAN1_RX0_IRQHandler(void)
144 {
145 printf("CAN1_RX0_IRQHandler\n");
146 }
147
148 void CAN1_RX1_IRQHandler(void)
149 {
150 printf("CAN1_RX1_IRQHandler\n");
151 }
152
153 void CAN1_SCE_IRQHandler(void)
154 {
155 printf("CAN1_SCE_IRQHandler\n");
156 }
157
158 void EXTI9_5_IRQHandler(void)
159 {
160 printf("EXTI9_5_IRQHandler\n");
161 }
162
163 void TIM1_BRK_TIM9_IRQHandler(void)
164 {
165 printf("TIM1_BRK_TIM9_IRQHandler\n");
166 }
167
168 void TIM1_UP_TIM10_IRQHandler(void)
169 {
170 printf("TIM1_UP_TIM10_IRQHandler\n");
171 }
172
173 void TIM1_TRG_COM_TIM11_IRQHandlerIM11(void)
174 {
175 printf("TIM1_TRG_COM_TIM11_IRQHandlerIM11");
176 }
177
178 void TIM1_CC_IRQHandler(void)
179 {
180 printf("TIM1_CC_IRQHandler\n");
181 }
182
183 void TIM2_IRQHandler(void)
184 {
185 printf("TIM2_IRQHandler\n");
186 }
187
188 void TIM3_IRQHandler(void)
189 {
190 printf("TIM3_IRQHandler\n");
191 }
192
193 void TIM4_IRQHandler(void)
194 {
195 printf("TIM4_IRQHandler\n");
196 }
197
198 void I2C1_EV_IRQHandler(void)
199 {
200 printf("I2C1_EV_IRQHandler\n");
201 }
202
203 void I2C1_ER_IRQHandler(void)
204 {
205 printf("I2C1_ER_IRQHandler\n");
206 }
207
208 void I2C2_EV_IRQHandler(void)
209 {
210 printf("I2C2_EV_IRQHandler\n");
211 }
212
213 void I2C2_ER_IRQHandler(void)
214 {
215 printf("I2C2_ER_IRQHandler\n");
216 }
217
218 void SPI1_IRQHandler(void)
219 {
220 printf("SPI1_IRQHandler\n");
221 }
222
223 void SPI2_IRQHandler(void)
224 {
225 printf("SPI2_IRQHandler\n");
226 }
227
228 void USART1_IRQHandler(void)
229 {
230 printf("USART1_IRQHandler\n");
231 }
232
233 void USART2_IRQHandler(void)
234 {
235 printf("USART2_IRQHandler\n");
236 }
237
238 void USART3_IRQHandler(void)
239 {
240 printf("USART3_IRQHandler\n");
241 }
242
243 void EXTI15_10_IRQHandler(void)
244 {
245 printf("EXTI15_10_IRQHandler\n");
246 }
247
248 void RTC_Alarm_IRQHandler(void)
249 {
250 printf("RTC_Alarm_IRQHandler\n");
251 }
252
253 void OTG_FS_WKUP_IRQHandler(void)
254 {
255 printf("OTG_FS_WKUP_IRQHandler\n");
256 }
257
258 void TIM8_BRK_TIM12_IRQHandler(void)
259 {
260 printf("TIM8_BRK_TIM12_IRQHandler\n");
261 }
262
263 void TIM8_UP_TIM13_IRQHandler(void)
264 {
265 printf("TIM8_UP_TIM13_IRQHandler\n");
266 }
267
268 void TIM8_TRG_COM_TIM14_IRQHandlerIM14(void)
269 {
270 printf("TIM8_TRG_COM_TIM14_IRQHandlerIM14");
271 }
272
273 void TIM8_CC_IRQHandler(void)
274 {
275 printf("TIM8_CC_IRQHandler\n");
276 }
277
278 void DMA1_Stream7_IRQHandler(void)
279 {
280 printf("DMA1_Stream7_IRQHandler\n");
281 }
282
283 void FSMC_IRQHandler(void)
284 {
285 printf("FSMC_IRQHandler\n");
286 }
287
288 void SDIO_IRQHandler(void)
289 {
290 printf("SDIO_IRQHandler\n");
291 }
292
293 void TIM5_IRQHandler(void)
294 {
295 printf("TIM5_IRQHandler\n");
296 }
297
298 void SPI3_IRQHandler(void)
299 {
300 printf("SPI3_IRQHandler\n");
301 }
302
303 void UART4_IRQHandler(void)
304 {
305 printf("UART4_IRQHandler\n");
306 }
307
308 void UART5_IRQHandler(void)
309 {
310 printf("UART5_IRQHandler\n");
311 }
312
313 void TIM6_DAC_IRQHandler(void)
314 {
315 printf("TIM6_DAC_IRQHandler\n");
316 }
317
318 void TIM7_IRQHandler(void)
319 {
320 printf("TIM7_IRQHandler\n");
321 }
322
323 void DMA2_Stream0_IRQHandler(void)
324 {
325 printf("DMA2_Stream0_IRQHandler\n");
326 }
327
328 void DMA2_Stream1_IRQHandler(void)
329 {
330 printf("DMA2_Stream1_IRQHandler\n");
331 }
332
333 void DMA2_Stream2_IRQHandler(void)
334 {
335 printf("DMA2_Stream2_IRQHandler\n");
336 }
337
338 void DMA2_Stream3_IRQHandler(void)
339 {
340 printf("DMA2_Stream3_IRQHandler\n");
341 }
342
343 void DMA2_Stream4_IRQHandler(void)
344 {
345 printf("DMA2_Stream4_IRQHandler\n");
346 }
347
348 void ETH_IRQHandler(void)
349 {
350 printf("ETH_IRQHandler\n");
351 }
352
353 void ETH_WKUP_IRQHandler(void)
354 {
355 printf("ETH_WKUP_IRQHandler\n");
356 }
357
358 void CAN2_TX_IRQHandler(void)
359 {
360 printf("CAN2_TX_IRQHandler\n");
361 }
362
363 void CAN2_RX0_IRQHandler(void)
364 {
365 printf("CAN2_RX0_IRQHandler\n");
366 }
367
368 void CAN2_RX1_IRQHandler(void)
369 {
370 printf("CAN2_RX1_IRQHandler\n");
371 }
372
373 void CAN2_SCE_IRQHandler(void)
374 {
375 printf("CAN2_SCE_IRQHandler\n");
376 }
377
378 void OTG_FS_IRQHandler(void)
379 {
380 printf("OTG_FS_IRQHandler\n");
381 }
382
383 void DMA2_Stream5_IRQHandler(void)
384 {
385 printf("DMA2_Stream5_IRQHandler\n");
386 }
387
388 void DMA2_Stream6_IRQHandler(void)
389 {
390 printf("DMA2_Stream6_IRQHandler\n");
391 }
392
393 void DMA2_Stream7_IRQHandler(void)
394 {
395 printf("DMA2_Stream7_IRQHandler\n");
396 }
397
398 void USART6_IRQHandler(void)
399 {
400 printf("USART6_IRQHandler\n");
401 }
402
403 void I2C3_EV_IRQHandler(void)
404 {
405 printf("I2C3_EV_IRQHandler\n");
406 }
407
408 void I2C3_ER_IRQHandler(void)
409 {
410 printf("I2C3_ER_IRQHandler\n");
411 }
412
413 void OTG_HS_EP1_OUT_IRQHandler(void)
414 {
415 printf("OTG_HS_EP1_OUT_IRQHandler\n");
416 }
417
418 void OTG_HS_EP1_IN_IRQHandler(void)
419 {
420 printf("OTG_HS_EP1_IN_IRQHandler\n");
421 }
422
423 void OTG_HS_WKUP_IRQHandler(void)
424 {
425 printf("OTG_HS_WKUP_IRQHandler\n");
426 }
427
428 void OTG_HS_IRQHandler(void)
429 {
430 printf("OTG_HS_IRQHandler\n");
431 }
432
433 void DCMI_IRQHandler(void)
434 {
435 printf("DCMI_IRQHandler\n");
436 }
437
438 void CRYP_IRQHandler(void)
439 {
440 printf("CRYP_IRQHandler\n");
441 }
442
443 void HASH_RNG_IRQHandler(void)
444 {
445 printf("HASH_RNG_IRQHandler\n");
446 }
447
448 void FPU_IRQHandler(void)
449 {
450 printf("FPU_IRQHandler\n");
451 }
452
@@ -0,0 +1,81
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@gmail.com
21 -------------------------------------------------------------------------------*/
22
23
24 #define __THREAD_PRIVATE__
25 #include <thread.h>
26
27 /*
28 For CM4 cf lazy Stacking and context switching form ARM
29 List of automatically saved registers:
30 R0
31 R1
32 R2
33 R3
34 R4
35 R5
36 R6
37 R7
38 R8
39 R9
40 R10
41 R11
42 R12
43 R13(SP)
44 R14(LR)
45 R15(PC)
46 xPSR
47 S0 to S15 (if enabled)
48
49 List of registers to save:
50 S16 to S31
51 */
52
53
54 void __cpusavecontext(void* dataspace)
55 {
56
57 }
58
59 void __cpurestorecontext(void* dataspace)
60 {
61
62 }
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@@ -0,0 +1,10
1
2
3
4
5
6
7
8
9
10
@@ -0,0 +1,14
1
2
3 LIBS += -L$$[QT_INSTALL_LIBS]/$$UCMODEL
4 LIBS += -lcpu
5
6
7
8
9
10
11
12
13
14
@@ -0,0 +1,25
1 TEMPLATE = lib
2
3 UCMODEL=simulator
4
5 prifile.files = cpu.pri startup.c fs.c
6 prifile.path = $$[QT_INSTALL_PREFIX]/mkspecs/features/$$UCMODEL
7
8 INCLUDEPATH += ../../includes
9
10 SOURCES += cpu.c
11
12
13 target.path = $$[QT_INSTALL_LIBS]/$$UCMODEL
14 INSTALLS += target prifile
15
16
17
18
19
20
21
22
23
24
25
@@ -0,0 +1,25
1 #include <stdint.h>
2 #include <streamdevices.h>
3 #include <stdio.h>
4 #include <bsp.h>
5
6 const int32_t __max_opened_files__ = __MAX_OPENED_FILES__;
7 volatile streamdevice* __opnfiles__[__MAX_OPENED_FILES__];
8 const int32_t __fs_root_size__ = __FS_ROOT_SIZE__;
9 int32_t __fs_root__[__FS_ROOT_SIZE__];
10
11
12 /*
13 void __init_fs()
14 {
15 int i=0;
16 for(i=0;i<__fs_root_size__;i++)
17 {
18 __fs_root__[i]=(int32_t)NULL;
19 }
20 for(i=0;i<__max_opened_files__ ;i++)
21 {
22 __opnfiles__[i]._stream=NULL;
23 }
24 }
25 */
@@ -0,0 +1,7
1
2
3 int main(void)
4 {
5 bsp_init();
6 libuc2_main_task();
7 }
@@ -0,0 +1,119
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the libuc, microcontroler library
3 -- Copyright (C) 2012, 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@gmail.com
21 -------------------------------------------------------------------------------*/
22 #include <gpio.h>
23
24
25
26 gpio_t gpioopen(uint32_t gpio)
27 {
28 gpio &= -1^GPIOSPEEDMASK;
29 gpio |= gpiolowspeed;
30 gpio &= -1^GPIODIRMASK;
31 gpio |= gpioindir;
32 gpio &= -1^GPIOOUTTYPEMASK;
33 gpio |= gpiopushpulltype;
34 gpio &= -1^GPIOPULLTYPEMASK;
35 gpio |= gpionopulltype;
36 return gpio;
37 }
38
39
40 void gpioclose(gpio_t gpio)
41 {
42 }
43
44 void gpiosetconfig(gpio_t* gpio)
45 {
46 gpiosetdir(gpio, (*gpio & GPIODIRMASK));
47 gpiosetspeed(gpio, (*gpio & GPIOSPEEDMASK));
48 gpiosetouttype(gpio, (*gpio & GPIOOUTTYPEMASK));
49 gpiosetpulltype(gpio, (*gpio & GPIOPULLTYPEMASK));
50 }
51
52 extern void gpiosetspeed(gpio_t* gpio,gpiospeed_t speed)
53 {
54
55 }
56
57
58 void gpiosetdir(gpio_t* gpio,gpiodir_t dir)
59 {
60
61
62 }
63
64
65 void gpiosetouttype(gpio_t* gpio, gpioouttype_t outtype)
66 {
67
68 }
69
70
71 void gpiosetpulltype(gpio_t* gpio,gpiopulltype_t pulltype)
72 {
73
74 }
75
76 void gpioset(gpio_t gpio)
77 {
78
79 }
80
81
82 void gpioclr(gpio_t gpio)
83 {
84
85 }
86
87 void gpiosetval(gpio_t gpio,int val)
88 {
89
90 }
91
92 int gpiogetval(gpio_t gpio)
93 {
94 return 0;
95 }
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
@@ -0,0 +1,12
1 TEMPLATE = lib
2 SOURCES += gpio.c
3
4 INCLUDEPATH += ../../includes
5
6
7 UCMODEL=simulator
8
9 target.path = $$[QT_INSTALL_LIBS]/$$UCMODEL
10 INSTALLS += target
11
12
@@ -0,0 +1,132
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the libuc, microcontroler library
3 -- Copyright (C) 2012, 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@gmail.com
21 -------------------------------------------------------------------------------*/
22
23 #include <i2c.h>
24 #include <gpio.h>
25
26
27 int i2ctimeout=1000*1000;
28
29
30 i2c_t i2copen(int count)
31 {
32 return -1;
33 }
34
35 i2c_t i2copenandconfig(int count,uint32_t cfg,uint32_t speed,uint32_t SDA,uint32_t SCL)
36 {
37 i2c_t dev = i2copen(count);
38 if(dev!=-1)
39 {
40 i2cclose(dev);
41 i2csetpins(dev,SDA,SCL);
42 i2copen(count);
43 i2csetspeed(dev,speed);
44 i2cenable(count);
45 }
46 return dev;
47 }
48
49 int i2cclose(i2c_t dev)
50 {
51 return 1;
52 }
53
54 int i2csetpins(i2c_t dev, uint32_t SDA, uint32_t SCL)
55 {
56 if((dev<i2c4)&&(dev>=i2c1))
57 {
58 return 0;
59 }
60 return -1;
61 }
62
63 int i2cenable(i2c_t dev)
64 {
65 if((dev<i2c4)&&(dev>=i2c1))
66 {
67
68 return 0;
69 }
70 return -1;
71 }
72
73 int i2cdisable(i2c_t dev)
74 {
75 if((dev<i2c4)&&(dev>=i2c1))
76 {
77
78 return 0;
79 }
80 return -1;
81 }
82
83
84 int i2csetspeed(i2c_t dev,uint32_t speed)
85 {
86 if((dev<i2c4)&&(dev>=i2c1))
87 {
88 return 0;
89 }
90 return -1;
91 }
92
93 int i2cbusy(i2c_t dev)
94 {
95 if((dev<i2c4)&&(dev>=i2c1))
96 {
97 return 0; /* Dev isn't busy */
98 }
99 return -1; /* Error, dev is out of range */
100 }
101
102 int i2cwrite(i2c_t dev,char address,char* data,int count)
103 {
104 if((dev<i2c4)&&(dev>=i2c1))
105 {
106
107 return 0;
108 }
109 return -1;
110 }
111
112 int i2cread(i2c_t dev,char address,char* data,int count)
113 {
114 if((dev<i2c4)&&(dev>=i2c1))
115 {
116 return 0;
117 }
118 return -1;
119 }
120
121
122 int i2cStatusCheck(i2c_t dev,int32_t flagMask)
123 {
124 int32_t flag;
125 if((dev<i2c4)&&(dev>=i2c1))
126 {
127 return 0;
128 }
129 return -1;
130 }
131
132
@@ -0,0 +1,12
1 TEMPLATE = lib
2 SOURCES += i2c.c
3
4 INCLUDEPATH += ../../includes
5
6
7 UCMODEL=simulator
8
9 target.path = $$[QT_INSTALL_LIBS]/$$UCMODEL
10 INSTALLS += target
11
12
@@ -0,0 +1,15
1 TEMPLATE = lib
2 TARGET = sdcard
3 SOURCES += fakesdcard.c
4
5 INCLUDEPATH += ../../includes
6 HEADERS += \
7 ../../includes/sdcard.h
8
9
10 UCMODEL=simulator
11
12 target.path = $$[QT_INSTALL_LIBS]/$$UCMODEL
13 INSTALLS += target
14
15
@@ -0,0 +1,115
1 #include <stdio.h>
2 #include <sdcard.h>
3 #include <sdcard-spi.h>
4
5 FILE* sdcardimg;
6
7
8 void sdcardmake(sdcardDev* sdcard,UHANDLE phy,void (*rcvr_mmc) (UHANDLE,char *,unsigned int ),void (*xmit_mmc) (UHANDLE,const char *,unsigned int ),void (*setspeed) (UHANDLE phy,unsigned int speed),unsigned int (*getspeed) (UHANDLE phy))
9 {
10
11 }
12
13
14 int sdcardselect (blkdevice* _this)
15 {
16 return 1;
17 }
18
19
20 void sdcarddeselect (blkdevice* _this)
21 {
22
23 }
24
25 int sdcardwait_ready (sdcardDev* sdcard)
26 {
27 return 1;
28 }
29
30 void sdcardpower (blkdevice* _this)
31 {
32
33 }
34
35 char sdcarddetect (blkdevice* _this)
36 {
37 return 1;
38 }
39
40 char sdcardwriteprotected (blkdevice* _this)
41 {
42 return 0;
43 }
44
45
46
47 int sdcardxmit_datablock (sdcardDev* sdcard,const char *buff,char token)
48 {
49 return 1;
50 }
51
52 int sdcardrcvr_datablock (sdcardDev* sdcard,char *buff,unsigned int btr)
53 {
54 return 1;
55 }
56
57 char sdcardsend_cmd (blkdevice* _this,char cmd,unsigned int arg)
58 {
59 return 1;
60 }
61
62 DSTATUS sdcarddisk_status (blkdevice* _this)
63 {}
64
65 DSTATUS sdcarddisk_initialize (blkdevice* _this)
66 {}
67
68 DRESULT sdcarddisk_read (blkdevice* _this,char *buff,unsigned long sector,char count)
69 {
70 int res = fseek(sdcardimg, sector*(unsigned long)512, SEEK_SET);
71 if(count*512== fread(buff,1,count*512,sdcardimg))
72 return RES_OK;
73 return RES_ERROR;
74 }
75
76 DRESULT sdcarddisk_write (blkdevice* _this,const char *buff,unsigned long sector,char count)
77 {
78 fseek(sdcardimg, sector*(unsigned long)512, SEEK_SET);
79 fwrite(buff,1,count*512,sdcardimg);
80 return RES_OK;
81 }
82
83 DRESULT sdcarddisk_ioctl (blkdevice* _this,char ctrl,void *buff)
84 {}
85
86
87 void sdcardspimakeblkdev(blkdevice* dev,sdcardDev* sdcard, blkdevselect_t select,blkdevpower_t power,blkdevdetect_t detect,blkdevwriteprotected_t writeprotected)
88 {
89 sdcardimg=fopen("sdcard.bin","rb");
90 // sdcardimg=fopen("usbkey.bin","rb");
91 if(sdcardimg!=NULL)printf("ok sdcard openned\n");
92 else printf("Nok sdcard not openned\n");
93 dev->phy=NULL;
94 dev->select= (blkdevselect_t)select;
95 dev->power = (blkdevpower_t)power;
96 dev->detect = (blkdevdetect_t)detect;
97 dev->writeprotected = (blkdevwriteprotected_t)writeprotected;
98 dev->write = sdcarddisk_write;
99 dev->read = sdcarddisk_read;
100 dev->ioctl = sdcarddisk_ioctl;
101 dev->initialize = sdcarddisk_initialize;
102 dev->status = sdcarddisk_status;
103 printf("sdcard opened\n");
104 }
105
106
107
108
109
110
111
112
113
114
115
@@ -0,0 +1,237
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@gmail.com
21 -------------------------------------------------------------------------------*/
22
23 #include <SDL.h>
24 #include <malloc.h>
25 #include "SDLCD.h"
26
27 SDL_Surface *screen;
28 SDL_Overlay *bmp;
29
30 int SDLCD_Xpos=0;
31 int SDLCD_Ypos=0;
32 int SDLCD_XWinStrt=0;
33 int SDLCD_YWinStrt=0;
34 int SDLCD_XWinEnd=0;
35 int SDLCD_YWinEnd=0;
36
37 void* SDLCD_buffer;
38 int SDLCD_bpp;
39 void SDLCD_putpixel(SDL_Surface *surface, int x, int y, Uint32 pixel);
40
41 void SDLCD_mkscreen(int resx,int resy,int bpp,int lcdtype)
42 {
43 int i=0;
44 if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER)) {
45 fprintf(stderr, "Could not initialize SDL - %s\n", SDL_GetError());
46 exit(1);
47 }
48 screen = SDL_SetVideoMode(resx, resy, bpp, 0);
49 if(!screen) {
50 fprintf(stderr, "SDL: could not set video mode - exiting\n");
51 exit(1);
52 }
53 if ( SDL_MUSTLOCK(screen) ) {
54 if ( SDL_LockSurface(screen) < 0 ) {
55 fprintf(stderr, "Can’t lock screen: %s\n", SDL_GetError());
56 return;
57 }
58 }
59 if ( SDL_MUSTLOCK(screen) ) {
60 SDL_UnlockSurface(screen);
61 }
62 SDL_UpdateRect(screen, 0, 0, resx, resy);
63 SDLCD_buffer = malloc(resx*resy*bpp/8);
64 SDLCD_bpp = bpp;
65 for(i=0;i<(resx*resy);i++)
66 {
67 SDLCD_putpixel(screen, i%resx, (i/resx), 0xFFFF);
68 }
69 }
70
71
72
73 int SDLCD_init()
74 {
75
76 }
77
78 void SDLCD_writereg(uint32_t reg,uint32_t data)
79 {
80 switch (reg) {
81 case ILI9328_REGISTER_HORIZONTALGRAMADDRESSSET:
82 SDLCD_Xpos = data;
83 break;
84 case ILI9328_REGISTER_VERTICALGRAMADDRESSSET:
85 SDLCD_Ypos = data;
86 break;
87 case ILI9328_REGISTER_HORIZONTALADDRESSSTARTPOSITION:
88 SDLCD_XWinStrt = data;
89 break;
90 case ILI9328_REGISTER_HORIZONTALADDRESSENDPOSITION:
91 SDLCD_XWinEnd = data;
92 break;
93 case ILI9328_REGISTER_VERTICALADDRESSSTARTPOSITION:
94 SDLCD_YWinStrt = data;
95 break;
96 case ILI9328_REGISTER_VERTICALADDRESSENDPOSITION:
97 SDLCD_YWinEnd = data;
98 break;
99 default:
100 break;
101 }
102 }
103
104 uint32_t SDLCD_readreg(uint32_t reg)
105 {
106 return 0;
107 }
108
109
110 void SDLCD_putpixel(SDL_Surface *surface, int x, int y, Uint32 pixel)
111 {
112 int bpp = surface->format->BytesPerPixel;
113 /* Here p is the address to the pixel we want to set */
114 Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;
115 switch(bpp) {
116 case 1:
117 *p = pixel;
118 break;
119 case 2:
120 *(Uint16 *)p = pixel;
121 break;
122 case 3:
123 if(SDL_BYTEORDER == SDL_BIG_ENDIAN) {
124 p[0] = (pixel >> 16) & 0xff;
125 p[1] = (pixel >> 8) & 0xff;
126 p[2] = pixel & 0xff;
127 } else {
128 p[0] = pixel & 0xff;
129 p[1] = (pixel >> 8) & 0xff;
130 p[2] = (pixel >> 16) & 0xff;
131 }
132 break;
133 case 4:
134 *(Uint32 *)p = pixel;
135 break;
136 }
137 }
138
139 Uint32 SDLCD_getpixel(SDL_Surface *surface, int x, int y)
140 {
141 int bpp = surface->format->BytesPerPixel;
142 /* Here p is the address to the pixel we want to retrieve */
143 Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;
144 switch(bpp) {
145 case 1:
146 return *p;
147 case 2:
148 return *(Uint16 *)p;
149 case 3:
150 if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
151 return p[0] << 16 | p[1] << 8 | p[2];
152 else
153 return p[0] | p[1] << 8 | p[2] << 16;
154 case 4:
155 return *(Uint32 *)p;
156 default:
157 return 0;
158 }
159 /* shouldn’t happen, but avoids warnings */
160 }
161
162 void SDLCD_writeGRAM(void* buffer,uint32_t count)
163 {
164 int i=0;
165 u_int16_t* ptr=(u_int16_t*)SDLCD_buffer;
166 u_int16_t* inptr=(u_int16_t*)buffer;
167 if ( SDL_MUSTLOCK(screen) ) {
168 if ( SDL_LockSurface(screen) < 0 ) {
169 fprintf(stderr, "Can’t lock screen: %s\n", SDL_GetError());
170 return;
171 }
172 }
173 for(i=0;i<count;i++)
174 {
175 SDLCD_putpixel(screen,SDLCD_Xpos,SDLCD_Ypos,inptr[i]);
176 SDLCD_Xpos+=1;
177 ptr[i]=inptr[i];
178 if(SDLCD_Xpos>=SDLCD_XWinEnd)
179 {
180 SDLCD_Xpos=SDLCD_XWinStrt;
181 SDLCD_Ypos+=1;
182 }
183 if(SDLCD_Ypos>=SDLCD_YWinEnd)
184 {
185 SDLCD_Ypos=SDLCD_YWinStrt;
186 }
187 }
188 if ( SDL_MUSTLOCK(screen) ) {
189 SDL_UnlockSurface(screen);
190 }
191 SDL_UpdateRect(screen, 0, 0, screen->w, screen->h);
192 }
193
194 void SDLCD_readGRAM(void* buffer,uint32_t count)
195 {
196 int i=0;
197 u_int16_t* ptr=(u_int16_t*)SDLCD_buffer;
198 u_int16_t* inptr=(u_int16_t*)buffer;
199 for(i=0;i<count;i++)
200 {
201 inptr[i]=SDLCD_getpixel(screen,SDLCD_Xpos,SDLCD_Ypos);
202 SDLCD_Xpos+=1;
203 ptr[i]=inptr[i];
204 if(SDLCD_Xpos>=SDLCD_XWinEnd)
205 {
206 SDLCD_Xpos=SDLCD_XWinStrt;
207 SDLCD_Ypos+=1;
208 }
209 if(SDLCD_Ypos>=SDLCD_YWinEnd)
210 {
211 SDLCD_Ypos=SDLCD_YWinStrt;
212 }
213 }
214
215 }
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
@@ -0,0 +1,46
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@gmail.com
21 -------------------------------------------------------------------------------*/
22
23 #include <SDL.h>
24 #include <ili9328.h>
25 #include <stdint.h>
26
27 #define LCDILI9328 9328
28
29 extern SDL_Surface *screen;
30 extern SDL_Overlay *bmp;
31
32 extern void SDLCD_mkscreen(int resx,int resy,int bbp,int lcdtype);
33 extern int SDLCD_init();
34 extern void SDLCD_writereg(uint32_t reg,uint32_t data);
35 extern uint32_t SDLCD_readreg(uint32_t reg);
36 extern void SDLCD_writeGRAM(void* buffer,uint32_t count);
37 extern void SDLCD_readGRAM(void* buffer,uint32_t count);
38
39
40
41
42
43
44
45
46
@@ -0,0 +1,18
1 TEMPLATE = lib
2 SOURCES += SDLCD.c
3
4 HEADERS += ./SDLCD.h
5
6 INCLUDEPATH += ../../includes
7
8 SDLCDHEADERS.files += \
9 ./SDLCD.h
10
11 SDLCDHEADERS.path = $$[QT_INSTALL_HEADERS]/simulator
12
13 UCMODEL=simulator
14
15 target.path = $$[QT_INSTALL_LIBS]/$$UCMODEL
16 INSTALLS += target SDLCDHEADERS
17
18
@@ -0,0 +1,255
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@gmail.com
21 -------------------------------------------------------------------------------*/
22
23 #include <spi.h>
24 #include <gpio.h>
25
26
27
28 spi_t spiopen(int count)
29 {
30
31 return -1;
32 }
33
34 spi_t spiopenandconfig(int count, uint32_t cfg, uint32_t speed, uint32_t MOSIpin, uint32_t MISOpin, uint32_t SCKpin, uint32_t SCSpin)
35 {
36 spi_t dev = spiopen(count);
37 if(dev!=-1)
38 {
39 spidisable(dev);
40 spisetpins(dev,MOSIpin, MISOpin, SCKpin, SCSpin);
41 spienable(dev);
42 spisetconfig(dev,cfg,speed);
43 }
44 return dev;
45 }
46
47
48 int spiclose(spi_t spidev)
49 {
50 if((spidev<3)&&(spidev>=0))
51 {
52
53 return 1;
54 }
55 return -1;
56 }
57
58 int spisetpins(spi_t spidev,uint32_t MOSIpin,uint32_t MISOpin,uint32_t SCKpin,uint32_t SCSpin)
59 {
60 if((spidev<3)&&(spidev>=0))
61 {
62
63 return 1;
64 }
65 return -1;
66 }
67
68
69 int spienable(spi_t spidev)
70 {
71 if((spidev<3)&&(spidev>=0))
72 {
73 return 1;
74 }
75 return -1;
76 }
77
78
79 int spidisable(spi_t spidev)
80 {
81 if((spidev<3)&&(spidev>=0))
82 {
83 return 1;
84 }
85 return -1;
86 }
87
88 int spisetconfig(spi_t spidev, uint32_t config, uint32_t speed)
89 {
90 if((spidev<3)&&(spidev>=0))
91 {
92 return 0;
93 }
94 return 1;
95 }
96
97 int spisetspeed(spi_t spidev, uint32_t speed)
98 {
99 if((spidev<3)&&(spidev>=0))
100 {
101 return 1;
102 }
103 return -1;
104 }
105
106 uint32_t spigetspeed(spi_t spidev)
107 {
108 if((spidev<3)&&(spidev>=0))
109 {
110
111 return 0;
112 }
113 return -1;
114 }
115
116 int spisetdatabits(spi_t spidev,spibits_t bitscnt)
117 {
118 if((spidev<3)&&(spidev>=0))
119 {
120 return 0;
121 }
122 return -1;
123 }
124
125 int spisetbitorder(spi_t spidev,spibitorder_t order)
126 {
127 if((spidev<3)&&(spidev>=0))
128 {
129 return 1;
130 }
131 return -1;
132 }
133
134 int spisetclkinhlevel(spi_t spidev,spiclkinhlvl_t level)
135 {
136 if((spidev<3)&&(spidev>=0))
137 {
138 return 1;
139 }
140 return -1;
141 }
142
143 int spisetclkphase(spi_t spidev,spiclkphase_t phase)
144 {
145 if((spidev<3)&&(spidev>=0))
146 {
147 return 1;
148 }
149 return -1;
150 }
151
152 int spiputw(spi_t spidev,uint16_t data)
153 {
154 if((spidev<3)&&(spidev>=0))
155 {
156 return 0;
157 }
158 return -1;
159 }
160 uint16_t spigetw(spi_t spidev)
161 {
162 if((spidev<3)&&(spidev>=0))
163 {
164 return 0;
165 }
166 return -1;
167 }
168
169 int spiputs(spi_t spidev,char* s)
170 {
171 while (*s) spiputw(spidev,*s++);
172 return 1;
173 }
174
175 int spigets(spi_t spidev,char* s)
176 {
177 do
178 {
179 (*s) = spigetw(spidev);
180 }
181 while(*s++);
182 return 1;
183 }
184
185 int spiputnw(spi_t spidev,uint16_t* w,int n)
186 {
187 while(n!=0)
188 {
189 spiputw(spidev,*w++);
190 n--;
191 }
192 return 1;
193 }
194
195 int spigetnw(spi_t spidev,uint16_t* w,int n)
196 {
197 while(n!=0)
198 {
199 *w++=spigetw(spidev);
200 n--;
201 }
202 return 1;
203 }
204
205 int spiputnc(spi_t spidev,char* c,int n)
206 {
207 while(n!=0)
208 {
209 spiputw(spidev,*c++);
210 n--;
211 }
212 return 1;
213 }
214
215 int spigetnc(spi_t spidev,char* c,int n)
216 {
217 while(n!=0)
218 {
219 *c++=spigetw(spidev);
220 n--;
221 }
222 return 1;
223 }
224
225 int spiavailiabledata(spi_t spidev)
226 {
227 return 0;
228 }
229
230
231 int spitransactionfinished(spi_t spidev)
232 {
233 if((spidev<3)&&(spidev>=0))
234 {
235 return 1;
236 }
237 return 0;
238 }
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
@@ -0,0 +1,14
1 TEMPLATE = lib
2 SOURCES += spi.c
3
4 HEADERS += ../../includes/spi.h
5
6 INCLUDEPATH += ../../includes
7
8
9 UCMODEL=simulator
10
11 target.path = $$[QT_INSTALL_LIBS]/$$UCMODEL
12 INSTALLS += target
13
14
@@ -0,0 +1,226
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@gmail.com
21 -------------------------------------------------------------------------------*/
22
23 #include <uart.h>
24 #include <gpio.h>
25 #include <stdio.h>
26
27
28
29 int _uartstrsetpos(streamdevice* device,int pos);
30 int _uartstrread(streamdevice* device,void* data,int size, int n);
31 int _uartstrwrite(streamdevice* device,void* data,int size, int n);
32
33 streamdevice_ops UART_OPS=
34 {
35 .write = &_uartstrwrite,
36 .read = &_uartstrread,
37 .setpos= &_uartstrsetpos,
38 .close = NULL
39 };
40
41 uart_t uartopen(int count)
42 {
43 return -1;
44 }
45
46 uart_t uartopenandconfig(int count, uint32_t cfg, uint32_t speed, uint32_t TXpin, uint32_t RXpin, uint32_t RTSpin, uint32_t CTSpin)
47 {
48 uart_t dev= uartopen(count);
49 uartsetconfig(dev,cfg,speed);
50 uartsetpins(dev,TXpin,RXpin,RTSpin,CTSpin);
51 return dev;
52 }
53
54
55 int uartclose(uart_t uart)
56 {
57 return 1;
58 }
59
60 int uartsetpins(uart_t uart,uint32_t TXpin,uint32_t RXpin,uint32_t RTSpin,uint32_t CTSpin)
61 {
62 if(uart >5)return -1;
63 if(uart <0)return -1;
64 return 1;
65 }
66
67 int uartsetconfig(uart_t uart, uint32_t cfg, uint32_t speed)
68 {
69 int res=1;
70 uartdisable(uart);
71 uartsetspeed(uart,speed);
72 uartsetparity(uart,cfg & UARTPARITYMASK);
73 uartsetdatabits(uart,cfg & UARTBITSMASK);
74 uartsetstopbits(uart,cfg & UARTSTOPBITSMASK);
75 uartenable(uart);
76 return res;
77 }
78
79 int uartenable(uart_t uart)
80 {
81 if((uart<6)&&(uart>=0))
82 {
83 return 1;
84 }
85 return -1;
86 }
87
88 int uartdisable(uart_t uart)
89 {
90 if((uart<6)&&(uart>=0))
91 {
92 return 1;
93 }
94 return -1;
95 }
96
97 int uartsetspeed(uart_t uart,uint32_t speed)
98 {
99 if((uart<6)&&(uart>=0))
100 {
101 return 1;
102 }
103 return -1;
104 }
105
106 int uartsetparity(uart_t uart,uartparity_t parity)
107 {
108 if((uart<6)&&(uart>=0))
109 {
110 return 1;
111 }
112 return -1;
113 }
114
115 int uartsetdatabits(uart_t uart,uartbits_t databits)
116 {
117 if((uart<6)&&(uart>=0))
118 {
119 return 1;
120 }
121 return -1;
122 }
123
124 int uartsetstopbits(uart_t uart,uartstopbits_t stopbits)
125 {
126 if((uart<6)&&(uart>=0))
127 {
128 return 1;
129 }
130 return -1;
131 }
132
133 int uartputc(uart_t uart,char c)
134 {
135 if((uart<6)&&(uart>=0))
136 {
137 return 1;
138 }
139 return -1;
140 }
141
142 char uartgetc(uart_t uart)
143 {
144 if((uart<6)&&(uart>=0))
145 {
146 return 0;
147 }
148 return -1;
149 }
150
151 int uartputs(uart_t uart,char* s)
152 {
153 while (*s) uartputc(uart,*s++);
154 return 1;
155 }
156
157 int uartgets(uart_t uart,char* s)
158 {
159 do
160 {
161 (*s) = uartgetc(uart);
162 }
163 while(*s++);
164 return 1;
165 }
166
167 int uartputnc(uart_t uart,char* c,int n)
168 {
169 int l=0;
170 while(l<n)
171 {
172 uartputc(uart,*c++);
173 l++;
174 }
175 return n;
176 }
177
178 int uartgetnc(uart_t uart,char* c,int n)
179 {
180 int l=0;
181 while(l<n)
182 {
183 *c++=uartgetc(uart);
184 l++;
185 }
186 return n;
187 }
188
189 int uartavailiabledata(uart_t uart)
190 {
191 if((uart<6)&&(uart>=0))
192 {
193 return 1;
194 }
195 return -1;
196 }
197
198
199 int _uartstrwrite(streamdevice* device,void* data,int size, int n)
200 {
201 return uartputnc((uart_t) device->_stream,(char*) data,size*n);
202 }
203
204 int _uartstrread(streamdevice* device,void* data,int size, int n)
205 {
206 return uartgetnc((uart_t) device->_stream,(char*) data,size*n);
207 }
208
209 int _uartstrsetpos(streamdevice* device,int pos)
210 {
211 return 1;
212 }
213
214 int uartmkstreamdev(uart_t uart,streamdevice* strdev)
215 {
216 strdev->_stream = (UHANDLE)uart;
217 strdev->ops = &UART_OPS;
218 strdev->streamPt = 0;
219 return 1;
220 }
221
222
223
224
225
226
@@ -0,0 +1,12
1 TEMPLATE = lib
2 SOURCES += uart.c
3
4 INCLUDEPATH += ../../includes
5
6
7 UCMODEL=simulator
8
9 target.path = $$[QT_INSTALL_LIBS]/$$UCMODEL
10 INSTALLS += target
11
12
@@ -0,0 +1,14
1 TEMPLATE = subdirs
2 CONFIG += ordered
3 SUBDIRS = CORE/core.pro \
4 CPU/cpu.pro \
5 GPIO/gpio.pro \
6 UART/uart.pro \
7 SPI/spi.pro \
8 I2C/i2c.pro \
9 SDCARD \
10 SDLCD
11
12
13
14
@@ -0,0 +1,452
1 #include <stdio.h>
2
3 void NMI_Handler(void)
4 {
5 printf("NMI_Handler\n");
6 }
7
8 void HardFault_Handler(void)
9 {
10 printf("HardFault_Handler\n");
11 }
12
13 void MemManage_Handler(void)
14 {
15 printf("MemManage_Handler\n");
16 }
17
18 void BusFault_Handler(void)
19 {
20 printf("BusFault_Handler\n");
21 }
22
23 void UsageFault_Handler(void)
24 {
25 printf("UsageFault_Handler\n");
26 }
27
28 void SVC_Handler(void)
29 {
30 printf("SVC_Handler\n");
31 }
32
33 void DebugMon_Handler(void)
34 {
35 printf("DebugMon_Handler\n");
36 }
37
38 void PendSV_Handler(void)
39 {
40 printf("PendSV_Handler\n");
41 }
42
43 void WWDG_IRQHandler(void)
44 {
45 printf("WWDG_IRQHandler\n");
46 }
47
48 void PVD_IRQHandler(void)
49 {
50 printf("PVD_IRQHandler\n");
51 }
52
53 void TAMP_STAMP_IRQHandler(void)
54 {
55 printf("TAMP_STAMP_IRQHandler\n");
56 }
57
58 void RTC_WKUP_IRQHandler(void)
59 {
60 printf("RTC_WKUP_IRQHandler\n");
61 }
62
63 void FLASH_IRQHandler(void)
64 {
65 printf("FLASH_IRQHandler\n");
66 }
67
68 void RCC_IRQHandler(void)
69 {
70 printf("RCC_IRQHandler\n");
71 }
72
73 void EXTI0_IRQHandler(void)
74 {
75 printf("EXTI0_IRQHandler\n");
76 }
77
78 void EXTI1_IRQHandler(void)
79 {
80 printf("EXTI1_IRQHandler\n");
81 }
82
83 void EXTI2_IRQHandler(void)
84 {
85 printf("EXTI2_IRQHandler\n");
86 }
87
88 void EXTI3_IRQHandler(void)
89 {
90 printf("EXTI3_IRQHandler\n");
91 }
92
93 void EXTI4_IRQHandler(void)
94 {
95 printf("EXTI4_IRQHandler\n");
96 }
97
98 void DMA1_Stream0_IRQHandler(void)
99 {
100 printf("DMA1_Stream0_IRQHandler\n");
101 }
102
103 void DMA1_Stream1_IRQHandler(void)
104 {
105 printf("DMA1_Stream1_IRQHandler\n");
106 }
107
108 void DMA1_Stream2_IRQHandler(void)
109 {
110 printf("DMA1_Stream2_IRQHandler\n");
111 }
112
113 void DMA1_Stream3_IRQHandler(void)
114 {
115 printf("DMA1_Stream3_IRQHandler\n");
116 }
117
118 void DMA1_Stream4_IRQHandler(void)
119 {
120 printf("DMA1_Stream4_IRQHandler\n");
121 }
122
123 void DMA1_Stream5_IRQHandler(void)
124 {
125 printf("DMA1_Stream5_IRQHandler\n");
126 }
127
128 void DMA1_Stream6_IRQHandler(void)
129 {
130 printf("DMA1_Stream6_IRQHandler\n");
131 }
132
133 void ADC_IRQHandler(void)
134 {
135 printf("ADC_IRQHandler\n");
136 }
137
138 void CAN1_TX_IRQHandler(void)
139 {
140 printf("CAN1_TX_IRQHandler\n");
141 }
142
143 void CAN1_RX0_IRQHandler(void)
144 {
145 printf("CAN1_RX0_IRQHandler\n");
146 }
147
148 void CAN1_RX1_IRQHandler(void)
149 {
150 printf("CAN1_RX1_IRQHandler\n");
151 }
152
153 void CAN1_SCE_IRQHandler(void)
154 {
155 printf("CAN1_SCE_IRQHandler\n");
156 }
157
158 void EXTI9_5_IRQHandler(void)
159 {
160 printf("EXTI9_5_IRQHandler\n");
161 }
162
163 void TIM1_BRK_TIM9_IRQHandler(void)
164 {
165 printf("TIM1_BRK_TIM9_IRQHandler\n");
166 }
167
168 void TIM1_UP_TIM10_IRQHandler(void)
169 {
170 printf("TIM1_UP_TIM10_IRQHandler\n");
171 }
172
173 void TIM1_TRG_COM_TIM11_IRQHandlerIM11(void)
174 {
175 printf("TIM1_TRG_COM_TIM11_IRQHandlerIM11");
176 }
177
178 void TIM1_CC_IRQHandler(void)
179 {
180 printf("TIM1_CC_IRQHandler\n");
181 }
182
183 void TIM2_IRQHandler(void)
184 {
185 printf("TIM2_IRQHandler\n");
186 }
187
188 void TIM3_IRQHandler(void)
189 {
190 printf("TIM3_IRQHandler\n");
191 }
192
193 void TIM4_IRQHandler(void)
194 {
195 printf("TIM4_IRQHandler\n");
196 }
197
198 void I2C1_EV_IRQHandler(void)
199 {
200 printf("I2C1_EV_IRQHandler\n");
201 }
202
203 void I2C1_ER_IRQHandler(void)
204 {
205 printf("I2C1_ER_IRQHandler\n");
206 }
207
208 void I2C2_EV_IRQHandler(void)
209 {
210 printf("I2C2_EV_IRQHandler\n");
211 }
212
213 void I2C2_ER_IRQHandler(void)
214 {
215 printf("I2C2_ER_IRQHandler\n");
216 }
217
218 void SPI1_IRQHandler(void)
219 {
220 printf("SPI1_IRQHandler\n");
221 }
222
223 void SPI2_IRQHandler(void)
224 {
225 printf("SPI2_IRQHandler\n");
226 }
227
228 void USART1_IRQHandler(void)
229 {
230 printf("USART1_IRQHandler\n");
231 }
232
233 void USART2_IRQHandler(void)
234 {
235 printf("USART2_IRQHandler\n");
236 }
237
238 void USART3_IRQHandler(void)
239 {
240 printf("USART3_IRQHandler\n");
241 }
242
243 void EXTI15_10_IRQHandler(void)
244 {
245 printf("EXTI15_10_IRQHandler\n");
246 }
247
248 void RTC_Alarm_IRQHandler(void)
249 {
250 printf("RTC_Alarm_IRQHandler\n");
251 }
252
253 void OTG_FS_WKUP_IRQHandler(void)
254 {
255 printf("OTG_FS_WKUP_IRQHandler\n");
256 }
257
258 void TIM8_BRK_TIM12_IRQHandler(void)
259 {
260 printf("TIM8_BRK_TIM12_IRQHandler\n");
261 }
262
263 void TIM8_UP_TIM13_IRQHandler(void)
264 {
265 printf("TIM8_UP_TIM13_IRQHandler\n");
266 }
267
268 void TIM8_TRG_COM_TIM14_IRQHandlerIM14(void)
269 {
270 printf("TIM8_TRG_COM_TIM14_IRQHandlerIM14");
271 }
272
273 void TIM8_CC_IRQHandler(void)
274 {
275 printf("TIM8_CC_IRQHandler\n");
276 }
277
278 void DMA1_Stream7_IRQHandler(void)
279 {
280 printf("DMA1_Stream7_IRQHandler\n");
281 }
282
283 void FSMC_IRQHandler(void)
284 {
285 printf("FSMC_IRQHandler\n");
286 }
287
288 void SDIO_IRQHandler(void)
289 {
290 printf("SDIO_IRQHandler\n");
291 }
292
293 void TIM5_IRQHandler(void)
294 {
295 printf("TIM5_IRQHandler\n");
296 }
297
298 void SPI3_IRQHandler(void)
299 {
300 printf("SPI3_IRQHandler\n");
301 }
302
303 void UART4_IRQHandler(void)
304 {
305 printf("UART4_IRQHandler\n");
306 }
307
308 void UART5_IRQHandler(void)
309 {
310 printf("UART5_IRQHandler\n");
311 }
312
313 void TIM6_DAC_IRQHandler(void)
314 {
315 printf("TIM6_DAC_IRQHandler\n");
316 }
317
318 void TIM7_IRQHandler(void)
319 {
320 printf("TIM7_IRQHandler\n");
321 }
322
323 void DMA2_Stream0_IRQHandler(void)
324 {
325 printf("DMA2_Stream0_IRQHandler\n");
326 }
327
328 void DMA2_Stream1_IRQHandler(void)
329 {
330 printf("DMA2_Stream1_IRQHandler\n");
331 }
332
333 void DMA2_Stream2_IRQHandler(void)
334 {
335 printf("DMA2_Stream2_IRQHandler\n");
336 }
337
338 void DMA2_Stream3_IRQHandler(void)
339 {
340 printf("DMA2_Stream3_IRQHandler\n");
341 }
342
343 void DMA2_Stream4_IRQHandler(void)
344 {
345 printf("DMA2_Stream4_IRQHandler\n");
346 }
347
348 void ETH_IRQHandler(void)
349 {
350 printf("ETH_IRQHandler\n");
351 }
352
353 void ETH_WKUP_IRQHandler(void)
354 {
355 printf("ETH_WKUP_IRQHandler\n");
356 }
357
358 void CAN2_TX_IRQHandler(void)
359 {
360 printf("CAN2_TX_IRQHandler\n");
361 }
362
363 void CAN2_RX0_IRQHandler(void)
364 {
365 printf("CAN2_RX0_IRQHandler\n");
366 }
367
368 void CAN2_RX1_IRQHandler(void)
369 {
370 printf("CAN2_RX1_IRQHandler\n");
371 }
372
373 void CAN2_SCE_IRQHandler(void)
374 {
375 printf("CAN2_SCE_IRQHandler\n");
376 }
377
378 void OTG_FS_IRQHandler(void)
379 {
380 printf("OTG_FS_IRQHandler\n");
381 }
382
383 void DMA2_Stream5_IRQHandler(void)
384 {
385 printf("DMA2_Stream5_IRQHandler\n");
386 }
387
388 void DMA2_Stream6_IRQHandler(void)
389 {
390 printf("DMA2_Stream6_IRQHandler\n");
391 }
392
393 void DMA2_Stream7_IRQHandler(void)
394 {
395 printf("DMA2_Stream7_IRQHandler\n");
396 }
397
398 void USART6_IRQHandler(void)
399 {
400 printf("USART6_IRQHandler\n");
401 }
402
403 void I2C3_EV_IRQHandler(void)
404 {
405 printf("I2C3_EV_IRQHandler\n");
406 }
407
408 void I2C3_ER_IRQHandler(void)
409 {
410 printf("I2C3_ER_IRQHandler\n");
411 }
412
413 void OTG_HS_EP1_OUT_IRQHandler(void)
414 {
415 printf("OTG_HS_EP1_OUT_IRQHandler\n");
416 }
417
418 void OTG_HS_EP1_IN_IRQHandler(void)
419 {
420 printf("OTG_HS_EP1_IN_IRQHandler\n");
421 }
422
423 void OTG_HS_WKUP_IRQHandler(void)
424 {
425 printf("OTG_HS_WKUP_IRQHandler\n");
426 }
427
428 void OTG_HS_IRQHandler(void)
429 {
430 printf("OTG_HS_IRQHandler\n");
431 }
432
433 void DCMI_IRQHandler(void)
434 {
435 printf("DCMI_IRQHandler\n");
436 }
437
438 void CRYP_IRQHandler(void)
439 {
440 printf("CRYP_IRQHandler\n");
441 }
442
443 void HASH_RNG_IRQHandler(void)
444 {
445 printf("HASH_RNG_IRQHandler\n");
446 }
447
448 void FPU_IRQHandler(void)
449 {
450 printf("FPU_IRQHandler\n");
451 }
452
@@ -0,0 +1,41
1 #
2 # qmake configuration for simulator
3 #
4
5 CONFIG +=
6 QMAKE_CC = gcc
7 QMAKE_CFLAGS += -g -O0
8 QMAKE_CFLAGS_DEPS += -M
9 QMAKE_CFLAGS_WARN_ON += -Wall
10 QMAKE_CFLAGS_WARN_OFF += -w
11 QMAKE_CFLAGS_RELEASE += -O2
12 QMAKE_CFLAGS_DEBUG +=
13
14 QMAKE_CXX = g++
15 QMAKE_CXXFLAGS += $$QMAKE_CFLAGS s
16 QMAKE_CXXFLAGS_DEPS += $$QMAKE_CFLAGS_DEPS
17 QMAKE_CXXFLAGS_WARN_ON += $$QMAKE_CFLAGS_WARN_ON
18 QMAKE_CXXFLAGS_WARN_OFF += $$QMAKE_CFLAGS_WARN_OFF
19 QMAKE_CXXFLAGS_RELEASE += $$QMAKE_CFLAGS_RELEASE
20 QMAKE_CXXFLAGS_DEBUG += $$QMAKE_CFLAGS_DEBUG
21 QMAKE_CXXFLAGS_SHLIB += $$QMAKE_CFLAGS_SHLIB
22 QMAKE_CXXFLAGS_STATIC_LIB += $$QMAKE_CFLAGS_STATIC_LIB
23 QMAKE_CXXFLAGS_YACC += $$QMAKE_CFLAGS_YACC
24 QMAKE_CXXFLAGS_HIDESYMS += $$QMAKE_CFLAGS_HIDESYMS
25
26 QMAKE_LINK = gcc
27 QMAKE_LINK_SHLIB = gcc
28 QMAKE_LINK_C = gcc
29 QMAKE_LINK_C_SHLIB = gcc
30 QMAKE_LFLAGS += -g -O0
31 QMAKE_LFLAGS_RELEASE +=
32 QMAKE_LFLAGS_DEBUG +=
33 QMAKE_LFLAGS_APP +=
34 QMAKE_LFLAGS_SHLIB +=
35 QMAKE_LFLAGS_PLUGIN += $$QMAKE_LFLAGS_SHLIB
36 QMAKE_LFLAGS_THREAD +=
37
38 QMAKE_AR = ar -ru
39 QMAKE_LIB = ar -ru
40 QMAKE_RANLIB =
41
@@ -0,0 +1,16
1
2
3 LIBS += -L$$[QT_INSTALL_LIBS]/$$UCMODEL
4 LIBS += -lcpu
5
6
7
8
9
10
11
12
13
14
15
16
@@ -0,0 +1,7
1
2
3 int main(void)
4 {
5 bsp_init();
6 libuc2_main_task();
7 }
@@ -0,0 +1,57
1 #
2 # qmake configuration for stm32f4
3 #
4 #
5
6
7 isEmpty(_simulator_conf){
8 _simulator_conf="oneshot"
9
10 QMAKE_CFLAGS= -std=c99
11
12 include(../common/simulator.conf)
13
14 DEFINES += \"assert_param(expr)=((void)0)\"
15 INCLUDEPATH += $$PWD /usr/include/SDL
16
17 DEFINES += BSP="\"\\\"$$BSP"\\\"\"
18
19 CONFIG += cpu
20
21 contains( TEMPLATE, app ) {
22 OBJECTS_DIR=obj-$$UCMODEL
23 DESTDIR=bin-$$UCMODEL
24 LIBS += -L$$[QT_INSTALL_PREFIX]/bsp/lib/$$BSP
25 LIBS += -lbsp -lSDLCD -lSDL -lz -lm
26 SOURCES +=$$[QT_INSTALL_PREFIX]/mkspecs/features/simulator/startup.c
27 SOURCES +=$$[QT_INSTALL_PREFIX]/mkspecs/features/simulator/fs.c
28
29
30 INCLUDEPATH+= $$[QT_INSTALL_PREFIX]/bsp/includes/$$BSP
31
32 }
33
34 contains( TEMPLATE, lib ) {
35 OBJECTS_DIR=obj-$$UCMODEL
36 DESTDIR=bin-$$UCMODEL
37 CONFIG+=staticlib
38 }
39
40 include(../common/libuc2libs.conf)
41
42 }
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
@@ -0,0 +1,42
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the qmake spec of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 //#include "../linux-g++/qplatformdefs.h"
@@ -17,7 +17,7
17 #-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 #-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 #-------------------------------------------------------------------------------
18 #-------------------------------------------------------------------------------
19 #-- Author : Alexis Jeandet
19 #-- Author : Alexis Jeandet
20 #-- Mail : alexis.jeandet@gmail.com
20 #-- Mail : alexis.jeandet@member.fsf.org
21 #-------------------------------------------------------------------------------
21 #-------------------------------------------------------------------------------
22
22
23 ________
23 ________
@@ -30,9 +30,6 own licence. If you reconize any of your
30 Intallation:
30 Intallation:
31 ~~~~~~~~~~~~
31 ~~~~~~~~~~~~
32 To install the libuc2 you just need to copy the libuc2 folder where you whant then you need to:
32 To install the libuc2 you just need to copy the libuc2 folder where you whant then you need to:
33 -add the libuc2 binary folder to the PATH, with linux you can append this to the end of your /etc/bashrc file:
34 PATH=$PATH:/opt/libuc2/bin
35 replace /opt/ by the path where is installed the libuc2.
36 -set the libuc2 environement varriable, with linux you can append this to the end of your /etc/bashrc file:
33 -set the libuc2 environement varriable, with linux you can append this to the end of your /etc/bashrc file:
37 libuc2=/opt/libuc2
34 libuc2=/opt/libuc2
38 replace /opt/ by the path where is installed the libuc2.
35 replace /opt/ by the path where is installed the libuc2.
@@ -41,7 +38,7 Intallation:
41 Contributions:
38 Contributions:
42 ~~~~~~~~~~~~~~
39 ~~~~~~~~~~~~~~
43 Feel free to modify everything in the libuc2, if you think that some of your improvement should be integrated in the
40 Feel free to modify everything in the libuc2, if you think that some of your improvement should be integrated in the
44 libuc2 you can send them to me at alexis.jeandet@lpp.polytechnique.fr or alexis.jeandet@gmail.fr.
41 libuc2 you can send them to me at alexis.jeandet@member.fsf.org or alexis.jeandet@gmail.fr.
45
42
46 ______________
43 ______________
47 Documentation:
44 Documentation:
@@ -58,8 +58,8 LCD_t lcd0={
58
58
59 terminal_t terminal0;
59 terminal_t terminal0;
60
60
61 volatile int8_t* lcd0_CMD=(volatile int8_t*) 0x60000000;
61 volatile uint8_t* lcd0_CMD=(volatile uint8_t*) 0x60000000;
62 volatile int8_t* lcd0_DATA=(volatile int8_t*)(0x61FFFFF0);
62 volatile uint8_t* lcd0_DATA=(volatile uint8_t*)(0x61FFFFF0);
63
63
64 float VREF0 =(float)3.3;
64 float VREF0 =(float)3.3;
65 volatile vs10XXDev audioCodec0;
65 volatile vs10XXDev audioCodec0;
@@ -124,7 +124,18 void bsp_GPIO_init()
124
124
125 void bsp_uart_init()
125 void bsp_uart_init()
126 {
126 {
127
127 // if(__opnfiles__[1]==NULL)
128 // {
129 // //uart_t* uart1 = (uart_t*)malloc(sizeof(uart_t));
130 // streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice));
131 // uart_t uart = uartopenandconfig(uart3,uartparitynone | uart8bits | uartonestop,115200,PD8,PD9,-1,-1);
132 // uartmkstreamdev(uart,fd1);
133 // __opnfiles__[1] = fd1;
134 // }
135 // else
136 // {
137 // uartopenandconfig(uart3,uartparitynone | uart8bits | uartonestop,115200,PD8,PD9,-1,-1);
138 // }
128 }
139 }
129
140
130 /*
141 /*
@@ -172,7 +183,7 int bsp_FSMC_init()
172 p.FSMC_DataLatency = 0;
183 p.FSMC_DataLatency = 0;
173 //ili9328 -> data hold time > 15ns
184 //ili9328 -> data hold time > 15ns
174 if(getCpuFreq()>66*1000*1000)
185 if(getCpuFreq()>66*1000*1000)
175 p.FSMC_DataLatency = 0;
186 p.FSMC_DataLatency = 1;
176 p.FSMC_AccessMode = FSMC_AccessMode_A;
187 p.FSMC_AccessMode = FSMC_AccessMode_A;
177
188
178 FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM1;
189 FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM1;
@@ -445,31 +456,38 void bsp_lcd0_writeGRAM(void* buffer,uin
445
456
446 void bsp_lcd0_readGRAM(void* buffer,uint32_t count)
457 void bsp_lcd0_readGRAM(void* buffer,uint32_t count)
447 {
458 {
448 uint32_t reg =ILI9328_REGISTER_WRITEDATATOGRAM;
459 // uint32_t reg =ILI9328_REGISTER_WRITEDATATOGRAM;
449 uint8_t* pt8 = (uint8_t*)(void*)&reg;
460 // int8_t* pt8 = (int8_t*)(void*)&reg;
450 #if __BYTE_ORDER__==__ORDER_BIG_ENDIAN__
461 #if __BYTE_ORDER__==__ORDER_BIG_ENDIAN__
451 *lcd0_CMD=pt8[3];
462 *lcd0_CMD=pt8[3];
452 *lcd0_CMD=pt8[2];
463 *lcd0_CMD=pt8[2];
453 pt8 = (uint8_t*)(void*)buffer;
464 pt8 = (uint8_t*)(void*)buffer;
454 pt8[0] = *lcd0_DATA;
455 pt8[0] = *lcd0_DATA;
456 for(int i=0;i<(int)count;i++)
465 for(int i=0;i<(int)count;i++)
457 {
466 {
458 pt8[(2*i) +1]=*lcd0_DATA;
467 pt8[(2*i) +1]=*lcd0_DATA;
468 __asm__("nop");
469 __asm__("nop");
470 __asm__("nop");
471 __asm__("nop");
472 __asm__("nop");
459 pt8[2*i]=*lcd0_DATA;
473 pt8[2*i]=*lcd0_DATA;
460 }
474 }
461 #else
475 #else
462
476 // lcd0_CMD=pt8[1];
463 *lcd0_CMD=pt8[1];
477 // lcd0_CMD=pt8[0];
464 *lcd0_CMD=pt8[0];
478 // pt8 = (int8_t*)(void*)buffer;
465 pt8 = (uint8_t*)(void*)buffer;
479 // for(int i=0;i<(int)count;i++)
466 pt8[0] = *lcd0_DATA;
480 // {
467 pt8[0] = *lcd0_DATA;
481 // pt8[(2*i) +1]=*lcd0_DATA;
468 for(int i=0;i<(int)count;i++)
482 // __asm__("nop");
469 {
483 // __asm__("nop");
470 pt8[(2*i) +1]=*lcd0_DATA;
484 // __asm__("nop");
471 pt8[2*i]=*lcd0_DATA;
485 // __asm__("nop");
472 }
486 // __asm__("nop");
487 // pt8[2*i]=*lcd0_DATA;
488 //pt8[(2*i) +1]=(uint8_t)0;
489 //pt8[(2*i)]=(uint8_t)0;
490 // }
473 #endif
491 #endif
474 }
492 }
475
493
@@ -477,9 +495,8 void bsp_GTerm_init()
477 {
495 {
478 if(__opnfiles__[1]==NULL)
496 if(__opnfiles__[1]==NULL)
479 {
497 {
480 //uart_t* uart1 = (uart_t*)malloc(sizeof(uart_t));
481 streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice));
498 streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice));
482 terminal_init(&terminal0 ,&lcd0,&ComicSansMS_8,fd1);
499 terminal_init(&terminal0 ,&lcd0,&ComicSansMS_18,fd1);
483 __opnfiles__[1] = fd1;
500 __opnfiles__[1] = fd1;
484 }
501 }
485 else
502 else
@@ -1,3 +1,3
1 CPU=stm32f4xxxG
1 CPU=stm32f4xxxG
2 DEFINES+=BSP=\\\"SOLAR_LFR_PSU\\\"
2 DEFINES+=BSP=\\\"STM32F4Discovery\\\"
3 UCMODEL=stm32f4
3 UCMODEL=stm32f4
@@ -7,7 +7,8 SUBDIRS += STM32F4Discovery \
7 BEAGLESYNTH \
7 BEAGLESYNTH \
8 STM32F4Eval \
8 STM32F4Eval \
9 STM32F4Discovery-EXT \
9 STM32F4Discovery-EXT \
10 OPLAYER
10 OPLAYER \
11 SIMULATOR
11
12
12
13
13
14
@@ -5,8 +5,10 CONFIG += cpu
5 UCMODEL=stm32f4
5 UCMODEL=stm32f4
6 BSP = OPLAYER
6 BSP = OPLAYER
7
7
8 DEFINES += CPUFREQ=160000000
8 DEFINES += CPUFREQ=180000000
9
9
10
10 SOURCES += \
11 SOURCES += \
11 main.c
12 main.c \
13 test_lcd.c
12
14
@@ -14,9 +14,11
14 #include <ucdirent.h>
14 #include <ucdirent.h>
15 #include <string.h>
15 #include <string.h>
16 #include <terminal.h>
16 #include <terminal.h>
17 #include <ili9328.h>
17
18
18
19
19 extern streamdevice* __opnfiles__[];
20 extern streamdevice* __opnfiles__[];
21 extern void test_Block_Move(LCD_t* LCD,int x,int y,int w,int h,int color);
20 char buffer[512];
22 char buffer[512];
21
23
22 void randBoxesDemo()
24 void randBoxesDemo()
@@ -36,109 +38,27 void randBoxesDemo()
36 //delay_100us(10);
38 //delay_100us(10);
37 //for(volatile int i=0;i<(1024*2);i++);
39 //for(volatile int i=0;i<(1024*2);i++);
38 }
40 }
39 void tryToplay1()
40 {
41
41
42 extern FAT32fs sdcard2FAT32part1;
42 void randTextDemo()
43 extern volatile vs10XXDev audioCodec0;
43 {
44 ucdirent root;
44 int16_t x,y,w,h,t,r;
45 char direntName[]=" \n";
45 char buf[2];
46 uint32_t fileLba,nextLba;
46 buf[1]='\0';
47 int i=0;
47 x=rand()%240;
48 spisetspeed(audioCodec0.SPIdev,2000000);
48 y=rand()%320;
49 if(DIRENT_noErr==fat32mkdirent(&sdcard2FAT32part1,&root))
49 if(x>y)
50 {
50 r=(rand()%(y))%(320-y);
51 if(DIRENT_noErr==fat32getrootfirstent(&root))
51 else
52 {
52 r=(rand()%(x))%(240-x);
53 do{
53 h=rand()%(320-y);
54 fat32getdirentname(&root,direntName);
54 buf[0]=rand()%(255);
55 printf("%s\n",direntName);
55 //ili9328paintFilRect(&lcd0,x,y,w,h,rand(),t,rand());
56 nextLba=fat32getdirentlba(&root);
56 ili9328paintText(&lcd0,buf,x,y,&ComicSansMS_18,rand());
57 printf("Streaming File\n");
57 //ili9328paintFilCirc(&lcd0,x,y,r,rand(),t,rand());
58 do
58 delay_100us(5000);
59 {
59 //for(volatile int i=0;i<(1024*2);i++);
60 fileLba = nextLba;
61 if(sdcard2FAT32part1.part->phy->read(sdcard2FAT32part1.part->phy,buffer,fileLba,1)==RES_OK)
62 {
63 for(i=0;i<512;i+=32)
64 {
65 vs10XXstream32bytes(&audioCodec0,buffer+i);
66 }
67 }
68 }while ((fat32nextsectorlba(&sdcard2FAT32part1,fileLba,&nextLba)==DIRENT_noErr) && (!gpiogetval(BP3)));
69 //vs10XXsoftReset(&audioCodec0);
70 while (gpiogetval(BP3))delay_100us(1000);
71 printf("looking for next file\n");
72 }while (DIRENT_noErr==fat32nextdirent(&root));
73 }
74 }
75 if(DIRENT_noErr==fat32mkdirent(&sdcard2FAT32part2,&root))
76 {
77 if(DIRENT_noErr==fat32getrootfirstent(&root))
78 {
79 fat32getdirentname(&root,direntName);
80 printf("%s\n",direntName);
81 nextLba=fat32getdirentlba(&root);
82 printf("Streaming File\n");
83 do
84 {
85 fileLba = nextLba;
86 if(sdcard2FAT32part2.part->phy->read(sdcard2FAT32part2.part->phy,buffer,fileLba,1)==RES_OK)
87 {
88 for(i=0;i<512;i+=32)
89 {
90 vs10XXstream32bytes(&audioCodec0,buffer+i);
91 }
92 }
93 }while ((fat32nextsectorlba(&sdcard2FAT32part2,fileLba,&nextLba)==DIRENT_noErr) && (!gpiogetval(BP3)));
94 while (gpiogetval(BP3))delay_100us(1000);
95 }
96 }
97 if(DIRENT_noErr==fat32mkdirent(&sdcard2FAT32part3,&root))
98 {
99 if(DIRENT_noErr==fat32getrootfirstent(&root))
100 {
101 fat32getdirentname(&root,direntName);
102 printf("%s\n",direntName);
103 nextLba=fat32getdirentlba(&root);
104 printf("Streaming File\n");
105 do
106 {
107 fileLba = nextLba;
108 if(sdcard2FAT32part3.part->phy->read(sdcard2FAT32part3.part->phy,buffer,fileLba,1)==RES_OK)
109 {
110 for(i=0;i<512;i+=32)
111 {
112 vs10XXstream32bytes(&audioCodec0,buffer+i);
113 }
114 }
115 }while ((fat32nextsectorlba(&sdcard2FAT32part3,fileLba,&nextLba)==DIRENT_noErr) && (!gpiogetval(BP3)));
116 while (gpiogetval(BP3))delay_100us(1000);
117 }
118 }
119 if(DIRENT_noErr==fat32mkdirent(&sdcard2FAT32part4,&root))
120 {
121 if(DIRENT_noErr==fat32getrootfirstent(&root))
122 {
123 fat32getdirentname(&root,direntName);
124 printf("%s\n",direntName);
125 nextLba=fat32getdirentlba(&root);
126 printf("Streaming File\n");
127 do
128 {
129 fileLba = nextLba;
130 if(sdcard2FAT32part4.part->phy->read(sdcard2FAT32part4.part->phy,buffer,fileLba,1)==RES_OK)
131 {
132 for(i=0;i<512;i+=32)
133 {
134 vs10XXstream32bytes(&audioCodec0,buffer+i);
135 }
136 }
137 }while ((fat32nextsectorlba(&sdcard2FAT32part4,fileLba,&nextLba)==DIRENT_noErr) && (!gpiogetval(BP3)));
138 while (gpiogetval(BP3))delay_100us(1000);
139 }
140 }
141 }
60 }
61
142 void tryToplay2()
62 void tryToplay2()
143 {
63 {
144
64
@@ -160,18 +80,122 void tryToplay2()
160 }
80 }
161 }
81 }
162
82
83 void playFile(ucdirent* file,FAT32fs* part)
84 {
85 extern volatile vs10XXDev audioCodec0;
86 char direntName[]=" \n";
87 uint32_t fileLba,nextLba;
88 int i=0;
89 fat32getdirentname(file,direntName);
90 gpioset(LCD_BACKL);
91 //printf("%s\n",direntName);
92 nextLba=fat32getdirentlba(file);
93 //printf("Streaming File\n");
94 gpioclr(LCD_BACKL);
95 do
96 {
97 fileLba = nextLba;
98 if(sdcard2FAT32part1.part->phy->read(part->part->phy,buffer,fileLba,1)==RES_OK)
99 {
100 for(i=0;i<512;i+=32)
101 {
102 vs10XXstream32bytes(&audioCodec0,buffer+i);
103 }
104 }
105 }while ((fat32nextsectorlba(part,fileLba,&nextLba)==DIRENT_noErr) && (!gpiogetval(BP3)));
106 vs10XXsoftReset(&audioCodec0);
107 while (gpiogetval(BP3))delay_100us(1000);
108 }
109
110 void playAllparts()
111 {
112 extern FAT32fs sdcard2FAT32part1,sdcard2FAT32part2,sdcard2FAT32part3,sdcard2FAT32part4;
113 ucdirent root;
114 if(DIRENT_noErr==fat32mkdirent(&sdcard2FAT32part1,&root))
115 {
116 printf("Reading on SDCARD2 part1\n");
117 if(DIRENT_noErr==fat32getrootfirstent(&root))
118 {
119 do{
120 playFile(&root,&sdcard2FAT32part1);
121 }while (DIRENT_noErr==fat32nextdirent(&root));
122 }
123 }
124 gpioset(LED2);
125 if(DIRENT_noErr==fat32mkdirent(&sdcard2FAT32part2,&root))
126 {
127 printf("Reading on SDCARD2 part2\n");
128 if(DIRENT_noErr==fat32getrootfirstent(&root))
129 {
130 do{
131 playFile(&root,&sdcard2FAT32part2);
132 }while (DIRENT_noErr==fat32nextdirent(&root));
133 }
134 }
135 }
136
163 int main()
137 int main()
164 {
138 {
139 int i=0;
140 int color=0;
141 for(i=0;i<240;i++)
142 {
143 if(i>(240/3))
144 {
145 color= (i<<5) + 0x1F;
146 }
147 else
148 {
149 color = i;
150 }
151 if(i>(2*240/3))
152 {
153 color= (i<<10) + 0x3FF;
154 }
155 lcd0.paintFilRect(&lcd0,i,0,1,100,0,0,color);
156 }
157 while(1)printf("test ");
158 // for(i=0;i<240;i++)
159 // {
160 // if(i>(240/3))
161 // {
162 // color= (i<<5) + 0x1F;
163 // }
164 // else
165 // {
166 // color = i;
167 // }
168 // if(i>(2*240/3))
169 // {
170 // color= (i<<10) + 0x3FF;
171 // }
172 // lcd0.paintFilRect(&lcd0,i,220,1,100,0,0,color);
173 // }
174 for(i=0;i<240;i++)
175 {
176 ili9328setFrame(&lcd0,i,0,1,100);
177 lcd0.interface->readGRAM(buffer,100);
178 lcd0.paint(&lcd0,buffer,i,200,1,100);
179 }
180 while(1);
181 }
182
183 int main2()
184 {
165 extern terminal_t terminal0;
185 extern terminal_t terminal0;
166 extern volatile vs10XXDev audioCodec0;
186 extern volatile vs10XXDev audioCodec0;
187 lcd0.paintText(&lcd0,"hello",20,50,&ComicSansMS_18 ,0xF0F0);
188 while (1)
189 randTextDemo();
167 printf("Volume=0x%x\n",vs10XXcmdread(&audioCodec0,VSVOL));
190 printf("Volume=0x%x\n",vs10XXcmdread(&audioCodec0,VSVOL));
168 vs10XXcmdwrite(&audioCodec0,VSCLOCKF,0x2000);
191 vs10XXcmdwrite(&audioCodec0,VSCLOCKF,0x2000);
169 vs10XXcmdwrite(&audioCodec0,VSVOL,0x2222);
192 delay_100us(1000);
193 vs10XXcmdwrite(&audioCodec0,VSVOL,0x2020);
170 printf("VSCLOCKF=0x%x\n",vs10XXcmdread(&audioCodec0,VSCLOCKF));
194 printf("VSCLOCKF=0x%x\n",vs10XXcmdread(&audioCodec0,VSCLOCKF));
171 printf("VSMODE=0x%x\n",vs10XXcmdread(&audioCodec0,VSMODE));
195 printf("VSMODE=0x%x\n",vs10XXcmdread(&audioCodec0,VSMODE));
172 terminal_clear(&terminal0);
196 //terminal_clear(&terminal0);
173 // tryToplay2();
197 gpioclr(LCD_BACKL);
174 tryToplay1();
198 playAllparts();
175 return 0;
199 return 0;
176 }
200 }
177
201
@@ -11,7 +11,8 SUBDIRS += QtTest/test.pro \
11 BeagleSynthHelloSupMon \
11 BeagleSynthHelloSupMon \
12 TEST_CMSIS_FFT \
12 TEST_CMSIS_FFT \
13 N25Q128_test \
13 N25Q128_test \
14 ssd2119Tests
14 ssd2119Tests \
15 TEST_SIMULATOR
15
16
16
17
17
18
@@ -1,4 +1,5
1 TEMPLATE = subdirs
1 TEMPLATE = subdirs
2 CONFIG += ordered
2 CONFIG += ordered
3
3
4 SUBDIRS += ./CS43L22_STM32F4.pro
4 SUBDIRS += ./CS43L22_STM32F4.pro \
5 ./CS43L22_SIMULATOR.pro
@@ -1,5 +1,4
1 TEMPLATE = lib
1 TEMPLATE = lib
2 OBJECTS_DIR = obj
3 TARGET = CS43L22
2 TARGET = CS43L22
4
3
5 SOURCES += CS43L22.c
4 SOURCES += CS43L22.c
@@ -1,15 +1,3
1 TEMPLATE = lib
1 TEMPLATE = subdirs
2 OBJECTS_DIR = obj
2 SUBDIRS += ./VS10XX_STM32F4.pro \
3 TARGET = vs10XX
3 ./VS10XX_SIMULATOR.pro
4
5 SOURCES += VS10XX.c
6
7
8 HEADERS += ../../../includes/VS10XX.h
9 INCLUDEPATH += ../../../includes
10
11 UCMODEL=stm32f4
12
13 target.path = $$[QT_INSTALL_LIBS]/$$UCMODEL
14 INSTALLS += target
15
@@ -1,16 +1,3
1 TEMPLATE = lib
1 TEMPLATE = subdirs
2 OBJECTS_DIR = obj
2 SUBDIRS += ./24LC0X_STM32F4.pro \
3
3 ./24LC0X_SIMULATOR.pro
4 SOURCES += 24LC0X.c
5 HEADERS += ../../../includes/24LC0X.h \
6 ../../../../includes/24LC0X.h
7
8 INCLUDEPATH += ../../../includes \
9 ../../CPU/STM32F4xx_StdPeriph_Driver/inc \
10 ../../CPU/CMSIS/Include
11
12
13 UCMODEL=stm32f4
14
15 target.path = $$[QT_INSTALL_LIBS]/$$UCMODEL
16 INSTALLS += target
@@ -1,15 +1,5
1 TEMPLATE = lib
1 TEMPLATE = subdirs
2 OBJECTS_DIR = obj
3
4 SOURCES += N25Q128.c
5 HEADERS += ../../../includes/N25Q128.h
6
7 INCLUDEPATH += ../../../includes \
8 ../../CPU/STM32F4xx_StdPeriph_Driver/inc \
9 ../../CPU/CMSIS/Include
10
2
11
3
12 UCMODEL=stm32f4
4 SUBDIRS += ./N25Q128_SIMULATOR.pro \
13
5 ./N25Q128_STM32F4.pro
14 target.path = $$[QT_INSTALL_LIBS]/$$UCMODEL
15 INSTALLS += target
@@ -1,5 +1,6
1 TEMPLATE = subdirs
1 TEMPLATE = subdirs
2 CONFIG += ordered
2 CONFIG += ordered
3
3
4 SUBDIRS += ./dirent_STM32F4.pro
4 SUBDIRS += ./dirent_STM32F4.pro \
5 ./dirent_SIMULATOR.pro
5
6
@@ -1,4 +1,5
1 TEMPLATE = subdirs
1 TEMPLATE = subdirs
2 CONFIG += ordered
2 CONFIG += ordered
3
3
4 SUBDIRS += ./fat32_STM32F4.pro
4 SUBDIRS += ./fat32_STM32F4.pro \
5 ./fat32_SIMULATOR.pro
@@ -25,77 +25,80
25 #include <stdint.h>
25 #include <stdint.h>
26 #include <hexviewer.h>
26 #include <hexviewer.h>
27
27
28 char fat32buff[512];
28 char fat32buff[512]__attribute__ ((aligned (4)));
29 uint32_t lastSecAddrs=-1;
29 uint32_t lastSecAddrs=-1;
30 FAT32fs* lastFATFS=0;
30 FAT32fs* lastFATFS=0;
31
31
32 int fat32open(FAT32fs* fs,dikpartition* part)
32 int fat32open(FAT32fs* fs,dikpartition* part)
33 {
33 {
34 char sector[512];
34 fs->valide = 0;
35 fs->part = part;
35 if(part->valide==0)return FATBadpart;
36 if(!isFat32(fs->part->TypeCode))return FATBadpart;
36 char sector[512];
37 if(fs->part->phy->read(fs->part->phy,sector,fs->part->LBABegin,1)!=RES_OK)return FATReadErr;
37 fs->part = part;
38 if(!isFat32(fs->part->TypeCode))return FATBadpart;
39 if(fs->part->phy->read(fs->part->phy,sector,fs->part->LBABegin,1)!=RES_OK)return FATReadErr;
38 fs->BPB_BytsPerSec = fat32Ui8_2_Ui16(sector,BPB_BytsPerSecoff);
40 fs->BPB_BytsPerSec = fat32Ui8_2_Ui16(sector,BPB_BytsPerSecoff);
39 fs->BPB_RsvdSecCnt = fat32Ui8_2_Ui16(sector,BPB_RsvdSecCntoff);
41 fs->BPB_RsvdSecCnt = fat32Ui8_2_Ui16(sector,BPB_RsvdSecCntoff);
40 fs->BPB_FATSz32 = fat32Ui8_2_Ui32(sector,BPB_FATSz32off);
42 fs->BPB_FATSz32 = fat32Ui8_2_Ui32(sector,BPB_FATSz32off);
41 fs->BPB_RootClus = fat32Ui8_2_Ui32(sector,BPB_RootClusoff);
43 fs->BPB_RootClus = fat32Ui8_2_Ui32(sector,BPB_RootClusoff);
42 fs->BPB_SecPerClus = sector[BPB_SecPerClusoff];
44 fs->BPB_SecPerClus = sector[BPB_SecPerClusoff];
43 fs->BPB_NumFATs = sector[BPB_NumFATsoff];
45 fs->BPB_NumFATs = sector[BPB_NumFATsoff];
44 fs->fat_begin_lba = (unsigned int)fs->part->LBABegin + (unsigned int)(unsigned short)fs->BPB_RsvdSecCnt;
46 fs->fat_begin_lba = (unsigned int)fs->part->LBABegin + (unsigned int)(unsigned short)fs->BPB_RsvdSecCnt;
45 fs->cluster_begin_lba = (unsigned int)fs->fat_begin_lba + ((unsigned int)fs->BPB_NumFATs * (unsigned int)fs->BPB_FATSz32 );
47 fs->cluster_begin_lba = (unsigned int)fs->fat_begin_lba + ((unsigned int)fs->BPB_NumFATs * (unsigned int)fs->BPB_FATSz32 );
46 return FATnoErr;
48 fs->valide=1;
49 return FATnoErr;
47 }
50 }
48
51
49
52
50 int fat32mkdirent(FAT32fs* fs,ucdirent* dirent)
53 int fat32mkdirent(FAT32fs* fs,ucdirent* dirent)
51 {
54 {
52 if(fs==0) return DIRENT_BabArg;
55 if((fs==0) || (fs->valide==0)) return DIRENT_BabArg;
53 if(dirent==0) return DIRENT_BabArg;
56 if(dirent==0) return DIRENT_BabArg;
54 dirent->fs = (UHANDLE)fs;
57 dirent->fs = (UHANDLE)fs;
55 dirent->getrootfirstent = &fat32getrootfirstent;
58 dirent->getrootfirstent = &fat32getrootfirstent;
56 dirent->nextdirent = &fat32nextdirent;
59 dirent->nextdirent = &fat32nextdirent;
57 return DIRENT_noErr;
60 return DIRENT_noErr;
58 }
61 }
59
62
60
63
61 int fat32getrootfirstent(ucdirent* entry)
64 int fat32getrootfirstent(ucdirent* entry)
62 {
65 {
63 if(entry==0) return DIRENT_BabArg;
66 if(entry==0) return DIRENT_BabArg;
64 entry->CurrentSec = ((FAT32fs*)entry->fs)->cluster_begin_lba;
67 entry->CurrentSec = ((FAT32fs*)entry->fs)->cluster_begin_lba;
65 entry->Currententry = 0;
68 entry->Currententry = 0;
66 return fat32nextdirent(entry);
69 return fat32nextdirent(entry);
67 }
70 }
68
71
69
72
70 int fat32getVolName(FAT32fs* fs,char* Name)
73 int fat32getVolName(FAT32fs* fs,char* Name)
71 {
74 {
72 if(fs==0) return DIRENT_BabArg;
75 if((fs==0) || (fs->valide==0)) return DIRENT_BabArg;
73 if(Name==0) return DIRENT_BabArg;
76 if(Name==0) return DIRENT_BabArg;
74 int i=0;
77 int i=0;
75 ucdirent entry;
78 ucdirent entry;
76 if(DIRENT_noErr==fat32mkdirent(fs,&entry))
79 if(DIRENT_noErr==fat32mkdirent(fs,&entry))
77 {
80 {
78 entry.CurrentSec = ((FAT32fs*)entry.fs)->cluster_begin_lba;
81 entry.CurrentSec = ((FAT32fs*)entry.fs)->cluster_begin_lba;
79 entry.Currententry = -1;
82 entry.Currententry = -1;
80 if(DIRENT_noErr!=fat32nextdirent(&entry))return DIRENT_ReadErr;
83 if(DIRENT_noErr!=fat32nextdirent(&entry))return DIRENT_ReadErr;
81 for(i=0;i<16;i++)
84 for(i=0;i<16;i++)
82 {
85 {
83 Name[i] = entry.DIR_Name[i];
86 Name[i] = entry.DIR_Name[i];
84 }
87 }
85 return DIRENT_noErr;
88 return DIRENT_noErr;
86 }
89 }
87 return DIRENT_ReadErr;
90 return DIRENT_ReadErr;
88 }
91 }
89
92
90
93
91 int fat32enterdirent(ucdirent* currententry,ucdirent* firstentry)
94 int fat32enterdirent(ucdirent* currententry,ucdirent* firstentry)
92 {
95 {
93 if(firstentry==0) return DIRENT_BabArg;
96 if(firstentry==0) return DIRENT_BabArg;
94 if(currententry==0) return DIRENT_BabArg;
97 if(currententry==0) return DIRENT_BabArg;
95 fat32mkdirent(((FAT32fs*)currententry->fs),firstentry);
98 fat32mkdirent(((FAT32fs*)currententry->fs),firstentry);
96 firstentry->CurrentSec = fat32getdirentlba(currententry);
99 firstentry->CurrentSec = fat32getdirentlba(currententry);
97 firstentry->Currententry = -1;
100 firstentry->Currententry = -1;
98 return fat32nextdirent(firstentry);
101 return fat32nextdirent(firstentry);
99 }
102 }
100
103
101
104
@@ -104,21 +107,33 int fat32nextdirent(ucdirent* entry)
104 uint32_t n=0,res=DIRENT_noErr,k,j;
107 uint32_t n=0,res=DIRENT_noErr,k,j;
105 k=(0xFF&((signed char)entry->Currententry)+1)*32; /*Restart at last dir entry*/
108 k=(0xFF&((signed char)entry->Currententry)+1)*32; /*Restart at last dir entry*/
106 j=entry->CurrentSec;// /*Restart at last sector*/
109 j=entry->CurrentSec;// /*Restart at last sector*/
107 do
110 do
108 {
111 {
112 //printf("reading new secotr\n",k);
109 fat32sectorreadout(((FAT32fs*)entry->fs),j);
113 fat32sectorreadout(((FAT32fs*)entry->fs),j);
110 for(k=k;k<(512);k+=32) /*512 Bytes per sector and 32 bytes per entry*/
114 //printf("done\n",k);
111 {
115 /*512 Bytes per sector and 32 bytes per entry*/
116 for(k=k;k<(512);k+=32)
117 {
112 if((fat32buff[DIR_Nameoff+k]!=(char)0xE5)) /*0xE5 = free entry*/
118 if((fat32buff[DIR_Nameoff+k]!=(char)0xE5)) /*0xE5 = free entry*/
113 {
119 {
120 //printf("Fount dir entry = %d, 0x%X\n",0xff & ((int)fat32buff[DIR_Nameoff+k]),0xff & ((int)fat32buff[DIR_Attroff+k]));
114 if(fat32buff[DIR_Nameoff+k]==(char)0)
121 if(fat32buff[DIR_Nameoff+k]==(char)0)
122 {
123 //printf("end of directory reached\n",k);
115 return DIRENT_EndOfDir; /*0x00 = end of dir*/
124 return DIRENT_EndOfDir; /*0x00 = end of dir*/
116 else
125 }
117 if((fat32buff[DIR_Attroff + k]==(char)ATTR_DIRECTORY)||(fat32buff[DIR_Attroff + k]==(char)ATTR_ARCHIVE)||(fat32buff[DIR_Attroff + k]==(char)(ATTR_READ_ONLY)))
126 else
118 {
127 {
119 for(n=0;n<16;n++)entry->DIR_Name[n] = '\0';
128 uint8_t attribute=fat32buff[DIR_Attroff + k];
120 for(n=0;n<11;n++)entry->DIR_Name[n] = fat32buff[n+DIR_Nameoff + k];
129 if( (attribute==ATTR_DIRECTORY)
121 entry->DIR_Attr = (uint8_t)fat32buff[DIR_Attroff + k];
130 ||(attribute==ATTR_ARCHIVE)
131 ||(attribute==ATTR_READ_ONLY)
132 ||(attribute==ATTR_READ_ONLY))
133 {
134 for(n=0;n<16;n++)entry->DIR_Name[n] = '\0';
135 for(n=0;n<11;n++)entry->DIR_Name[n] = fat32buff[n+DIR_Nameoff + k];
136 entry->DIR_Attr = attribute;
122 entry->DIR_CrtTimeTenth = (uint8_t)fat32buff[DIR_CrtTimeTenthoff + k];
137 entry->DIR_CrtTimeTenth = (uint8_t)fat32buff[DIR_CrtTimeTenthoff + k];
123 entry->DIR_CrtTime = fat32extract16b(fat32buff,(DIR_CrtTimeoff + k));
138 entry->DIR_CrtTime = fat32extract16b(fat32buff,(DIR_CrtTimeoff + k));
124 entry->DIR_CrtDate = fat32extract16b(fat32buff,(DIR_CrtDateoff + k));
139 entry->DIR_CrtDate = fat32extract16b(fat32buff,(DIR_CrtDateoff + k));
@@ -127,23 +142,26 int fat32nextdirent(ucdirent* entry)
127 entry->DIR_WrtTime = fat32extract16b(fat32buff,(DIR_WrtTimeoff + k));
142 entry->DIR_WrtTime = fat32extract16b(fat32buff,(DIR_WrtTimeoff + k));
128 entry->DIR_FstClustLO = fat32extract16b(fat32buff, (DIR_FstClusLOoff + k));
143 entry->DIR_FstClustLO = fat32extract16b(fat32buff, (DIR_FstClusLOoff + k));
129 entry->DIR_FileSize = fat32extract32b(fat32buff,(DIR_FileSizeoff + k));
144 entry->DIR_FileSize = fat32extract32b(fat32buff,(DIR_FileSizeoff + k));
130 entry->CurrentSec = j;
145 entry->CurrentSec = j;
131 entry->Currententry = (unsigned char)(k/32);
146 entry->Currententry = (uint8_t)(0xFF&(k>>5));
132 return DIRENT_noErr;
147 return DIRENT_noErr;
133 }
148 }
134 }
149 }
135
150 }
136 }
151 }
137 j=fat32nextsectorlba(((FAT32fs*)entry->fs),j,&k);
152 //printf("asking for next sector\n");
138 if(j!=DIRENT_noErr)
153 //printf("current = 0x%X\n",j);
139 {
154 j=fat32nextsectorlba(((FAT32fs*)entry->fs),j,&k);
140 if(j==DIRENT_LastSect) return DIRENT_EndOfDir; /*Not clean but can avoid some bugs*/
155 //printf("got it 0x%x\n",k);
141 return j;
156 if(j!=DIRENT_noErr)
142 }
157 {
143 j=k;
158 if(j==DIRENT_LastSect) return DIRENT_EndOfDir; /*Not clean but can avoid some bugs*/
144 k=0;
159 return j;
145 }while(res==DIRENT_noErr);
160 }
146 return res;
161 j=k;
162 k=0;
163 }while(res==DIRENT_noErr);
164 return res;
147 }
165 }
148
166
149
167
@@ -183,7 +201,7 int fat32getdirentname(ucdirent* entry,c
183 if(k==0)
201 if(k==0)
184 {
202 {
185 //get previous sector
203 //get previous sector
186 if(fat32prevsectorlba((FAT32fs*)entry->fs, j,&j)!=DIRENT_noErr)return DIRENT_ReadErr;
204 if(fat32prevsectorlba2((FAT32fs*)entry->fs,entry, j,&j)!=DIRENT_noErr)return DIRENT_ReadErr;
187 fat32sectorreadout(((FAT32fs*)entry->fs),j);
205 fat32sectorreadout(((FAT32fs*)entry->fs),j);
188 k=512-32;
206 k=512-32;
189 for(n=0;n<5;n++)nameBuffer[i++] = fat32buff[((n<<1)|1) + k];
207 for(n=0;n<5;n++)nameBuffer[i++] = fat32buff[((n<<1)|1) + k];
@@ -226,7 +244,7 uint32_t fat32getdirentlba(ucdirent* ent
226 {
244 {
227 uint32_t clusterNum = (uint32_t)((uint16_t)entry->DIR_FstClustLO) + ((uint32_t)((uint16_t)entry->DIR_FstClusHI) <<16);
245 uint32_t clusterNum = (uint32_t)((uint16_t)entry->DIR_FstClustLO) + ((uint32_t)((uint16_t)entry->DIR_FstClusHI) <<16);
228 uint32_t lba=clusterlba(((FAT32fs*)entry->fs),clusterNum);
246 uint32_t lba=clusterlba(((FAT32fs*)entry->fs),clusterNum);
229 return lba;
247 return lba;
230 }
248 }
231
249
232
250
@@ -234,9 +252,9 int fat32nextsectorlba(FAT32fs* fs,uint3
234 {
252 {
235
253
236 if(((lastsector_lba + 1 - fs->cluster_begin_lba) & ((uint32_t)(fs->BPB_SecPerClus)-1))!=0) /*Is it the last sector of the cluster?*/
254 if(((lastsector_lba + 1 - fs->cluster_begin_lba) & ((uint32_t)(fs->BPB_SecPerClus)-1))!=0) /*Is it the last sector of the cluster?*/
237 {
255 {
238 *nextsector_lba = lastsector_lba+1; /*if not just increment lba*/
256 *nextsector_lba = lastsector_lba+1; /*if not just increment lba*/
239 return DIRENT_noErr;
257 return DIRENT_noErr;
240 }
258 }
241
259
242 uint32_t clusternum=fat32sectorlbatoclusternum(fs,lastsector_lba); /*Get cluster Number from sector number*/
260 uint32_t clusternum=fat32sectorlbatoclusternum(fs,lastsector_lba); /*Get cluster Number from sector number*/
@@ -246,17 +264,14 int fat32nextsectorlba(FAT32fs* fs,uint3
246 *nextsector_lba=fat32Ui8_2_Ui32(fat32buff,i);
264 *nextsector_lba=fat32Ui8_2_Ui32(fat32buff,i);
247 if(*nextsector_lba==0xFFFFFFF7)
265 if(*nextsector_lba==0xFFFFFFF7)
248 {
266 {
249
250 printf("DIRENT_BadSect\n");
251 return DIRENT_BadSect;
267 return DIRENT_BadSect;
252 }
268 }
253 if((uint32_t)(*nextsector_lba)>=(uint32_t)0xFFFFFFF6)
269 if((uint32_t)(*nextsector_lba)>=(uint32_t)0xFFFFFFF6)
254 {
270 {
255 printf("DIRENT_LastSect\n");
256 return DIRENT_LastSect;
271 return DIRENT_LastSect;
257 }
272 }
258 *nextsector_lba = clusterlba(fs,*nextsector_lba);
273 *nextsector_lba = clusterlba(fs,*nextsector_lba);
259 return DIRENT_noErr;
274 return DIRENT_noErr;
260 }
275 }
261
276
262
277
@@ -268,25 +283,23 int fat32prevsectorlba(FAT32fs* fs,uint3
268 *nextsector_lba = lastsector_lba-1; /*if not just decrement lba*/
283 *nextsector_lba = lastsector_lba-1; /*if not just decrement lba*/
269 return DIRENT_noErr;
284 return DIRENT_noErr;
270 }
285 }
271 uint32_t clusternum=fat32sectorlbatoclusternum(fs,lastsector_lba); /*Get cluster Number from sector number*/
286
287 uint32_t clusternum = fat32sectorlbatoclusternum(fs,lastsector_lba); /*Get cluster Number from sector number*/
272 fatsec=fat32clusterinfatsect(fs,clusternum); /*Get FAT sector number*/
288 fatsec=fat32clusterinfatsect(fs,clusternum); /*Get FAT sector number*/
273 do
289 while(fatsec>=fs->fat_begin_lba)
274 {
290 {
275
276 fat32sectorreadout(fs,fatsec);
291 fat32sectorreadout(fs,fatsec);
277 fatsec--;
292 fatsec--;
278 for(i=511;i>3;i-=4)
293 for(i=508;i>2;i-=4)
279 {
294 {
280 *nextsector_lba = fat32Ui8_2_Ui32(fat32buff,i-3);
295 *nextsector_lba = fat32Ui8_2_Ui32(fat32buff,i);
281 if (*nextsector_lba ==clusternum)
296 if (*nextsector_lba ==clusternum)
282 {
297 {
283 *nextsector_lba = clusterlba(fs,*nextsector_lba);
298 *nextsector_lba = clusterlba(fs,*nextsector_lba);
284 return DIRENT_noErr;
299 return DIRENT_noErr;
285 }
300 }
286
287 }
301 }
288
302 }
289 }while(fatsec>=fs->fat_begin_lba);
290
303
291 clusternum=fat32sectorlbatoclusternum(fs,lastsector_lba); /*Get cluster Number from sector number*/
304 clusternum=fat32sectorlbatoclusternum(fs,lastsector_lba); /*Get cluster Number from sector number*/
292 fatsec=fat32clusterinfatsect(fs,clusternum); /*Get FAT sector number*/
305 fatsec=fat32clusterinfatsect(fs,clusternum); /*Get FAT sector number*/
@@ -305,8 +318,44 int fat32prevsectorlba(FAT32fs* fs,uint3
305 }
318 }
306
319
307 }
320 }
321 }while(fatsec<=(fs->fat_begin_lba+fs->BPB_FATSz32));
322 return DIRENT_ReadErr;
323 }
308
324
309 }while(fatsec<=(fs->fat_begin_lba+fs->BPB_FATSz32));
325
326 int fat32prevsectorlba2(FAT32fs* fs,ucdirent* entry,uint32_t lastsector_lba,uint32_t *nextsector_lba)
327 {
328 uint32_t i=0,fatsec=0;
329 if(((lastsector_lba - 1 - fs->cluster_begin_lba) & (fs->BPB_SecPerClus-1))!=0) /*Is it the first sector of the cluster?*/
330 {
331 *nextsector_lba = lastsector_lba-1; /*if not just decrement lba*/
332 return DIRENT_noErr;
333 }
334
335 uint32_t clusternum = fat32sectorlbatoclusternum(fs,lastsector_lba); /*Get cluster Number from sector number*/
336 uint32_t currentClusternum = fat32sectorlbatoclusternum(fs,(fat32getdirentlba(entry)));
337 fatsec=fat32clusterinfatsect(fs,currentClusternum); /*Get FAT sector number*/
338 *nextsector_lba = fat32getdirentlba(entry);
339 while(fatsec<=(fs->fat_begin_lba+fs->BPB_FATSz32))
340 {
341 uint32_t currentClusternum = fat32sectorlbatoclusternum(fs,(*nextsector_lba));
342 fatsec=fat32clusterinfatsect(fs,currentClusternum); /*Get FAT sector number*/
343 fat32sectorreadout(fs,fatsec);
344 i= fat32clusterinfatoff(currentClusternum);
345 if(i==clusternum)
346 {
347 return DIRENT_noErr;
348 }
349 *nextsector_lba=fat32Ui8_2_Ui32(fat32buff,i);
350 if(*nextsector_lba==0xFFFFFFF7)
351 {
352 return DIRENT_BadSect;
353 }
354 if((uint32_t)(*nextsector_lba)>=(uint32_t)0xFFFFFFF6)
355 {
356 return DIRENT_LastSect;
357 }
358 }
310 return DIRENT_ReadErr;
359 return DIRENT_ReadErr;
311 }
360 }
312
361
@@ -332,5 +381,3 int fat32prevsectorlba(FAT32fs* fs,uint3
332
381
333
382
334
383
335
336
@@ -1,4 +1,5
1 TEMPLATE = subdirs
1 TEMPLATE = subdirs
2 CONFIG += ordered
2 CONFIG += ordered
3
3
4 SUBDIRS += ./mbr_STM32F4.pro
4 SUBDIRS += ./mbr_STM32F4.pro \
5 ./mbr_SIMULATOR.pro
@@ -19,7 +19,7
19 -- Author : Alexis Jeandet
19 -- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@gmail.com
21 -------------------------------------------------------------------------------*/
21 -------------------------------------------------------------------------------*/
22 #include "mbr.h"
22 #include <mbr.h>
23 #include <stdio.h>
23 #include <stdio.h>
24
24
25
25
@@ -33,6 +33,7 int mbropen(blkdevice* phy,dikpartition*
33 {
33 {
34 printf("can't read MBR!\n");
34 printf("can't read MBR!\n");
35 printf("%x %x %x %x %x %x %x %x\n",mbr[0],mbr[1],mbr[2],mbr[3],mbr[4],mbr[5],mbr[6],mbr[7]);
35 printf("%x %x %x %x %x %x %x %x\n",mbr[0],mbr[1],mbr[2],mbr[3],mbr[4],mbr[5],mbr[6],mbr[7]);
36 part->valide = 0;
36 return MBRReadErr;
37 return MBRReadErr;
37 }
38 }
38 if(((mbr[510]) == (char)0x55) && ((mbr[511]) == (char)0xAA))
39 if(((mbr[510]) == (char)0x55) && ((mbr[511]) == (char)0xAA))
@@ -41,9 +42,11 int mbropen(blkdevice* phy,dikpartition*
41 part->LBABegin = (unsigned int)mbr[(512-82+LBABeginoffset)+partNum*16] + ((unsigned int)mbr[(512-82+LBABeginoffset+1)+partNum*16]<<8)+ ((unsigned int)mbr[(512-82+LBABeginoffset+2)+partNum*16]<<16)+ ((unsigned int)mbr[(512-82+LBABeginoffset+3)+partNum*16]<<24);
42 part->LBABegin = (unsigned int)mbr[(512-82+LBABeginoffset)+partNum*16] + ((unsigned int)mbr[(512-82+LBABeginoffset+1)+partNum*16]<<8)+ ((unsigned int)mbr[(512-82+LBABeginoffset+2)+partNum*16]<<16)+ ((unsigned int)mbr[(512-82+LBABeginoffset+3)+partNum*16]<<24);
42 part->NumOfSec = (unsigned int)mbr[(512-82+NumOfSecoffset)+partNum*16] + ((unsigned int)mbr[(512-82+NumOfSecoffset+1)+partNum*16]<<8)+ ((unsigned int)mbr[(512-82+NumOfSecoffset+2)+partNum*16]<<16)+ ((unsigned int)mbr[(512-82+NumOfSecoffset+3)+partNum*16]<<24);
43 part->NumOfSec = (unsigned int)mbr[(512-82+NumOfSecoffset)+partNum*16] + ((unsigned int)mbr[(512-82+NumOfSecoffset+1)+partNum*16]<<8)+ ((unsigned int)mbr[(512-82+NumOfSecoffset+2)+partNum*16]<<16)+ ((unsigned int)mbr[(512-82+NumOfSecoffset+3)+partNum*16]<<24);
43 printf("MBR Ok\n");
44 printf("MBR Ok\n");
45 part->valide = 1;
44 return MBRnoErr;
46 return MBRnoErr;
45 }
47 }
46 printf("Bad MBR MBR[510]=0x%.2X MBR[511]=0x%.2X!\n",0xff&mbr[510],0xff&mbr[511]);
48 printf("Bad MBR MBR[510]=0x%.2X MBR[511]=0x%.2X!\n",0xff&mbr[510],0xff&mbr[511]);
49 part->valide = 0;
47 return MBRBadMbr;
50 return MBRBadMbr;
48
51
49 }
52 }
@@ -15,3 +15,6 UCMODEL=stm32f4
15 target.path = $$[QT_INSTALL_LIBS]/$$UCMODEL
15 target.path = $$[QT_INSTALL_LIBS]/$$UCMODEL
16 INSTALLS += target
16 INSTALLS += target
17
17
18 HEADERS += \
19 ../../../includes/mbr.h
20
@@ -1,5 +1,4
1 TEMPLATE = lib
1 TEMPLATE = lib
2 OBJECTS_DIR = obj
3 TARGET = sdcard
2 TARGET = sdcard
4
3
5 SOURCES += \
4 SOURCES += \
@@ -1,4 +1,5
1 TEMPLATE = subdirs
1 TEMPLATE = subdirs
2 CONFIG += ordered
2 CONFIG += ordered
3
3
4 SUBDIRS += ./ili9328_STM32F4.pro
4 SUBDIRS += ./ili9328_STM32F4.pro \
5 ./ili9328_SIMULATOR.pro
@@ -29,7 +29,6
29 #include <optimised_math.h>
29 #include <optimised_math.h>
30 #endif
30 #endif
31
31
32 #define _delay_(del) for(volatile int _d_e_l_=0;_d_e_l_<(del);_d_e_l_++);
33
32
34 #define ilipaintLine(LCD,X,Y,W,buffer,buffsize) \
33 #define ilipaintLine(LCD,X,Y,W,buffer,buffsize) \
35 for(int l=0;l<1;l++)\
34 for(int l=0;l<1;l++)\
@@ -339,6 +338,8 void ili9328paintText(LCD_t* LCD,char* b
339 uint8_t line=0;
338 uint8_t line=0;
340 while(*buffer!='\0')
339 while(*buffer!='\0')
341 {
340 {
341 if(*buffer<32)*buffer=32;
342 if(*buffer>127)*buffer=32;
342 ili9328setFrame(LCD,Xpos+(charnum*w),Ypos-h,w,1);
343 ili9328setFrame(LCD,Xpos+(charnum*w),Ypos-h,w,1);
343 LCD->interface->readGRAM(tmp,w);
344 LCD->interface->readGRAM(tmp,w);
344 for(int i=0;i<(h*w);i++)
345 for(int i=0;i<(h*w);i++)
@@ -358,6 +359,7 void ili9328paintText(LCD_t* LCD,char* b
358 {
359 {
359 line=font->table[(((*buffer)-32)*h*bpl)+tableoffset++];
360 line=font->table[(((*buffer)-32)*h*bpl)+tableoffset++];
360 }
361 }
362 tmp[pix]=0;
361 if((line & (uint8_t)0x01)==(uint8_t)1)tmp[pix]=(uint16_t)color;
363 if((line & (uint8_t)0x01)==(uint8_t)1)tmp[pix]=(uint16_t)color;
362 pix++;
364 pix++;
363 line>>=1;
365 line>>=1;
@@ -1,4 +1,5
1 TEMPLATE = subdirs
1 TEMPLATE = subdirs
2 CONFIG += ordered
2 CONFIG += ordered
3
3
4 SUBDIRS += ./ssd2119_STM32F4.pro
4 SUBDIRS += ./ssd2119_STM32F4.pro \
5 ./ssd2119_SIMULATOR.pro
@@ -1,5 +1,4
1 TEMPLATE = lib
1 TEMPLATE = lib
2 OBJECTS_DIR = obj
3 TARGET = ssd2119
2 TARGET = ssd2119
4
3
5 SOURCES += \
4 SOURCES += \
@@ -1,5 +1,6
1 TEMPLATE = subdirs
1 TEMPLATE = subdirs
2 SUBDIRS += ./FONTS_STM32F4.pro
2 SUBDIRS += ./FONTS_STM32F4.pro \
3 ./FONTS_SIMULATOR.pro
3
4
4
5
5
6
@@ -25,7 +25,7
25 #include <stdio.h>
25 #include <stdio.h>
26 #include <gpio.h>
26 #include <gpio.h>
27 #include <core.h>
27 #include <core.h>
28
28 #include <malloc.h>
29
29
30 #define CHARXPOS(terminal,charwidth) (((terminal)->column * charwidth) + (terminal)->Xpos)
30 #define CHARXPOS(terminal,charwidth) (((terminal)->column * charwidth) + (terminal)->Xpos)
31 #define CHARYPOS(terminal,charheight) ((terminal)->line * charheight + (terminal)->Ypos+charheight)
31 #define CHARYPOS(terminal,charheight) ((terminal)->line * charheight + (terminal)->Ypos+charheight)
@@ -46,19 +46,26 int terminal_init(terminal_t* terminal,L
46 terminal->font=font;
46 terminal->font=font;
47 terminal->line = 0;
47 terminal->line = 0;
48 terminal->column = 0;
48 terminal->column = 0;
49 terminal->horizontalSpace=0;
49 terminal->horizontalSpace = 0;
50 terminal->verticalSpace=0;
50 terminal->verticalSpace = 0;
51 int charw=terminal->font->Width + terminal->horizontalSpace;
51 int charw=terminal->font->Width + terminal->horizontalSpace;
52 int charh=terminal->font->Height + terminal->verticalSpace;
52 int charh=terminal->font->Height + terminal->verticalSpace;
53 terminal->textColor=0xFFFF;
53 terminal->textColor=0xFFFF;
54 terminal->backgroundColor=0x0000;
54 terminal->backgroundColor=0x0000;
55 terminal_setgeometry(terminal,5,5,terminal->LCD->width-(10),terminal->LCD->height-(10));
55 terminal_setgeometry(terminal,5,5,terminal->LCD->width-(10),terminal->LCD->height-(10));
56
57 strdev->_stream = (UHANDLE)terminal;
56 strdev->_stream = (UHANDLE)terminal;
58 strdev->ops = &TERMINAL_OPS;
57 strdev->ops = &TERMINAL_OPS;
59 strdev->streamPt = 0;
58 strdev->streamPt = 0;
60 terminal_clear(terminal);
59 terminal_clear(terminal);
61 terminal->LCD->paintFilRect(terminal->LCD,CHARXPOS(terminal, charw),CHARYPOS(terminal, charh)-charh,charw,charh,terminal->backgroundColor,0,terminal->backgroundColor);
60 terminal->LCD->paintFilRect(terminal->LCD,CHARXPOS(terminal, charw),CHARYPOS(terminal, charh)-charh,charw,charh,terminal->backgroundColor,0,terminal->backgroundColor);
61 terminal->buffer = (char*)malloc(terminal->lineCount*(terminal->columnCount + 1));
62 terminal->firstLine = 0;
63 terminal->lastLine = 0;
64 terminal->empty = 1;
65 for(int i=1;i<=terminal->lineCount;i++)
66 {
67 terminal->buffer[i * terminal->columnCount]='\n';
68 }
62 return 1;
69 return 1;
63 }
70 }
64 return 0;
71 return 0;
@@ -84,6 +91,11 void terminal_setgeometry(terminal_t* te
84
91
85 void terminal_clear(terminal_t* terminal)
92 void terminal_clear(terminal_t* terminal)
86 {
93 {
94 terminal->firstLine = 0;
95 terminal->lastLine = 0;
96 terminal->empty = 1;
97 terminal->line =0;
98 terminal->column=0;
87 terminal->LCD->paintFilRect(terminal->LCD,terminal->Xpos,terminal->Ypos,terminal->width,terminal->height,terminal->backgroundColor,0,terminal->backgroundColor);
99 terminal->LCD->paintFilRect(terminal->LCD,terminal->Xpos,terminal->Ypos,terminal->width,terminal->height,terminal->backgroundColor,0,terminal->backgroundColor);
88 }
100 }
89
101
@@ -103,12 +115,16 void terminal_movecursor(terminal_t* ter
103 int charw=terminal->font->Width + terminal->horizontalSpace;
115 int charw=terminal->font->Width + terminal->horizontalSpace;
104 int charh=terminal->font->Height + terminal->verticalSpace;
116 int charh=terminal->font->Height + terminal->verticalSpace;
105 terminal->column += n;
117 terminal->column += n;
106 if(terminal->column>terminal->columnCount)
118 if(terminal->column>(terminal->columnCount))
107 {
119 {
108 terminal->line += (terminal->column)/terminal->columnCount;
120 terminal->line += (terminal->column)/terminal->columnCount;
109 terminal->LCD->paintFilRect(terminal->LCD,CHARXPOS(terminal, charw),CHARYPOS(terminal,charh)-charh,charw*(terminal->columnCount-terminal->column),charh,terminal->backgroundColor,0,terminal->backgroundColor);
110 terminal->line = terminal->line % terminal->lineCount;
121 terminal->line = terminal->line % terminal->lineCount;
111 terminal->column = terminal->column % terminal->columnCount;
122 terminal->column = (terminal->column % terminal->columnCount)-1;
123 int x=CHARXPOS(terminal, charw);
124 int y=CHARYPOS(terminal,charh)-charh;
125 int w=charw*(terminal->columnCount-terminal->column);
126 int h=charh;
127 terminal->LCD->paintFilRect(terminal->LCD,CHARXPOS(terminal, charw),CHARYPOS(terminal,charh)-charh,charw*(terminal->columnCount-terminal->column-1),charh,terminal->backgroundColor,0,terminal->backgroundColor);
112 }
128 }
113 terminal->LCD->paintFilRect(terminal->LCD,CHARXPOS(terminal,charw),CHARYPOS(terminal,charh)-charh,charw,charh,terminal->backgroundColor,0,terminal->backgroundColor);
129 terminal->LCD->paintFilRect(terminal->LCD,CHARXPOS(terminal,charw),CHARYPOS(terminal,charh)-charh,charw,charh,terminal->backgroundColor,0,terminal->backgroundColor);
114 }
130 }
@@ -134,24 +150,66 int terminal_writenc(terminal_t* termina
134 {
150 {
135 terminal->line= (terminal->line+1) % terminal->lineCount;
151 terminal->line= (terminal->line+1) % terminal->lineCount;
136 terminal->column = 0;
152 terminal->column = 0;
137 terminal_clearCurentLine(terminal);
153 if(terminal->line==0)
154 terminal_clear(terminal);
155 else
156 terminal_clearCurentLine(terminal);
138 }else {
157 }else {
139 if(buffer[0]=='\t')
158 if(buffer[0]=='\t')
140 {
159 {
141 for(int i=0;i<1;i++)terminal_movecursor(terminal,1);
160 for(int i=0;i<1;i++)terminal_movecursor(terminal,1);
142 }else
161 }else
143 if(terminal->column==0)terminal_clearCurentLine(terminal);
162 if(terminal->column==0)terminal_clearCurentLine(terminal);
144 if(buffer[0]!='\r'){
163 if(buffer[0]!='\r'){
145 terminal->LCD->paintFilRect(terminal->LCD,CHARXPOS(terminal,charw),CHARYPOS(terminal, charh)-charh,charw,charh,terminal->backgroundColor,0,terminal->backgroundColor);
164 terminal->LCD->paintFilRect(terminal->LCD,CHARXPOS(terminal,charw),CHARYPOS(terminal, charh)-charh,charw,charh,terminal->backgroundColor,0,terminal->backgroundColor);
146 terminal->LCD->paintText(terminal->LCD,buffer,CHARXPOS(terminal,charw),CHARYPOS(terminal, charh),terminal->font,terminal->textColor);
165 terminal->LCD->paintText(terminal->LCD,buffer,CHARXPOS(terminal,charw),CHARYPOS(terminal, charh),terminal->font,terminal->textColor);
147 terminal_movecursor(terminal,1);
166 terminal_movecursor(terminal,1);
148 }
167 }
149 }
168 }
150 l++;
169 l++;
151 }
170 }
152 return n;
171 return n;
153 }
172 }
154
173
174 void terminal_print_line(terminal_t* terminal,int line)
175 {
176 int charw=terminal->font->Width + terminal->horizontalSpace;
177 int charh=terminal->font->Height + terminal->verticalSpace;
178 terminal_clearCurentLine(terminal);
179 terminal->LCD->paintText(terminal->LCD,terminal->buffer+(line*(terminal->columnCount + 1)),CHARXPOS(terminal,charw),CHARYPOS(terminal, charh),terminal->font,terminal->textColor);
180 }
181
182 int terminal_writenc2(terminal_t* terminal,char* data, int n)
183 {
184 int charw=terminal->font->Width + terminal->horizontalSpace;
185 int charh=terminal->font->Height + terminal->verticalSpace;
186 /* First copy to buffer*/
187 int offset = (terminal->lastLine*(terminal->columnCount + 1)) + terminal->column;
188 for(int i=0;i<n;i++)
189 {
190 terminal->empty=0;
191 terminal->buffer[offset] = data[i];
192 if(data[i]=='\n')
193 {
194 offset = ((offset/(terminal->columnCount + 1) + 1) * (terminal->columnCount + 1));
195 }
196 else
197 {
198 offset++;
199 }
200 }
201 if(!terminal->empty)
202 {
203 for(int i=terminal->firstLine;i<=terminal->lastLine;i++)
204 {
205 terminal_print_line(terminal,i);
206 }
207 }
208 return n;
209 }
210
211
212
155 int terminal_write(streamdevice* device,void* data,int size, int n)
213 int terminal_write(streamdevice* device,void* data,int size, int n)
156 {
214 {
157 return terminal_writenc((terminal_t*)device->_stream,(char*) data,size*n);
215 return terminal_writenc((terminal_t*)device->_stream,(char*) data,size*n);
@@ -1,3 +1,5
1 TEMPLATE = subdirs
1 TEMPLATE = subdirs
2 SUBDIRS += ./Terminal_STM32F4.pro
2 SUBDIRS += ./Terminal_STM32F4.pro \
3 ./Terminal_SIMULATOR.pro
3
4
5
@@ -1,4 +1,5
1 TEMPLATE = subdirs
1 TEMPLATE = subdirs
2 CONFIG += ordered
2 CONFIG += ordered
3
3
4 SUBDIRS += ./STMPE811_STM32F4.pro
4 SUBDIRS += ./STMPE811_STM32F4.pro \
5 ./STMPE811_SIMULATOR.pro
@@ -1,5 +1,4
1 TEMPLATE = lib
1 TEMPLATE = lib
2 OBJECTS_DIR = obj
3 TARGET = STMPE811
2 TARGET = STMPE811
4
3
5 SOURCES += \
4 SOURCES += \
@@ -1,4 +1,5
1 TEMPLATE = subdirs
1 TEMPLATE = subdirs
2 CONFIG += ordered
2 CONFIG += ordered
3
3
4 SUBDIRS += ./ina226_STM32F4.pro
4 SUBDIRS += ./ina226_STM32F4.pro \
5 ./ina226_SIMULATOR.pro
@@ -1,5 +1,4
1 TEMPLATE = lib
1 TEMPLATE = lib
2 OBJECTS_DIR = obj
3 TARGET = ina226
2 TARGET = ina226
4
3
5 SOURCES += ina226.c
4 SOURCES += ina226.c
@@ -33,6 +33,8 typedef struct terminal_t
33 uint16_t column;
33 uint16_t column;
34 uint16_t lineCount;
34 uint16_t lineCount;
35 uint16_t columnCount;
35 uint16_t columnCount;
36 uint16_t firstLine;
37 uint16_t lastLine;
36 uint16_t Xpos;
38 uint16_t Xpos;
37 uint16_t Ypos;
39 uint16_t Ypos;
38 uint16_t width;
40 uint16_t width;
@@ -41,8 +43,10 typedef struct terminal_t
41 uint32_t textColor;
43 uint32_t textColor;
42 int8_t verticalSpace;
44 int8_t verticalSpace;
43 int8_t horizontalSpace;
45 int8_t horizontalSpace;
46 int8_t empty;
44 LCD_t* LCD;
47 LCD_t* LCD;
45 sFONT* font;
48 sFONT* font;
49 char* buffer;
46 }terminal_t;
50 }terminal_t;
47
51
48 int terminal_init(terminal_t* terminal,LCD_t* LCD,sFONT* font,streamdevice* strdev);
52 int terminal_init(terminal_t* terminal,LCD_t* LCD,sFONT* font,streamdevice* strdev);
@@ -28,41 +28,41
28 #include <stdint-gcc.h>
28 #include <stdint-gcc.h>
29 /*BPB (Boot Sector) Offsets */
29 /*BPB (Boot Sector) Offsets */
30
30
31 #define BS_jmpBootoff 0
31 #define BS_jmpBootoff 0
32 #define BS_OEMNameoff 3
32 #define BS_OEMNameoff 3
33 #define BPB_BytsPerSecoff 11
33 #define BPB_BytsPerSecoff 11
34 #define BPB_SecPerClusoff 13
34 #define BPB_SecPerClusoff 13
35 #define BPB_RsvdSecCntoff 14
35 #define BPB_RsvdSecCntoff 14
36 #define BPB_NumFATsoff 16
36 #define BPB_NumFATsoff 16
37 #define BPB_RootEntCntoff 17
37 #define BPB_RootEntCntoff 17
38 #define BPB_TotSec16off 19
38 #define BPB_TotSec16off 19
39 #define BPB_Mediaoff 21
39 #define BPB_Mediaoff 21
40 #define BPB_FATSz16off 22
40 #define BPB_FATSz16off 22
41 #define BPB_SecPerTrkoff 24
41 #define BPB_SecPerTrkoff 24
42 #define BPB_NumHeadsoff 26
42 #define BPB_NumHeadsoff 26
43 #define BPB_HiddSecoff 28
43 #define BPB_HiddSecoff 28
44 #define BPB_TotSec32off 32
44 #define BPB_TotSec32off 32
45 /*FAT16*/
45 /*FAT16*/
46 #define BS_DrvNumFAT16off 36
46 #define BS_DrvNumFAT16off 36
47 #define BS_Reserved1FAT16off 37
47 #define BS_Reserved1FAT16off 37
48 #define BS_BootSigFAT16off 38
48 #define BS_BootSigFAT16off 38
49 #define BS_VolIDFAT16off 39
49 #define BS_VolIDFAT16off 39
50 #define BS_VolLabFAT16off 43
50 #define BS_VolLabFAT16off 43
51 #define BS_FilSysTypeFAT16off 54
51 #define BS_FilSysTypeFAT16off 54
52 /*FAT32*/
52 /*FAT32*/
53 #define BPB_FATSz32off 36
53 #define BPB_FATSz32off 36
54 #define BPB_ExtFlagsoff 40
54 #define BPB_ExtFlagsoff 40
55 #define BPB_FSVeroff 42
55 #define BPB_FSVeroff 42
56 #define BPB_RootClusoff 44
56 #define BPB_RootClusoff 44
57 #define BPB_FSInfooff 48
57 #define BPB_FSInfooff 48
58 #define BPB_BkBootSecoff 50
58 #define BPB_BkBootSecoff 50
59 #define BPB_Reservedoff 52
59 #define BPB_Reservedoff 52
60 #define BS_DrvNumFAT32off 64
60 #define BS_DrvNumFAT32off 64
61 #define BS_Reserved1FAT32off 65
61 #define BS_Reserved1FAT32off 65
62 #define BS_BootSigFAT32off 66
62 #define BS_BootSigFAT32off 66
63 #define BS_VolIDFAT32off 67
63 #define BS_VolIDFAT32off 67
64 #define BS_VolLabFAT32off 71
64 #define BS_VolLabFAT32off 71
65 #define BS_FilSysTypeFAT32off 82
65 #define BS_FilSysTypeFAT32off 82
66
66
67
67
68 #define DIR_Nameoff 0
68 #define DIR_Nameoff 0
@@ -79,11 +79,15
79
79
80
80
81
81
82 #define FATBadpart 1
82 #define FATBadpart 1
83 #define FATBabArg 2
83 #define FATBabArg 2
84 #define FATReadErr 3
84 #define FATReadErr 3
85 #define FATnoErr 0
85 #define FATnoErr 0
86
86
87 /*
88 TODO :
89 intergrate a per BLKDEV or per partition buffer.
90 */
87 typedef struct FAT32fs
91 typedef struct FAT32fs
88 {
92 {
89 uint16_t BPB_BytsPerSec;
93 uint16_t BPB_BytsPerSec;
@@ -94,6 +98,7 typedef struct FAT32fs
94 uint32_t cluster_begin_lba;
98 uint32_t cluster_begin_lba;
95 uint8_t BPB_SecPerClus;
99 uint8_t BPB_SecPerClus;
96 uint8_t BPB_NumFATs;
100 uint8_t BPB_NumFATs;
101 char valide;
97 dikpartition* part;
102 dikpartition* part;
98 }FAT32fs;
103 }FAT32fs;
99
104
@@ -108,8 +113,24 typedef struct FAT32fs
108 #define castI16(val) ((int16_t)(val))
113 #define castI16(val) ((int16_t)(val))
109 #define castI8(val) ((int8_t)(val))
114 #define castI8(val) ((int8_t)(val))
110
115
111 #define fat32Ui8_2_Ui32(table,lsBindex) ((uint32_t)((0xFF&(table[lsBindex]))+(0xFF00&(((uint32_t)table[lsBindex+1])<<8))+(0xFF0000&(((uint32_t)table[lsBindex+2])<<16))+(0xFF000000&(((uint32_t)table[lsBindex+3])<<24))))
116 /*
112 #define fat32Ui8_2_Ui16(table,lsBindex) ((uint16_t)((0xFF&(table[lsBindex]))+(0xFF00&(((uint16_t)table[lsBindex+1])<<8))))
117 TODO :
118 Should add global function for casting with endianness care.
119 have a look at REV, REV16, REVSH, and RBIT ARMV7m asm
120 */
121
122 #if __BYTE_ORDER__==__ORDER_BIG_ENDIAN__
123 #define fat32Ui8_2_Ui32(table,lsBindex) ((uint32_t)((0xFF&(table[lsBindex]))+(0xFF00&(((uint32_t)table[lsBindex+1])<<8))+(0xFF0000&(((uint32_t)table[lsBindex+2])<<16))+(0xFF000000&(((uint32_t)table[lsBindex+3])<<24))))
124 #define fat32Ui8_2_Ui16(table,lsBindex) ((uint16_t)((0xFF&(table[lsBindex]))+(0xFF00&(((uint16_t)table[lsBindex+1])<<8))))
125 #define fat32extract16b(table, LSBOffset) (uint16_t)(( (uint16_t) ((uint8_t)table[(LSBOffset)]) ) + (uint16_t)( ((uint8_t)table[(LSBOffset)+1]) << 8 ))
126 #define fat32extract32b(table, LSBOffset) (uint32_t)(( (uint32_t) ((uint8_t)table[(LSBOffset)]) ) + (uint32_t)( ((uint8_t)table[(LSBOffset)+1]) << 8 )+ (uint32_t)( ((uint8_t)table[(LSBOffset)+2]) << 16 )+ (uint32_t)( ((uint8_t)table[(LSBOffset)+3]) << 24 ))
127 #else
128 #define fat32Ui8_2_Ui32(table,lsBindex) ((uint32_t)((0xFF&(table[lsBindex]))+(0xFF00&(((uint32_t)table[lsBindex+1])<<8))+(0xFF0000&(((uint32_t)table[lsBindex+2])<<16))+(0xFF000000&(((uint32_t)table[lsBindex+3])<<24))))
129 #define fat32Ui8_2_Ui16(table,lsBindex) ((uint16_t)((0xFF&(table[lsBindex]))+(0xFF00&(((uint16_t)table[lsBindex+1])<<8))))
130 #define fat32extract16b(table, LSBOffset) (uint16_t)(( (uint16_t) ((uint8_t)table[(LSBOffset)]) ) + (uint16_t)( ((uint8_t)table[(LSBOffset)+1]) << 8 ))
131 #define fat32extract32b(table, LSBOffset) (uint32_t)(( (uint32_t) ((uint8_t)table[(LSBOffset)]) ) + (uint32_t)( ((uint8_t)table[(LSBOffset)+1]) << 8 )+ (uint32_t)( ((uint8_t)table[(LSBOffset)+2]) << 16 )+ (uint32_t)( ((uint8_t)table[(LSBOffset)+3]) << 24 ))
132 #endif
133
113
134
114 /* Get the first sector lba of given cluster number*/
135 /* Get the first sector lba of given cluster number*/
115 #define clusterlba(fs,cluster_number) ((uint32_t)fs->cluster_begin_lba + (((uint32_t)cluster_number) - (2)) * (uint32_t)fs->BPB_SecPerClus)
136 #define clusterlba(fs,cluster_number) ((uint32_t)fs->cluster_begin_lba + (((uint32_t)cluster_number) - (2)) * (uint32_t)fs->BPB_SecPerClus)
@@ -119,11 +140,9 typedef struct FAT32fs
119 #define fat32clusterinfatoff(cluster_number) (((cluster_number)&0x7F)*4)
140 #define fat32clusterinfatoff(cluster_number) (((cluster_number)&0x7F)*4)
120
141
121 /*Get cluster index in FAT Table from sector address*/
142 /*Get cluster index in FAT Table from sector address*/
122 #define fat32masksectorlba(sectorlba,fs) (sectorlba & (castUI32(-1)^castUI32(fs->BPB_SecPerClus-1)))
143 #define fat32masksectorlba(sectorlba,fs) (sectorlba)//(sectorlba & (castUI32(-1)^castUI32(fs->BPB_SecPerClus-1)))
123 #define fat32sectorlbatoclusternum(fs,sectorlba) (((fat32masksectorlba(castUI32(sectorlba),fs) -(castUI32(fs->cluster_begin_lba)))/castUI32(fs->BPB_SecPerClus))+castUI32(2))
144 #define fat32sectorlbatoclusternum(fs,sectorlba) (((fat32masksectorlba(castUI32(sectorlba),fs) -(castUI32(fs->cluster_begin_lba)))/castUI32(fs->BPB_SecPerClus))+castUI32(2))
124
145
125 #define fat32extract16b(table, LSBOffset) (uint16_t)(( (uint16_t) ((uint8_t)table[(LSBOffset)]) ) + (uint16_t)( ((uint8_t)table[(LSBOffset)+1]) << 8 ))
126 #define fat32extract32b(table, LSBOffset) (uint32_t)(( (uint32_t) ((uint8_t)table[(LSBOffset)]) ) + (uint32_t)( ((uint8_t)table[(LSBOffset)+1]) << 8 )+ (uint32_t)( ((uint8_t)table[(LSBOffset)+2]) << 16 )+ (uint32_t)( ((uint8_t)table[(LSBOffset)+3]) << 24 ))
127
146
128 #ifdef FAT32_PRIVATE
147 #ifdef FAT32_PRIVATE
129 #define fat32sectorreadout(fs,fatsec) \
148 #define fat32sectorreadout(fs,fatsec) \
@@ -145,6 +164,7 extern int fat32getrootfirstent(ucdirent
145 extern int fat32nextdirent(ucdirent* entry);
164 extern int fat32nextdirent(ucdirent* entry);
146 extern int fat32nextsectorlba(FAT32fs* fs,uint32_t lastsector_lba,uint32_t* nextsector_lba);
165 extern int fat32nextsectorlba(FAT32fs* fs,uint32_t lastsector_lba,uint32_t* nextsector_lba);
147 extern int fat32prevsectorlba(FAT32fs* fs,uint32_t lastsector_lba,uint32_t *nextsector_lba);
166 extern int fat32prevsectorlba(FAT32fs* fs,uint32_t lastsector_lba,uint32_t *nextsector_lba);
167 extern int fat32prevsectorlba2(FAT32fs* fs,ucdirent* entry,uint32_t lastsector_lba,uint32_t *nextsector_lba);
148 extern uint32_t fat32getdirentlba(ucdirent* entry);
168 extern uint32_t fat32getdirentlba(ucdirent* entry);
149 extern int fat32getdirentname(ucdirent* entry,char* nameBuffer);
169 extern int fat32getdirentname(ucdirent* entry,char* nameBuffer);
150
170
@@ -39,6 +39,7
39 typedef struct dikpartition
39 typedef struct dikpartition
40 {
40 {
41 char TypeCode;
41 char TypeCode;
42 char valide;
42 unsigned int LBABegin;
43 unsigned int LBABegin;
43 unsigned int NumOfSec;
44 unsigned int NumOfSec;
44 blkdevice* phy;
45 blkdevice* phy;
@@ -4,6 +4,7 CONFIG += ordered
4 SUBDIRS += stm32f4
4 SUBDIRS += stm32f4
5
5
6 SUBDIRS += common
6 SUBDIRS += common
7 SUBDIRS += simulator
7
8
8 headers.files = includes/*.h \
9 headers.files = includes/*.h \
9 includes/GRAPHIC/CONTROLERS/*.h \
10 includes/GRAPHIC/CONTROLERS/*.h \
@@ -25,6 +25,7
25 #include <stdlib.h>
25 #include <stdlib.h>
26 #include <stdio.h>
26 #include <stdio.h>
27 #include <core_cm4.h>
27 #include <core_cm4.h>
28 #include <gpio.h>
28
29
29 extern uint32_t OSC0;
30 extern uint32_t OSC0;
30 extern uint32_t INTOSC;
31 extern uint32_t INTOSC;
@@ -36,6 +37,8 volatile uint32_t tickCounter=0;
36 void SysTick_Handler(void)
37 void SysTick_Handler(void)
37 {
38 {
38 tickCounter+=1;
39 tickCounter+=1;
40 if((tickCounter&0xFFF)==0x800)
41 gpiosetval(PC15,!gpiogetval(PC15));
39 }
42 }
40
43
41 void delay_us(uint32_t value)
44 void delay_us(uint32_t value)
@@ -3,7 +3,8 OBJECTS_DIR = obj
3
3
4 SOURCES += \
4 SOURCES += \
5 core.c \
5 core.c \
6 threads.c
6 threads.c \
7 irq_handlers.c
7
8
8 INCLUDEPATH += ../../includes \
9 INCLUDEPATH += ../../includes \
9 ../CPU/STM32F4xx_StdPeriph_Driver/inc \
10 ../CPU/STM32F4xx_StdPeriph_Driver/inc \
@@ -46,9 +46,9 void cpu_init()
46 while(1)
46 while(1)
47 {
47 {
48 delay_100us(10000);
48 delay_100us(10000);
49 gpioset(LED1);
49 gpioset(LED2);
50 delay_100us(10000);
50 delay_100us(10000);
51 gpioclr(LED1);
51 gpioclr(LED2);
52 }
52 }
53 }
53 }
54
54
@@ -36,8 +36,8 ENTRY(Reset_Handler)
36 _estack = 0x20020000; /* end of 128K RAM on AHB bus*/
36 _estack = 0x20020000; /* end of 128K RAM on AHB bus*/
37
37
38 /* Generate a link error if heap and stack don't fit into RAM */
38 /* Generate a link error if heap and stack don't fit into RAM */
39 _Min_Heap_Size = 0; /* required amount of heap */
39 _Min_Heap_Size = 0x2000; /* required amount of heap */
40 _Min_Stack_Size = 0x1000; /* required amount of stack */
40 _Min_Stack_Size = 0x2000; /* required amount of stack */
41
41
42 /* Specify the memory areas */
42 /* Specify the memory areas */
43 MEMORY
43 MEMORY
@@ -10,6 +10,7
10 #include <gpio.h>
10 #include <gpio.h>
11 #include <uart.h>
11 #include <uart.h>
12 #include <stdint.h>
12 #include <stdint.h>
13 #include <bsp.h>
13
14
14 #undef errno
15 #undef errno
15
16
@@ -29,7 +30,13 char **environ = __env;
29
30
30 int _exit()
31 int _exit()
31 {
32 {
32 while(1);
33 while(1)
34 {
35 delay_100us(10000);
36 gpioset(LED2);
37 delay_100us(10000);
38 gpioclr(LED2);
39 }
33 }
40 }
34
41
35 int _close(int file)
42 int _close(int file)
@@ -48,7 +55,7 int _write(int file, char *ptr, int len)
48 {
55 {
49 if(__opnfiles__[file]->ops->write(__opnfiles__[file],ptr,1,len)) return len;
56 if(__opnfiles__[file]->ops->write(__opnfiles__[file],ptr,1,len)) return len;
50 }
57 }
51 return 0;
58 return len;
52 }
59 }
53
60
54 int _execve(char *name, char **argv, char **env) {
61 int _execve(char *name, char **argv, char **env) {
@@ -139,8 +146,15 caddr_t _sbrk(int incr) {
139 }
146 }
140 prev_heap_end = heap_end;
147 prev_heap_end = heap_end;
141 if (heap_end + incr > stack_ptr) {
148 if (heap_end + incr > stack_ptr) {
142 _write (1, "Heap and stack collision\n", 25);
149 printf("Heap and stack collision\n");
143 abort ();
150 //abort ();
151 while(1)
152 {
153 delay_100us(10000);
154 gpioset(LED2);
155 delay_100us(10000);
156 gpioclr(LED2);
157 }
144 }
158 }
145 heap_end += incr;
159 heap_end += incr;
146 return (caddr_t) prev_heap_end;
160 return (caddr_t) prev_heap_end;
@@ -220,8 +234,15 caddr_t _sbrk_r (struct _reent *r, int i
220 }
234 }
221 prev_heap_end = heap_end;
235 prev_heap_end = heap_end;
222 if (heap_end + incr > stack_ptr) {
236 if (heap_end + incr > stack_ptr) {
223 _write (1, "Heap and stack collision\n", 25);
237 printf( "Heap and stack collision\n");
224 abort ();
238 //abort ();
239 while(1)
240 {
241 delay_100us(10000);
242 gpioset(LED2);
243 delay_100us(10000);
244 gpioclr(LED2);
245 }
225 }
246 }
226 heap_end += incr;
247 heap_end += incr;
227 return (caddr_t) prev_heap_end;
248 return (caddr_t) prev_heap_end;
@@ -4,11 +4,11
4
4
5 CONFIG +=
5 CONFIG +=
6 QMAKE_CC = arm-none-eabi-gcc
6 QMAKE_CC = arm-none-eabi-gcc
7 QMAKE_CFLAGS +=
7 QMAKE_CFLAGS +=
8 QMAKE_CFLAGS_DEPS += -M
8 QMAKE_CFLAGS_DEPS += -M
9 QMAKE_CFLAGS_WARN_ON += -Wall
9 QMAKE_CFLAGS_WARN_ON += -Wall
10 QMAKE_CFLAGS_WARN_OFF += -w
10 QMAKE_CFLAGS_WARN_OFF += -w
11 QMAKE_CFLAGS_RELEASE += -O2
11 QMAKE_CFLAGS_RELEASE += -O3
12 QMAKE_CFLAGS_DEBUG += -g -O0
12 QMAKE_CFLAGS_DEBUG += -g -O0
13
13
14 QMAKE_CXX = arm-none-eabi-g++
14 QMAKE_CXX = arm-none-eabi-g++
@@ -28,7 +28,7 QMAKE_LINK_SHLIB = arm-none-eabi-gcc
28 QMAKE_LINK_C = arm-none-eabi-gcc
28 QMAKE_LINK_C = arm-none-eabi-gcc
29 QMAKE_LINK_C_SHLIB = arm-none-eabi-gcc
29 QMAKE_LINK_C_SHLIB = arm-none-eabi-gcc
30 QMAKE_LFLAGS +=
30 QMAKE_LFLAGS +=
31 QMAKE_LFLAGS_RELEASE +=
31 QMAKE_LFLAGS_RELEASE += -O3
32 QMAKE_LFLAGS_DEBUG +=
32 QMAKE_LFLAGS_DEBUG +=
33 QMAKE_LFLAGS_APP +=
33 QMAKE_LFLAGS_APP +=
34 QMAKE_LFLAGS_SHLIB +=
34 QMAKE_LFLAGS_SHLIB +=
@@ -23,8 +23,8 DEFINES += BSP="\"\\\"$$BSP"\\\"\"
23 CONFIG += cpu
23 CONFIG += cpu
24
24
25 contains( TEMPLATE, app ) {
25 contains( TEMPLATE, app ) {
26 OBJECTS_DIR=obj
26 OBJECTS_DIR=obj-$$UCMODEL
27 DESTDIR=bin
27 DESTDIR=bin-$$UCMODEL
28 unix:QMAKE_POST_LINK += arm-none-eabi-objcopy -O ihex "$(TARGET)" $$DESTDIR/"$(QMAKE_TARGET).hex" && arm-none-eabi-objcopy -O binary "$(TARGET)" $$DESTDIR/"$(QMAKE_TARGET).bin && python $$[QT_INSTALL_BINS]/dfu.py -b 0x08000000:"$$DESTDIR/"$(QMAKE_TARGET).bin " $$DESTDIR/"$(QMAKE_TARGET).dfu"
28 unix:QMAKE_POST_LINK += arm-none-eabi-objcopy -O ihex "$(TARGET)" $$DESTDIR/"$(QMAKE_TARGET).hex" && arm-none-eabi-objcopy -O binary "$(TARGET)" $$DESTDIR/"$(QMAKE_TARGET).bin && python $$[QT_INSTALL_BINS]/dfu.py -b 0x08000000:"$$DESTDIR/"$(QMAKE_TARGET).bin " $$DESTDIR/"$(QMAKE_TARGET).dfu"
29 win32:QMAKE_POST_LINK += arm-none-eabi-objcopy -O ihex "$(DESTDIR_TARGET)" $$DESTDIR/"$(QMAKE_TARGET).hex" && arm-none-eabi-objcopy -O binary "$(DESTDIR_TARGET)" $$DESTDIR/"$(QMAKE_TARGET).bin"
29 win32:QMAKE_POST_LINK += arm-none-eabi-objcopy -O ihex "$(DESTDIR_TARGET)" $$DESTDIR/"$(QMAKE_TARGET).hex" && arm-none-eabi-objcopy -O binary "$(DESTDIR_TARGET)" $$DESTDIR/"$(QMAKE_TARGET).bin"
30
30
@@ -46,12 +46,14 contains( TEMPLATE, app ) {
46 stflash.target = stflash
46 stflash.target = stflash
47 stflash.commands = cd $$DESTDIR && sudo st-flash write $(QMAKE_TARGET).bin 0x08000000
47 stflash.commands = cd $$DESTDIR && sudo st-flash write $(QMAKE_TARGET).bin 0x08000000
48 dfu.target = dfu
48 dfu.target = dfu
49 dfu.commands = cd $$DESTDIR && sudo dfu-util d 0483:df11 -c 1 -i 0 -a 0 -s 0x08000000 -D $(QMAKE_TARGET).bin 0x08000000
49 dfu.commands = cd $$DESTDIR && dfu-util d 0483:df11 -c 1 -i 0 -a 0 -s 0x08000000 -D $(QMAKE_TARGET).bin 0x08000000
50 QMAKE_EXTRA_TARGETS += stflash dfu
50 QMAKE_EXTRA_TARGETS += stflash dfu
51 }
51 }
52
52
53 contains( TEMPLATE, lib ) {
53 contains( TEMPLATE, lib ) {
54 CONFIG+=staticlib
54 CONFIG+=staticlib
55 OBJECTS_DIR=obj-$$UCMODEL
56 DESTDIR=bin-$$UCMODEL
55 message( "You can only build static library for stm32f4" )
57 message( "You can only build static library for stm32f4" )
56 }
58 }
57
59
General Comments 0
You need to be logged in to leave comments. Login now