增加 BLE MAC 地址管理功能,添加电量灯颜色设置,优化调度器挂起和恢复逻辑
This commit is contained in:
@@ -3,7 +3,8 @@
|
||||
#include "task.h"
|
||||
|
||||
static size_t int_flag;
|
||||
static portMUX_TYPE s_os_service = portMUX_INITIALIZER_UNLOCKED;
|
||||
static portMUX_TYPE s_spin_lock = portMUX_INITIALIZER_UNLOCKED;
|
||||
static os_mutex_t s_scheduler_mutex;
|
||||
|
||||
int os_start(void *heap_mem, size_t heap_size)
|
||||
{
|
||||
@@ -32,12 +33,12 @@ bool os_is_isr_context(void)
|
||||
|
||||
void os_interrupt_disable(void)
|
||||
{
|
||||
portENTER_CRITICAL(&s_os_service);
|
||||
portENTER_CRITICAL(&s_spin_lock);
|
||||
}
|
||||
|
||||
void os_interrupt_enable(void)
|
||||
{
|
||||
portEXIT_CRITICAL(&s_os_service);
|
||||
portEXIT_CRITICAL(&s_spin_lock);
|
||||
}
|
||||
|
||||
void os_scheduler_suspend(void)
|
||||
@@ -48,7 +49,11 @@ void os_scheduler_suspend(void)
|
||||
OS_ERR("Called in isr"); // 在中断中不要挂起调度器,可能会导致死锁
|
||||
return;
|
||||
}
|
||||
vTaskSuspendAll();
|
||||
if (!os_mutex_is_valid(&s_scheduler_mutex))
|
||||
{
|
||||
os_mutex_create(&s_scheduler_mutex);
|
||||
}
|
||||
os_mutex_lock(&s_scheduler_mutex, OS_WAIT_FOREVER);
|
||||
}
|
||||
|
||||
void os_scheduler_resume(void)
|
||||
@@ -56,7 +61,7 @@ void os_scheduler_resume(void)
|
||||
// 只有在非中断上下文中才恢复调度器
|
||||
if (!os_is_isr_context())
|
||||
{
|
||||
xTaskResumeAll();
|
||||
os_mutex_unlock(&s_scheduler_mutex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user