1139 lines
37 KiB
C
1139 lines
37 KiB
C
/**
|
|
****************************************************************************************
|
|
*
|
|
* @file rwip.h
|
|
*
|
|
* @brief RW IP SW main module
|
|
*
|
|
* Copyright (C) RivieraWaves 2009-2015
|
|
*
|
|
*
|
|
****************************************************************************************
|
|
*/
|
|
#ifndef _RWIP_H_
|
|
#define _RWIP_H_
|
|
|
|
/**
|
|
****************************************************************************************
|
|
* @addtogroup ROOT
|
|
* @brief Entry points of the RW IP stacks/modules
|
|
*
|
|
* This module contains the primitives that allow an application accessing and running the
|
|
* RW IP protocol stacks / modules.
|
|
*
|
|
* @{
|
|
****************************************************************************************
|
|
*/
|
|
|
|
/*
|
|
* INCLUDE FILES
|
|
****************************************************************************************
|
|
*/
|
|
#include "rwip_config.h" // stack configuration
|
|
|
|
#include <stdint.h> // standard integer definitions
|
|
#include <stdbool.h> // standard boolean definitions
|
|
#include "co_bt_defines.h"
|
|
|
|
#define __RAM_EM __attribute__((section("ram_em")))
|
|
#define KE_HEAP0 __attribute__((section("ke_heap0")))
|
|
#define KE_HEAP1 __attribute__((section("ke_heap1")))
|
|
/*
|
|
* DEFINES
|
|
****************************************************************************************
|
|
*/
|
|
/// Maximum value of a Bluetooth timestamp (in us)
|
|
#define RWIP_MAX_BTS_TIME (0xFFFFFFFF)
|
|
/// Maximum value of a Bluetooth clock (in 312.5us half slots)
|
|
#define RWIP_MAX_CLOCK_TIME ((1L<<28) - 1)
|
|
/// Maximum value of a 10ms Bluetooth clock
|
|
#define RWIP_MAX_10MS_TIME ((1L<<23) - 1)
|
|
/// Invalid target time
|
|
#define RWIP_INVALID_TARGET_TIME (0xFFFFFFFFL)
|
|
/// timer margin to ensure proper programming in microseconds
|
|
#define RWIP_BTS_TIMER_MARGIN (50)
|
|
/// timer margin to ensure proper programming in half microseconds
|
|
#define RWIP_TIMER_MARGIN_HUS (100)
|
|
/// Maximum additional random increment value (range 0-3)
|
|
#define RWIP_PRIO_MAX_RAND_INC (4)
|
|
|
|
#if (BLE_EMB_PRESENT && BLE_ISO_PRESENT)
|
|
/// Maximum simultaneous ISO timers
|
|
#define RWIP_ISO_TIMER_FIFO_DEPTH 5
|
|
#endif // (BLE_EMB_PRESENT && BLE_ISO_PRESENT)
|
|
|
|
/**
|
|
* Inverse an intra-half-slot value (in half-us), from/to following formats:
|
|
* - A: elapsed time from the previous half-slot (in half-us)
|
|
* - B: remaining time to the next half-slot (in half-us)
|
|
* The function from A to B or from B to A.
|
|
* ____________________________________________________________________________________________________
|
|
* Half-slot N-1 | Half-slot N | Half-slot N+1
|
|
* ____________________________|______________________________________|________________________________
|
|
* |<---------- A ---------->|<---- B --->|
|
|
* ____________________________|______________________________________|________________________________
|
|
*/
|
|
#define HALF_SLOT_INV(x) (HALF_SLOT_SIZE - x - 1)
|
|
#define __RAM_EM_CODE __attribute__((section("ram_em")))
|
|
|
|
/// result of sleep state.
|
|
enum rwip_sleep_state
|
|
{
|
|
/// Some activity pending, can not enter in sleep state
|
|
RWIP_ACTIVE = 0,
|
|
/// CPU can be put in sleep state
|
|
RWIP_CPU_SLEEP,
|
|
/// IP could enter in deep sleep
|
|
RWIP_DEEP_SLEEP,
|
|
};
|
|
|
|
|
|
/// Definition of the bits preventing the system from sleeping
|
|
enum prevent_sleep
|
|
{
|
|
/// Flag indicating that the wake up process is ongoing
|
|
RW_WAKE_UP_ONGOING = 0x0001,
|
|
/// Flag indicating that an TX transfer is ongoing on Transport Layer
|
|
RW_TL_TX_ONGOING = 0x0002,
|
|
/// Flag indicating that an RX transfer is ongoing on Transport Layer
|
|
RW_TL_RX_ONGOING = 0x0004,
|
|
/// Flag indicating the IP is in sleep, to avoid running sleep algorithm while already entering sleep
|
|
RW_DEEP_SLEEP = 0x0008,
|
|
/// Flag indicating that an encryption is ongoing
|
|
RW_CRYPT_ONGOING = 0x0010,
|
|
/// Flag indicating that controller shall not sleep due to not CSB LPO_Allowed
|
|
RW_CSB_NOT_LPO_ALLOWED = 0x0040,
|
|
/// Flag indicating the MWS/WLAN Event Generator is in operation
|
|
RW_MWS_WLAN_EVENT_GENERATOR_ACTIVE = 0x0080,
|
|
/// Flag to indicate that platform does not support deep sleep
|
|
RW_PLF_DEEP_SLEEP_DISABLED = 0x0100,
|
|
/// Flag to indicate that a baseband frame is ongoing
|
|
RW_BB_FRAME_ONGOING = 0x0200,
|
|
/// Flag to indicate that BLE Hopping computation on-going
|
|
RW_HOP_CALC_ONGOING = 0x0400,
|
|
/// Flag to indicate that BT is in active mode (ACL, SCO)
|
|
RW_BT_ACTIVE_MODE = 0x0800,
|
|
/// Flag to indicate that BLE requires active mode
|
|
RW_BLE_ACTIVE_MODE = 0x1000,
|
|
};
|
|
|
|
/// Parameters - Possible Returned Status
|
|
enum PARAM_STATUS
|
|
{
|
|
/// PARAM status OK
|
|
PARAM_OK,
|
|
/// generic PARAM status KO
|
|
PARAM_FAIL,
|
|
/// PARAM ID unrecognized
|
|
PARAM_ID_NOT_DEFINED,
|
|
/// No space for PARAM
|
|
PARAM_NO_SPACE_AVAILABLE,
|
|
/// Length violation
|
|
PARAM_LENGTH_OUT_OF_RANGE,
|
|
/// PARAM parameter locked
|
|
PARAM_PARAM_LOCKED,
|
|
/// PARAM corrupted
|
|
PARAM_CORRUPT
|
|
};
|
|
|
|
/**
|
|
* External interface type types.
|
|
*/
|
|
enum rwip_eif_types
|
|
{
|
|
/// Host Controller Interface - Controller part
|
|
RWIP_EIF_HCIC,
|
|
|
|
/// Host Controller Interface - Host part
|
|
RWIP_EIF_HCIH,
|
|
|
|
/// Application Host interface
|
|
RWIP_EIF_AHI,
|
|
};
|
|
|
|
|
|
/// Enumeration of External Interface status codes
|
|
enum rwip_eif_status
|
|
{
|
|
/// EIF status OK
|
|
RWIP_EIF_STATUS_OK,
|
|
/// EIF status KO
|
|
RWIP_EIF_STATUS_ERROR,
|
|
|
|
#if (BLE_EMB_PRESENT == 0)
|
|
/// External interface detached
|
|
RWIP_EIF_STATUS_DETACHED,
|
|
/// External interface attached
|
|
RWIP_EIF_STATUS_ATTACHED,
|
|
#endif // (BLE_EMB_PRESENT == 0)
|
|
};
|
|
|
|
/// Enumeration of RF modulations
|
|
enum rwip_rf_mod
|
|
{
|
|
MOD_GFSK = 0x01,
|
|
MOD_DQPSK = 0x02,
|
|
MOD_8DPSK = 0x03,
|
|
};
|
|
|
|
/// Enumeration of txpwr_cs_get search options
|
|
enum rwip_txpwr_cs_get_opt
|
|
{
|
|
TXPWR_CS_LOWER,
|
|
TXPWR_CS_HIGHER,
|
|
TXPWR_CS_NEAREST,
|
|
};
|
|
|
|
#if RW_DEBUG
|
|
/// Assert type
|
|
/*@TRACE*/
|
|
enum assert_type
|
|
{
|
|
ASSERT_TYPE_WARNING = 0,
|
|
ASSERT_TYPE_ERROR = 1,
|
|
};
|
|
#endif //RW_DEBUG
|
|
|
|
/// Types of initialization of the IP
|
|
enum rwip_init_type
|
|
{
|
|
/// IP initialization
|
|
RWIP_INIT = 0,
|
|
/// IP first reset (done once after initialization, before protocol stack is used)
|
|
RWIP_1ST_RST,
|
|
/// Normal IP reset (can be done at any time when protocol stack is in use)
|
|
RWIP_RST,
|
|
};
|
|
|
|
|
|
/*
|
|
* TYPE DEFINITIONS
|
|
****************************************************************************************
|
|
*/
|
|
|
|
/// Time information
|
|
/*@TRACE*/
|
|
typedef struct
|
|
{
|
|
/// Integer part of the time (in half-slot)
|
|
uint32_t hs;
|
|
/// Fractional part of the time (in half-us) (range: 0-624)
|
|
uint16_t hus;
|
|
/// Bluetooth timestamp value (in us) 32 bits counter
|
|
uint32_t bts;
|
|
} rwip_time_t;
|
|
|
|
|
|
/// Time information
|
|
/*@TRACE*/
|
|
typedef struct
|
|
{
|
|
/// Integer part of the time (in half-slot)
|
|
uint32_t hs;
|
|
/// Fractional part of the time (in half-us) (range: 0-624)
|
|
uint16_t hus;
|
|
} rwip_tgt_timer_t;
|
|
|
|
/// API functions of the RF driver that are used by the BLE or BT software
|
|
struct rwip_rf_api
|
|
{
|
|
/// Function called upon HCI reset command reception
|
|
void (*reset)(void);
|
|
/// Function called to enable/disable force AGC mechanism (true: en / false : dis)
|
|
void (*force_agc_enable)(bool);
|
|
/// Function called when TX power has to be decreased for a specific link id
|
|
bool (*txpwr_dec)(uint8_t);
|
|
/// Function called when TX power has to be increased for a specific link id
|
|
bool (*txpwr_inc)(uint8_t);
|
|
/// Function called when TX power has to be set to max for a specific link id
|
|
void (*txpwr_max_set)(uint8_t);
|
|
/// Function called to convert a TX power CS power field into the corresponding value in dBm
|
|
int8_t (*txpwr_dbm_get)(uint8_t, uint8_t);
|
|
/// Function called to convert a power in dBm into a control structure tx power field
|
|
uint8_t (*txpwr_cs_get)(int8_t, uint8_t);
|
|
/// Function called to convert the RSSI read from the control structure into a real RSSI
|
|
int8_t (*rssi_convert)(uint8_t);
|
|
/// Function used to read a RF register
|
|
uint32_t (*reg_rd)(uint32_t);
|
|
/// Function used to write a RF register
|
|
void (*reg_wr)(uint32_t, uint32_t);
|
|
/// Function called to put the RF in deep sleep mode
|
|
void (*sleep)(void);
|
|
/// Index of minimum TX power
|
|
uint8_t txpwr_min;
|
|
/// Index of maximum TX power
|
|
uint8_t txpwr_max;
|
|
/// RSSI high threshold ('real' signed value in dBm)
|
|
int8_t rssi_high_thr;
|
|
/// RSSI low threshold ('real' signed value in dBm)
|
|
int8_t rssi_low_thr;
|
|
/// interferer threshold ('real' signed value in dBm)
|
|
int8_t rssi_interf_thr;
|
|
/// RF wakeup delay (in slots)
|
|
uint8_t wakeup_delay;
|
|
};
|
|
|
|
/// API functions of the parameters that are used by the BLE or BT software
|
|
struct rwip_param_api
|
|
{
|
|
/**
|
|
* Get a parameter value
|
|
* @param[in] param_id Parameter identifier
|
|
* @param[in/out] lengthPtr Pointer to the length of the parameter (input: contain max length, output contain the effective param length, in bytes)
|
|
* @param[out] buf Pointer to the buffer be filled with the parameter value
|
|
* @return status 0: success | >0 : error
|
|
*/
|
|
uint8_t (*get) (uint8_t param_id, uint8_t * lengthPtr, uint8_t *buf);
|
|
|
|
/**
|
|
* Set a parameter value
|
|
* @param[in] param_id Parameter identifier
|
|
* @param[in/out] length Length of the parameter (in bytes)
|
|
* @param[out] buf Pointer to the buffer containing the parameter value
|
|
* @return status 0: success | >0 : error
|
|
*/
|
|
uint8_t (*set) (uint8_t param_id, uint8_t length, uint8_t *buf);
|
|
|
|
/**
|
|
* Delete a parameter
|
|
* @param[in] param_id Parameter identifier
|
|
* @return status 0: success | >0 : error
|
|
*/
|
|
uint8_t (*del) (uint8_t param_id);
|
|
};
|
|
|
|
/// Internal API for priority
|
|
struct rwip_prio
|
|
{
|
|
///value
|
|
uint8_t value;
|
|
///Increment
|
|
uint8_t increment;
|
|
};
|
|
|
|
/**
|
|
****************************************************************************************
|
|
* @brief Function called when packet transmission/reception is finished.
|
|
|
|
* @param[in] dummy Dummy data pointer returned to callback when operation is over.
|
|
* @param[in] status Ok if action correctly performed, else reason status code.
|
|
*****************************************************************************************
|
|
*/
|
|
typedef void (*rwip_eif_callback) (void*, uint8_t);
|
|
|
|
/**
|
|
* Transport layer communication interface.
|
|
*/
|
|
struct rwip_eif_api
|
|
{
|
|
/**
|
|
*************************************************************************************
|
|
* @brief Starts a data reception.
|
|
*
|
|
* @param[out] bufptr Pointer to the RX buffer
|
|
* @param[in] size Size of the expected reception
|
|
* @param[in] callback Pointer to the function called back when transfer finished
|
|
* @param[in] dummy Dummy data pointer returned to callback when reception is finished
|
|
*************************************************************************************
|
|
*/
|
|
void (*read) (uint8_t *bufptr, uint32_t size, rwip_eif_callback callback, void* dummy);
|
|
|
|
/**
|
|
*************************************************************************************
|
|
* @brief Starts a data transmission.
|
|
*
|
|
* @param[in] bufptr Pointer to the TX buffer
|
|
* @param[in] size Size of the transmission
|
|
* @param[in] callback Pointer to the function called back when transfer finished
|
|
* @param[in] dummy Dummy data pointer returned to callback when transmission is finished
|
|
*************************************************************************************
|
|
*/
|
|
void (*write)(uint8_t *bufptr, uint32_t size, rwip_eif_callback callback, void* dummy);
|
|
|
|
/**
|
|
*************************************************************************************
|
|
* @brief Enable Interface flow.
|
|
*************************************************************************************
|
|
*/
|
|
void (*flow_on)(void);
|
|
|
|
/**
|
|
*************************************************************************************
|
|
* @brief Disable Interface flow.
|
|
*
|
|
* @return True if flow has been disabled, False else.
|
|
*************************************************************************************
|
|
*/
|
|
bool (*flow_off)(void);
|
|
};
|
|
|
|
|
|
#if (BLE_EMB_PRESENT && BLE_ISO_PRESENT)
|
|
|
|
/**
|
|
*************************************************************************************
|
|
* @brief Callback definition to inform that a timer as elapsed
|
|
*
|
|
* @param[in] tgt_bts Target bluetooth timestamp configured
|
|
*************************************************************************************
|
|
*/
|
|
typedef void (*rwip_iso_timer_cb) (uint32_t tgt_bts);
|
|
#endif // (BLE_EMB_PRESENT && BLE_ISO_PRESENT)
|
|
typedef uint16_t ke_msg_id_t;
|
|
typedef uint16_t ke_task_id_t;
|
|
|
|
|
|
struct rom_env_tag
|
|
{
|
|
//#if(BLE_HOST_PRESENT)
|
|
// ke_task_id_t (*prf_get_id_from_task)(ke_msg_id_t task);
|
|
// ke_task_id_t (*prf_get_task_from_id)(ke_msg_id_t id);
|
|
|
|
void (*prf_init)(uint8_t reset);
|
|
void (*prf_create)(uint8_t conidx);
|
|
void (*prf_cleanup)(uint8_t conidx, uint8_t reason);
|
|
|
|
uint8_t (*prf_add_profile)(uint8_t api_id, uint8_t sec_lvl, uint8_t user_prio, const void* p_params, const void* p_cb,
|
|
uint16_t* p_start_hdl);
|
|
//#endif
|
|
|
|
// void (*rwip_reset)(void);
|
|
|
|
void (*platform_reset)(uint32_t error);
|
|
|
|
void (*rwble_sleep_wakeup_end)(void);
|
|
int (*stack_printf)(const char *fmt,...);
|
|
uint8_t (*gapc_get_conidx)(uint16_t conhdl);
|
|
void (*rwble_hl_init)(uint8_t init_type);
|
|
//void(*assert_err) (const char *condition, const char * file, int line);
|
|
//void(*assert_param)(int param0, int param1, const char * file, int line);
|
|
//void (*assert_warn)(int param0, int param1, const char * file, int line);
|
|
|
|
//uint8_t (*Read_Uart_Buf)(void);
|
|
//void (*uart_clear_rxfifo)(void);
|
|
int (*rom_hci_command_llc_handler)(ke_msg_id_t const msgid, uint16_t const *param, ke_task_id_t const dest_id, ke_task_id_t const src_id);
|
|
struct ke_task_desc * rom_TASK_DESC_LLC;
|
|
struct llcp_pdu_handler_info * rom_llcp_pdu_handler;
|
|
void (*ecc_init)(uint8_t init_type);
|
|
void (*llm_init)(uint8_t init_type);
|
|
void (*llm_le_features_get)(struct le_features *feats);
|
|
struct le_chnl_map* (*llm_master_ch_map_get)(void);
|
|
bool (*llm_le_evt_mask_check)(uint8_t event_id);
|
|
struct sch_plan_elt_tag *(*llm_plan_elt_get)(uint8_t act_id);
|
|
void (*llm_link_disc)(uint8_t link_id);
|
|
int16_t (*llm_rx_path_comp_get)(void);
|
|
void (*hci_init)(uint8_t init_type);
|
|
void (*hci_send_2_host)(void *param);
|
|
void (*stack_mem_init)();
|
|
void (*stack_mem_co_buf_init)(uint8_t rwip_rst_state);
|
|
void (*ip_err_handler)(uint32_t err);
|
|
|
|
void (*llc_disconnect)(uint8_t link_id, uint8_t reason, bool immediate);
|
|
void (*llc_init_term_proc)(uint8_t link_id, uint8_t reason);
|
|
bool clck_rc32k;
|
|
uint16_t enable_activity_num;
|
|
uint16_t enable_adv_activity_num;
|
|
uint8_t adv_buf_num;
|
|
uint16_t max_adv_buffer_size;
|
|
uint16_t em_ble_rx_buf_num;
|
|
uint16_t max_rx_buffer_size;
|
|
uint16_t em_ble_tx_buf_num;
|
|
uint16_t em_ble_tx_desc_num;
|
|
uint16_t max_tx_buffer_size ;
|
|
uint8_t co_buf_big_nb;
|
|
uint8_t co_buf_small_nb;
|
|
};
|
|
|
|
enum {
|
|
BLE_HANDLER_ID,
|
|
HCI_ACL_DATA_HANDLER_ID,
|
|
HCI_RD_RSSI_CMD_HANDLER_ID,
|
|
KE_CHECK_MALLOC_ID,
|
|
KE_EVENT_SCHEDULE_ID,
|
|
KE_FREE_ID,
|
|
KE_HANDLER_SEARCH_ID,
|
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
LLD_CON_TX_PROG_ID,
|
|
LLD_CORE_INIT_ID,
|
|
LLD_INIT_ID,
|
|
LLD_INIT_COMPUTE_WINOFFSET_ID,
|
|
LLD_INIT_CONNECT_REQ_PACK_ID,
|
|
LLD_INIT_END_ID,
|
|
LLD_INIT_EVT_CANCELED_CBK_ID,
|
|
LLD_INIT_EVT_START_CBK_ID,
|
|
LLD_INIT_FRM_CBK_ID,
|
|
LLD_INIT_FRM_EOF_ISR_ID,
|
|
LLD_INIT_FRM_SKIP_ISR_ID,
|
|
LLD_INIT_INIT_ID,
|
|
LLD_INIT_PROCESS_PKT_RX_ID,
|
|
LLD_INIT_PROCESS_PKT_TX_ID,
|
|
LLD_INIT_SCHED_ID,
|
|
LLD_INIT_START_ID,
|
|
LLD_INIT_STOP_ID,
|
|
LLD_INSTANT_PROC_END_ID,
|
|
LLD_LLCP_RX_IND_HANDLER_ID,
|
|
LLD_LLCP_TX_CFM_HANDLER_ID,
|
|
LLD_PER_ADV_LIST_ADD_ID,
|
|
LLD_PER_ADV_LIST_REM_ID,
|
|
LLD_RAL_SEARCH_ID,
|
|
LLD_RES_LIST_ADD_ID,
|
|
LLD_RES_LIST_LOCAL_RPA_GET_ID,
|
|
LLD_RES_LIST_PEER_RPA_GET_ID,
|
|
LLD_RES_LIST_PEER_UPDATE_ID,
|
|
LLD_RES_LIST_PRIV_MODE_UPDATE_ID,
|
|
LLD_RES_LIST_REM_ID,
|
|
LLD_RPA_RENEW_ID,
|
|
LLD_RPA_RENEW_EVT_CANCELED_CBK_ID,
|
|
LLD_RPA_RENEW_EVT_START_CBK_ID,
|
|
LLD_RPA_RENEW_INSTANT_CBK_ID,
|
|
LLD_RXDESC_BUF_READY_ID,
|
|
LLD_RXDESC_CHECK_ID,
|
|
LLD_RXDESC_FREE_ID,
|
|
LLD_SCAN_END_ID,
|
|
LLD_SCAN_EVT_CANCELED_CBK_ID,
|
|
LLD_SCAN_EVT_START_CBK_ID,
|
|
LLD_SCAN_FRM_CBK_ID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L_UPD_PROC_CONTINUE_ID,
|
|
LLC_REM_DL_UPD_PROC_ID,
|
|
RWIP_WAKEUP_ID,
|
|
RWIP_WAKEUP_END_ID,
|
|
BLE_UTIL_BUF_ACL_TX_ALLOC_ID,
|
|
BLE_UTIL_BUF_ACL_TX_ELT_GET_ID,
|
|
BLE_UTIL_BUF_ACL_TX_FREE_ID,
|
|
BLE_UTIL_BUF_ADV_TX_ALLOC_ID,
|
|
BLE_UTIL_BUF_ADV_TX_FREE_ID,
|
|
BLE_UTIL_BUF_INIT_ID,
|
|
BLE_UTIL_BUF_LLCP_TX_ALLOC_ID,
|
|
BLE_UTIL_BUF_LLCP_TX_FREE_ID,
|
|
BLE_UTIL_BUF_RX_ALLOC_ID,
|
|
BLE_UTIL_BUF_RX_FREE_ID,
|
|
MAX_PATCH_NUM,
|
|
};
|
|
|
|
/*
|
|
* VARIABLE DECLARATION
|
|
*****************************************************************************************
|
|
*/
|
|
extern void * PATCH_FUN[MAX_PATCH_NUM];
|
|
extern struct rom_env_tag rom_env;
|
|
/// API for RF driver
|
|
extern struct rwip_rf_api rwip_rf;
|
|
/// API for parameters
|
|
extern struct rwip_param_api rwip_param;
|
|
extern struct ke_task_desc rom_TASK_DESC_LLC;
|
|
#if (BLE_EMB_PRESENT || BT_EMB_PRESENT)
|
|
/// API for dual mode priority
|
|
extern const struct rwip_prio rwip_priority[RWIP_PRIO_IDX_MAX];
|
|
#if (RW_WLAN_COEX || RW_MWS_COEX)
|
|
/// API for COEX configuration
|
|
extern const uint8_t rwip_coex_cfg[RWIP_COEX_CFG_MAX];
|
|
#endif //(RW_WLAN_COEX || RW_MWS_COEX)
|
|
/// Programming delay, margin for programming the baseband in advance of each activity (in half-slots)
|
|
extern uint8_t rwip_prog_delay;
|
|
#endif //(BT_EMB_PRESENT || BLE_EMB_PRESENT)
|
|
|
|
/*
|
|
* MACROS
|
|
****************************************************************************************
|
|
*/
|
|
|
|
/// Get Event status flag
|
|
#if (BT_EMB_PRESENT || BLE_EMB_PRESENT)
|
|
#define RWIP_PRIO_INC(prio_idx) (rwip_priority[prio_idx].increment + CO_MOD(co_rand_byte(), RWIP_PRIO_MAX_RAND_INC))
|
|
#if (RW_WLAN_COEX || RW_MWS_COEX)
|
|
#define RWIP_COEX_GET(coex_cfg_idx, bit_field) \
|
|
(uint8_t)(((rwip_coex_cfg[RWIP_COEX_ ## coex_cfg_idx ##_IDX]) >> RWIP_ ## bit_field ## _POS ) & RWIP_COEX_BIT_MASK)
|
|
#else //!(RW_WLAN_COEX || RW_MWS_COEX)
|
|
#define RWIP_COEX_GET(coex_cfg_idx, bit_field) 0
|
|
#endif //(RW_WLAN_COEX || RW_MWS_COEX)
|
|
#endif //(BT_EMB_PRESENT || BLE_EMB_PRESENT)
|
|
|
|
/*
|
|
* FUNCTION DECLARATION
|
|
*****************************************************************************************
|
|
*/
|
|
|
|
/**
|
|
****************************************************************************************
|
|
* @brief Initializes the RW BT SW.
|
|
*
|
|
****************************************************************************************
|
|
*/
|
|
void rwip_init(uint32_t error);
|
|
|
|
/**
|
|
****************************************************************************************
|
|
* @brief Reset the RW BT SW.
|
|
*
|
|
****************************************************************************************
|
|
*/
|
|
void rwip_reset(void);
|
|
|
|
|
|
|
|
#if (BT_EMB_PRESENT)
|
|
|
|
#if PCA_SUPPORT
|
|
/**
|
|
****************************************************************************************
|
|
* @brief Check if clock dragging limitation
|
|
*
|
|
* @return true if clock dragging must be used
|
|
****************************************************************************************
|
|
*/
|
|
bool rwip_pca_clock_dragging_only(void);
|
|
#endif //PCA_SUPPORT
|
|
#endif // (BT_EMB_PRESENT)
|
|
|
|
#if (BT_EMB_PRESENT || BLE_EMB_PRESENT)
|
|
#if (RW_MWS_COEX)
|
|
/**
|
|
****************************************************************************************
|
|
* @brief Enable/Disable the MWS coexistence interface.
|
|
*
|
|
* @param[in] CoexSetting Coexistence value
|
|
*
|
|
****************************************************************************************
|
|
*/
|
|
void rwip_mwscoex_set(bool state);
|
|
#endif //RW_MWS_COEX
|
|
|
|
#if (RW_WLAN_COEX)
|
|
/**
|
|
****************************************************************************************
|
|
* @brief Enable/Disable the Wireless LAN coexistence interface.
|
|
*
|
|
* @param[in] CoexSetting Coexistence value
|
|
*
|
|
****************************************************************************************
|
|
*/
|
|
void rwip_wlcoex_set(bool state);
|
|
#endif //RW_WLAN_COEX
|
|
#endif //(BT_EMB_PRESENT || BLE_EMB_PRESENT)
|
|
|
|
/**
|
|
****************************************************************************************
|
|
* @brief Function to implement in platform in order to retrieve each external interface API
|
|
*
|
|
* @param[in] idx External interface index
|
|
*
|
|
* @return External interface api structure
|
|
****************************************************************************************
|
|
*/
|
|
extern const struct rwip_eif_api* rwip_eif_get(uint8_t idx);
|
|
|
|
#if RW_DEBUG
|
|
/**
|
|
****************************************************************************************
|
|
* @brief Raises an assertion message to the control interface (if present)
|
|
*
|
|
* @param[in] file File name
|
|
* @param[in] line Line number
|
|
* @param[in] param0 Parameter 0 (custom value given by the assert instruction)
|
|
* @param[in] param1 Parameter 1 (custom value given by the assert instruction)
|
|
* @param[in] type 0: warning / 1: error
|
|
****************************************************************************************
|
|
*/
|
|
void rwip_assert(const char * file, int line, int param0, int param1, uint8_t type);
|
|
#endif //RW_DEBUG
|
|
|
|
|
|
/* **************************************************************************************
|
|
* Driver functions
|
|
* **************************************************************************************
|
|
*/
|
|
|
|
/**
|
|
****************************************************************************************
|
|
* @brief Retrieved sampled time
|
|
*
|
|
* @note Shall be called within a critical section
|
|
*
|
|
* @return current time sampled (@see rwip_time_t)
|
|
****************************************************************************************
|
|
*/
|
|
rwip_time_t rwip_time_get(void);
|
|
|
|
|
|
#if (BT_EMB_PRESENT)
|
|
/**
|
|
****************************************************************************************
|
|
* @brief Set current time
|
|
*
|
|
* @param clock value in half-slots
|
|
****************************************************************************************
|
|
*/
|
|
void rwip_time_set(uint32_t clock);
|
|
|
|
/**
|
|
****************************************************************************************
|
|
* @brief Adjust current time
|
|
*
|
|
* @param adjustment value in us
|
|
****************************************************************************************
|
|
*/
|
|
void rwip_time_adj(int16_t clk_adj_us);
|
|
#endif // (BT_EMB_PRESENT)
|
|
|
|
/**
|
|
****************************************************************************************
|
|
* @brief Set the common target timer
|
|
*
|
|
* @note if target is RWIP_INVALID_TARGET_TIME, no timer is programmed
|
|
*
|
|
* @param[in] target_bts 1us Timer target value (in microseconds)
|
|
****************************************************************************************
|
|
*/
|
|
void rwip_timer_co_set(uint32_t target_bts);
|
|
|
|
#if (BLE_EMB_PRESENT || BT_EMB_PRESENT)
|
|
/**
|
|
****************************************************************************************
|
|
* @brief Set the an alarm target timer
|
|
*
|
|
* @note if target is RWIP_INVALID_TARGET_TIME, no timer is programmed
|
|
*
|
|
* @param[in] target Half Slot Timer target value
|
|
* @param[in] half_us_delay Half us timer delay in corresponding half slot (range [0:624])
|
|
****************************************************************************************
|
|
*/
|
|
void rwip_timer_alarm_set(uint32_t target, uint32_t half_us_delay);
|
|
|
|
/**
|
|
****************************************************************************************
|
|
* @brief Set the an Arbiter target timer
|
|
*
|
|
* @note if target is RWIP_INVALID_TARGET_TIME, no timer is programmed
|
|
*
|
|
* @param[in] target Half Slot Timer target value
|
|
* @param[in] half_us_delay Half us timer delay in corresponding half slot (range [0:624])
|
|
****************************************************************************************
|
|
*/
|
|
void rwip_timer_arb_set(uint32_t target, uint32_t half_us_delay);
|
|
#endif // (BLE_EMB_PRESENT || BT_EMB_PRESENT)
|
|
|
|
/**
|
|
****************************************************************************************
|
|
* @brief Start AES encryption
|
|
*
|
|
* The exchange memory must be filled before calling this function.
|
|
* This function expect to be called from a BLE Module
|
|
*
|
|
* @param[in] key AES Encryption key must be 16 bytes
|
|
* @param[in] val 16 bytes value array to encrypt using AES
|
|
****************************************************************************************
|
|
*/
|
|
void rwip_aes_encrypt(const uint8_t *key, const uint8_t* val);
|
|
|
|
#if (BLE_EMB_PRESENT || BT_EMB_PRESENT)
|
|
/**
|
|
****************************************************************************************
|
|
* @brief Request a Software interrupt to be triggered
|
|
****************************************************************************************
|
|
*/
|
|
void rwip_sw_int_req(void);
|
|
#endif // (BLE_EMB_PRESENT || BT_EMB_PRESENT)
|
|
|
|
/**
|
|
****************************************************************************************
|
|
* @brief Invoke the sleep function.
|
|
*
|
|
* @return sleep status (@see enum rwip_sleep_state)
|
|
****************************************************************************************
|
|
*/
|
|
uint8_t rwip_sleep(uint32_t *duration, uint8_t wake_up_early, uint32_t max_sleep_time, uint8_t min_duratin);
|
|
|
|
|
|
#if (BLE_EMB_PRESENT || BT_EMB_PRESENT)
|
|
/**
|
|
****************************************************************************************
|
|
* @brief Handle the common core interrupts.
|
|
****************************************************************************************
|
|
*/
|
|
void rwip_isr(void);
|
|
#endif // (BLE_EMB_PRESENT || BT_EMB_PRESENT)
|
|
|
|
#if (BLE_EMB_PRESENT && BT_EMB_PRESENT)
|
|
/**
|
|
****************************************************************************************
|
|
* @brief Handle the btdm-specific core interrupts.
|
|
****************************************************************************************
|
|
*/
|
|
void rwip_btdm_isr(void);
|
|
#endif // (BLE_EMB_PRESENT && BT_EMB_PRESENT)
|
|
|
|
/**
|
|
****************************************************************************************
|
|
* @brief Set a bit in the prevent sleep bit field, in order to prevent the system from
|
|
* going to sleep
|
|
*
|
|
* @param[in] prv_slp_bit Bit to be set in the prevent sleep bit field
|
|
****************************************************************************************
|
|
*/
|
|
void rwip_prevent_sleep_set(uint16_t prv_slp_bit);
|
|
|
|
/**
|
|
****************************************************************************************
|
|
* @brief Clears a bit in the prevent sleep bit field, in order to allow the system
|
|
* going to sleep
|
|
*
|
|
* @param[in] prv_slp_bit Bit to be cleared in the prevent sleep bit field
|
|
****************************************************************************************
|
|
*/
|
|
void rwip_prevent_sleep_clear(uint16_t prv_slp_bit);
|
|
|
|
#if (BLE_EMB_PRESENT || BT_EMB_PRESENT)
|
|
/**
|
|
****************************************************************************************
|
|
* @brief Check if the system is permanently active (e.g. for BT ACL connection)
|
|
*
|
|
* @return false: system might sleep | true: system stays active
|
|
****************************************************************************************
|
|
*/
|
|
bool rwip_active_check(void);
|
|
#endif // (BLE_EMB_PRESENT || BT_EMB_PRESENT)
|
|
|
|
/**
|
|
****************************************************************************************
|
|
* @brief Schedule all pending events.
|
|
*
|
|
****************************************************************************************
|
|
*/
|
|
void rwip_schedule(void);
|
|
|
|
|
|
#if (BLE_EMB_PRESENT && BLE_ISO_PRESENT)
|
|
/**
|
|
****************************************************************************************
|
|
* @brief Handle the ISO Bluetooth timestamp interrupts.
|
|
****************************************************************************************
|
|
*/
|
|
void rwip_bts_isr(void);
|
|
|
|
/**
|
|
****************************************************************************************
|
|
* @brief Program an ISO timer
|
|
*
|
|
* Note: Function should be called under interrupt context.
|
|
* New timer must target later than the previous one
|
|
*
|
|
* @param[in] tgt_bts Targeted Bluetooth Timestamp
|
|
****************************************************************************************
|
|
*/
|
|
void rwip_iso_timer_set(uint32_t tgt_bts);
|
|
|
|
/**
|
|
****************************************************************************************
|
|
* @brief Clear ISO timers
|
|
*
|
|
* Note: Function should be called under interrupt context.
|
|
****************************************************************************************
|
|
*/
|
|
void rwip_iso_timer_clear();
|
|
|
|
#endif // (BLE_EMB_PRESENT && BLE_ISO_PRESENT)
|
|
|
|
/**
|
|
****************************************************************************************
|
|
* @brief Convert Bluetooth time provided in parameters to a Bluetooth timestamp value
|
|
*
|
|
* @param[in] hs Bluetooth time in half slot
|
|
* @param[in] hus Bluetooth time in half microseconds
|
|
*
|
|
* @return Bluetooth timestamp in microseconds
|
|
****************************************************************************************
|
|
*/
|
|
uint32_t rwip_bt_time_to_bts(uint32_t hs, uint16_t hus);
|
|
|
|
/**
|
|
****************************************************************************************
|
|
* @brief Convert Bluetooth timestamp value to Bluetooth time
|
|
*
|
|
* @param[in] bts Bluetooth timestamp
|
|
* @param[out] p_hs Bluetooth time in half slot
|
|
* @param[out] p_hus Bluetooth time in half microseconds
|
|
****************************************************************************************
|
|
*/
|
|
void rwip_bts_to_bt_time(uint32_t bts, uint32_t* p_hs, uint16_t* p_hus);
|
|
|
|
|
|
|
|
///@} ROOT
|
|
|
|
|
|
#define readb(addr) (*(volatile unsigned char *) (addr))
|
|
#define readw(addr) (*(volatile unsigned short *) (addr))
|
|
#define readl(addr) (*(volatile unsigned int *) (addr))
|
|
|
|
#define writeb(addr, value) (*(volatile unsigned char *) (addr) = (value))
|
|
#define writew(addr, value) (*(volatile unsigned short *) (addr) = (value))
|
|
#define writel(addr, value) (*(volatile unsigned int *) (addr) = (value))
|
|
|
|
#ifdef BT_SIMULATION
|
|
#define writel_x(addr,value) \
|
|
do{ \
|
|
char *ptr = value; \
|
|
writel(addr,*ptr); \
|
|
writel(addr,*(ptr + 1)); \
|
|
writel(addr,'\n'); \
|
|
}while(0)
|
|
#else
|
|
#define writel_x
|
|
#endif
|
|
|
|
#endif // _RWIP_H_
|