/**************************************************************************** Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED. This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT be copied by any method or incorporated into another program without the express written consent of Aerospace C.Power. This Information or any portion thereof remains the property of Aerospace C.Power. The Information contained herein is believed to be accurate and Aerospace C.Power assumes no responsibility or liability for its use in any way and conveys no license or title under any patent or copyright and makes no representation or warranty that this Information is free from patent or copyright infringement. ****************************************************************************/ #ifndef _APP_CUS_TASK_H_ #define _APP_CUS_TASK_H_ #include "app_common.h" #include "app_types.h" #ifdef __cplusplus extern "C" { #endif #define APP_CUS_HANDLE_TASK_PRIO 8 #define APP_CUS_PENDING_LIMIT 32 #define APP_CUS_TASK_PRIO_QUE 1 /* message id */ #define APP_CUS_TASK_MSG_ID_UART (1) #define APP_CUS_TASK_MSG_ID_FROM_APP (2) #define APP_CUS_TASK_MSG_ID_PEROID_TMR (3) #define APP_CUS_TASK_TIMER_PERIOD (1000) /* units:ms */ typedef struct _app_cus_task_t { /* task handle */ iot_task_h task; /* uart handle */ iot_uart_h uart_h; /* timer handle */ timer_id_t peroid_timer; } app_cus_task_t; typedef enum { E_CUS_START = 0, E_CUS_FROM_UART_MSG, /* message from uart. */ E_CUS_FROM_APPTASK_MSG, /* message from app-msg-task. */ E_CUS_PEROID_TIMER_MSG, /* message from timer. */ E_CUS_END } app_cus_task_msg_e; #define APP_CUS_VALID(msg) ((msg) > E_CUS_START && (msg) < E_CUS_END) typedef struct { iot_task_msg_t msg; /* The main entity of message. */ void *data; /* The user data inside this message. */ } app_cus_task_msg_t; typedef struct { iot_task_h handle; /* Task handle. */ iot_task_config_t cfg; /* Keep the task configuration. */ } app_cus_task_h; uint16_t app_cus_task_init(void); void app_cus_task_msg_post(uint16_t msg_type, uint16_t msg_id, iot_pkt_t *data); uint16_t app_tx_to_cus_uart_msg(uint8_t * data, uint16_t data_length); #endif /* _APP_CUS_TASK_H_ */