/**
|
*******************************************************************************
|
* @file utility.c
|
* @create 2024-11-01
|
* @author Panchip BLE GROUP
|
* @note
|
* Copyright (c) 2022 Shanghai Panchip Microelectronics Co.,Ltd.
|
*
|
*******************************************************************************
|
*/
|
#include "utility.h"
|
#include "FreeRTOS.h"
|
#include "task.h"
|
#include "cmsis_compiler.h"
|
#include "app_log.h"
|
|
/*******************************************************************************
|
* OS Hook
|
******************************************************************************/
|
#if configCHECK_FOR_STACK_OVERFLOW
|
void vApplicationStackOverflowHook(TaskHandle_t xTask, char *pcTaskName)
|
{
|
APP_LOG_ERR("task overflow:%s\r\n", pcTaskName);
|
app_assert(0);
|
}
|
#endif
|
|
#if configUSE_MALLOC_FAILED_HOOK
|
void vApplicationMallocFailedHook(void)
|
{
|
APP_LOG_ERR("OS Heap Size no enough\r\n");
|
app_assert(0);
|
}
|
#endif
|
|
/**
|
* @brief : Verify that the current program is in interrupt.
|
*/
|
bool IN_ISR(void)
|
{
|
return (SCB->ICSR & SCB_ICSR_VECTACTIVE_Msk) != 0;
|
}
|
|
|
/*******************************************************************************
|
* keil system call
|
******************************************************************************/
|
__attribute__((weak,noreturn))
|
void __aeabi_assert (const char *expr, const char *file, int line) {
|
char str[12], *p;
|
|
fputs("*** assertion failed: ", stderr);
|
fputs(expr, stderr);
|
fputs(", file ", stderr);
|
fputs(file, stderr);
|
fputs(", line ", stderr);
|
|
p = str + sizeof(str);
|
*--p = '\0';
|
*--p = '\n';
|
while (line > 0) {
|
*--p = '0' + (line % 10);
|
line /= 10;
|
}
|
fputs(p, stderr);
|
|
abort();
|
}
|
|
__attribute__((weak))
|
void abort(void) {
|
for (;;);
|
}
|