48 lines
1.1 KiB
C
48 lines
1.1 KiB
C
#ifndef APP_FRM_SIGNAL_H
|
|
#define APP_FRM_SIGNAL_H
|
|
|
|
#ifdef __cplusplus
|
|
extern "C"
|
|
{
|
|
#endif
|
|
|
|
#include <stdint.h>
|
|
#include "app_dependence.h"
|
|
|
|
#define MAX_SIGNALS 500u // 每个优先级的最大信号数量
|
|
#define MAX_SUBSCRIBERS 100u // 不同信号的订阅者数量
|
|
#define MAX_CALLBACKS 25u // 每个信号最多支持多少订阅者
|
|
#define PRIORITY_LEVELS 2u // 优先级层次
|
|
|
|
|
|
// 回调函数类型定义
|
|
typedef void (*CallbackFunc)(void *signal_id);
|
|
|
|
// 函数声明
|
|
void initFramework(void);
|
|
int32_t subscribe(void *signal_id, CallbackFunc callback);
|
|
int32_t publishMessage(void *signal_id, uint8_t priority);
|
|
void processMessages(void);
|
|
int32_t getSignalCount(uint32_t priority);
|
|
uint32_t getSubscriberCount(void);
|
|
|
|
// 进入临界区,禁用中断,并返回之前的中断状态
|
|
static inline irq_state_t enter_critical_section(void)
|
|
{
|
|
return arch_irq_save();
|
|
}
|
|
|
|
// 退出临界区,恢复之前的中断状态
|
|
static inline void exit_critical_section(irq_state_t saved_state)
|
|
{
|
|
arch_irq_restore(saved_state);
|
|
}
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif // APP_FRM_SIGNAL_H
|