diff options
| author | Bernard Xiong <[email protected]> | 2021-05-28 16:20:08 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-05-28 16:20:08 +0800 |
| commit | 92beddf3bccf6346e26aa097f82464456fb8e6bd (patch) | |
| tree | 197e4a108118dda016ea02274172f0c40e7ee8ed /bsp/mini4020/applications | |
| parent | b18a99b44240ec3152011e159cc24a5af8dff0ce (diff) | |
| parent | 03f4d40e30f3c94e1db0b3a65b3610dee695694a (diff) | |
Merge pull request #4737 from mysterywolf/3,1,xformatv3.1.5
[lts 3.1.x] format codes
Diffstat (limited to 'bsp/mini4020/applications')
| -rw-r--r-- | bsp/mini4020/applications/application.c | 116 | ||||
| -rw-r--r-- | bsp/mini4020/applications/startup.c | 80 |
2 files changed, 98 insertions, 98 deletions
diff --git a/bsp/mini4020/applications/application.c b/bsp/mini4020/applications/application.c index 688055933c..f5a77d8c60 100644 --- a/bsp/mini4020/applications/application.c +++ b/bsp/mini4020/applications/application.c @@ -4,15 +4,15 @@ * SPDX-License-Identifier: Apache-2.0 * * Change Logs: - * Date Author Notes - * 2007-11-20 Yi.Qiu add rtgui application - * 2008-6-28 Bernard no rtgui init + * Date Author Notes + * 2007-11-20 Yi.Qiu add rtgui application + * 2008-6-28 Bernard no rtgui init */ /** * @addtogroup mini4020 */ - + /*@{*/ #include <board.h> @@ -34,54 +34,54 @@ extern void radio_rtgui_init(void); void rt_init_thread_entry(void *parameter) { - int fd; - rt_uint32_t sz; - char buffer[20]; + int fd; + rt_uint32_t sz; + char buffer[20]; #ifdef RT_USING_DFS - dfs_init(); + dfs_init(); #ifdef RT_USING_DFS_ELMFAT - elm_init(); - /* mount sd card fat partition 1 as root directory */ - if (dfs_mount("sd0", "/", "elm", 0, 0) == 0) - { - rt_kprintf("File System initialized!\n"); + elm_init(); + /* mount sd card fat partition 1 as root directory */ + if (dfs_mount("sd0", "/", "elm", 0, 0) == 0) + { + rt_kprintf("File System initialized!\n"); + + /*Open a file*/ + fd = open("/fattest.txt", O_RDWR|O_CREAT, 0); + if (fd < 0) + { + rt_kprintf("open file for write failed\n"); + return; + } - /*Open a file*/ - fd = open("/fattest.txt", O_RDWR|O_CREAT, 0); - if (fd < 0) - { - rt_kprintf("open file for write failed\n"); - return; - } + sz = write(fd,"Hello RT-Thread!",sizeof("Hello RT-Thread!")); - sz = write(fd,"Hello RT-Thread!",sizeof("Hello RT-Thread!")); + if (sz != 0) + { + rt_kprintf("written %d\n",sz); + } + else + rt_kprintf("haven't written\n"); - if (sz != 0) - { - rt_kprintf("written %d\n",sz); - } - else - rt_kprintf("haven't written\n"); + lseek(fd, 0, SEEK_SET); - lseek(fd, 0, SEEK_SET); - - sz = read(fd, buffer, sizeof(buffer)); + sz = read(fd, buffer, sizeof(buffer)); - if (sz != 0) - { - rt_kprintf("READ %d:",sz); - while (sz--) - rt_kprintf("%c",buffer[sz]);//opposite - rt_kprintf("\n"); - } - else - rt_kprintf("haven't read\n"); + if (sz != 0) + { + rt_kprintf("READ %d:",sz); + while (sz--) + rt_kprintf("%c",buffer[sz]);//opposite + rt_kprintf("\n"); + } + else + rt_kprintf("haven't read\n"); - close(fd); - } - else - rt_kprintf("File System initialzation failed!\n"); -#endif + close(fd); + } + else + rt_kprintf("File System initialzation failed!\n"); +#endif #endif } @@ -104,23 +104,23 @@ void rt_led_thread_entry(void *parameter) int rt_application_init(void) { - rt_thread_t init_thread; - rt_thread_t led_thread; + rt_thread_t init_thread; + rt_thread_t led_thread; + + init_thread = rt_thread_create("init", + rt_init_thread_entry, RT_NULL, + RT_INIT_THREAD_STACK_SIZE, 8, 20); + led_thread = rt_thread_create("led", + rt_led_thread_entry, RT_NULL, + 512, 200, 20); - init_thread = rt_thread_create("init", - rt_init_thread_entry, RT_NULL, - RT_INIT_THREAD_STACK_SIZE, 8, 20); - led_thread = rt_thread_create("led", - rt_led_thread_entry, RT_NULL, - 512, 200, 20); + if (init_thread != RT_NULL) + rt_thread_startup(init_thread); - if (init_thread != RT_NULL) - rt_thread_startup(init_thread); + if (led_thread != RT_NULL) + rt_thread_startup(led_thread); - if (led_thread != RT_NULL) - rt_thread_startup(led_thread); - - return 0; + return 0; } /*@}*/ diff --git a/bsp/mini4020/applications/startup.c b/bsp/mini4020/applications/startup.c index 94c0c43a26..6a006dced0 100644 --- a/bsp/mini4020/applications/startup.c +++ b/bsp/mini4020/applications/startup.c @@ -22,12 +22,12 @@ #include <netif/ethernetif.h> #endif -#define SDRAM_BASE 0x30000000 +#define SDRAM_BASE 0x30000000 #ifdef __CC_ARM extern int Image$$RW_RAM1$$ZI$$Limit; #elif (defined (__GNUC__)) - extern unsigned char __bss_end; + extern unsigned char __bss_end; #endif extern void rt_application_init(void); @@ -36,78 +36,78 @@ extern void sd_init(void); void rtthread_startup() { - /* init hardware interrupt */ - rt_hw_interrupt_init(); + /* init hardware interrupt */ + rt_hw_interrupt_init(); - /* init board */ - rt_hw_board_init(); + /* init board */ + rt_hw_board_init(); - /* show version */ - rt_show_version(); - - /* init tick */ - rt_system_tick_init(); + /* show version */ + rt_show_version(); - /* init kernel object */ - rt_system_object_init(); + /* init tick */ + rt_system_tick_init(); - /* init timer system */ - rt_system_timer_init(); + /* init kernel object */ + rt_system_object_init(); - /* init heap memory system */ + /* init timer system */ + rt_system_timer_init(); + + /* init heap memory system */ #ifdef __CC_ARM - rt_system_heap_init((void*)&Image$$RW_RAM1$$ZI$$Limit, (void*)(SDRAM_BASE + 0x200000)); + rt_system_heap_init((void*)&Image$$RW_RAM1$$ZI$$Limit, (void*)(SDRAM_BASE + 0x200000)); #else - rt_system_heap_init(&__bss_end, (void*)0x34000000); + rt_system_heap_init(&__bss_end, (void*)0x34000000); #endif - /* init scheduler system */ - rt_system_scheduler_init(); + /* init scheduler system */ + rt_system_scheduler_init(); #ifdef RT_USING_DEVICE #ifdef RT_USING_DFS - rt_hw_sdcard_init(); + rt_hw_sdcard_init(); #endif #ifdef RT_USING_LWIP - eth_system_device_init(); - rt_hw_dm9161_init(); + eth_system_device_init(); + rt_hw_dm9161_init(); #endif #endif - /* init application */ - rt_application_init(); + /* init application */ + rt_application_init(); #ifdef RT_USING_FINSH - /* init finsh */ - finsh_system_init(); + /* init finsh */ + finsh_system_init(); #ifdef RT_USING_DEVICE - finsh_set_device("uart0"); + finsh_set_device("uart0"); #endif #endif - /* init idle thread */ - rt_thread_idle_init(); + /* init idle thread */ + rt_thread_idle_init(); + + /* start scheduler */ + rt_system_scheduler_start(); - /* start scheduler */ - rt_system_scheduler_start(); + /* never reach here */ + return ; - /* never reach here */ - return ; - } int main() { - /* disable interrupt first */ - rt_hw_interrupt_disable(); + /* disable interrupt first */ + rt_hw_interrupt_disable(); - /* startup RT-Thread RTOS */ - rtthread_startup(); + /* startup RT-Thread RTOS */ + rtthread_startup(); - return 0; + return 0; } |
