#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 // standard definition #include // standard integer #include "co_bt.h" // BT standard definitions #include "hci_ble.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< 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_CONNECTION_MAX]; #endif //(BT_EMB_PRESENT) }; /* * GLOBAL VARIABLE DECLARATIONS **************************************************************************************** */ #if BLE_HOST_PRESENT extern const uint8_t hl_task_type[]; #endif //BLE_HOST_PRESENT ///HCI environment context extern struct hci_env_tag hci_env; /* * FUNCTION DECLARATIONS **************************************************************************************** */ /** **************************************************************************************** * @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 ***************************************************************************************** */ void hci_tl_init(bool reset); /** **************************************************************************************** * @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_