183 lines
6.3 KiB
C
183 lines
6.3 KiB
C
/****************************************************************************
|
|
|
|
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_DEV_TEST_H
|
|
#define IOT_DEV_TEST_H
|
|
|
|
#include "iot_flashinfo.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#define IOT_DEV_TEST_PRIO (7)
|
|
|
|
#if (IOT_PSRAM_ENABLE)
|
|
#define IOT_DEV_TEST_TASK_POOL_SIZE (128)
|
|
#else
|
|
#define IOT_DEV_TEST_TASK_POOL_SIZE (32)
|
|
#endif
|
|
|
|
/* define priorities for message to be handle */
|
|
#define IOT_DEV_TEST_TASK_QUEUE_LP (0)
|
|
#define IOT_DEV_TEST_TASK_QUEUE_MAX_PRIO (1)
|
|
|
|
/* message type host */
|
|
#define DEV_TEST_MCU_RX_MSG (0)
|
|
/* message type plc */
|
|
#define DEV_TEST_PLC_RX_MSG (1)
|
|
/* message type - timer */
|
|
#define DEV_TEST_TIMER_MSG (2)
|
|
|
|
/* message id - timer for send mode config interval */
|
|
#define DEV_TEST_TIMER_MODE_CONFIG_INTVL (0)
|
|
/* message id - timer for ckq mode cmd interval */
|
|
#define DEV_TEST_TIMER_CKQ_CMD_INTVL (1)
|
|
/* message id - timer for ckq mode timeout */
|
|
#define DEV_TEST_TIMER_CKQ_TIMEOUT (2)
|
|
|
|
#define DEV_TEST_TMR_MODE_CFG_INTVL (1000) //unit ms
|
|
#define DEV_TEST_TMR_CKQ_CMD_INTVL (500) //unit ms
|
|
#define DEV_TEST_TMR_CKQ_TIMEOUT_INTVL (1000) //unit ms
|
|
|
|
#define DEV_TEST_DEFAULT_FRQ_BAND PLC_LIB_FREQ_BAND_1
|
|
/*
|
|
the duration of test mode, ckq config it to dut, dut will get in test
|
|
mode by this duration, unit is second
|
|
*/
|
|
#define DEV_TEST_DEFAULT_MODE_CFG_DUR (30)
|
|
|
|
#define DEV_TEST_UNICAST_RETRY_DEFAULT_CNT (1)
|
|
|
|
/* define target device type ID */
|
|
#define DEV_TEST_TARGET_ID_CCO (0)
|
|
#define DEV_TEST_TARGET_ID_STA (1)
|
|
|
|
/* defining target device type identifier mask */
|
|
#define DEV_TEST_TARGET_ID_MSK_CCO (1 << DEV_TEST_TARGET_ID_CCO)
|
|
#define DEV_TEST_TARGET_ID_MSK_STA (1 << DEV_TEST_TARGET_ID_STA)
|
|
|
|
#define DEV_TEST_MODULE_MAGIC_KEY (0x78ab5434)
|
|
|
|
#define IOT_DEV_TEST_LOG_BUF_LEN (384)
|
|
|
|
#define IOT_DEV_TEST_UART_BAUD_IDX_9600 (1)
|
|
|
|
typedef struct _dev_test_message_t
|
|
{
|
|
iot_task_msg_t msg; /* The main entity of message. */
|
|
void *data; /* The pointer of message. */
|
|
}dev_test_msg_t;
|
|
|
|
#pragma pack(push) // save the pack status
|
|
#pragma pack(1) // 1 byte align
|
|
|
|
typedef struct _protpkt_list protpkt_list_t;
|
|
typedef struct _plctxrx_rx_data_info_t plctxrx_rx_data_info_t;
|
|
typedef struct _protpkt_tx_info_t protpkt_tx_info_t;
|
|
|
|
/* send received frame to motherboard MCU.*/
|
|
typedef uint32_t (*fn_send_to_ext_mcu_t)(iot_pkt_t *data);
|
|
|
|
/* send cmd to the downlayer. dev test uses it, downlayer registered. */
|
|
typedef uint8_t(*fn_cmd_send_to_plc_t)(iot_pkt_t *data);
|
|
|
|
/* send data to the downlayer. dev test uses it, downlayer registered. */
|
|
typedef uint8_t (*fn_data_send_to_plc_t)(uint8_t *data, uint8_t len,
|
|
protpkt_tx_info_t *txinfo);
|
|
|
|
/* register callback handles for dev test module using. */
|
|
typedef struct _dev_test_cb_t
|
|
{
|
|
/*
|
|
provied by grapp top uart, called by dev test moudle, send data to host uart.
|
|
*/
|
|
fn_send_to_ext_mcu_t up_send_cb;
|
|
/*
|
|
provided by plctxrx moudle. used by dev test moudle. send cmd to plctxrx
|
|
moudle.
|
|
*/
|
|
fn_cmd_send_to_plc_t cmd_send_cb;
|
|
/*
|
|
provided by plctxrx moudle. used by dev test moudle. send data to plctxrx
|
|
moudle.
|
|
*/
|
|
fn_data_send_to_plc_t data_send_cb;
|
|
}dev_test_cb_t;
|
|
|
|
/* top level structure of dev test. */
|
|
typedef struct _dev_test_context_t
|
|
{
|
|
/*
|
|
magic key to tell if dev test command module initialized.
|
|
mkey = 0x78ab5434 : initialized, else NOT.
|
|
*/
|
|
uint32_t mkey;
|
|
/* indicate, proto layer is one task.*/
|
|
iot_task_h task_handle;
|
|
/* iot_task configuration */
|
|
iot_task_config_t task_cfg;
|
|
/* local device type. */
|
|
uint8_t dev_type;
|
|
/* role of local device */
|
|
uint8_t dev_role;
|
|
/* local mac address. */
|
|
uint8_t mac[IOT_MAC_ADDR_LEN];
|
|
/* callback handles for dev test module using */
|
|
dev_test_cb_t fn_callback;
|
|
/* timer for sending mode config */
|
|
timer_id_t mod_cfg_tmr;
|
|
/* the interval of ckq mode enable cmd and ckq mode read cmd */
|
|
timer_id_t ckq_cmd_intvl_tmr;
|
|
/* timer for ckq read timeout */
|
|
timer_id_t ckq_timeout_tmr;
|
|
/* cache of load/save info into custom flash */
|
|
custom_flash_info_t flashinfo;
|
|
}dev_test_context_t;
|
|
|
|
#pragma pack(pop) // restore the pack status
|
|
|
|
#if IOT_GE_CKQ_MODE_ENABLE
|
|
|
|
/* regitster the function to send received frame to MCU*/
|
|
uint8_t iot_dev_test_fn_register_send_to_uart(fn_send_to_ext_mcu_t fn);
|
|
|
|
/* registered in app, called when recv MCU data */
|
|
uint8_t iot_dev_test_uart_meter_port_func(uint8_t *buf, uint16_t blen);
|
|
|
|
/* registered in app, called when recv plc data */
|
|
uint8_t iot_dev_test_plc_data_recv_func(protpkt_list_t *report_framelist,
|
|
plctxrx_rx_data_info_t *rxinfo);
|
|
|
|
/* registered in app, called when recv plc cmd */
|
|
uint8_t iot_dev_test_plctxrx_cmd_resp_func(iot_pkt_t *data);
|
|
|
|
/* hook interface with plctxrx layer */
|
|
uint8_t iot_dev_test_fn_register_send_to_plc(fn_cmd_send_to_plc_t cmd_cb,
|
|
fn_data_send_to_plc_t data_cb);
|
|
|
|
dev_test_context_t *iot_dev_test_context_get(void);
|
|
|
|
void iot_dev_test_task_deinit(void);
|
|
|
|
iot_task_h iot_dev_test_task_init(void);
|
|
|
|
#endif
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* IOT_DEV_TEST_H */
|