/*---------------------------------------------------------------------------- * Copyright (c) Fenda Technologies Co., Ltd. 2020. All rights reserved. * * Description: sys_rtos.c * * Author: saimen * * Create: 2022-7-16 *--------------------------------------------------------------------------*/ #include #include #include "am_mcu_apollo.h" #include "FreeRTOS.h" #include "task.h" #include "queue.h" #include "portmacro.h" #include "portable.h" #include "sys_config.h" #include "sys_typedef.h" #include "sys_rtos.h" #include "task_ble.h" #define ENABLE_STATIC_PRINT false extern uint32_t am_util_stdio_printf(const char *pcFmt, ...); #define static_print_remind(...) am_util_stdio_printf(__VA_ARGS__) #if ENABLE_STATIC_PRINT #define static_print_info(...) am_util_stdio_printf(__VA_ARGS__) #else #define static_print_info(...) #endif //***************************************************************************** // // Task handle for the initial setup task. // //***************************************************************************** TaskHandle_t xSetupTask; //***************************************************************************** // // Interrupt handler for the CTIMER module. // //***************************************************************************** void am_timer_isr(void) { uint32_t ui32Status; am_hal_timer_interrupt_status_get(false, &ui32Status); am_hal_timer_interrupt_clear(ui32Status); // we don't have this function in new hal // am_hal_ctimer_int_service(ui32Status); } //***************************************************************************** // // Sleep function called from FreeRTOS IDLE task. // Do necessary application specific Power down operations here // Return 0 if this function also incorporates the WFI, else return value same // as idleTime // //***************************************************************************** uint32_t am_freertos_sleep(uint32_t idleTime) { am_hal_sysctrl_sleep(AM_HAL_SYSCTRL_SLEEP_DEEP); return 0; } //***************************************************************************** // // Recovery function called from FreeRTOS IDLE task, after waking up from Sleep // Do necessary 'wakeup' operations here, e.g. to power up/enable peripherals etc. // //***************************************************************************** void am_freertos_wakeup(uint32_t idleTime) { return; } //***************************************************************************** // // FreeRTOS debugging functions. // //***************************************************************************** void vApplicationMallocFailedHook(void) { // // Called if a call to pvPortMalloc() fails because there is insufficient // free memory available in the FreeRTOS heap. pvPortMalloc() is called // internally by FreeRTOS API functions that create tasks, queues, software // timers, and semaphores. The size of the FreeRTOS heap is set by the // configTOTAL_HEAP_SIZE configuration constant in FreeRTOSConfig.h. // static_print_remind("vApplicationMallocFailedHook()"); while (1); } void vApplicationStackOverflowHook(TaskHandle_t pxTask, char *pcTaskName) { (void) pcTaskName; (void) pxTask; // // Run time stack overflow checking is performed if // configconfigCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook // function is called if a stack overflow is detected. // static_print_remind("vApplicationStackOverflowHook():[%s]",pcTaskName); while (1) { __asm("BKPT #0\n") ; // Break into the debugger } }