129 lines
		
	
	
		
			3.6 KiB
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			129 lines
		
	
	
		
			3.6 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_FTM_INTERNAL_H
 | 
						|
#define IOT_FTM_INTERNAL_H
 | 
						|
 | 
						|
/* os shim includes */
 | 
						|
#include "os_types.h"
 | 
						|
 | 
						|
/* common includes */
 | 
						|
#include "iot_config.h"
 | 
						|
#include "iot_task.h"
 | 
						|
 | 
						|
/* ftm internal includes */
 | 
						|
#include "iot_ftm_msg.h"
 | 
						|
#include "mac_dsr.h"
 | 
						|
 | 
						|
#ifdef __cplusplus
 | 
						|
extern "C" {
 | 
						|
#endif
 | 
						|
 | 
						|
/* define ftm message pool size */
 | 
						|
#define IOT_FTM_MSG_POOL_SIZE       128
 | 
						|
 | 
						|
/* define the ftm message queue count and priorities, the higer the priority
 | 
						|
 * the lower the queue number.
 | 
						|
 */
 | 
						|
#define IOT_FTM_MSG_QUEUE_HP        0
 | 
						|
#define IOT_FTM_MSG_QUEUE_MAX_PRIO  1
 | 
						|
 | 
						|
/* define ftm message id */
 | 
						|
#define IOT_FTM_MSG_FTM_CMD         1
 | 
						|
#define IOT_FTM_MSG_FTM_SEND        2
 | 
						|
 | 
						|
/* define ftm task size */
 | 
						|
#define IOT_FTM_TASK_STACK_SIZE     1024
 | 
						|
 | 
						|
//copy from mac dsr
 | 
						|
/*
 | 
						|
 * function callback to handle specific dsr
 | 
						|
 * @arg:    arg parameter registered alone with the callback
 | 
						|
 */
 | 
						|
typedef void (*ftm_dsr_func_t)();
 | 
						|
 | 
						|
/* mac dsr entry defintion */
 | 
						|
typedef struct _ftm_dsr_entry {
 | 
						|
    /* ftm dsr function callback */
 | 
						|
    ftm_dsr_func_t dsr;
 | 
						|
} ftm_dsr_entry_t;
 | 
						|
 | 
						|
typedef struct _ftm_dsr_table {
 | 
						|
    ftm_dsr_entry_t entry[MAC_DSR_MAX_ID];
 | 
						|
} ftm_dsr_table_t;
 | 
						|
 | 
						|
typedef struct _iot_ftm_global {
 | 
						|
    /* ftm task configuration */
 | 
						|
    iot_task_config_t   task_cfg;
 | 
						|
    /* ftm task handle */
 | 
						|
    iot_task_h          task_h;
 | 
						|
    /* pending command id */
 | 
						|
    uint16_t            cmd_id;
 | 
						|
    /* pending command total len */
 | 
						|
    uint16_t            cmd_total_len;
 | 
						|
    /* pending command received len */
 | 
						|
    uint16_t            cmd_recv_len;
 | 
						|
    /* pending command buffer cache */
 | 
						|
    uint8_t             cmd[IOT_FTM_CMD_MAX_LEN];
 | 
						|
    /* pending event id */
 | 
						|
    uint16_t            event_id;
 | 
						|
    /* pending event total len */
 | 
						|
    uint16_t            event_total_len;
 | 
						|
    /* pending event buffer cache */
 | 
						|
    uint8_t             event[IOT_FTM_EVENT_MAX_LEN];
 | 
						|
    /* used cmd cnt */
 | 
						|
    uint8_t             cmd_used_cnt;
 | 
						|
    /* mac dsr handler table */
 | 
						|
    ftm_dsr_table_t     dsr_table;
 | 
						|
    /* timer for watch dog reboot */
 | 
						|
    timer_id_t          wdg_timer;
 | 
						|
} iot_ftm_global_t;
 | 
						|
 | 
						|
/* ftm message */
 | 
						|
typedef struct _iot_ftm_msg {
 | 
						|
    /* iot task message */
 | 
						|
    iot_task_msg_t  task_msg;
 | 
						|
    /* pointer to message data */
 | 
						|
    void            *data;
 | 
						|
} iot_ftm_msg_t;
 | 
						|
 | 
						|
void iot_ftm_dsr_clear(uint32_t dsr);
 | 
						|
 | 
						|
/* ftm command handler function type
 | 
						|
 * @data:   command data buffer
 | 
						|
 * @len:    length of the data
 | 
						|
 */
 | 
						|
typedef void (*iot_ftm_cmd_func_t)(uint8_t *data, uint16_t len);
 | 
						|
 | 
						|
#ifndef INCLUDE_IOT_DTEST_FTM_MODE
 | 
						|
extern iot_ftm_global_t *p_ftm_glb;
 | 
						|
#endif
 | 
						|
 | 
						|
extern const iot_ftm_cmd_func_t p_ftm_cmd_table[IOT_FTM_CMD_ID_MAX];
 | 
						|
 | 
						|
void ftm_dsr_set_entry(ftm_dsr_table_t *table, uint8_t dsr_id,
 | 
						|
    ftm_dsr_func_t entry);
 | 
						|
 | 
						|
void ftm_dsr_set(uint32_t dsr);
 | 
						|
 | 
						|
void ftm_dsr_clear(uint32_t dsr);
 | 
						|
 | 
						|
 | 
						|
#ifdef __cplusplus
 | 
						|
}
 | 
						|
#endif
 | 
						|
 | 
						|
#endif /* IOT_FTM_INTERNAL_H */
 |