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