刚刚把LiteOS Studio在windows上装好。下载了润和官方的HiHope_WiFi-IoT_Hi3861SPC025 SDK下的代码,板子是可以跑的,一点问题也没有,不会出现重启的现像。
我在用户入口函数只加上下面的这些,也好像没有问题:
- wifi_delay();
- printf("start sta!!!rn");
- hi_wifi_start_sta();
- wifi_delay();
- wifi_delay();
复制代码
但是如果我随便创建一个线程就跑一会就重启。
跑完这些个语句我再while(1);让单片机死循环也不行,也会无限重启。
还有,比方说我在上面的代码前面加上这两行:
- gpio_init();
- app_led_blink();
复制代码就会重启,
上面的函数的实现部分是这样的:
- //************* LED part *************************
- hi_void gpio_init(hi_void)
- {
- /* Take gpio 0 as an example */
- hi_u32 ret;
- // hi_gpio_value gpio_val = HI_GPIO_VALUE1;
- ret = hi_gpio_init();
- if (ret != HI_ERR_SUCCESS) {
- printf("===== ERROR ===== gpio -> hi_gpio_init ret:%drn", ret);
- return;
- }
- printf("----- gpio init success-----rn");
- // ret = hi_io_set_func(HI_IO_NAME_GPIO_9, HI_IO_FUNC_GPIO_0_GPIO);
- // if (ret != HI_ERR_SUCCESS) {
- // printf("===== ERROR ===== gpio -> hi_io_set_func ret:%drn", ret);
- // return;
- // }
- // printf("----- io set func success-----rn");
- ret = hi_gpio_set_dir(HI_GPIO_IDX_9, HI_GPIO_DIR_OUT);
- if (ret != HI_ERR_SUCCESS) {
- printf("===== ERROR ===== gpio -> hi_gpio_set_dir1 ret:%drn", ret);
- return;
- }
- printf("----- gpio set dir success! -----rn");
- return;
- }
- static hi_void *led_toggole(hi_void *param)
- {
- /* Releases the app_main stack memory. */
- hi_unref_param(param);
- while (1)
- {
- hi_gpio_set_ouput_val(HI_GPIO_IDX_9, 1);
- hi_udelay(1000000);
- hi_gpio_set_ouput_val(HI_GPIO_IDX_9, 0);
- hi_udelay(1000000);
- }
- return HI_NULL;
- }
- hi_void app_led_blink(hi_void)
- {
- /* Releases the app_main stack memory. */
- hi_u32 task_id = 5;
- hi_task_attr attr = {0};
- attr.stack_size = 0x1000;
- attr.task_prio = 0x04;
- attr.task_name = (hi_char*)"app_led_blink";
- hi_u32 ret = hi_task_create(&task_id, &attr, led_toggole, HI_NULL);
- if (ret != HI_ERR_SUCCESS) {
- printf("Falied to create app_led_blink task:0x%xn", ret);
- }
- return;
- }
复制代码stack_size从0x400到0x1000试过都不行。
注释掉这些,程序的最后创建一个不断Ping的线程也不行:
- hi_u32 task_id = 0;
- hi_task_attr attr = {0};
- attr.stack_size = 0x1000;
- attr.task_prio = 11;
- attr.task_name = (hi_char*)"wifi_ping_task";
- ret = hi_task_create(&task_id, &attr, ping_task, HI_NULL);
- if (ret != HI_ERR_SUCCESS) {
- printf("Falied to create app_demo_ping task:0x%xn", ret);
- }
复制代码
整个的app_main.c文件上传的,麻烦有经验的大神帮忙看看,先谢谢了。