/** * @file main * */ /********************* * INCLUDES *********************/ #include #include #include "FreeRTOS.h" #include "task.h" #include "queue.h" #include "board.h" #include "chip.h" #include "animation.h" #include "sfud.h" #include "romfile.h" #include "ota_update.h" #include "sysinfo.h" #ifdef WIFI_SUPPORT #include "carlink_ey.h" #include "carlink_ec.h" #endif #include "test_demo.h" #ifdef USE_ULOG #ifdef ULOG_EASYFLASH_BACKEND_ENABLE #include "easyflash.h" #include "ulog_easyflash.h" #endif #ifdef ULOG_FILE_BACKEND_ENABLE #include "ulog_file.h" #endif #endif #undef TASK_STATUS_MONITOR extern int ark_network_init(); extern int tp_init(void); extern int gui_app_start(int lcd_w, int lcd_h); #ifdef ULOG_BACKEND_USING_CONSOLE extern int ulog_console_backend_init(void); #endif extern int get_usb_mode(); extern int ark_network_init(void); extern void ncm_update_demo(); extern void ncm_log_demo(); extern void wifi_update_demo(void); extern void vRegisterSampleCLICommands( void ); extern void vUARTCommandConsoleStart( uint16_t usStackSize, UBaseType_t uxPriority ); #ifdef CARLINK_ENABLE static char qr_text_buf[100] = {0}; //手机互联二维码数据缓存 int get_qr_text_buf(char *buf, int len) { int ret = -1; int qr_len = strlen(qr_text_buf); if ((qr_len > 0) && (len > qr_len)) { strcpy(buf, qr_text_buf); ret = 0; } return ret; } void set_qr_text_buf(const char *str) { if (strlen(str) < sizeof(qr_text_buf)) { strcpy(qr_text_buf, str); } } #endif static void awtk_run_thread(void *param) { gui_app_start (OSD_WIDTH, OSD_HEIGHT); printf("### ERR: %s exit.\n", __func__); vTaskDelete(NULL); } static void awtk_thread(void *param) { printf("awtk thread start.\n"); #if DEVICE_TYPE_SELECT != EMMC_FLASH /* initialize the spi flash */ sfud_init(); #ifdef SPI0_QSPI_MODE sfud_qspi_fast_read_enable(sfud_get_device(0), 4); #endif #else mmcsd_wait_cd_changed(portMAX_DELAY); #endif #ifdef USE_ULOG ulog_init(); #ifdef ULOG_BACKEND_USING_CONSOLE ulog_console_backend_init(); #endif #ifdef ULOG_EASYFLASH_BACKEND_ENABLE easyflash_init(); ulog_ef_backend_init(); #endif #ifdef ULOG_FILE_BACKEND_ENABLE usb_wait_stor_dev_pluged(portMAX_DELAY); ulog_file_backend_init(); #endif TRACE_INFO("use ulog.\n"); //read_all_flash_log(); #endif /* read sysinfo */ ReadSysInfo(); empty_chip_update_demo(); /* initialize carback */ #ifdef CARBACK_DETECT carback_init(); #endif /* play animation */ #if ANIMATION_POLICY != ANIMATION_NONE animation_init(); animation_start(); #endif /* uart rx demo */ //uart_rx_demo(); /* read sd card demo */ #ifdef SDMMC1_SUPPORT #if SDMMC_TEST sdcard_read_demo(); #endif #endif #ifdef USB_SUPPORT if (get_usb_mode()) { ark_network_init(); #ifdef NCM_UPDATE_SUPPORT ncm_update_demo(); #endif #ifdef NCM_LOG_SUPPORT ncm_log_demo(); #endif } else { #if defined(WIFI_UPDATE_SUPPORT) wifi_update_demo(); #elif USB_TEST usb_read_demo(); #endif } #endif #ifdef MAILBOX_SUPPORT #if CAN_UPDATE_TEST CanUpdateReceiveDemo(); #endif #endif #ifdef WIFI_SUPPORT #if WIFI_TEST wifi_demo_test(); #else #if USE_LWIP && (0 == CARLINK_EY && 0 == CARLINK_EC) ark_network_init(); #endif #if CARLINK_EY set_carlink_display_info(0, 0, LCD_WIDTH, LCD_HEIGHT); set_carlink_video_info(LCD_WIDTH, LCD_HEIGHT, 30); carlink_ey_init(); #endif #if CARLINK_EC set_carlink_display_info(0, 0, LCD_WIDTH, LCD_HEIGHT); set_carlink_video_info(LCD_WIDTH, LCD_HEIGHT, 30); carlink_ec_init(0, NULL); #endif #endif #endif /* read romfile */ ReadRomFile(); #ifdef AUDIO_REPLAY #if REPLAY_TEST wavplay_demo(); #endif #endif #ifdef AUDIO_RECORD #if RECORD_TEST wavrecord_demo(); #endif #endif #ifdef TP_SUPPORT tp_init(); #endif #ifdef ETH_SUPPORT #if ETH_TEST eth_test_demo(); #endif #endif xTaskCreate(awtk_run_thread, "awtk_gui", 32768, NULL, configMAX_PRIORITIES/2, NULL); #if ANIMATION_POLICY == ANIMATION_NONE /* Disable video layer and Enable UI layer when no animation */ vTaskDelay(pdMS_TO_TICKS(10)); ark_lcd_osd_enable(LCD_UI_LAYER, 1); ark_lcd_set_osd_sync(LCD_UI_LAYER); ark_lcd_osd_enable(LCD_VIDEO_LAYER, 0); ark_lcd_set_osd_sync(LCD_VIDEO_LAYER); #endif while(1) { #if TASK_STATUS_MONITOR static uint32_t idletick = 0; uint8_t CPU_RunInfo[1024]; if (xTaskGetTickCount() - idletick > configTICK_RATE_HZ * 10) { memset(CPU_RunInfo,0,1024); vTaskList((char *)&CPU_RunInfo); //获取任务运行时间信息 printf("---------------------------------------------\r\n"); printf("Task State Priority Stack #\r\n"); printf("%s", CPU_RunInfo); printf("---------------------------------------------\r\n"); memset(CPU_RunInfo,0,1024); vTaskGetRunTimeStats((char *)&CPU_RunInfo); printf("Task Abs Time % Time\r\n"); printf("%s", CPU_RunInfo); printf("---------------------------------------------\r\n\n"); idletick = xTaskGetTickCount(); } #endif vTaskDelay(pdMS_TO_TICKS(10)); /*Just to let the system breath*/ } } void main_awtk(void) { /* Start the task that manages the command console for FreeRTOS+CLI. */ vUARTCommandConsoleStart( ( configMINIMAL_STACK_SIZE * 3 ), tskIDLE_PRIORITY ); /* Register the standard CLI commands. */ vRegisterSampleCLICommands(); xTaskCreate(awtk_thread, "awtk", 32768, NULL, tskIDLE_PRIORITY + 1, NULL); }