This commit is contained in:
2024-07-12 15:19:46 +08:00
commit 7ca1af130d
895 changed files with 282694 additions and 0 deletions
+479
View File
@@ -0,0 +1,479 @@
/**
****************************************************************************************
*
* @file hci.h
*
* @brief This file contains definitions related to the HCI module.
*
* Copyright (C) RivieraWaves 2009-2015
*
*
****************************************************************************************
*/
#ifndef HCI_H_
#define HCI_H_
/**
****************************************************************************************
* @addtogroup HCI Host Controller Interface
* @ingroup ROOT
* @brief HCI module handling communication between lower and higher layers in split
* architecture.
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "rwip_config.h" // SW configuration
#if (HCI_PRESENT)
#include <stddef.h> // standard definition
#include <stdint.h> // standard integer
#include "co_bt.h" // BT standard definitions
#include "rwip_task.h" // Task definitions
/*
* DEFINES
****************************************************************************************
*/
#if (BLE_EMB_PRESENT || BLE_HOST_PRESENT)
#if (BLE_CENTRAL || BLE_PERIPHERAL)
#define HCI_BLE_CON_SUPPORT 1
#else // (BLE_CENTRAL || BLE_PERIPHERAL)
#define HCI_BLE_CON_SUPPORT 0
#endif // (BLE_CENTRAL || BLE_PERIPHERAL)
#else //(BLE_EMB_PRESENT || BLE_HOST_PRESENT)
#define HCI_BLE_CON_SUPPORT 0
#endif //(BLE_EMB_PRESENT || BLE_HOST_PRESENT)
/// Length of HCI Reset Message
#define HCI_RESET_MSG_LEN 4
/// HCI Reset Message use to resync.
#define HCI_RESET_MSG_BUF {HCI_CMD_MSG_TYPE, (HCI_RESET_CMD_OPCODE & 0xFF), ((HCI_RESET_CMD_OPCODE >> 8) & 0xFF), 0}
/*
* TYPE DEFINITIONS
****************************************************************************************
*/
/// Message API of the HCI task
/*@TRACE*/
enum hci_msg_id
{
HCI_MSG_ID_FIRST = TASK_FIRST_MSG(TASK_ID_HCI),
HCI_CMD_CMP_EVENT,
HCI_CMD_STAT_EVENT,
HCI_EVENT,
#if (BLE_EMB_PRESENT || BLE_HOST_PRESENT)
HCI_LE_EVENT,
#if BLE_ISO_PRESENT
HCI_ISO_DATA,
#endif //BLE_ISO_PRESENT
#endif //(BLE_EMB_PRESENT || BLE_HOST_PRESENT)
HCI_COMMAND,
#if (HCI_BLE_CON_SUPPORT || BT_EMB_PRESENT)
HCI_ACL_DATA,
#endif // (HCI_BLE_CON_SUPPORT)
#if BT_EMB_PRESENT
#if VOICE_OVER_HCI
HCI_SYNC_DATA,
#endif //VOICE_OVER_HCI
#endif //BT_EMB_PRESENT
HCI_DBG_EVT,
HCI_MSG_ID_LAST
};
/// Status of HCI command header processing
enum HCI_CMD_HDR
{
/// Header is correct
HCI_CMD_HDR_STATUS_OK,
/// Opcode is unknown
HCI_CMD_HDR_STATUS_UNKNOWN,
/// Header is not correct
HCI_CMD_HDR_STATUS_FAIL
};
/*
* GLOBAL VARIABLE DECLARATIONS
****************************************************************************************
*/
/*
* FUNCTION DECLARATIONS
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Initialize HCI (including transport)
*
* @param[in] init_type Type of initialization (@see enum rwip_init_type)
*****************************************************************************************
*/
void hci_init(uint8_t init_type);
#if (BLE_EMB_PRESENT || BT_EMB_PRESENT)
/**
****************************************************************************************
* @brief Function called when an internal task needs to send a HCI message to Host
*
* This function decides whether the message is sent externally onto HCI Transport Layer
* or redirected into an internal task of the other side of the HCI.
*
* The input message ID, length and parameters must be filled.
* In case the message is an HCI command or event, the source ID must be filled with the
* command opcode or event code.
* In case the message concerns a particular BT or BLE link, the destination ID must be
* filled with the associated link ID.
*
* @param[in] param Pointer to the parameters of the Kernel message carrying the HCI message
*****************************************************************************************
*/
void hci_send_2_host(void *param);
#endif // (BLE_EMB_PRESENT || BT_EMB_PRESENT)
#if BLE_HOST_PRESENT
/**
****************************************************************************************
* @brief Function called when an internal task needs to send a HCI message to Controller
*
* This function decides whether the message is sent externally onto HCI Transport Layer
* or redirected into an internal task of the other side of the HCI.
*
* The input message ID, length and parameters must be filled.
* In case the message is an HCI command or event, the source ID must be filled with the
* command opcode or event code.
* In case the message concerns a particular BT or BLE link, the destination ID must be
* filled with the associated link ID.
*
* @param[in] param Pointer to the parameters of the Kernel message carrying the HCI message
*****************************************************************************************
*/
void hci_send_2_controller(void *param);
/**
****************************************************************************************
* @brief function used to send a basic command, without parameters to the controller.
*
* @param[in] opcode Operation code of the command
*****************************************************************************************
*/
void hci_basic_cmd_send_2_controller(uint16_t opcode);
#endif //BLE_HOST_PRESENT
#if (BLE_EMB_PRESENT && HCI_BLE_CON_SUPPORT)
/**
****************************************************************************************
* @brief Register connection handle for a BLE connection
*
* @param[in] link_id BLE connection link ID
*****************************************************************************************
*/
void hci_ble_conhdl_register(uint8_t link_id);
/**
****************************************************************************************
* @brief Unregister a BLE connection
*
* @param[in] link_id BLE connection link ID
*****************************************************************************************
*/
void hci_ble_conhdl_unregister(uint8_t link_id);
#endif //(BLE_EMB_PRESENT && !BLE_HOST_PRESENT && HCI_BLE_CON_SUPPORT)
#if (BT_EMB_PRESENT)
/**
****************************************************************************************
* @brief Register BD address for a BT ACL connection
*
* @param[in] link_id BT ACL connection link ID
* @param[in] bd_addr Pointer to the device BD address associated to the connection
*****************************************************************************************
*/
void hci_bt_acl_bdaddr_register(uint8_t link_id, struct bd_addr* bd_addr);
/**
****************************************************************************************
* @brief Register connection handle for a BT ACL connection
*
* @param[in] link_id BT ACL connection link ID
*****************************************************************************************
*/
void hci_bt_acl_conhdl_register(uint8_t link_id);
/**
****************************************************************************************
* @brief Unregister a BT ACL connection
*
* @param[in] link_id BT ACL connection link ID
*****************************************************************************************
*/
void hci_bt_acl_bdaddr_unregister(uint8_t link_id);
#endif //(BT_EMB_PRESENT)
/**
****************************************************************************************
* @brief Set the event mask
*
* @param[in] evt_msk Pointer to the new event mask
* @param[in] page indicate which event page should be changed
*
* @return The status of the event mask saving
*****************************************************************************************
*/
uint8_t hci_evt_mask_set(struct evt_mask const *evt_msk, uint8_t page);
#if (BT_EMB_PRESENT)
/**
****************************************************************************************
* @brief Add an event filter according to the parameters of the HCI command
*
* Note: the consistency of the parameters according to the input has already been checked by HCI during the special
* unpacking.
*
* @param[in] param Pointer to the HCI parameter
*
* @return The status of the filter addition
*****************************************************************************************
*/
uint8_t hci_evt_filter_add(struct hci_set_evt_filter_cmd const *param);
#if (MAX_NB_SYNC > 0)
/**
****************************************************************************************
* @brief Get voice setting (for SCO auto-accept via event filter)
*
* @return Voice settings
*****************************************************************************************
*/
uint16_t hci_voice_settings_get(void);
/**
****************************************************************************************
* @brief Set voice setting (for SCO auto-accept via event filter)
*
* @param[in] voice_settings Voice settings
*
* @return Status (0: Success | Others: failure)
*****************************************************************************************
*/
uint8_t hci_voice_settings_set(uint16_t voice_settings);
#endif // (MAX_NB_SYNC > 0)
#endif //(BT_EMB_PRESENT)
#if (HCI_TL_SUPPORT)
#if (BLE_EMB_PRESENT || BT_EMB_PRESENT)
/**
****************************************************************************************
* @brief Get the maximum parameter size for a specific command
*
* This function is used by TL to know the theoretical maximum parameters size for a
* specific HCI command.
* Note: if the command is not supported by HCI (unknown), the maximum possible value of
* 255 bytes is returned.
*
* @param[in] opcode Opcode received
*
* @return The command maximum parameters size / 255 if command is unknown
*****************************************************************************************
*/
uint8_t hci_cmd_get_max_param_size(uint16_t opcode);
/**
****************************************************************************************
* @brief Indicates that a HCI command has been received
*
* This function is used by TL to indicate the reception of a HCI command.
*
* @param[in] opcode Command Opcode
* @param[in] length Parameters length
* @param[in] payload Pointer to payload
*****************************************************************************************
*/
void hci_cmd_received(uint16_t opcode, uint8_t length, uint8_t *payload);
/**
****************************************************************************************
* @brief Allocates the reception buffer for ACL TX data
*
* @param[in] hdl_flags Connection handle and data flags from HCI ACL packet header
* @param[in] len Length to receive (from HCI ACL packet header)
*
* @return Buffer for data reception (NULL if not possible to allocate one)
*****************************************************************************************
*/
uint8_t* hci_acl_tx_data_alloc(uint16_t hdl_flags, uint16_t len);
/**
****************************************************************************************
* @brief Indicates that a HCI ACL TX data packet has been received
*
* This function is used by TL to indicate the reception of a HCI ACL TX data.
*
* @param[in] hdl_flags Connection handle and data flags from HCI ACL packet header
* @param[out] datalen Data length
* @param[in] payload Pointer to payload
*****************************************************************************************
*/
void hci_acl_tx_data_received(uint16_t hdl_flags, uint16_t datalen, uint8_t * payload);
#if (BT_EMB_PRESENT)
#if (VOICE_OVER_HCI)
/**
****************************************************************************************
* @brief Allocates the reception buffer for Sync TX data
*
* @param[in] conhdl_flags Connection handle and data flags from HCI Sync packet header
* @param[in] len Length to receive (from HCI Sync packet header)
*
* @return Buffer for data reception (NULL if not possible to allocate one)
*****************************************************************************************
*/
uint8_t* hci_sync_tx_data_alloc(uint16_t conhdl_flags, uint8_t len);
/**
****************************************************************************************
* @brief Indicates that a HCI Sync TX data packet has been received
*
* This function is used by TL to indicate the reception of a HCI Sync TX data.
*
* @param[in] conhdl_flags Connection handle and data flags from HCI Sync packet header
* @param[in] len Length to receive (from HCI Sync packet header)
* @param[in] payload Pointer to payload
*****************************************************************************************
*/
void hci_sync_tx_data_received(uint16_t conhdl_flags, uint8_t len, uint8_t * payload);
#endif // (VOICE_OVER_HCI)
#endif // (BT_EMB_PRESENT)
#endif // (BLE_EMB_PRESENT || BT_EMB_PRESENT)
#if ((BLE_HOST_PRESENT) && (!BLE_EMB_PRESENT))
/**
****************************************************************************************
* @brief Allocates the reception buffer for ACL RX data
*
* @param[in] hdl_flags Connection handle and data flags from HCI ACL RX packet header
* @param[in] len Length to receive (from HCI ACL packet header)
*
* @return Buffer for data reception (NULL if not possible to allocate one)
*****************************************************************************************
*/
uint8_t* hci_acl_rx_data_alloc(uint16_t hdl_flags, uint16_t len);
/**
****************************************************************************************
* @brief Indicates that a HCI ACL RX data packet has been received
*
* This function is used by TL to indicate the reception of a HCI ACL RX data.
*
* @param[in] hdl_flags Connection handle and data flags from HCI ACL packet header
* @param[out] datalen Data length
* @param[in] payload Pointer to payload
*****************************************************************************************
*/
void hci_acl_rx_data_received(uint16_t hdl_flags, uint16_t datalen, uint8_t * payload);
/**
****************************************************************************************
* @brief Indicates that a HCI event has been received
*
* This function is used by TL to indicate the reception of a HCI event.
*
* @param[in] code Event code
* @param[in] length Parameters length
* @param[in] payload Pointer to payload
*
* @return status of receive operation
*****************************************************************************************
*/
uint8_t hci_evt_received(uint8_t code, uint8_t length, uint8_t *payload);
#endif // ((BLE_HOST_PRESENT) && (!BLE_EMB_PRESENT))
#endif // HCI_TL_SUPPORT
//common for both BLE & BT
/**
****************************************************************************************
* @brief process HostBufferSize
*
* @param[in] acl_pkt_len ACL packet length
* @param[in] nb_acl_pkts Number of ACL packets
*
* @return status
*****************************************************************************************
*/
uint8_t hci_fc_acl_buf_size_set(uint16_t acl_pkt_len, uint16_t nb_acl_pkts);
/**
****************************************************************************************
* @brief process HostBufferSize
*
* @param[in] sync_pkt_len SYNC packet length
* @param[in] nb_sync_pkts Number of SYNC packets
*
* @return status
*****************************************************************************************
*/
uint8_t hci_fc_sync_buf_size_set(uint8_t sync_pkt_len, uint16_t nb_sync_pkts);
/**
****************************************************************************************
* @brief set the state of the ACL flow control
*
* @param[in] flow_enable boolean state of control
*
* @return status
*****************************************************************************************
*/
uint8_t hci_fc_acl_en(bool flow_enable);
/**
****************************************************************************************
* @brief set the state of the SYNC flow control
*
* @param[in] flow_enable boolean state of control
*****************************************************************************************
*/
void hci_fc_sync_en(bool flow_enable);
/**
****************************************************************************************
* @brief update data packet counters according to HostNumberOfCompletePackets
*
* @param[in] acl_pkt_nb accumulated number for ACL handles
***************************************************************************************a**
*/
void hci_fc_host_nb_acl_pkts_complete(uint16_t acl_pkt_nb);
/**
****************************************************************************************
* @brief update data packet counters according to HostNumberOfCompletePackets
*
* @param[in] sync_pkt_nb accumulated number for SCO handles
***************************************************************************************a**
*/
void hci_fc_host_nb_sync_pkts_complete(uint16_t sync_pkt_nb);
#endif //HCI_PRESENT
/// @} HCI
#endif // HCI_H_
+478
View File
@@ -0,0 +1,478 @@
/**
****************************************************************************************
*
* @file hci.h
*
* @brief This file contains definitions related to the HCI module.
*
* Copyright (C) RivieraWaves 2009-2015
*
*
****************************************************************************************
*/
#ifndef HCI_INT_H_
#define HCI_INT_H_
/**
****************************************************************************************
* @addtogroup HCI Host Controller Interface
*@{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "rwip_config.h" // SW configuration
#if (HCI_PRESENT)
#include <stddef.h> // standard definition
#include <stdint.h> // standard integer
#include "co_bt.h" // BT standard definitions
#include "hci.h"
#include "ke_msg.h" // Kernel message definitions
/*
* DEFINES
****************************************************************************************
*/
/// Macro to get OCF of a known command
#define OCF(cmd) (HCI_OP2OCF(HCI_##cmd##_CMD_OPCODE))
/// Unknown opcode identifier
#define HCI_OPCODE_UNKNOWN 0xFFFF
/**
* Destination field decoding
*
* bit | 7 6 | 5 4 | 3..0 |
* def | Rsvd (pkupk) | HL | LL |
*/
#define HCI_CMD_DEST_LL_POS 0
#define HCI_CMD_DEST_LL_MASK 0x0F
#define HCI_CMD_DEST_HL_POS 4
#define HCI_CMD_DEST_HL_MASK 0x30
/**
* Destination field decoding
*
* bit | 7..2 | 1 0 |
* def | Rsvd | HL |
*/
#define HCI_EVT_DEST_HL_POS 0
#define HCI_EVT_DEST_HL_MASK 0x03
#if (HCI_TL_SUPPORT)
/// Special Pack-Unpack settings for HCI commands (parameters and return parameters)
/**
* Special Pack-Unpack settings for HCI commands (parameters and return parameters)
*
* bit | 7 | 6 | 5..0 |
* def | RET PAR | PAR | Rsvd |
*/
#define HCI_CMD_DEST_SPEC_PAR_PK_POS 6
#define HCI_CMD_DEST_SPEC_PAR_PK_MSK 0x40
#define HCI_CMD_DEST_SPEC_RET_PAR_PK_POS 7
#define HCI_CMD_DEST_SPEC_RET_PAR_PK_MSK 0x80
#define PK_GEN_GEN (0x00)
#define PK_GEN_SPE (HCI_CMD_DEST_SPEC_RET_PAR_PK_MSK)
#define PK_SPE_GEN (HCI_CMD_DEST_SPEC_PAR_PK_MSK)
#define PK_SPE_SPE (HCI_CMD_DEST_SPEC_RET_PAR_PK_MSK | HCI_CMD_DEST_SPEC_PAR_PK_MSK)
/// Special Pack settings for HCI events
#define PK_GEN 0x00
#define PK_SPE 0x01
/// Macro for building a command descriptor in split mode (with parameters packing/unpacking)
#define CMD(opcode, dest_ll, dest_hl, pkupk, par_size_max, par_fmt, ret_fmt) {HCI_##opcode##_CMD_OPCODE, (dest_ll<<HCI_CMD_DEST_LL_POS) | (dest_hl<<HCI_CMD_DEST_HL_POS) | pkupk, par_size_max, (void*)par_fmt, (void*)ret_fmt}
/// Macro for building an event descriptor in split mode (with parameters packing/unpacking)
#define EVT(code, dest_hl, pkupk, par_fmt) {HCI_##code##_EVT_CODE, (dest_hl<<HCI_EVT_DEST_HL_POS), pkupk, (void*)par_fmt}
/// Macro for building an event descriptor in split mode (with parameters packing/unpacking)
#define LE_EVT(subcode, dest_hl, pkupk, par_fmt) {HCI_##subcode##_EVT_SUBCODE, (dest_hl<<HCI_EVT_DEST_HL_POS), pkupk, (void*)par_fmt}
/// Macro for building an event descriptor in split mode (with parameters packing/unpacking)
#define DBG_EVT(subcode, dest_hl, pkupk, par_fmt) {HCI_##subcode##_EVT_SUBCODE, (dest_hl<<HCI_EVT_DEST_HL_POS), pkupk, (void*)par_fmt}
#else //(HCI_TL_SUPPORT)
/// Macro for building a command descriptor in full mode (without parameters packing/unpacking)
#define CMD(opcode, dest_ll, dest_hl, pkupk, par_size_max, par_fmt, ret_fmt) {HCI_##opcode##_CMD_OPCODE, (dest_ll<<HCI_CMD_DEST_LL_POS) | (dest_hl<<HCI_CMD_DEST_HL_POS)}
/// Macro for building an event descriptor in full mode (without parameters packing/unpacking)
#define EVT(code, dest_hl, pkupk, par_fmt) {HCI_##code##_EVT_CODE, (dest_hl<<HCI_EVT_DEST_HL_POS)}
/// Macro for building an event descriptor in full mode (without parameters packing/unpacking)
#define LE_EVT(subcode, dest_hl, pkupk, par_fmt) {HCI_##subcode##_EVT_SUBCODE, (dest_hl<<HCI_EVT_DEST_HL_POS)}
/// Macro for building an event descriptor in full mode (without parameters packing/unpacking)
#define DBG_EVT(subcode, dest_hl, pkupk, par_fmt) {HCI_##subcode##_EVT_SUBCODE, (dest_hl<<HCI_EVT_DEST_HL_POS)}
#endif //(HCI_TL_SUPPORT)
/*
* ENUMERATIONS DEFINITIONS
****************************************************************************************
*/
/// Possible destination field values within lower layers
enum HCI_MSG_DEST_LL
{
MNG,
CTRL,
BLE_MNG,
BLE_CTRL,
BT_MNG,
BT_CTRL_CONHDL,
BT_CTRL_BD_ADDR,
BT_BCST,
DBG,
BLE_ISO,
LL_UNDEF,
};
/// Possible destination field values within higher layers
enum HCI_MSG_DEST_HL
{
HL_MNG,
HL_CTRL,
HL_DATA,
HL_ISO,
HL_UNDEF,
};
#if (HCI_TL_SUPPORT)
/// Status returned by generic packer-unpacker
enum HCI_PACK_STATUS
{
HCI_PACK_OK,
HCI_PACK_IN_BUF_OVFLW,
HCI_PACK_OUT_BUF_OVFLW,
HCI_PACK_WRONG_FORMAT,
HCI_PACK_ERROR,
};
#endif //(HCI_TL_SUPPORT)
#if (BT_EMB_PRESENT)
/// Status of BT ACL connection at HCI level
enum HCI_BT_ACL_CON_STATUS
{
/// ACL link not active
HCI_BT_ACL_STATUS_NOT_ACTIVE,
/// ACL link ID associated with BD address
HCI_BT_ACL_STATUS_BD_ADDR,
/// ACL link ID associated with BD address + connection handle
HCI_BT_ACL_STATUS_BD_ADDR_CONHDL,
};
#endif //(BT_EMB_PRESENT)
/*
* STRUCTURES DEFINITIONS
****************************************************************************************
*/
/// HCI command descriptor structure
struct hci_cmd_desc_tag
{
/// Command opcode with flags indicating if a special packing or unpacking is needed
uint16_t opcode;
/// Destination field (used to find the internal destination task)
uint8_t dest_field;
#if (HCI_TL_SUPPORT)
/// Maximum size of the parameters
uint8_t par_size_max;
/// Parameters format string (or special unpacker)
void* par_fmt;
/// Return parameters format string (or special unpacker)
void* ret_par_fmt;
#endif //(HCI_TL_SUPPORT)
};
/// HCI event descriptor structure
struct hci_evt_desc_tag
{
/// Event opcode
uint8_t code;
/// Destination field (used to find the internal destination task)
uint8_t dest_field;
#if (HCI_TL_SUPPORT)
/// Flag indicating if a special packing is needed
uint8_t special_pack;
/// Parameters format string (or special unpacker)
void* par_fmt;
#endif //(HCI_TL_SUPPORT)
};
#if (HCI_TL_SUPPORT)
/// HCI pack/unpack function pointer type definition
typedef uint16_t (*hci_pkupk_func_t)(uint8_t *out, uint8_t *in, uint16_t* out_len, uint16_t in_len);
#endif //(HCI_TL_SUPPORT)
#if (BT_EMB_PRESENT)
/// HCI Environment context structure
struct hci_bt_acl_con_tag
{
/**
* BT ACL connection status
* - 0x00: Not active
* - 0x01: link ID associated with BD address
* - 0x02: link ID associated with BD address + connection handle
*/
uint8_t state;
/// BD address associated with link ID
struct bd_addr bd_addr;
};
/// Condition based on class of device
struct classofdevcondition
{
/// Class of device
struct devclass classofdev;
/// Device mask
struct devclass class_mask;
};
/// Condition based on device class
union cond
{
/// Device class
struct classofdevcondition device_class;
/// BD address
struct bd_addr bdaddr;
};
/// Event Filter Record
struct hci_evt_filter_tag
{
bool in_use;
uint8_t type;
uint8_t condition;
uint8_t auto_accept;
union cond param;
};
#elif (BLE_HOST_PRESENT && !BLE_EMB_PRESENT)
/// HCI Environment context structure
struct hci_ble_acl_con_tag
{
/// Code
uint8_t code;
};
#endif //(BT_EMB_PRESENT || (BLE_HOST_PRESENT && !BLE_EMB_PRESENT))
/// HCI Environment context structure
struct hci_env_tag
{
/// Event mask
struct evt_mask evt_msk;
/// Event mask page 2
struct evt_mask evt_msk_page_2;
#if (BLE_EMB_PRESENT)
/// LE Event mask
struct evt_mask le_evt_msk;
#endif // (BLE_EMB_PRESENT)
#if (BLE_EMB_PRESENT && HCI_BLE_CON_SUPPORT)
/// Link association table for BLE link-oriented messages routing
bool ble_con_state[BLE_ACTIVITY_MAX];
#endif //(BLE_EMB_PRESENT && !BLE_HOST_PRESENT && HCI_BLE_CON_SUPPORT)
#if (BT_EMB_PRESENT)
/// Link association table for BT link-oriented messages routing
struct hci_bt_acl_con_tag bt_acl_con_tab[MAX_NB_ACTIVE_ACL];
/// Event filters
struct hci_evt_filter_tag evt_filter[HCI_FILTER_NB];
/**
* Current auto-accept command opcode, used to filter the associated CS event
* Note: assume that there would be 1 auto accept command at the same time
* Note: could be HCI_Accept_Con, HCI_Accept_sync_Con
*/
uint16_t auto_accept_opcode;
#if (MAX_NB_SYNC > 0)
/**
* Voice settings used when SCO connection is auto-accepted
*/
uint16_t voice_settings;
#endif //(MAX_NB_SYNC > 0)
/**
* Auto-reject flag, used to filter the complete event when a request has been auto-rejected
*/
bool auto_reject;
#elif (BLE_HOST_PRESENT && !BLE_EMB_PRESENT && (BLE_CENTRAL || BLE_PERIPHERAL))
/// Link association table for BLE link-oriented messages routing
struct hci_ble_acl_con_tag ble_acl_con_tab[BLE_ACTIVITY_MAX];
#endif //(BT_EMB_PRESENT)
};
/*
* GLOBAL VARIABLE DECLARATIONS
****************************************************************************************
*/
#if BLE_HOST_PRESENT
extern const uint8_t hl_task_type[];
#endif //BLE_HOST_PRESENT
#if (BLE_EMB_PRESENT && BLE_HOST_PRESENT && HCI_TL_SUPPORT)
/**
* Indicate if HCI is used by external Host, or internal Host.
* Used in Full mode only. By default HCI is used by internal Host.
* HCI switches to external host as soon as an HCI command is received.
* This variable should not be reset.
*/
extern bool hci_ext_host;
#endif // (BLE_EMB_PRESENT && BLE_HOST_PRESENT && HCI_TL_SUPPORT)
///HCI environment context
extern struct hci_env_tag hci_env;
/*
* FUNCTION DECLARATIONS
****************************************************************************************
*/
#if (RW_DEBUG)
/**
****************************************************************************************
* @brief Check all command/event descriptor tables to ensure that they are sorted in opcode
* ascending order. An ASSERT_ERR will be triggered if not.
*****************************************************************************************
*/
void hci_check_desc_tabs_order();
#endif // (RW_DEBUG)
/**
****************************************************************************************
* @brief Look for a command descriptor that could match with the specified opcode
*
* @param[in] opcode Command opcode
*
* @return Pointer the command descriptor (NULL if not found)
*****************************************************************************************
*/
const struct hci_cmd_desc_tag* hci_look_for_cmd_desc(uint16_t opcode);
/**
****************************************************************************************
* @brief Look for an event descriptor that could match with the specified event code
*
* @param[in] code event code
*
* @return Pointer the event descriptor (NULL if not found)
*****************************************************************************************
*/
const struct hci_evt_desc_tag* hci_look_for_evt_desc(uint8_t code);
/**
****************************************************************************************
* @brief Look for an event descriptor that could match with the specified DBG subcode
*
* @param[in] subcode DBG event subcode
*
* @return Pointer the event descriptor (NULL if not found)
*****************************************************************************************
*/
const struct hci_evt_desc_tag* hci_look_for_dbg_evt_desc(uint8_t subcode);
#if (BLE_EMB_PRESENT || BLE_HOST_PRESENT)
/**
****************************************************************************************
* @brief Look for an event descriptor that could match with the specified LE subcode
*
* @param[in] subcode LE event subcode
*
* @return Pointer the event descriptor (NULL if not found)
*****************************************************************************************
*/
const struct hci_evt_desc_tag* hci_look_for_le_evt_desc(uint8_t subcode);
#endif //(BLE_EMB_PRESENT || BLE_HOST_PRESENT)
#if (HCI_TL_SUPPORT)
/**
****************************************************************************************
* @brief Initialize HIC TL part
*
* @param[in] init_type Type of initialization (@see enum rwip_init_type)
*****************************************************************************************
*/
void hci_tl_init(uint8_t init_type);
/**
****************************************************************************************
* @brief Send an HCI message over TL
*
* @param[in] msg Kernel message carrying the HCI message
*****************************************************************************************
*/
void hci_tl_send(struct ke_msg *msg);
#endif //(HCI_TL_SUPPORT)
/**
****************************************************************************************
* @brief Initialize Flow Control Structure
*
*****************************************************************************************
*/
void hci_fc_init(void);
/**
****************************************************************************************
* @brief count ACL packets sent to Host
*
*****************************************************************************************
*/
void hci_fc_acl_packet_sent(void);
/**
****************************************************************************************
* @brief count SCO packets sent to Host
*
*****************************************************************************************
*/
void hci_fc_sync_packet_sent(void);
/**
****************************************************************************************
* @brief Calculate number of ACL packets slots available on Host side
*
* @return number of packets available
*****************************************************************************************
*/
uint16_t hci_fc_check_host_available_nb_acl_packets(void);
/**
****************************************************************************************
* @brief Calculate number of SCO packets slots available on Host side
*
* @return number of packets available
*****************************************************************************************
*/
uint16_t hci_fc_check_host_available_nb_sync_packets(void);
#endif //HCI_PRESENT
/// @} HCI
#endif // HCI_INT_H_