@@ -1,332 +1,333 | |||
|
1 | 1 | /*------------------------------------------------------------------------------ |
|
2 | 2 | -- This file is a part of the libuc, microcontroler library |
|
3 | 3 | -- Copyright (C) 2011, Alexis Jeandet |
|
4 | 4 | -- |
|
5 | 5 | -- This program is free software; you can redistribute it and/or modify |
|
6 | 6 | -- it under the terms of the GNU General Public License as published by |
|
7 | 7 | -- the Free Software Foundation; either version 3 of the License, or |
|
8 | 8 | -- (at your option) any later version. |
|
9 | 9 | -- |
|
10 | 10 | -- This program is distributed in the hope that it will be useful, |
|
11 | 11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 | 12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 | 13 | -- GNU General Public License for more details. |
|
14 | 14 | -- |
|
15 | 15 | -- You should have received a copy of the GNU General Public License |
|
16 | 16 | -- along with this program; if not, write to the Free Software |
|
17 | 17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
18 | 18 | ------------------------------------------------------------------------------- |
|
19 | 19 | -- Author : Alexis Jeandet |
|
20 | 20 | -- Mail : alexis.jeandet@member.fsf.org |
|
21 | 21 | -------------------------------------------------------------------------------*/ |
|
22 | 22 | #include "bsp.h" |
|
23 | 23 | #include <streamdevices.h> |
|
24 | 24 | #include <malloc.h> |
|
25 | 25 | #include <stdio.h> |
|
26 | 26 | |
|
27 | 27 | |
|
28 | 28 | uint32_t OSC0 =8000000; |
|
29 | 29 | uint32_t INTOSC =16000000; |
|
30 | 30 | uint32_t RTCOSC =32768; |
|
31 | 31 | uint32_t currentCpuFreq=0; |
|
32 | 32 | extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__]; |
|
33 | 33 | |
|
34 | 34 | |
|
35 | 35 | LCD_IF_t lcdIF0={ |
|
36 | 36 | .init = &SDLCD_init, |
|
37 | 37 | .writereg = &SDLCD_writereg, |
|
38 | 38 | .readreg = &SDLCD_readreg, |
|
39 | 39 | .writeGRAM = &SDLCD_writeGRAM_16bpp, |
|
40 | 40 | .readGRAM = &SDLCD_readGRAM_16bpp |
|
41 | 41 | }; |
|
42 | 42 | |
|
43 | 43 | LCD_t lcd0={ |
|
44 | 44 | .interface = &lcdIF0, |
|
45 | 45 | .init = &ili9328init, |
|
46 | 46 | .paint = &ili9328paint, |
|
47 | 47 | .paintText = &ili9328paintText, |
|
48 | 48 | .paintFilRect = &ili9328paintFilRect, |
|
49 | 49 | .getPix = &ili9328getPix, |
|
50 | 50 | .refreshenable = &ili9328refreshenable, |
|
51 | 51 | .width= 600, |
|
52 | 52 | .height = 800 |
|
53 | 53 | }; |
|
54 | 54 | |
|
55 | 55 | terminal_t terminal0; |
|
56 | 56 | |
|
57 | 57 | volatile int8_t* lcd0_CMD=(volatile int8_t*) 0x60000000; |
|
58 | 58 | volatile int8_t* lcd0_DATA=(volatile int8_t*)(0x61FFFFF0); |
|
59 | 59 | |
|
60 | 60 | float VREF0 =(float)3.3; |
|
61 | 61 | volatile vs10XXDev audioCodec0; |
|
62 | 62 | |
|
63 | 63 | sdcardDev sdcard2; |
|
64 | 64 | blkdevice sdcard2blkdev; |
|
65 | 65 | dikpartition sdcard2Part1; |
|
66 | 66 | FAT32fs sdcard2FAT32part1; |
|
67 | 67 | dikpartition sdcard2Part2; |
|
68 | 68 | FAT32fs sdcard2FAT32part2; |
|
69 | 69 | dikpartition sdcard2Part3; |
|
70 | 70 | FAT32fs sdcard2FAT32part3; |
|
71 | 71 | dikpartition sdcard2Part4; |
|
72 | 72 | FAT32fs sdcard2FAT32part4; |
|
73 | 73 | |
|
74 | ||
|
75 | ||
|
74 | 76 | int bsp_init() |
|
75 | 77 | { |
|
76 | 78 | int i=0; |
|
77 | 79 | for(i=0;i<__MAX_OPENED_FILES__;i++) |
|
78 | 80 | { |
|
79 | 81 | __opnfiles__[i] = NULL; |
|
80 | 82 | } |
|
81 | 83 | bsp_GPIO_init(); |
|
82 | 84 | bsp_uart_init(); |
|
83 | 85 | bsp_iic_init(); |
|
84 | 86 | bsp_FSMC_init(); |
|
85 | 87 | bsp_GTerm_init(); |
|
86 | 88 | bsp_spi_init(); |
|
87 | 89 | bsp_SD_init(); |
|
88 | 90 | bsp_Audio_init(); |
|
89 | 91 | printf("\r=====================\n\r"); |
|
90 | 92 | printf( "=====================\n\r"); |
|
91 | 93 | printf(BSP); |
|
92 | 94 | printf(" initialised\n\r"); |
|
93 | 95 | printf( "=====================\n\r"); |
|
94 | 96 | return 1; |
|
95 | 97 | } |
|
96 | 98 | |
|
97 | 99 | void bsp_GPIO_init() |
|
98 | 100 | { |
|
99 | 101 | |
|
100 | 102 | } |
|
101 | 103 | |
|
102 | 104 | void bsp_uart_init() |
|
103 | 105 | { |
|
104 | 106 | |
|
105 | 107 | } |
|
106 | 108 | |
|
107 | 109 | /* |
|
108 | 110 | D0 PD14 D1 PD15 D2 PD0 D3 PD1 D4 PE7 |
|
109 | 111 | D5 PE8 D6 PE9 D7 PE10 |
|
110 | 112 | A20 PE4 = RS FSMC_NE1 PD7 CS FSMC_NWE PD5 W/S |
|
111 | 113 | FSMC_NOE PD4 RD |
|
112 | 114 | */ |
|
113 | 115 | |
|
114 | 116 | int bsp_FSMC_init() |
|
115 | 117 | { |
|
116 | 118 | |
|
117 | 119 | return 1; |
|
118 | 120 | } |
|
119 | 121 | |
|
120 | 122 | void bsp_spi_init() |
|
121 | 123 | { |
|
122 | 124 | |
|
123 | 125 | } |
|
124 | 126 | |
|
125 | 127 | |
|
126 | 128 | void bsp_iic_init() |
|
127 | 129 | { |
|
128 | 130 | |
|
129 | 131 | } |
|
130 | 132 | |
|
131 | 133 | |
|
132 | 134 | void bsp_Audio_init() |
|
133 | 135 | { |
|
134 | 136 | |
|
135 | 137 | } |
|
136 | 138 | |
|
137 | 139 | void bsp_SD_init() |
|
138 | 140 | { |
|
139 | 141 | sdcardspimakeblkdev(&sdcard2blkdev,&sdcard2, bspsdcardselect,bsppowersdcard,bspsdcardpresent,bspsdcardwriteprotected); |
|
140 | 142 | if(sdcard2blkdev.initialize(&sdcard2blkdev)!=STA_NOINIT) |
|
141 | 143 | { |
|
142 | 144 | if(mbropen(&sdcard2blkdev,&sdcard2Part1,1)==MBRnoErr) |
|
143 | 145 | { |
|
144 | 146 | if(FATnoErr!=fat32open(&sdcard2FAT32part1,&sdcard2Part1)) |
|
145 | 147 | printf("Can't open fat32 partition 1\n"); |
|
146 | 148 | } |
|
147 | 149 | else |
|
148 | 150 | { |
|
149 | 151 | printf("Can't open or read MBR\n"); |
|
150 | 152 | } |
|
151 | 153 | delay_100us(1000); |
|
152 | 154 | if(mbropen(&sdcard2blkdev,&sdcard2Part2,2)==MBRnoErr) |
|
153 | 155 | { |
|
154 | 156 | if(FATnoErr!=fat32open(&sdcard2FAT32part2,&sdcard2Part2)) |
|
155 | 157 | printf("Can't open fat32 partition 2\n"); |
|
156 | 158 | } |
|
157 | 159 | else |
|
158 | 160 | { |
|
159 | 161 | printf("Can't open or read MBR\n"); |
|
160 | 162 | } |
|
161 | 163 | delay_100us(1000); |
|
162 | 164 | if(mbropen(&sdcard2blkdev,&sdcard2Part3,3)==MBRnoErr) |
|
163 | 165 | { |
|
164 | 166 | if(FATnoErr!=fat32open(&sdcard2FAT32part3,&sdcard2Part3)) |
|
165 | 167 | printf("Can't open fat32 partition 3\n"); |
|
166 | 168 | } |
|
167 | 169 | else |
|
168 | 170 | { |
|
169 | 171 | printf("Can't open or read MBR\n"); |
|
170 | 172 | } |
|
171 | 173 | delay_100us(1000); |
|
172 | 174 | if(mbropen(&sdcard2blkdev,&sdcard2Part4,4)==MBRnoErr) |
|
173 | 175 | { |
|
174 | 176 | if(FATnoErr!=fat32open(&sdcard2FAT32part4,&sdcard2Part4)) |
|
175 | 177 | printf("Can't open fat32 partition 4\n"); |
|
176 | 178 | } |
|
177 | 179 | else |
|
178 | 180 | { |
|
179 | 181 | printf("Can't open or read MBR\n"); |
|
180 | 182 | } |
|
181 | 183 | } |
|
182 | 184 | else |
|
183 | 185 | { |
|
184 | 186 | printf("Can't initialize SDCARD\n"); |
|
185 | 187 | } |
|
186 | 188 | |
|
187 | 189 | delay_100us(2000); |
|
188 | 190 | } |
|
189 | 191 | |
|
190 | 192 | void vs1052setXCS(char val) |
|
191 | 193 | { |
|
192 | 194 | } |
|
193 | 195 | |
|
194 | 196 | void vs1052setXDCS(char val) |
|
195 | 197 | { |
|
196 | 198 | } |
|
197 | 199 | |
|
198 | 200 | void vs1052setRST(char val) |
|
199 | 201 | { |
|
200 | 202 | } |
|
201 | 203 | |
|
202 | 204 | int vs10XXDREQ() |
|
203 | 205 | { |
|
204 | 206 | return 1; |
|
205 | 207 | } |
|
206 | 208 | |
|
207 | 209 | |
|
208 | 210 | void bsppowersdcard(char onoff) //always ON |
|
209 | 211 | { |
|
210 | 212 | |
|
211 | 213 | } |
|
212 | 214 | |
|
213 | 215 | char bspsdcardpresent() |
|
214 | 216 | { |
|
215 | 217 | return 1; |
|
216 | 218 | } |
|
217 | 219 | |
|
218 | 220 | char bspsdcardwriteprotected() |
|
219 | 221 | { |
|
220 | 222 | return 0; |
|
221 | 223 | } |
|
222 | 224 | |
|
223 | 225 | void bspsdcardselect(char YESNO) |
|
224 | 226 | { |
|
225 | 227 | |
|
226 | 228 | } |
|
227 | 229 | |
|
228 | 230 | |
|
229 | 231 | void bsp_lcd0_write_reg(uint32_t reg,uint32_t data) |
|
230 | 232 | { |
|
231 | 233 | |
|
232 | 234 | } |
|
233 | 235 | |
|
234 | 236 | uint32_t bsp_lcd0_read_reg(uint32_t reg) |
|
235 | 237 | { |
|
236 | 238 | return 0; |
|
237 | 239 | } |
|
238 | 240 | |
|
239 | 241 | void bsp_lcd0_writeGRAM(void* buffer,uint32_t count) |
|
240 | 242 | { |
|
241 | 243 | |
|
242 | 244 | } |
|
243 | 245 | |
|
244 | 246 | void bsp_lcd0_readGRAM(void* buffer,uint32_t count) |
|
245 | 247 | { |
|
246 | 248 | |
|
247 | 249 | } |
|
248 | 250 | |
|
249 | 251 | void bsp_GTerm_init() |
|
250 | 252 | { |
|
251 | 253 | SDLCD_mkscreen(lcd0.width,lcd0.height,16,LCDILI9328); |
|
252 | 254 | |
|
253 | 255 | if(__opnfiles__[1]==NULL) |
|
254 | 256 | { |
|
255 | 257 | streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice)); |
|
256 | 258 | terminal_init(&terminal0 ,&lcd0,&ComicSansMS_18,fd1); |
|
257 | 259 | lcd0.paintFilRect(&lcd0,0,0,lcd0.width,lcd0.height,0,0,0x0f0f); |
|
258 | 260 | __opnfiles__[1] = fd1; |
|
259 | 261 | } |
|
260 | 262 | else |
|
261 | 263 | { |
|
262 | 264 | |
|
263 | 265 | } |
|
264 | 266 | } |
|
265 | 267 | |
|
266 | 268 | |
|
267 | 269 | |
|
268 | 270 | |
|
269 | 271 | |
|
270 | 272 | |
|
271 | 273 | |
|
272 | 274 | void putpixel(SDL_Surface *surface, int x, int y, Uint32 pixel) |
|
273 | 275 | { |
|
274 | 276 | int bpp = surface->format->BytesPerPixel; |
|
275 | 277 | /* Here p is the address to the pixel we want to set */ |
|
276 | 278 | Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp; |
|
277 | 279 | switch(bpp) { |
|
278 | 280 | case 1: |
|
279 | 281 | *p = pixel; |
|
280 | 282 | break; |
|
281 | 283 | case 2: |
|
282 | 284 | *(Uint16 *)p = pixel; |
|
283 | 285 | break; |
|
284 | 286 | case 3: |
|
285 | 287 | if(SDL_BYTEORDER == SDL_BIG_ENDIAN) { |
|
286 | 288 | p[0] = (pixel >> 16) & 0xff; |
|
287 | 289 | p[1] = (pixel >> 8) & 0xff; |
|
288 | 290 | p[2] = pixel & 0xff; |
|
289 | 291 | } else { |
|
290 | 292 | p[0] = pixel & 0xff; |
|
291 | 293 | p[1] = (pixel >> 8) & 0xff; |
|
292 | 294 | p[2] = (pixel >> 16) & 0xff; |
|
293 | 295 | } |
|
294 | 296 | break; |
|
295 | 297 | case 4: |
|
296 | 298 | *(Uint32 *)p = pixel; |
|
297 | 299 | break; |
|
298 | 300 | } |
|
299 | 301 | } |
|
300 | 302 | |
|
301 | 303 | Uint32 getpixel(SDL_Surface *surface, int x, int y) |
|
302 | 304 | { |
|
303 | 305 | int bpp = surface->format->BytesPerPixel; |
|
304 | 306 | /* Here p is the address to the pixel we want to retrieve */ |
|
305 | 307 | Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp; |
|
306 | 308 | switch(bpp) { |
|
307 | 309 | case 1: |
|
308 | 310 | return *p; |
|
309 | 311 | case 2: |
|
310 | 312 | return *(Uint16 *)p; |
|
311 | 313 | case 3: |
|
312 | 314 | if(SDL_BYTEORDER == SDL_BIG_ENDIAN) |
|
313 | 315 | return p[0] << 16 | p[1] << 8 | p[2]; |
|
314 | 316 | else |
|
315 | 317 | return p[0] | p[1] << 8 | p[2] << 16; |
|
316 | 318 | case 4: |
|
317 | 319 | return *(Uint32 *)p; |
|
318 | 320 | default: |
|
319 | 321 | return 0; |
|
320 | 322 | } |
|
321 | 323 | /* shouldn’t happen, but avoids warnings */ |
|
322 | 324 | } |
|
323 | 325 | |
|
324 | 326 | |
|
325 | 327 | |
|
326 | 328 | |
|
327 | 329 | |
|
328 | 330 | |
|
329 | 331 | |
|
330 | 332 | |
|
331 | 333 | |
|
332 |
@@ -1,19 +1,23 | |||
|
1 | 1 | |
|
2 | 2 | #include <stdio.h> |
|
3 | 3 | #include <fat32.h> |
|
4 | 4 | #include <ucdirent.h> |
|
5 | #include <stdarg.h> | |
|
6 | #include <streamdevices.h> | |
|
7 | ||
|
8 | ||
|
5 | 9 | |
|
6 | 10 | void printRootClustersChain(FAT32fs* sdcard2FAT32part) |
|
7 | 11 | { |
|
8 | 12 | ucdirent root; |
|
9 | 13 | uint32_t sector_lba,res,tmp=sdcard2FAT32part->cluster_begin_lba; |
|
10 | 14 | sector_lba=tmp; |
|
11 | 15 | do |
|
12 | 16 | { |
|
13 | 17 | printf("Sector @0x%x\n",tmp); |
|
14 | 18 | //sector_lba=tmp+sdcard2FAT32part->BPB_SecPerClus-1; |
|
15 | 19 | sector_lba=tmp; |
|
16 | 20 | res=fat32nextsectorlba(sdcard2FAT32part,sector_lba,&tmp); |
|
17 | 21 | }while((res==DIRENT_noErr)&&(res!=DIRENT_LastSect)); |
|
18 | 22 | |
|
19 | 23 | } |
@@ -1,47 +1,45 | |||
|
1 | 1 | /*------------------------------------------------------------------------------ |
|
2 | 2 | -- This file is a part of the libuc, microcontroler library |
|
3 | 3 | -- Copyright (C) 2013, Alexis Jeandet |
|
4 | 4 | -- |
|
5 | 5 | -- This program is free software; you can redistribute it and/or modify |
|
6 | 6 | -- it under the terms of the GNU General Public License as published by |
|
7 | 7 | -- the Free Software Foundation; either version 3 of the License, or |
|
8 | 8 | -- (at your option) any later version. |
|
9 | 9 | -- |
|
10 | 10 | -- This program is distributed in the hope that it will be useful, |
|
11 | 11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 | 12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 | 13 | -- GNU General Public License for more details. |
|
14 | 14 | -- |
|
15 | 15 | -- You should have received a copy of the GNU General Public License |
|
16 | 16 | -- along with this program; if not, write to the Free Software |
|
17 | 17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
18 | 18 | -------------------------------------------------------------------------------*/ |
|
19 | 19 | /** @author Alexis Jeandet alexis.jeandet@member.fsf.org |
|
20 | 20 | -------------------------------------------------------------------------------*/ |
|
21 | 21 | /** |
|
22 | 22 | * This file is a simple hello world example it should run on any supported |
|
23 | 23 | * board/architecture couple. To change target board and architecture modify |
|
24 | 24 | * the project file. The value BSP contains the board name, and UCMODEL contain |
|
25 | 25 | * the target architecture. |
|
26 | 26 | */ |
|
27 | #include <stdio.h> | |
|
28 | ||
|
29 | 27 | |
|
30 | 28 | int libuc_main() |
|
31 | 29 | { |
|
32 | 30 | /** |
|
33 | 31 | Depending on the board the printf can be directed on one uart or LCD screen or |
|
34 | 32 | any other stream device. |
|
35 | 33 | */ |
|
36 | 34 | printf("hello world\n\r"); |
|
37 | 35 | return 0; |
|
38 | 36 | } |
|
39 | 37 | |
|
40 | 38 | |
|
41 | 39 | |
|
42 | 40 | |
|
43 | 41 | |
|
44 | 42 | |
|
45 | 43 | |
|
46 | 44 | |
|
47 | 45 |
@@ -1,41 +1,41 | |||
|
1 | 1 | # |
|
2 | 2 | # qmake configuration for simulator |
|
3 | 3 | # |
|
4 | 4 | |
|
5 | 5 | CONFIG += |
|
6 | 6 | QMAKE_CC = gcc |
|
7 | 7 | QMAKE_CFLAGS += -g -O0 |
|
8 | 8 | QMAKE_CFLAGS_DEPS += -M |
|
9 | 9 | QMAKE_CFLAGS_WARN_ON += -Wall |
|
10 | 10 | QMAKE_CFLAGS_WARN_OFF += -w |
|
11 | 11 | QMAKE_CFLAGS_RELEASE += -O2 |
|
12 | 12 | QMAKE_CFLAGS_DEBUG += |
|
13 | 13 | |
|
14 | 14 | QMAKE_CXX = g++ |
|
15 | 15 | QMAKE_CXXFLAGS += $$QMAKE_CFLAGS s |
|
16 | 16 | QMAKE_CXXFLAGS_DEPS += $$QMAKE_CFLAGS_DEPS |
|
17 | 17 | QMAKE_CXXFLAGS_WARN_ON += $$QMAKE_CFLAGS_WARN_ON |
|
18 | 18 | QMAKE_CXXFLAGS_WARN_OFF += $$QMAKE_CFLAGS_WARN_OFF |
|
19 | 19 | QMAKE_CXXFLAGS_RELEASE += $$QMAKE_CFLAGS_RELEASE |
|
20 | 20 | QMAKE_CXXFLAGS_DEBUG += $$QMAKE_CFLAGS_DEBUG |
|
21 | 21 | QMAKE_CXXFLAGS_SHLIB += $$QMAKE_CFLAGS_SHLIB |
|
22 | 22 | QMAKE_CXXFLAGS_STATIC_LIB += $$QMAKE_CFLAGS_STATIC_LIB |
|
23 | 23 | QMAKE_CXXFLAGS_YACC += $$QMAKE_CFLAGS_YACC |
|
24 | 24 | QMAKE_CXXFLAGS_HIDESYMS += $$QMAKE_CFLAGS_HIDESYMS |
|
25 | 25 | |
|
26 | 26 | QMAKE_LINK = gcc |
|
27 | 27 | QMAKE_LINK_SHLIB = gcc |
|
28 | 28 | QMAKE_LINK_C = gcc |
|
29 | 29 | QMAKE_LINK_C_SHLIB = gcc |
|
30 | QMAKE_LFLAGS += -g -O0 | |
|
30 | QMAKE_LFLAGS += -g -O0 -Wl,-wrap,printf -Wl,-wrap,puts | |
|
31 | 31 | QMAKE_LFLAGS_RELEASE += |
|
32 | 32 | QMAKE_LFLAGS_DEBUG += |
|
33 | 33 | QMAKE_LFLAGS_APP += |
|
34 | 34 | QMAKE_LFLAGS_SHLIB += |
|
35 | 35 | QMAKE_LFLAGS_PLUGIN += $$QMAKE_LFLAGS_SHLIB |
|
36 | 36 | QMAKE_LFLAGS_THREAD += |
|
37 | 37 | |
|
38 | 38 | QMAKE_AR = ar -ru |
|
39 | 39 | QMAKE_LIB = ar -ru |
|
40 | 40 | QMAKE_RANLIB = |
|
41 | 41 |
@@ -1,7 +1,35 | |||
|
1 | #include <stdio.h> | |
|
2 | #include <stdarg.h> | |
|
3 | #include <streamdevices.h> | |
|
1 | 4 | |
|
5 | extern streamdevice* __opnfiles__[]; | |
|
6 | ||
|
7 | extern int __real_printf(const char *format,...); | |
|
8 | ||
|
9 | int __wrap_printf(const char *format,...) | |
|
10 | { | |
|
11 | char* str_buffer; | |
|
12 | // for(int i =0;i<512;i++)str_buffer[i]='\0'; | |
|
13 | int i; | |
|
14 | va_list ap; | |
|
15 | va_start(ap,format); | |
|
16 | vasprintf(&str_buffer,format,ap); | |
|
17 | va_end(ap); | |
|
18 | i=strlen(str_buffer); | |
|
19 | __opnfiles__[1]->ops->write(__opnfiles__[1],(void*)str_buffer,1,i); | |
|
20 | } | |
|
21 | ||
|
22 | extern int __real_puts(const char *s); | |
|
23 | ||
|
24 | int __wrap_puts(const char *s) | |
|
25 | { | |
|
26 | int i; | |
|
27 | i=strlen(s); | |
|
28 | __opnfiles__[1]->ops->write(__opnfiles__[1],(void*)s,1,i); | |
|
29 | } | |
|
2 | 30 | |
|
3 | 31 | int main(void) |
|
4 | 32 | { |
|
5 | 33 | bsp_init(); |
|
6 | 34 | libuc_main(); |
|
7 | 35 | } |
@@ -1,7 +1,35 | |||
|
1 | #include <stdio.h> | |
|
2 | #include <stdarg.h> | |
|
3 | #include <streamdevices.h> | |
|
1 | 4 | |
|
5 | extern streamdevice* __opnfiles__[]; | |
|
6 | ||
|
7 | extern int __real_printf(const char *format,...); | |
|
8 | ||
|
9 | int __wrap_printf(const char *format,...) | |
|
10 | { | |
|
11 | char* str_buffer; | |
|
12 | // for(int i =0;i<512;i++)str_buffer[i]='\0'; | |
|
13 | int i; | |
|
14 | va_list ap; | |
|
15 | va_start(ap,format); | |
|
16 | vasprintf(&str_buffer,format,ap); | |
|
17 | va_end(ap); | |
|
18 | i=strlen(str_buffer); | |
|
19 | __opnfiles__[1]->ops->write(__opnfiles__[1],(void*)str_buffer,1,i); | |
|
20 | } | |
|
21 | ||
|
22 | extern int __real_puts(const char *s); | |
|
23 | ||
|
24 | int __wrap_puts(const char *s) | |
|
25 | { | |
|
26 | int i; | |
|
27 | i=strlen(s); | |
|
28 | __opnfiles__[1]->ops->write(__opnfiles__[1],(void*)s,1,i); | |
|
29 | } | |
|
2 | 30 | |
|
3 | 31 | int main(void) |
|
4 | 32 | { |
|
5 | 33 | bsp_init(); |
|
6 | 34 | libuc_main(); |
|
7 | 35 | } |
General Comments 0
You need to be logged in to leave comments.
Login now