Share Task
概述
share task 模块为其他模块提供处理各种工作的 task。可以用来处理中断下半部工作。
功能特性
支持高低两种优先级 Task 处理工作。
队列接收工作消息,按顺序处理。
支持深拷贝模式。
支持中断中发送消息,用于处理中断下半部。
具备线程安全性。
资源依赖
OS Queue
OS Task
OS Event
用法流程
发送任务给 ShareTask
wq_share_task_post_event()wq_share_task_post_data()
参考样例
examples/share_task_demo
API 介绍
Defines
-
WQ_SHARE_TASK_QUEUE_HP
define higher priorities for message to be handle
-
WQ_SHARE_TASK_QUEUE_LP
define lower priorities for message to be handle
Typedefs
-
typedef void (*wq_share_task_event_handler)(void)
Share task event handler.
-
typedef void (*wq_share_task_data_handler)(void *data, uint32_t data_len)
Share task data handler.
Functions
-
WQ_RET wq_share_task_init(void)
This function is to init share task and to create the background.
- 返回:
WQ_RET WQ_RET_OK for success else error.
-
void wq_share_task_deinit(void)
This function is to deinit share task and to delete the background share task.
-
WQ_RET wq_share_task_post_event(uint32_t prio, wq_share_task_event_handler handler)
This function is to post address of message to share task.
- 参数:
prio -- is priority to handle this message.
handler -- is the callback fun of the message.
- 返回:
WQ_RET WQ_RET_OK for success else error.
-
WQ_RET wq_share_task_post_event_from_isr(uint32_t prio, wq_share_task_event_handler handler)
This function is to post address of message to share task from isr.
- 参数:
prio -- is priority to handle this message.
handler -- is the callback fun of the message.
- 返回:
WQ_RET WQ_RET_OK for success else error.
-
WQ_RET wq_share_task_post_data(uint32_t prio, wq_share_task_data_handler handler, const void *data, uint32_t data_len)
This function is to post message to share task.
- Attention
Share Task will copy the data to another space. So modify param data in handler will not change the data input.
- 参数:
prio -- is priority to handle this message.
handler -- is the callback fun of the message.
data -- is the address of message data.
data_len -- is the len of message data.
- 返回:
WQ_RET WQ_RET_OK for success else error.
-
WQ_RET wq_share_task_post_data_from_isr(uint32_t prio, wq_share_task_data_handler handler, const void *data, uint32_t data_len)
This function is to post message to share task from isr.
- Attention
Share Task will copy the data to another space. So modify param data in handler will not change the data input.
- 参数:
prio -- is priority to handle this message.
handler -- is the callback fun of the message.
data -- is the address of message data.
data_len -- is the len of message data.
- 返回:
WQ_RET WQ_RET_OK for success else error.