##// END OF EJS Templates
SYNC
Jeandet Alexis -
r86:ac0656f4856d dev_alexis
parent child
Show More
@@ -1,138 +1,138
1 1 #include <stdio.h>
2 2 #include <fat32.h>
3 3 #include <gpio.h>
4 4 #include <uart.h>
5 5 #include <bsp.h>
6 6 #include <core.h>
7 7 #include <bsp.h>
8 8 #include <spi.h>
9 9 #include <fat32.h>
10 10 #include <ucdirent.h>
11 11 #include <string.h>
12 12 #include <unistd.h>
13 13 #include <terminal.h>
14 14 #include <stdarg.h>
15 15 #include <malloc.h>
16 16
17 17 extern streamdevice* __opnfiles__[];
18 18 extern void test_Block_Move(LCD_t* LCD,int x,int y,int w,int h,int color);
19 19 extern void test_address(LCD_t* LCD);
20 20 extern void printRootClustersChain(FAT32fs* sdcard2FAT32part);
21 21 char buffer[512];
22 22
23 23
24 24 //void streamdevicePrint(streamdevice* dev, const char* format,...)
25 25 //{
26 26 // char str_buffer[512]="";
27 27 // int i;
28 28 // va_list ap;
29 29 // va_start(ap,format);
30 30 // vasprintf(str_buffer,format,ap);
31 31 // va_end(ap);
32 32 // i=strlen(str_buffer);
33 33 // dev->ops->write(dev,(void*)str_buffer,1,i);
34 34 //}
35 35
36 36 int _write(int file, char *ptr, int len)
37 37 {
38 38 if(file<__MAX_OPENED_FILES__ && __opnfiles__[file]!=NULL)
39 39 {
40 40 if(__opnfiles__[file]->ops->write(__opnfiles__[file],ptr,1,len)) return len;
41 41 }
42 42 return len;
43 43 }
44 44
45 45 int _write_r (struct _reent *r, int file, char * ptr, int len)
46 46 {
47 47 return _write(file, ptr, len);
48 48 }
49 49
50 50 //int printf(const char *format,...)
51 51 //{
52 52 // char str_buffer[512]="";
53 53 // for(int i =0;i<512;i++)str_buffer[i]='\0';
54 54 // int i;
55 55 // va_list ap;
56 56 // va_start(ap,format);
57 57 // vasprintf(str_buffer,format,ap);
58 58 // va_end(ap);
59 59 // i=strlen(str_buffer);
60 60 // __opnfiles__[1]->ops->write(__opnfiles__[1],(void*)str_buffer,1,i);
61 61 //}
62 62
63 63 void lcd_print()
64 64 {
65 65 lcd0.paintFilRect(&lcd0,10,10,100,100,0,0,0x0F0F);
66 66 // __opnfiles__[1]->ops->write(__opnfiles__[1],(void*)"hello",1,5);
67 67 }
68 68
69 69
70 70 void playFile(ucdirent* file,FAT32fs* part)
71 71 {
72 72 extern volatile vs10XXDev audioCodec0;
73 73 char direntName[]=" \n";
74 74 uint32_t fileLba,nextLba;
75 75 int i=0;
76 76 fat32getdirentname(file,direntName);
77 77 //gpioset(LCD_BACKL);
78 78 printf("%s\n",direntName);
79 79 nextLba=fat32getdirentlba(file);
80 80 //printf("Streaming File\n");
81 81 //gpioclr(LCD_BACKL);
82 82 }
83 83
84 84 void listFiles()
85 85 {
86 86 extern FAT32fs sdcard2FAT32part1,sdcard2FAT32part2,sdcard2FAT32part3,sdcard2FAT32part4;
87 87 ucdirent root;
88 88 if(DIRENT_noErr==fat32mkdirent(&sdcard2FAT32part1,&root))
89 89 {
90 90 printf("Reading on SDCARD2 part1\n");
91 91 if(DIRENT_noErr==fat32getrootfirstent(&root))
92 92 {
93 93 do{
94 94 playFile(&root,&sdcard2FAT32part1);
95 95 }while (DIRENT_noErr==fat32nextdirent(&root));
96 96 }
97 97 }
98 98 gpioset(LED2);
99 99 if(DIRENT_noErr==fat32mkdirent(&sdcard2FAT32part2,&root))
100 100 {
101 101 printf("Reading on SDCARD2 part2\n");
102 102 if(DIRENT_noErr==fat32getrootfirstent(&root))
103 103 {
104 104 do{
105 105 playFile(&root,&sdcard2FAT32part2);
106 106 }while (DIRENT_noErr==fat32nextdirent(&root));
107 107 }
108 108 }
109 109 }
110 110
111 111
112 112 int libuc_main2()
113 113 {
114 114 printRootClustersChain(&sdcard2FAT32part1);
115 115
116 116 }
117 117
118 118 int libuc_main()
119 119 {
120 120 char in[255];
121 121 //lcd_print();
122 122 printf("hello world\n");
123 123 delay_100us(10000);
124 124 // streamdevicePrint(__opnfiles__[1],"test Hello %d %f \n",1234567,8.96);
125 lcd0.paintText(&lcd0,"A",10,100,&ComicSansMS_18,0x0);
126 while(1)test_address(&lcd0);
127 // listFiles();
125 listFiles();
126 // lcd0.paintText(&lcd0,"A",10,100,&ComicSansMS_18,0x0);
127 // while(1)test_address(&lcd0);
128 128 // while (scanf("%c",in))
129 129 // {
130 130 sleep(5);
131 131 // }
132 132
133 133 }
134 134
135 135
136 136
137 137
138 138
@@ -1,282 +1,281
1 1 #include <stdlib.h>
2 2 #include <errno.h>
3 3 #include <string.h>
4 4 #include <sys/stat.h>
5 5 #include <sys/types.h>
6 6 #include <sys/times.h>
7 7 #include <streamdevices.h>
8 8 #include <string.h>
9 9 #include <stdio.h>
10 10 #include <gpio.h>
11 11 #include <uart.h>
12 12 #include <stdint.h>
13 13 #include <bsp.h>
14 #include <core.h>
15 14
16 15 #undef errno
17 16
18 17
19 18 #ifdef __cplusplus
20 19 extern "C" {
21 20 #endif
22 21 extern int errno;
23 22 extern int32_t __max_opened_files__;
24 23 extern streamdevice* __opnfiles__[];
25 24 extern int32_t* __fs_root__;
26 25 extern int32_t __fs_root_size__;
27 26
28 27 char *__env[1] = { 0 };
29 28 char **environ = __env;
30 29
31 30 int _exit()
32 31 {
33 32 while(1)
34 33 {
35 34 delay_100us(10000);
36 35 gpioset(LED2);
37 36 delay_100us(10000);
38 37 gpioclr(LED2);
39 38 }
40 39 }
41 40
42 41 int _close(int file)
43 42 {
44 43 if(file<__max_opened_files__ && __opnfiles__[file]!=NULL)
45 44 {
46 45 return __opnfiles__[file]->ops->close( __opnfiles__[file]);
47 46 }
48 47 return 0;
49 48 }
50 49
51 50
52 51 int _write(int file, char *ptr, int len)
53 52 {
54 53 if(file<__max_opened_files__ && __opnfiles__[file]!=NULL)
55 54 {
56 55 if(__opnfiles__[file]->ops->write(__opnfiles__[file],ptr,1,len)) return len;
57 56 }
58 57 return len;
59 58 }
60 59
61 60 int _execve(char *name, char **argv, char **env) {
62 61 errno = ENOMEM;
63 62 return -1;
64 63 }
65 64
66 65
67 66 int _fork(void) {
68 67 errno = EAGAIN;
69 68 return -1;
70 69 }
71 70
72 71 int _fstat(int file, struct stat *st) {
73 72 st->st_mode = S_IFCHR;
74 73 return 0;
75 74 }
76 75
77 76
78 77 int _getpid(void) {
79 78 return 1;
80 79 }
81 80
82 81
83 82 int _isatty(int file) {
84 83 return 1;
85 84 }
86 85
87 86
88 87 int _kill(int pid, int sig) {
89 88 errno = EINVAL;
90 89 return -1;
91 90 }
92 91
93 92
94 93 int _link(char *old, char *_new) {
95 94 errno = EMLINK;
96 95 return -1;
97 96 }
98 97
99 98
100 99 int _lseek(int file, int ptr, int dir) {
101 100 return 0;
102 101 }
103 102
104 103 #include <gpio.h>
105 104
106 105 int _open(const char *name, int flags, int mode)
107 106 {
108 107 if(!strncmp("UART", name, 4) && ((name[4] & 0x30)==0x30))
109 108 {
110 109 //uart_t* uart1 = malloc(sizeof(uart_t));
111 110 streamdevice* fd1 = malloc(sizeof(streamdevice));
112 111 uart_t uart=uartopen((name[4] & 0xF)-1);
113 112 if(uart!=-1);
114 113 {
115 114 uartmkstreamdev(uart,fd1);
116 115 int i=2;
117 116 while((i<__max_opened_files__) && (__opnfiles__[i]!=NULL))i++;
118 117 if(i!=__max_opened_files__)
119 118 {
120 119 __opnfiles__[i] = fd1;
121 120 return i;
122 121 }
123 122 else printf("Too much files opened\n\r");
124 123 }
125 124 }
126 125 return -1;
127 126 }
128 127
129 128 int _read(int file, char *ptr, int len) {
130 129 if(file<__max_opened_files__ && __opnfiles__[file]!=NULL)
131 130 {
132 131 if(__opnfiles__[file]->ops->read(__opnfiles__[file],ptr,1,len)) return len;
133 132 }
134 133 return 0;
135 134 }
136 135
137 136
138 137
139 138 caddr_t _sbrk(int incr) {
140 139 register char * stack_ptr __asm__ ("sp");
141 140 extern char end; /* Defined by the linker */
142 141 static char *heap_end;
143 142 char *prev_heap_end;
144 143 if (heap_end == 0) {
145 144 heap_end = &end;
146 145 }
147 146 prev_heap_end = heap_end;
148 147 if (heap_end + incr > stack_ptr) {
149 148 printf("Heap and stack collision\n");
150 149 //abort ();
151 150 while(1)
152 151 {
153 152 delay_100us(10000);
154 153 gpioset(LED2);
155 154 delay_100us(10000);
156 155 gpioclr(LED2);
157 156 }
158 157 }
159 158 heap_end += incr;
160 159 return (caddr_t) prev_heap_end;
161 160 }
162 161
163 162
164 163
165 164 int _stat(char *file, struct stat *st) {
166 165 st->st_mode = S_IFCHR;
167 166 return 0;
168 167 }
169 168
170 169
171 170 int _times(struct tms *buf) {
172 171 return -1;
173 172 }
174 173
175 174
176 175 int _unlink(char *name) {
177 176 errno = ENOENT;
178 177 return -1;
179 178 }
180 179
181 180 int _wait(int *status) {
182 181 errno = ECHILD;
183 182 return -1;
184 183 }
185 184
186 185
187 186 int _read_r (struct _reent *r, int file, char * ptr, int len)
188 187 {
189 188 r = r;
190 189 file = file;
191 190 ptr = ptr;
192 191 len = len;
193 192 _read(file,ptr,len);
194 193 errno = EINVAL;
195 194 return -1;
196 195 }
197 196
198 197 /***************************************************************************/
199 198
200 199 int _lseek_r (struct _reent *r, int file, int ptr, int dir)
201 200 {
202 201 r = r;
203 202 file = file;
204 203 ptr = ptr;
205 204 dir = dir;
206 205
207 206 return 0;
208 207 }
209 208
210 209 /***************************************************************************/
211 210
212 211 int _write_r (struct _reent *r, int file, char * ptr, int len)
213 212 {
214 213 return _write(file, ptr, len);
215 214 }
216 215
217 216 /***************************************************************************/
218 217
219 218 int _close_r (struct _reent *r, int file)
220 219 {
221 220 return 0;
222 221 }
223 222
224 223 /***************************************************************************/
225 224
226 225 caddr_t _sbrk_r (struct _reent *r, int incr)
227 226 {
228 227 register char * stack_ptr __asm__ ("sp");
229 228 extern char end; /* Defined by the linker */
230 229 static char *heap_end;
231 230 char *prev_heap_end;
232 231 if (heap_end == 0) {
233 232 heap_end = &end;
234 233 }
235 234 prev_heap_end = heap_end;
236 235 if (heap_end + incr > stack_ptr) {
237 236 printf( "Heap and stack collision\n");
238 237 //abort ();
239 238 while(1)
240 239 {
241 240 delay_100us(10000);
242 241 gpioset(LED2);
243 242 delay_100us(10000);
244 243 gpioclr(LED2);
245 244 }
246 245 }
247 246 heap_end += incr;
248 247 return (caddr_t) prev_heap_end;
249 248 }
250 249
251 250 /***************************************************************************/
252 251
253 252 int _fstat_r (struct _reent *r, int file, struct stat * st)
254 253 {
255 254 r = r;
256 255 file = file;
257 256
258 257 memset (st, 0, sizeof (* st));
259 258 st->st_mode = S_IFCHR;
260 259 return 0;
261 260 }
262 261
263 262 /***************************************************************************/
264 263 int _open_r(struct _reent *r,const char *name, int flags, int mode)
265 264 {
266 265 return _open(name, flags, mode);
267 266 }
268 267
269 268 int _isatty_r(struct _reent *r, int fd)
270 269 {
271 270 r = r;
272 271 fd = fd;
273 272
274 273 return 1;
275 274 }
276 275
277 276
278 277 #ifdef __cplusplus
279 278 }
280 279 #endif
281 280
282 281
1 NO CONTENT: file was removed, binary diff hidden
1 NO CONTENT: file was removed, binary diff hidden
General Comments 0
You need to be logged in to leave comments. Login now