116 lines
3.5 KiB
C
Executable File
116 lines
3.5 KiB
C
Executable File
/****************************************************************************
|
|
|
|
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 _IOT_CUS_TASK_H_
|
|
#define _IOT_CUS_TASK_H_
|
|
|
|
#include "iot_task_api.h"
|
|
#include "iot_pkt_api.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#ifndef bit
|
|
#define bit(b) (1 << (b))
|
|
#endif
|
|
|
|
/* Event ID defination */
|
|
#define IOT_CUS_TASK_EID_EXT_PORTS bit(0)
|
|
|
|
/** Message type defination: */
|
|
#define IOT_CUS_TASK_MT_UART 1 /** message from uart. */
|
|
#define IOT_CUS_TASK_MT_TIMER 2 /** message from timer. */
|
|
#define IOT_CUS_TASK_MT_INTERNAL 3 /** message from cus-task. */
|
|
#define IOT_CUS_TASK_MT_GE 4 /** message from GE. */
|
|
|
|
/* message id for IOT_CUS_TASK_MT_TIMER */
|
|
#define IOT_CUS_TASK_MSG_ID_TMR_TIMEOUT (1)
|
|
#define IOT_CUS_TASK_MSG_ID_CMD_HANDLE (2)
|
|
|
|
#define IOT_CUS_TASK_ID IOT_GREE_APP_MID
|
|
|
|
/* stack size of task */
|
|
#if (IOT_PSRAM_ENABLE)
|
|
#define IOT_CUS_TASK_TASK_STACK_SIZE (2048)
|
|
#else
|
|
#define IOT_CUS_TASK_TASK_STACK_SIZE (0)
|
|
#endif
|
|
|
|
#define IOT_CUS_TASK_PROTO_TASK_PRIO (6)
|
|
|
|
/* number of messages pending in queue. */
|
|
#if (IOT_PSRAM_ENABLE)
|
|
#define IOT_CUS_TASK_TASK_POOL_SIZE (128)
|
|
#else
|
|
#define IOT_CUS_TASK_TASK_POOL_SIZE (32)
|
|
#endif
|
|
|
|
#define IOT_CUS_PORT_TIMER_PERIOD (100) /* units:ms */
|
|
|
|
#define IOT_CUS_TASK_TIMER_PERIOD (1000) /* units:ms */
|
|
|
|
/** uart data process handle */
|
|
typedef void (*iot_cus_task_uart_data_handle)(iot_pkt_t *p_pkt, uint32_t arg);
|
|
|
|
/** type of function send pkt data to ge. */
|
|
typedef uint8_t(*data_send_to_ge)(uint8_t *buf, uint16_t buf_len);
|
|
|
|
/** cus_task message */
|
|
typedef struct _iot_cus_task_msg {
|
|
/* iot task message */
|
|
iot_task_msg_t task_msg;
|
|
/* pointer to message data */
|
|
void *data;
|
|
/* another data field */
|
|
uint32_t data2;
|
|
} iot_cus_task_msg_t;
|
|
|
|
/**
|
|
* @brief iot_cus_task_uart_send() - Send data to uart port.
|
|
* @param p_pkt: packet for sending to uart port.
|
|
* @return: ERR_OK - send successfully.
|
|
* ERR_FAIL - send failed.
|
|
*/
|
|
uint32_t iot_cus_task_uart_send(iot_pkt_t *p_pkt);
|
|
|
|
/**
|
|
* @brief iot_cus_task_msg_post() - port pkt data.
|
|
* @param msg_type: message type.
|
|
* @param msg_id : message id.
|
|
* @param data : iot_pkt data will be post.
|
|
*/
|
|
void iot_cus_task_msg_post(uint16_t msg_type, uint16_t msg_id, iot_pkt_t *data);
|
|
|
|
/**
|
|
* @brief iot_cus_task_event_post() - post event to cus task.
|
|
* @param events: event type.
|
|
*/
|
|
void iot_cus_task_event_post(uint32_t events);
|
|
|
|
/**
|
|
* @brief iot_cus_task_ports_data_receive() - port data receive callback fn.
|
|
* @param port: port id.
|
|
* @param buf : buffer.
|
|
* @param blen : length of buffer.
|
|
*/
|
|
void iot_cus_task_ports_data_receive(uint32_t port, uint8_t *buf, uint32_t blen);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* _IOT_CUS_TASK_H_ */
|