This commit is contained in:
huxi
2025-12-03 11:12:34 +08:00
parent c23ae4f24c
commit bc195654bf
8163 changed files with 3799544 additions and 92 deletions
@@ -0,0 +1,610 @@
/*********************************************************************************************
* Filename : hci_ll.h
* Description : 提供Vendor Host 直接调用Controller API LL Part
* Author : Bingquan
* Email : bingquan_cai@zh-jieli.com
* Last modifiled : 2018-12-04 11:58
* Copyright:(c)JIELI 2011-2017 @ , All Rights Reserved.
*********************************************************************************************/
#ifndef _HCI_LL_H_
#define _HCI_LL_H_
#include <stdint.h>
#include <stdlib.h>
#include <stdarg.h>
#include "typedef.h"
#if 0
// LE CONTROLLER COMMANDS
#define HCI_LE_READ_ISO_TX_SYNC 0x0061
#define HCI_LE_SET_CIG_PARAMS 0x0062
#define HCI_LE_SETUP_ISO_DATA_PATH 0x006E
#define HCI_LE_CREATE_BIG 0x0068
// LE EVENTS
#define HCI_SUBEVENT_LE_BIG_INFO_ADV_REPORT_EVT 0x22
#define HCI_SUBEVENT_LE_TERMINATE_BIG_CMPL_EVT 0x1C
#define HCI_SUBEVENT_LE_BIG_SYNC_EST_EVT 0x1D
#define HCI_SUBEVENT_LE_BIG_SYNC_LOST_EVT 0x1E
#define HCI_EVENT_NUMBER_OF_COMPLETED_PACKETS 0x13
#define HCI_SUBEVENT_LE_ADVERTISING_REPORT 0x02
#endif
#define HCI_LE_CIS_ESTABLISHED_EVENT 0x19
#define HCI_LE_CIS_REQUEST_EVENT 0x1A
#define HCI_LE_CREATE_BIG_COMPLETE_EVENT 0x1B
#define HCI_LE_SET_EXTENDED_ADVERTISING_ENABLE 0x0039
// Controller Error Codes
#define CONNECTION_TERMINATED_BY_LOCAL_HOST 0x16
enum {
LL_EVENT_SUPERVISION_TIMEOUT,
LL_EVENT_RX,
LL_EVENT_ACL_TX_POST,
};
typedef struct {
u8 Own_Address_Type: 2;
u8 Adv_Filter_Policy: 2;
u8 Scan_Filter_Policy: 2;
u8 initiator_filter_policy: 2;
} hci_ll_param_t;
/*! \brief LE Advertising report event. */
typedef enum {
EVT_TYPE_ADV_IND,
EVT_TYPE_ADV_DIRECT_IND,
EVT_TYPE_ADV_SCAN_IND,
EVT_TYPE_ADV_NONCONN_IND,
EVT_TYPE_SCAN_RSP,
} le_evt_type_e;
typedef struct {
uint8_t Subevent_Code;
uint8_t Num_Reports;
uint8_t Event_Type;
uint8_t Address_Type;
uint8_t Address[6];
uint8_t Data_Length;
uint8_t Data[0];
} _GNU_PACKED_ le_adv_report_evt_t;
/*! \brief LE Extended Advertising report event. */
typedef union {
struct {
uint16_t Connectable_advertising : 1,
Scannable_advertising : 1,
Directed_advertising : 1,
Scan_response : 1,
Legacy_adv_PDUs_used : 1,
Data_status : 2,
All_other_bits : 9;
};
uint16_t event_type;
} _GNU_PACKED_ le_evt_type_t;
typedef struct {
uint8_t Subevent_Code;
uint8_t Num_Reports;
le_evt_type_t Event_Type;
uint8_t Address_Type;
uint8_t Address[6];
uint8_t Primary_PHY;
uint8_t Secondary_PHY;
uint8_t Advertising_SID;
uint8_t Tx_Power;
uint8_t RSSI;
uint16_t Periodic_Advertising_Interval;
uint8_t Direct_Address_Type;
uint8_t Direct_Address[6];
uint8_t Data_Length;
uint8_t Data[0];
} _GNU_PACKED_ le_ext_adv_report_evt_t;
struct __periodic_adv_report_event {
u8 Subevent_Code;
u16 Sync_Handle;
u8 Tx_Power;
u8 RSSI;
u8 Unused;
u8 Data_Status;
u8 Data_Length;
u8 Data[0];
} _GNU_PACKED_ ;
struct __periodic_creat_sync {
u8 Filter_Policy;
u8 Advertising_SID;
u8 Advertising_Address_Type;
u8 Advertiser_Address[6];
u8 Skip[2];
u8 Sync_Timeout[2];
u8 Unused;
} _GNU_PACKED_;
/*! \brief LE Set Scan Parameters. */
typedef struct {
uint8_t LE_Scan_Type;
uint16_t LE_Scan_Interval;
uint16_t LE_Scan_Window;
uint8_t Own_Address_Type;
uint8_t Scanning_Filter_Policy;
} _GNU_PACKED_ le_set_scan_param_t;
typedef struct {
uint8_t Own_Address_Type;
uint8_t Scanning_Filter_Policy;
uint8_t Scanning_PHYs;
uint8_t Scan_Type;
uint16_t Scan_Interval;
uint16_t Scan_Window;
} _GNU_PACKED_ le_ext_scan_param_lite_t;
struct __ext_scan_param {
u8 Own_Address_Type;
u8 Scanning_Filter_Policy;
u8 Scanning_PHYs;
struct __scan_phy_param {
u8 Scan_Type;
u16 Scan_Interval;
u16 Scan_Window;
} _GNU_PACKED_ scan_phy_param[0];
} _GNU_PACKED_;
struct __ext_scan_enable {
u8 Enable;
u8 Filter_Duplicates;
u16 Duration;
u16 Period;
} _GNU_PACKED_;
/*! \brief LE Set Extended Advertising Parameters. */
typedef struct {
uint8_t Advertising_Handle;
uint16_t Advertising_Event_Properties;
uint8_t Primary_Advertising_Interval_Min[3];
uint8_t Primary_Advertising_Interval_Max[3];
uint8_t Primary_Advertising_Channel_Map;
uint8_t Own_Address_Type;
uint8_t Peer_Address_Type;
uint8_t Peer_Address[6];
uint8_t Advertising_Filter_Policy;
uint8_t Advertising_Tx_Power;
uint8_t Primary_Advertising_PHY;
uint8_t Secondary_Advertising_Max_Skip;
uint8_t Secondary_Advertising_PHY;
uint8_t Advertising_SID;
uint8_t Scan_Request_Notification_Enable;
} _GNU_PACKED_ le_set_ext_adv_param_t;
/*! \brief LE Set Extended Advertising Data. */
typedef struct {
uint8_t Advertising_Handle;
uint8_t Operation;
uint8_t Fragment_Preference;
uint8_t Advertising_Data_Length;
uint8_t Advertising_Data[31];
} _GNU_PACKED_ le_set_ext_adv_data_t;
/*! \brief LE Set Extended Advertising Enable. */
typedef struct {
uint8_t Enable;
uint8_t Number_of_Sets;
uint8_t Advertising_Handle;
uint16_t Duration;
uint8_t Max_Extended_Advertising_Events;
} _GNU_PACKED_ le_set_ext_adv_en_t;
struct periodic_advertising_param {
u8 Advertising_Handle;
u16 Periodic_Advertising_Interval_Min;
u16 Periodic_Advertising_Interval_Max;
u16 Periodic_Advertising_Properties;
} _GNU_PACKED_;
struct periodic_advertising_data {
u8 Advertising_Handle;
u8 Operation;
u8 Advertising_Data_Length;
u8 Advertising_Data[31];
} _GNU_PACKED_;
typedef struct {
uint8_t Advertising_Handle;
uint8_t Operation;
uint8_t Advertising_Data_Length; // 0 to 252
uint8_t Advertising_Data[0];
} _GNU_PACKED_ le_set_prd_adv_data_t;
struct periodic_advertising_enable {
u8 Enable;
u8 Advertising_Handle;
} _GNU_PACKED_;
typedef struct {
uint16_t Sync_Handle;
} _GNU_PACKED_ periodic_adv_terminate_sync;
/*! \brief HCI ACL Data packets */
typedef struct {
uint16_t Handle : 12;
uint16_t PB_Flag : 2;
uint16_t BC_Flag : 2;
uint16_t Data_Total_Length;
uint8_t Data[0];
} _GNU_PACKED_ hci_acl_data_packets_t ;
/*! \brief LE Set CIG Parameters */
typedef struct {
uint8_t GIG_ID;
uint8_t SDU_Interval_C_To_P[3];
uint8_t SDU_Interval_P_To_C[3];
uint8_t Worst_Case_SCA;
uint8_t Packing;
uint8_t Framing;
uint16_t Max_Transport_Latency_C_To_P;
uint16_t Max_Transport_Latency_P_To_C;
uint8_t CIS_Count;
struct le_cis_param_t {
uint8_t CIS_ID;
uint16_t Max_SDU_C_To_P;
uint16_t Max_SDU_P_To_C;
uint8_t PHY_C_To_P;
uint8_t PHY_P_To_C;
uint8_t RTN_C_To_P;
uint8_t RTN_P_To_C;
} _GNU_PACKED_ param[0];
} _GNU_PACKED_ le_set_cig_param_t;
/*! \brief LE Create CIS */
typedef struct {
uint8_t CIS_Count;
struct le_cis_hdl_t {
uint16_t CIS_Connection_Handle;
uint16_t ACL_Connection_Handle;
} _GNU_PACKED_ param[0];
} _GNU_PACKED_ le_create_cis_t;
/*! \brief LE Remove CIS */
typedef struct {
uint8_t CIG_ID;
} _GNU_PACKED_ le_remove_cig_t;
/*! \brief LE Setup ISO Data Path */
typedef struct {
uint16_t Connection_Handle;
uint8_t Data_Path_Direction;
uint8_t Data_Path_ID;
struct {
uint8_t Coding_Format;
uint16_t Company_Identifier;
uint16_t Vendor_ID;
} _GNU_PACKED_ Codec_ID;
uint8_t Controller_Delay[3];
uint8_t Codec_Configuratin_Length;
uint8_t Codec_Configuratin[0];
} _GNU_PACKED_ le_setup_iso_data_path_t;
/*! \brief LE Create BIG */
typedef struct {
uint8_t BIG_Handle;
uint8_t Advertising_Handle;
uint8_t Num_BIS;
uint8_t SDU_Interval[3];
uint16_t Max_SDU;
uint16_t Max_Transport_Latency;
uint8_t RTN;
uint8_t PHY;
uint8_t Packing;
uint8_t Framing;
uint8_t Encryption;
uint8_t Broadcast_Code[16];
} _GNU_PACKED_ le_create_big_t;
/*! \brief LE Terminate BIG */
typedef struct {
uint8_t BIG_Handle;
uint8_t Reason;
} _GNU_PACKED_ le_terminate_big_t;
/*! \brief LE BIG Create Sync */
typedef struct {
uint8_t BIG_Handle;
uint16_t Sync_Handle;
uint8_t Encryption;
uint8_t Broadcast_Code[16];
uint8_t MSE;
uint16_t BIG_Sync_Timeout;
uint8_t Num_BIS;
uint8_t BIS[0];
} _GNU_PACKED_ le_big_create_sync_t;
/*! \brief LE BIG Terminate Sync */
typedef struct {
uint8_t BIG_Handle;
} _GNU_PACKED_ le_big_terminate_sync_t;
/*! \brief LE Read ISO TX Sync */
typedef struct {
uint16_t Connection_Handle;
} _GNU_PACKED_ le_read_iso_tx_sync_t;
/*! \brief HCI ISO Data packets */
typedef struct {
uint32_t Connection_Handle : 12;
uint32_t PB_Flag : 2;
uint32_t TS_Flag : 1;
uint32_t RFU : 1;
uint32_t ISO_Data_Load_Length : 14;
uint32_t RFU2 : 2;
uint32_t Time_Stamp;
uint32_t Packet_Sequence_Num : 16;
uint32_t ISO_SDU_Length : 12;
uint32_t RFU3 : 2;
uint32_t Packet_Status_Flag : 2;
uint8_t ISO_SDU_Fragment[0];
} _GNU_PACKED_ hci_iso_data_packets_t ;
typedef struct {
u32 handle : 12;
//0b00 frist fragment of a fragmented SDU
//0b01 a continuation fragment of a fragmented SDU
//0b10 a complete SDU
//0b11 the last fragment of an SDU
u32 pb_flag : 2;
u32 ts_flag : 1;
u32 rfu : 1;
u32 iso_data_load_length : 14;
u32 rfu2 : 2;
u32 time_stamp;
u32 packet_sequence_num : 16;
u32 iso_sdu_length : 12;
u32 rfu3 : 2;
//0b00 Valid data. The complete ISO_SDU was received correctly.
//0b01 Possibly invalid data. The contents of the ISO_SDU may contain errors or
// part of the ISO_SDU may be missing. This is reported as "data with possible
// errors".
//0b10 Part(s) of the ISO_SDU were not received correctly. This is reported as
// "lost data".
u32 packet_status_flag : 2;
uint8_t *iso_sdu;
} hci_iso_hdr_t;
/*! \brief LE BIGInfo Advertising report event */
typedef struct {
// uint8_t Subevent_Code;
uint16_t Sync_Handle;
uint8_t Num_BIS;
uint8_t NSE;
uint16_t ISO_Interval;
uint8_t BN;
uint8_t PTO;
uint8_t IRC;
uint16_t Max_PDU;
uint8_t SDU_Interval[3];
uint16_t Max_SDU;
uint8_t PHY;
uint8_t Framing;
uint8_t Encryption;
} _GNU_PACKED_ le_biginfo_adv_report_evt_t;
/*! \brief LE Create BIG Complete event */
typedef struct {
// uint8_t Subevent_Code;
uint8_t Status;
uint32_t BIG_Handle : 8,
BIG_Sync_Delay : 24;
uint32_t Transport_Latency_BIG : 24,
PHY : 8;
uint8_t NSE;
uint8_t BN;
uint8_t PTO;
uint8_t IRC;
uint16_t Max_PDU;
uint16_t ISO_Interval;
uint8_t Num_BIS;
uint16_t Connection_Handle[0];
} _GNU_PACKED_ le_create_big_complete_evt_t;
/*! \brief LE BIG Sync Established event */
typedef struct {
// uint8_t Subevent_Code;
uint8_t Status;
uint8_t BIG_Handle;
uint32_t Transport_Latency_BIG : 24,
NSE : 8;
uint8_t BN;
uint8_t PTO;
uint8_t IRC;
uint16_t Max_PDU;
uint16_t ISO_Interval;
uint8_t Num_BIS;
uint16_t Connection_Handle[0];
} _GNU_PACKED_ le_big_sync_established_evt_t;
/*! \brief LE Read ISO TX Sync Return Parameters */
typedef struct {
uint8_t Status;
uint16_t Connection_Handle;
uint16_t Paket_Sequence_Number;
uint32_t TX_Time_Stamp;
uint32_t Time_Offset : 24;
} _GNU_PACKED_ le_read_iso_tx_sync_ret_t;
/*! \brief LE BIG Sync Lost event */
typedef struct {
uint8_t BIG_Handle;
uint8_t Reason;
} _GNU_PACKED_ le_big_sync_lost_evt_t;
/*! \brief LE CIS Request event */
typedef struct {
// uint8_t Subevent_Code;
uint16_t ACL_Connection_Handle;
uint16_t CIS_Connection_Handle;
uint8_t CIG_ID;
uint8_t CIS_ID;
} _GNU_PACKED_ le_cis_request_evt_t;
/*! \brief LE CIS Established event */
typedef struct {
// uint8_t Subevent_Code;
uint8_t Status;
uint16_t Connection_Handle;
uint8_t CIG_Sync_Delay[3];
uint8_t CIS_Sync_Delay[3];
uint8_t Transport_Latency_C_To_P[3];
uint8_t Transport_Latency_P_To_C[3];
uint8_t PHY_C_To_P;
uint8_t PHY_P_To_C;
uint8_t NSE;
uint8_t BN_C_To_P;
uint8_t BN_P_To_C;
uint8_t FT_C_To_P;
uint8_t FT_P_To_C;
uint16_t Max_PDU_C_To_P;
uint16_t Max_PDU_P_To_C;
uint16_t ISO_Interval;
} _GNU_PACKED_ le_cis_established_evt_t;
//Adjust Host part API
void ll_hci_init(void);
void ll_hci_reset(void);
void ll_hci_destory(void);
void ll_hci_set_event_mask(const u8 *mask);
void ll_hci_set_name(const char *name);
void ll_hci_adv_set_params(uint16_t adv_int_min, uint16_t adv_int_max, uint8_t adv_type,
uint8_t direct_address_type, uint8_t *direct_address,
uint8_t channel_map, uint8_t filter_policy);
void ll_hci_adv_set_data(uint8_t advertising_data_length, uint8_t *advertising_data);
void ll_hci_adv_scan_response_set_data(uint8_t scan_response_data_length, uint8_t *scan_response_data);
int ll_hci_adv_enable(bool enable);
void ll_hci_scan_set_params(uint8_t scan_type, uint16_t scan_interval, uint16_t scan_window);
int ll_hci_scan_enable(bool enable, u8 filter_duplicates);
int ll_hci_create_conn(u8 *conn_param, u8 *addr_param);
int ll_hci_create_conn_ext(void *param);
int ll_hci_create_conn_cancel(void);
int ll_hci_vendor_send_key_num(u16 con_handle, u8 num);
int ll_vendor_latency_hold_cnt(u16 conn_handle, u16 hold_cnt);
int ll_hci_encryption(u8 *key, u8 *plaintext_data);
int ll_hci_get_le_rand(void);
int ll_hci_start_encryption(u16 handle, u32 rand_low, u32 rand_high, u16 peer_ediv, u8 *ltk);
int ll_hci_long_term_key_request_reply(u16 handle, u8 *ltk);
int ll_hci_long_term_key_request_nagative_reply(u16 handle);
int ll_hci_connection_update(u16 handle, u16 conn_interval_min, u16 conn_interval_max,
u16 conn_latency, u16 supervision_timeout,
u16 minimum_ce_length, u16 maximum_ce_length);
u16 ll_hci_get_acl_data_len(void);
u16 ll_hci_get_acl_total_num(void);
void ll_hci_set_random_address(u8 *addr);
int ll_hci_disconnect(u16 handle, u8 reason);
int ll_hci_read_local_p256_pb_key(void);
int ll_hci_generate_dhkey(const u8 *data, u32 size);
//Adjust Controller part API
void ll_hci_cmd_handler(int *cmd);
void ll_event_handler(int *msg);
void ll_hci_private_free_dma_rx(u8 *rx_head);
void ll_hci_set_data_length(u16 conn_handle, u16 tx_octets, u16 tx_time);
hci_ll_param_t *ll_hci_param_config_get(void);
void hci_ll_get_device_address(uint8_t *addr_type, u8 *addr);
void ll_hci_set_host_channel_classification(u8 *channel_map);
// ble5
void ll_hci_set_ext_adv_params(u8 *data, u32 size);
void ll_hci_set_ext_adv_data(u8 *data, u32 size);
void ll_hci_set_ext_adv_enable(u8 *data, u32 size);
void ll_hci_set_phy(u16 conn_handle, u8 all_phys, u8 tx_phy, u8 rx_phy, u16 phy_options);
void ll_hci_set_ext_scan_params(u8 *data, u32 size);
void ll_hci_set_ext_scan_enable(u8 *data, u32 size);
void ll_hci_ext_create_conn(u8 *data, u32 size);
void ll_hci_set_periodic_adv_params(u8 *data, u32 size);
void ll_hci_set_periodic_adv_data(u8 *data, u32 size);
void ll_hci_set_periodic_adv_enable(u8 *data, u32 size);
void ll_hci_periodic_adv_creat_sync(u8 *data, u32 size);
void ll_hci_periodic_adv_terminate_sync(u8 *data, u32 size);
void ll_hci_periodic_adv_create_sync_cancel(void);
void ll_hci_set_cig_params(uint8_t *data, size_t size);
void ll_hci_create_cis(uint8_t *data, size_t size);
void ll_hci_remove_cig(uint8_t *data, size_t size);
void ll_hci_accept_cis_req(uint8_t *data, size_t size);
void ll_hci_create_big(uint8_t *data, size_t size);
void ll_hci_big_create_sync(uint8_t *data, size_t size);
void ll_hci_big_terminate_sync(uint8_t *data, size_t size);
void ll_hci_read_iso_tx_sync(uint8_t *data, size_t size);
void ll_hci_setup_iso_data_path(uint8_t *data, size_t size);
void ll_hci_read_iso_tx_sync(uint8_t *data, size_t size);
int le_controller_set_mac(void *addr);
void hci_add_event_handler(void *callback_handler);
void hci_remove_event_handler(void *callback_handler);
/* vendor */
void hci_iso_receive_callback_register(void *callback);
void ll_big_tx_align_callback_register(uint8_t big_handle, const void *callback);
void ll_config_ctrler_clk(uint16_t handle, uint8_t sel);
void ll_get_ctrler_clk(uint16_t hdl, uint16_t *us_1per12, uint32_t *ref_clk_us, uint32_t *evt);
void ll_set_vendor_param(uint8_t *vendor_param, size_t size);
void ll_cig_tx_align_callback_register(uint8_t cig_id, const void *callback);
void ll_conn_rx_acl_callback_register(void (*callback)(uint8_t *packet, size_t size));
void ll_set_scan_priority(uint8_t priority);
void rf_mdm_con_ble_sync_word(int tws_esco);
uint8_t ll_iso_unpack_hdr(const uint8_t *sdu, hci_iso_hdr_t *hdr);
void access_addr_generate(u8 *aa);
typedef void (*timeout_callback_t)(void *priv);
void bb_le_timer_set(uint8_t idx, uint32_t usec, timeout_callback_t callback, void *priv);
u32 bb_le_clk_get_time_us(void);
uint8_t bb_le_timer_get(void);
void bb_le_timer_reset(uint8_t idx, uint32_t usec);
#endif
@@ -0,0 +1,260 @@
/*********************************************************************************************
* Filename : ll_config.h
* Description : Lto 优化Macro 定义
* Author : Bingquan
* Email : bingquan_cai@zh-jieli.com
* Last modifiled : 2018-12-19 16:12
* Copyright:(c)JIELI 2011-2017 @ , All Rights Reserved.
*********************************************************************************************/
#ifndef _LL_CONFIG_H_
#define _LL_CONFIG_H_
#include <stdint.h> //for UINT64_C
/*
*-------------------LE FEATURE SUPPORT
* brief : 运行时优化(LTO)下,代码空间优化;
*/
/* --- Core Spec 4.0 --- */
#define LL_FEAT_ENCRYPTION (UINT64_C(1) << ( 0)) /*!< Encryption supported. */
/* --- Core Spec 4.2 --- */
#define LL_FEAT_CONN_PARAM_REQ_PROC (UINT64_C(1) << ( 1)) /*!< Connection Parameters Request Procedure supported. */
#define LL_FEAT_EXT_REJECT_IND (UINT64_C(1) << ( 2)) /*!< Extended Reject Indication supported. */
#define LL_FEAT_SLV_INIT_FEAT_EXCH (UINT64_C(1) << ( 3)) /*!< Slave-Initiated Features Exchange supported. */
#define LL_FEAT_LE_PING (UINT64_C(1) << ( 4)) /*!< LE Ping supported. */
#define LL_FEAT_DATA_LEN_EXT (UINT64_C(1) << ( 5)) /*!< Data Length Extension supported. */
#define LL_FEAT_PRIVACY (UINT64_C(1) << ( 6)) /*!< LL Privacy supported. */
#define LL_FEAT_EXT_SCAN_FILT_POLICY (UINT64_C(1) << ( 7)) /*!< Extended Scan Filter Policy supported. */
/* --- Core Spec 5.0 --- */
#define LL_FEAT_LE_2M_PHY (UINT64_C(1) << ( 8)) /*!< LE 2M PHY supported. */
#define LL_FEAT_STABLE_MOD_IDX_TRANSMITTER (UINT64_C(1) << ( 9)) /*!< Stable Modulation Index - Transmitter supported. */
#define LL_FEAT_STABLE_MOD_IDX_RECEIVER (UINT64_C(1) << (10)) /*!< Stable Modulation Index - Receiver supported. */
#define LL_FEAT_LE_CODED_PHY (UINT64_C(1) << (11)) /*!< LE Coded PHY supported. */
#define LL_FEAT_LE_EXT_ADV (UINT64_C(1) << (12)) /*!< LE Extended Advertising supported. */
#define LL_FEAT_LE_PER_ADV (UINT64_C(1) << (13)) /*!< LE Periodic Advertising supported. */
#define LL_FEAT_CH_SEL_2 (UINT64_C(1) << (14)) /*!< Channel Selection Algorithm #2 supported. */
#define LL_FEAT_LE_POWER_CLASS_1 (UINT64_C(1) << (15)) /*!< LE Power Class 1 supported. */
#define LL_FEAT_MIN_NUM_USED_CHAN (UINT64_C(1) << (16)) /*!< Minimum Number of Used Channels supported. */
/* --- Core Spec 5.1 --- */
#define LL_FEAT_CONN_CTE_REQ (UINT64_C(1) << (17)) /*!< Connection CTE Request supported */
#define LL_FEAT_CONN_CTE_RSP (UINT64_C(1) << (18)) /*!< Connection CTE Response supported */
#define LL_FEAT_CONNLESS_CTE_TRANS (UINT64_C(1) << (19)) /*!< Connectionless CTE Transmitter supported */
#define LL_FEAT_CONNLESS_CTE_RECV (UINT64_C(1) << (20)) /*!< Connectionless CTE Receiver supported */
#define LL_FEAT_ANTENNA_SWITCH_AOD (UINT64_C(1) << (21)) /*!< Anetenna Switching during CTE Transmission (AoD) supported */
#define LL_FEAT_ANTENNA_SWITCH_AOA (UINT64_C(1) << (22)) /*!< Anetenna Switching during CTE Reception (AoA) supported */
#define LL_FEAT_RECV_CTE (UINT64_C(1) << (23)) /*!< Receive Constant Tone Extension supported */
#define LL_FEAT_PAST_SENDER (UINT64_C(1) << (24)) /*!< Periodic Advertising Sync Transfer Sender supported. */
#define LL_FEAT_PAST_RECIPIENT (UINT64_C(1) << (25)) /*!< Periodic Advertising Sync Transfer Recipient supported. */
#define LL_FEAT_SCA_UPDATE (UINT64_C(1) << (26)) /*!< Sleep Clock Accuracy Updates supported. */
#define LL_FEAT_REMOTE_PUB_KEY_VALIDATION (UINT64_C(1) << (27)) /*!< Remote Public Key Validation supported. */
/* --- Core Spec 5.2 --- */
#define LL_FEAT_CIS_MASTER_ROLE (UINT64_C(1) << (28)) /*!< Connected Isochronous Stream Master Role supported. */
#define LL_FEAT_CIS_SLAVE_ROLE (UINT64_C(1) << (29)) /*!< Connected Isochronous Stream Slave Role supported. */
#define LL_FEAT_ISO_BROADCASTER (UINT64_C(1) << (30)) /*!< Isochronous Broadcaster Role supported. */
#define LL_FEAT_ISO_SYNC (UINT64_C(1) << (31)) /*!< Isochronous Synchronizer Role supported. */
#define LL_FEAT_ISO_HOST_SUPPORT (UINT64_C(1) << (32)) /*!< Host support for ISO Channels. */
#define LL_FEAT_POWER_CONTROL_REQUEST (UINT64_C(1) << (33)) /*!< Power control requests supported. */
#define LL_FEAT_POWER_CHANGE_IND (UINT64_C(1) << (34)) /*!< Power control power change indication supported. */
#define LL_FEAT_PATH_LOSS_MONITOR (UINT64_C(1) << (35)) /*!< Path loss monitoring supported. */
#define LL_FEAT_PATH_LOSS_MONITOR (UINT64_C(1) << (35)) /*!< Path loss monitoring supported. */
#define LL_FEAT_PERIODIC_ADV_ADI_SUPPORT (UINT64_C(1) << (36)) /*!< Periodic Advertising ADI supported. */
#define LL_FEAT_CONN_SUBRATE (UINT64_C(1) << (37)) /*!< Connection subrating supported. */
#define LL_FEAT_CONN_SUBRATE_HOST_SUPPORT (UINT64_C(1) << (38)) /*!< Connection subratingHost supported. */
#define LL_FEAT_CHANNEL_CLASSIFICATION (UINT64_C(1) << (39)) /*!< Channel classification supported. */
#define LL_FEAT_VENDOR_BIG_SYNC_TRANSFER (UINT64_C(1) << (62)) /*!< Vendor BIG sync transfer. */
#define LL_FEAT_VENDOR_BIG_TRANSFER (UINT64_C(1) << (63)) /*!< Vendor BIG transfer. */
#define LE_ENCRYPTION LL_FEAT_ENCRYPTION
#define CONNECTION_PARAMETER_REQUEST LL_FEAT_CONN_PARAM_REQ_PROC
#define EXTENDED_REJECT_INDICATION LL_FEAT_EXT_REJECT_IND
#define LE_SLAVE_INIT_FEATURES_EXCHANGE LL_FEAT_SLV_INIT_FEAT_EXCH
#define LE_PING LL_FEAT_LE_PING
#define LE_DATA_PACKET_LENGTH_EXTENSION LL_FEAT_DATA_LEN_EXT
#define LL_PRIVACY LL_FEAT_PRIVACY
#define EXTENDED_SCANNER_FILTER_POLICIES LL_FEAT_EXT_SCAN_FILT_POLICY
#define LE_2M_PHY LL_FEAT_LE_2M_PHY
#define LE_CODED_PHY LL_FEAT_LE_CODED_PHY
#define LE_EXTENDED_ADVERTISING LL_FEAT_LE_EXT_ADV
#define LE_PERIODIC_ADVERTISING LL_FEAT_LE_PER_ADV
#define CHANNEL_SELECTION_ALGORITHM_2 LL_FEAT_CH_SEL_2
#define LE_CORE_V50_FEATURES \
( \
LE_2M_PHY | \
LE_CODED_PHY | \
LE_EXTENDED_ADVERTISING | \
LE_PERIODIC_ADVERTISING | \
CHANNEL_SELECTION_ALGORITHM_2 | \
0 \
)
#if (LE_CORE_V50_FEATURES & LE_PERIODIC_ADVERTISING)
#if ((LE_CORE_V50_FEATURES & LE_EXTENDED_ADVERTISING) == 0)
#error "enable <LE_PERIODIC_ADVERTISING> must enable <LE_EXTENDED_ADVERTISING> at the same time"
#endif
#endif
#define LE_FEATURES_CONST_TONE (LL_FEAT_CONN_CTE_REQ | \
LL_FEAT_CONN_CTE_RSP | \
LL_FEAT_CONNLESS_CTE_TRANS | \
LL_FEAT_CONNLESS_CTE_RECV | \
LL_FEAT_ANTENNA_SWITCH_AOD | \
LL_FEAT_ANTENNA_SWITCH_AOA | \
LL_FEAT_RECV_CTE)
#define LE_FEATURES_PAST (LL_FEAT_PAST_SENDER | \
LL_FEAT_PAST_RECIPIENT)
#define LE_FEATURES_CIS (LL_FEAT_CIS_MASTER_ROLE | \
LL_FEAT_CIS_SLAVE_ROLE | \
LL_FEAT_ISO_HOST_SUPPORT)
#define LE_FEATURES_BIS (LL_FEAT_ISO_BROADCASTER | \
LL_FEAT_ISO_SYNC | \
LL_FEAT_ISO_HOST_SUPPORT)
#define LE_FEATURES_ISO (LE_FEATURES_BIS|LE_FEATURES_CIS)
#define LE_FEATURES_POWER_CONTROL (LL_FEAT_POWER_CONTROL_REQUEST | \
LL_FEAT_POWER_CHANGE_IND | \
LL_FEAT_PATH_LOSS_MONITOR)
extern const uint64_t config_btctler_le_features;
#define LE_FEATURES_IS_SUPPORT(x) (config_btctler_le_features & (x))
#define LE_FEATURES_IS_SUPPORT_OPTIMIZE(x) if (LE_FEATURES_IS_SUPPORT(x) == 0x0) return
/*-----------------------------------------------------------*/
/*
*-------------------LE ROLES SUPPORT
* brief : 运行时优化(LTO)下,代码空间优化;
*/
#define LE_MASTER BIT(0)
#define LE_SLAVE BIT(1)
#define LE_ADV BIT(2)
#define LE_SCAN BIT(3)
#define LE_INIT BIT(4)
/*! \brief Combination */
#define LE_CONN (LE_MASTER|LE_SLAVE)
extern const int config_btctler_le_roles;
#define LE_ROLES_IS_SUPPORT(x) (config_btctler_le_roles & x)
#define LE_ROLES_IS_SUPPORT_OPTIMIZE(x) if (LE_ROLES_IS_SUPPORT(x) == 0x0) return
/*-----------------------------------------------------------*/
extern const int config_btctler_le_tws;
#define LE_TWS_IS_SUPPORT() (config_btctler_le_tws)
/*-----------------------------------------------------------*/
extern const int config_btctler_le_afh_en;
#define LE_AFH_IS_SUPPORT() (config_btctler_le_afh_en)
#define LE_AFH_IS_SUPPORT_OPTIMIZE(x) if (LE_AFH_IS_SUPPORT() == 0x0) return
/*
*-------------------LE PARAM CHECK
* brief : 运行时优化(LTO)下,代码空间优化;
*/
// extern const int config_btctler_le_param_check;
#define LE_PARAM_IS_CHECK() TRUE//(config_btctler_le_param_check)
/*
*-------------------LE RAM CONTROL
*
*/
extern const int config_btctler_le_hw_nums;
extern const int config_btctler_le_rx_nums;
extern const int config_btctler_le_acl_packet_length;
extern const int config_btctler_le_acl_total_nums;
extern const int config_btctler_le_slave_conn_update_winden;
extern const int config_btctler_le_iso_tx;
extern const int config_btctler_le_iso_rx;
/*-----------------------------------------------------------*/
/*
*-------------------LE Multi-link CONTROL
*/
extern const int config_btctler_le_master_multilink;
/*-----------------------------------------------------------*/
/*
*-------------------LE Vendor baseband CONTROL
*/
#define VENDOR_BB_PIS_EN BIT(0)
#define VENDOR_BB_PIS_HB BIT(1)
#define VENDOR_BB_PIS_HB_M BIT(2)
#define VENDOR_BB_MD_CLOSE BIT(3)
#define VENDOR_BB_CONNECT_SLOT BIT(4)
#define VENDOR_BB_NEW_SCAN_STRATEGY BIT(5)
#define VENDOR_BB_VENDOR_AFH BIT(5)
#define VENDOR_BB_PIS_HB_R BIT(6)
#define VENDOR_BB_WL_COEX_ROLE_EN BIT(6)
#define VENDOR_BB_WL_COEX_ROLE BIT(7)
#define VENDOR_BB_ADV_PDU_INT(x) ((x) << 8) /* 4bit */
#define VENDOR_BB_EVT_HOLD_TRIGG(x) ((x) << 12) /* 6bit */
#define VENDOR_BB_RX_PAYLOAD_LEN(x) ((x) << 18) /* 7bit */
#define VENDOR_BB_PIS_TX_PAYLOAD_LEN(x) ((x) << 25) /* 7bit*/
extern const u32 config_vendor_le_bb;
extern const int config_ble_adv_tx_pwr_level;
extern const int config_rf_oob;
extern const int config_bb_optimized_ctrl;
// config_bb_optimized_ctrl 控制变量说明
#define LE_BB_OPT_FEAT_PKT_UNFILT BIT(0)
#define LE_BB_OPT_FEAT_EXT_UPLOAD_EN BIT(1)
#define LE_BB_OPT_FEAT_CC_CODE_EN BIT(2)
#define LE_BB_OPT_FEAT_RESERVED0 BIT(3)
#define LE_BB_OPT_FEAT_HARD_CMB_EN BIT(4)
#define LE_BB_OPT_FEAT_RX_LOG_EN BIT(5) //only for big rx
#define LE_BB_OPT_FEAT_RSSI_AFH_EN BIT(6)
#define LE_BB_OPT_FEAT_PWR_CTRL_EN BIT(7)
#define LE_BB_OPT_FEAT_RX_PRE_CLOSE BIT(8)
#define LE_BB_OPT_FEAT_TX_PWR_LOW_SEL BIT(9) //only for br29
#define LE_BB_OPT_FEAT_PER_AFH_EN BIT(10)
#define LE_BB_OPT_FEAT_RESERVED1 BIT(11)|BIT(12)
#define LE_BB_OPT_FEAT_CIG_ENC_DIS BIT(13)
#define LE_BB_OPT_FEAT_CIG_SEVT_CLOSE BIT(14)
#define LE_BB_OPT_FEAT_CIG_PACK_MODE BIT(16) //sequential or interleved
#define LE_BB_OPT_FEAT_CODE_OPTIMIZED BIT(17)
#define LE_BB_OPT_FEAT_CIG_RSSI_GET_EN BIT(18)
#define LE_BB_OPT_FEAT_PKT_V3_EN BIT(18)
#define LE_BB_OPT_FEAT_PKT_V3_DYNAMIC BIT(19) //only for rx
#define LE_BB_OPT_FEAT_ISO_DIRECT_PUSH BIT(21)
#define LE_BB_OPT_FEAT_BCTRL_DISABLE BIT(22)
#define LE_ADV_RSSI_AFH_EN() (config_bb_optimized_ctrl & BIT(6))
#define LE_ADV_PER_AFH_EN() (config_bb_optimized_ctrl & BIT(10))
#define LE_ADV_PWR_CTRL_EN() (config_bb_optimized_ctrl & BIT(7))
#define LE_BIS_RX_PRE_CLOSE() (config_bb_optimized_ctrl & BIT(8))
#define LE_VENDOR_API_EN() (config_bb_optimized_ctrl & BIT(31))
struct le_adv_link_param_cfg {
u8 param1;
s8 param2[2];
s8 param3[2];
u8 param4[2];
u8 param5;
};
/*-----------------------------------------------------------*/
/*
*-------------------LE close wait
*/
extern const int ble_disable_wait_enable;
/*-----------------------------------------------------------*/
#endif //_LL_CONFIG_H_
@@ -0,0 +1,59 @@
/*********************************************************************************************
* Filename : btcontroller_modules.h
* Description : Lto 优化Macro 定义
* Author : Bingquan
* Email : bingquan_cai@zh-jieli.com
* Last modifiled : 2018-12-19 16:38
* Copyright:(c)JIELI 2011-2017 @ , All Rights Reserved.
*********************************************************************************************/
#ifndef _BTCONTROLLER_MODE_H_
#define _BTCONTROLLER_MODE_H_
/*
ble 测试串口默认使用usb口,代码要确保usb口没有其他地方使用
开启测试模式,uart0 key 等一些功能默认关闭,请看特殊情况
自行处理
1、提供实验室测试rf bqb的时候配 BT_BQB
2、提供实验室测试rf fcc的时候配 BT_FCC
3、如果要定频测试配BT_FRE 频点:2402 , 发射功率最大
4、性能测试配BT_PER,使用仪器直接连接测试即可,测试完毕后
需要复位或者上电开机才会恢复正常流程,不复位或上电的话只支持链接一个设备
量产测试性能可直接配BT_NORMAL 然后通过某个外部操作来
调用 void bredr_set_dut_enble(u8 en,u8 phone )
en 1 :使能 bredr dut 测试然后就可以使用仪器链接测试
phone: 1 可以被手机连接,0 不可以被手机连接上
如果样机通过按键等操作进入dut测试调用bredr_set_dut_enble使能可以被仪器链接,
同时调用下面函数,关闭耳机快速链接,开启可发现可链接
tws_cancle_all_noconn() ;
user_send_cmd_prepare(USER_CTRL_WRITE_SCAN_ENABLE, 0, NULL);
user_send_cmd_prepare(USER_CTRL_WRITE_CONN_ENABLE, 0, NULL);
5、可以调用 void bt_fix_fre_api() 函数实现经典蓝牙定频测试,频点2402,发射功率最大,
调用后不可恢复之前状态,只是用来量产测试,测试完需要复位或重新上电开机!
6、可以调用 void ble_fix_fre_api()函数实现ble定频测试,发射功率最大,
*/
#define BT_NORMAL 0x01
#define BT_BQB 0x02
#define BT_FCC 0x04
#define BT_FRE 0x10
#define BT_PER 0x20
#define CONFIG_BT_MODE BT_NORMAL
#endif
@@ -0,0 +1,290 @@
/*********************************************************************************************
* Filename : btcontroller_modules.h
* Description : Lto 优化Macro 定义
* Author : Bingquan
* Email : bingquan_cai@zh-jieli.com
* Last modifiled : 2018-12-19 16:38
* Copyright:(c)JIELI 2011-2017 @ , All Rights Reserved.
*********************************************************************************************/
#ifndef _BTCONTROLLER_H_
#define _BTCONTROLLER_H_
#include "hci_transport.h"
#include "btcontroller_mode.h"
#include "ble/hci_ll.h"
#include "classic/hci_lmp.h"
/* app 层修改蓝牙版本,可在BT_STATUS_INIT_OK case
调用 set_bt_version 函数更改蓝牙版本号
*/
#define BLUETOOTH_CORE_SPEC_42 0x08
#define BLUETOOTH_CORE_SPEC_50 0x09
#define BLUETOOTH_CORE_SPEC_51 0x0a
#define BLUETOOTH_CORE_SPEC_52 0x0b
extern void set_bt_version(u8 version);
/*
*-------------------Module SUPPORT
* brief : 运行时优化(LTO)下,代码空间优化;
*/
#define BT_MODULE_CLASSIC BIT(0)
#define BT_MODULE_LE BIT(1)
extern const int config_btctler_modules;
#define BT_MODULES_IS_SUPPORT(x) (config_btctler_modules & (x))
/*-----------------------------------------------------------*/
extern const int config_stack_modules;
#define STACK_MODULES_IS_SUPPORT(x) (config_stack_modules & (x))
/*
*-------------------Mode SELECT
* brief : 运行时优化(LTO)下,代码空间优化;
*/
extern const int config_btctler_mode;
#define BT_MODE_IS(x) (config_btctler_mode & (x))
/*-----------------------------------------------------------*/
extern const int config_btctler_hci_standard;
#define BT_HCI_STANDARD_IS_SUPPORT(x) (config_btctler_hci_standard)
extern const int config_bt_function ;
#define BT_ENCTRY_TASK BIT(0)
#define BT_MASTER_AFH BIT(1)
#define BT_MASTER_QOS BIT(2)
#define BT_FUNCTION_IS(x) (config_bt_function & (x))
/*---------------------- tws fun-------------------------------------*/
extern const int CONFIG_BTCTLER_TWS_FUN;
#define TWS_ESCO_FORWARD BIT(0) ///tws 通话转发使能
#define TWS_FUNCTION_IS(x) ( CONFIG_BTCTLER_TWS_FUN & (x))
/*---------------------- tws fun end -------------------------------------*/
extern const int CONFIG_TEST_DUT_CODE;
extern const int CONFIG_TEST_FCC_CODE;
extern const int CONFIG_TEST_DUT_ONLY_BOX_CODE;
extern const int CONFIG_BREDR_INQUIRY;
extern const int CONFIG_INQUIRY_PAGE_OFFSET_ADJUST ;
extern const int CONFIG_LMP_NAME_REQ_ENABLE ;
extern const int CONFIG_LMP_PASSKEY_ENABLE ;
extern const int CONFIG_LMP_MASTER_ESCO_ENABLE ;
extern const int config_btctler_bredr_master ;
extern const int config_bredr_afh_user ;
extern const int config_bredr_master_afh ;
extern const int CONFIG_ESCO_MUX_RX_BULK_ENABLE ;
extern const int config_bt_temperature_pll_trim ;
extern const int CONFIG_WIFI_DETECT_ENABLE;
extern const int ESCO_FORWARD_ENABLE;
/********************************************************************************/
/*
* API
*
*/
/* --------------------------------------------------------------------------*/
/**
* @brief rf_set_24g_hackable_coded
*
* @param coded 2.4G 配对码
*/
/* ----------------------------------------------------------------------------*/
void rf_set_24g_hackable_coded(int coded);
/* --------------------------------------------------------------------------*/
/**
* @brief bt_pll_para
*
* @param osc
* @param sys
* @param low_power
* @param xosc
*/
/* ----------------------------------------------------------------------------*/
void bt_pll_para(u32 osc, u32 sys, u8 low_power, u8 xosc);
/* --------------------------------------------------------------------------*/
/**
* @brief bt_production_test
*
* @param en
*/
/* ----------------------------------------------------------------------------*/
void bt_production_test(u8 en);
/* --------------------------------------------------------------------------*/
/**
* @brief bt_set_rxtx_status_enable
*
* @param en
*
*
TX RX
AI800x PA13 PA12
AC692x PA13 PA12
AC693x PA8 PA9
AC695x PA9 PA10
AC696x PC1 PC2
AC694x PB1 PB2
AC697x PC2 PC3
AC631x PA7 PA8
*/
/* ----------------------------------------------------------------------------*/
void bt_set_rxtx_status_enable(u8 en);
/* --------------------------------------------------------------------------*/
/**
* @brief bt_osc_offset_ext_save
*
* @param offset
*
* 更新并且保存频偏
*/
/* ----------------------------------------------------------------------------*/
void bt_osc_offset_ext_save(s32 offset);
/* --------------------------------------------------------------------------*/
/**
* @brief bt_osc_offset_ext_updata
*
* @param offset
*
* 更新频偏
*/
/* ----------------------------------------------------------------------------*/
void bt_osc_offset_ext_updata(s32 offset);
/* --------------------------------------------------------------------------*/
/**
* @brief 初始化配置蓝牙发射功率最大值范围
*
* @param pwr edr 连接后发射功率(range:0~9)
* @param pg_pwr edr page 可连接状态发射功率
* @param iq_pwr edr inquiry 可发现状态发射功率
* @param ble_pwr ble 发射功率
*/
/* ----------------------------------------------------------------------------*/
/*
蓝牙TX发射功率档位, 参考功率值(dbm) ,超过等级范围默认设置为最高档
BD29: rang(0~8) {-18.3, -14.6, -12.1, -8.5, -6.0, -4.1, -1.1, +1.1, +4.0, +6.1}
BD19: rang(0~10) {-17.6, -14.0, -11.5, -9.6, -6.6, -4.4, -0.79, +1.12, +3.8, +5.65, +8.04}
BR23: rang(0~9) {-15.7, -12.5, -10.0, -6.6, -4.4, -2.5, -0.1, +2.1, +4.6, +6.4}
BR25: rang(0~9) {-15.7, -12.5, -10.0, -6.6, -4.4, -2.5, -0.1, +2.1, +4.6, +6.4}
BR30: rang(0~8) {-17.48, -11.46, -7.96, -3.59, -0.79, +1.12, +3.8, +6.5, +8.44}
BR34: rang(0~10) {-17.6, -14.0, -11.5, -9.6, -6.6, -4.4, -1.8, 0, +2.1, +4, +6.3}
*/
void bt_max_pwr_set(u8 pwr, u8 pg_pwr, u8 iq_pwr, u8 ble_pwr);
/* --------------------------------------------------------------------------*/
/**
* @brief bt_set_ldos
*
* @param mode
*/
/* ----------------------------------------------------------------------------*/
void bt_set_ldos(u8 mode);
/* --------------------------------------------------------------------------*/
/**
* @brief ble_set_fix_pwr
*
* @param fix (0~max)
* 动态调整BLE的发射功率
*/
/* ----------------------------------------------------------------------------*/
void ble_set_fix_pwr(u8 fix);
/* --------------------------------------------------------------------------*/
/**
* @brief bredr_set_fix_pwr
*
* @param fix (0~max)
* 动态调整EDR的发射功率
*/
/* ----------------------------------------------------------------------------*/
void bredr_set_fix_pwr(u8 fix);
/* --------------------------------------------------------------------------*/
/**
* @brief ble_rf_vendor_fixed_channel
*
* @param channel_index: 指定信道定频: range 0~39 fixed freq, or 0xff --close fixed,default 37、38、39
* @param pktcnt: adv方式,1次发包的个数: range 1~3
* 配置ble 的 adv、scan、init 状态定频
*/
/* ----------------------------------------------------------------------------*/
bool ble_rf_vendor_fixed_channel(u8 channel_index, u8 pktcnt);
/* --------------------------------------------------------------------------*/
/**
* @brief bredr_get_rssi_for_address
* 获取已连接设备的rssi
*
* @param address 对方mac地址
* @return rssi 值,range(-127 ~ +127)
*/
/* ----------------------------------------------------------------------------*/
s8 bredr_get_rssi_for_address(u8 *address);
/* --------------------------------------------------------------------------*/
/**
* @brief 配置tx 是否支持包类型, (sdk默认支持)
*
* @param packet_type
* @param support_en 0 or 1
* @return true or false
*/
/* ----------------------------------------------------------------------------*/
typedef enum {
PKT_TYPE_2DH5_EU = 0,
} pkt_type_eu;
bool bredr_link_vendor_support_packet_enable(pkt_type_eu packet_type, u8 support_en);
/* --------------------------------------------------------------------------*/
/**
* @brief 配置ble 优先级锁定不低压ACL, (sdk 默认自动调节)
*
* @param role:0--master,1--slave
* @param enalbe 0 or 1
* @return null
*/
/* ----------------------------------------------------------------------------*/
void ble_vendor_set_hold_prio(u8 role, u8 enable);
void set_bt_afh_classs_enc(u8 afh_class);
void set_bt_enhanced_power_control(u8 en);
void set_bt_data_rate_acl_3mbs_mode(u8 en);
void set_bt_full_name_event(u8 en);
/* coexist between bt chips */
void bt_wl_coex_init(uint8_t state);
void bt_wl_coex_enable(bool enable);
#endif
@@ -0,0 +1,25 @@
#ifndef __BTCTRLER_API_FOR_UPDATE_H__
#define __BTCTRLER_API_FOR_UPDATE_H__
extern u32 bt_updata_get_flag(void);
extern void bt_updata_clr_flag(u8 bit_flag);
extern u16 bt_updata_control(u8 btupdata_sw, u16 len, u8 seek_type, u32 seek_offsize);
extern struct lmp_connection *lmp_conn_for_address(u8 *address);
extern void lmp_update_init(void);
extern void bt_rf_init(void);
extern void bredr_bd_init(void);
extern void bredr_link_init(void);
extern void lmp_init(void);
extern int lmp_hci_write_scan_enable(u8 enable);
extern void btctler_nv_memory_apply(void);
extern int link_bulk_init(void);
extern void stack_run_loop_resume(void);
extern void init_soft_interrupt(void);
extern void reg_revic_buf_addr(void *addr);
extern void lmp_hci_write_local_name(const char *name);
extern void lmp_hci_write_local_address(const u8 *addr);
extern void lmp_hci_write_super_timeout(u16 timeout);
extern void bt_max_pwr_set(u8 pwr, u8 pg_pwr, u8 iq_pwr, u8 ble_pwr);
extern void hci_controller_destory(void);
#endif
@@ -0,0 +1,253 @@
#ifndef LMP_API_H
#define LMP_API_H
#include "generic/typedef.h"
struct a2dp_media_frame {
u8 *packet;
u32 clkn;
u8 coding_type;
};
void lmp_private_a2dp_start(void *_conn);
void lmp_private_a2dp_stop(void *_conn);
int lmp_private_is_clearing_a2dp_packet(void *_conn);
int lmp_private_a2dp_channel_exist(void *_conn);
int lmp_private_get_sbc_remain_time(void *_conn, u8 include_tws);
void lmp_private_set_media_type(u8 *addr, u8 type);
u8 lmp_private_get_media_type(void *conn);
void *lmp_private_open_sbc_channel(u8 *addr);
void lmp_private_set_a2dp_rx_notify(void *_conn, void *priv, void (*notify)(void *));
void lmp_private_free_sbc_packet(void *_conn, void *packet);
int lmp_private_get_sbc_data_len(void *_conn);
int lmp_private_get_rx_buffer_size();
void lmp_private_set_max_rx_buf_persent(u8 *addr, int persent);
void *lmp_private_fetch_sbc_packet(void *_conn, int *len, void *_prev, int);
int lmp_private_get_sbc_packet_num(void *_conn);
void lmp_private_close_sbc_channel(void *_conn);
void lmp_private_a2dp_mute(void *_conn);
void lmp_private_a2dp_unmute(void *_conn);
bool lmp_private_a2dp_is_mute(void *_conn);
int lmp_private_get_sbc_packet(void *_conn, struct a2dp_media_frame *frame, int block);
void lmp_private_put_sbc_packet(void *_conn, void *packet);
u8 *lmp_private_get_tx_packet_buffer(int size);
int lmp_private_clear_a2dp_packet(void *_conn, u16 seqn_number);
int lmp_private_get_esco_packet_type();
void *lmp_private_get_esco_packet(int *len, u32 *hash);
void lmp_private_free_esco_packet(void *packet);
int lmp_private_send_esco_packet(void *priv, u8 *packet, int len);
int lmp_private_get_esco_tx_packet_num();
void lmp_esco_set_rx_notify(u8 *addr, void *priv, void (*notify)(void *));
u8 *lmp_private_remote_addr_for_handler(int handle);
u16 lmp_private_handler_for_remote_addr(u8 *addr, int link_type);
int lmp_private_get_rx_buffer_total_size(void *_conn);
int lmp_private_get_rx_buffer_remain_size(void *_conn);
void lmp_hci_private_hold_acl_packet(u8 *packet);
void lmp_hci_private_free_acl_packet(u8 *packet);
void lmp_hci_private_try_free_acl_packet(u8 *packet);
int lmp_hci_send_packet(u8 *packet, int len);
int lmp_hci_send_packet_standard(const u8 *packet, int len);
int lmp_hci_reset();
int lmp_hci_write_scan_enable(u8 enable);
void lmp_hci_write_class_of_device(int dev_class);
void lmp_hci_write_local_name(const char *name);
void lmp_hci_write_local_priv_version(const char *ic_verson, const char *priv_version, u8 *tws_local_addr);
void lmp_hci_write_local_address(const u8 *addr);
void lmp_hci_write_simple_pairing_mode(u8 enable);
void lmp_hci_write_super_timeout(u16 timeout);
void lmp_hci_write_page_timeout(u16 timeout);
void lmp_hci_write_tws_internal_addr(u8 *internal_addr_local, u8 *internal_addr_remote);
void lmp_hci_write_link_supervision_timeout(u16 handle, int);
int lmp_hci_write_le_host_support(int features);
int lmp_hci_read_pin_type();
void lmp_hci_set_pin_code(const char *code, u8 len);
void lmp_hci_pin_code_request_reply(u8 *addr, u8 len, u8 *pin_code);
void lmp_hci_pin_code_request_negative_reply(u8 *addr);
int lmp_hci_write_pin_type(u8 type);
int lmp_hci_set_connection_encryption(u16 handle, int enable);
void lmp_hci_io_capability_request_reply(u8 *addr, u8 io_cap, u8 oob_data, u8 auth_req);
void lmp_hci_user_confirmation_request_reply(u8 *address);
void lmp_hci_user_confirmation_request_negative_reply(u8 *addr);
int lmp_hci_disconnect(u16 handle, u8 reason);
int lmp_hci_test_key_cmd(u8 cmd, u16 handle);
int lmp_hci_send_user_info_cmd(u32 info, u16 handle);
void lmp_hci_accept_connection_request(u8 *addr, u8 role);
void lmp_hci_accept_sco_connection_request(u8 *addr, u32 tx_bandwidth,
u32 rx_bandwidth, u16 max_latency, u16 content_format,
u8 retransmission, u16 packey_type);
void lmp_hci_reject_connection_request(u8 *addr, u8 reason);
void lmp_hci_switch_role_command(u8 *addr, u8 role);
void lmp_hci_authentication_requested(u16 handler);
void lmp_hci_link_key_request_reply(u8 *addr, u8 *link_key);
void lmp_hci_link_key_request_negative_reply(u8 *addr);
void lmp_hci_write_default_link_policy_settings(u16 setting);
void lmp_hci_release_packet(u8 *packet);
void lmp_hci_create_connection(const u8 *addr, u16 packet_type,
u8 repetition_mode, u8 reserved,
u16 clk_offset, u8 allow_role_switch);
void lmp_hci_connection_cancel(u8 *addr);;
void lmp_hci_cancel_page();
void lmp_hci_inquiry(int lap, u8 length, u8 num);
void lmp_hci_cancel_inquiry();
void lmp_hci_sniff_mode_command(u16 handle, u16 max_interval, u16 min_interval, u16 attempt, u16 timeout);
void lmp_hci_exit_sniff_mode_command(u16 handle);
void lmp_hci_host_num_of_completed_packets(u16 handle, u16 num_of_completed_packet);
int lmp_hci_read_remote_version_information(u16 handle);
void lmp_hci_read_remote_supported_features(u16 handle);
void lmp_hci_read_remote_extended_features(u16 handle);
void lmp_hci_role_discovery(u16 handle);
void lmp_hci_read_clock_offset(u16 handle);
void lmp_hci_read_link_policy_settings(u16 handle);
void lmp_hci_write_link_policy_settings(u16 handle, u16 policy);
void lmp_hci_remote_name_request(u8 *addr, u8 page_scan_repetition_mode, u16 clk_offset);
void lmp_set_sniff_establish_by_remote(u8 enable);
void lmp_set_sniff_disable(void);
u8 lmp_hci_read_local_supported_features(int octet);
void lmp_hci_write_local_supported_features(u8 features, int octet);
u8 lmp_standard_connect_check(void);
void lmp_hci_send_keypress_notification(u8 *addr, u8 key);
void lmp_hci_user_keypress_request_reply(u8 *addr, u32 key);
void lmp_hci_user_keypress_request_negative_reply(u8 *addr, u8 key);
void lmp_hci_set_role_switch_supported(bool enable);
void lmp_hci_tx_channel_chassification(u8 *map);
u8 *get_tws_internal_addr(int channel);
extern int lmp_private_esco_suspend_resume(int flag);;
void user_set_tws_box_mode(u8 mode);
void bt_set_tx_power(u8 txpower);
void bredr_bulk_change(u8 mode);
extern u8 get_bredr_link_state();
extern u32 get_bt_slot_time(u8 type, u32 time, int *ret_time, int (*local_us_time)(void));
extern u32 get_sync_rec_instant_us_time();
extern u8 tws_remote_state_check(void);
extern void tws_remote_state_clear(void);
extern void user_set_tws_box_mode(u8 mode);
extern void bredr_fcc_init(u8 mode, u8 fre);
extern void bredr_set_dut_enble(u8 en, u8 phone);
struct link_fix_rx_result {
u32 rx_err_b; //接收到err bit
u32 rx_sum_b; //接收到正确bit
u32 rx_perr_p; //接收到crc 错误 包数
u32 rx_herr_p; //接收到crc 以外其他错误包数
u32 rx_invail_p; //接收到crc错误bit太多的包数,丢弃不统计到err bit中
};
#define DH1_1 0
#define DH3_1 1
#define DH5_1 2
#define DH1_2 3
#define DH3_2 4
#define DH5_2 5
int link_fix_tx_enable(u8 *remote_addr, u8 fre, u8 packet_type, u16 payload);
int link_fix_rx_enable(u8 *remote_addr, u8 fre, u8 packet_type, u16 payload);
void link_fix_txrx_disable();
void link_fix_rx_update_result(struct link_fix_rx_result *result);
void link_fix_rx_dump_result();
struct lmp_connection *lmp_conn_for_handle(int handle);
#endif
@@ -0,0 +1,18 @@
/*********************************************************************************************
* Filename : lmp_config.h
* Description : Lto 优化Macro 定义
* Author : Bingquan
* Email : bingquan_cai@zh-jieli.com
* Last modifiled : 2018-12-19 16:38
* Copyright:(c)JIELI 2011-2017 @ , All Rights Reserved.
*********************************************************************************************/
#ifndef _LMP_CONFIG_H_
#define _LMP_CONFIG_H_
#endif
@@ -0,0 +1,249 @@
/*********************************************************************************************
* Filename : hci_transport.h
* Description :
* Author : Bingquan
* Email : bingquan_cai@zh-jieli.com
* Last modifiled : 2017-01-17 15:14
* Copyright:(c)JIELI 2011-2016 @ , All Rights Reserved.
*********************************************************************************************/
#ifndef __BTCONTROLLER_HCI_TRANSPORT_H
#define __BTCONTROLLER_HCI_TRANSPORT_H
//#include <stdint.h>
#include "generic/typedef.h"
#if defined __cplusplus
extern "C" {
#endif
/* API_START */
typedef struct {
uint32_t baudrate;
int flowcontrol;
const char *device_name;
} btstack_uart_config_t;
typedef enum {
// UART active, sleep off
BTSTACK_UART_SLEEP_OFF = 0,
// used for eHCILL
BTSTACK_UART_SLEEP_RTS_HIGH_WAKE_ON_CTS_PULSE,
// used for H5 and for eHCILL without support for wake on CTS pulse
BTSTACK_UART_SLEEP_RTS_LOW_WAKE_ON_RX_EDGE,
} btstack_uart_sleep_mode_t;
typedef enum {
BTSTACK_UART_SLEEP_MASK_RTS_HIGH_WAKE_ON_CTS_PULSE = 1 << BTSTACK_UART_SLEEP_RTS_HIGH_WAKE_ON_CTS_PULSE,
BTSTACK_UART_SLEEP_MASK_RTS_LOW_WAKE_ON_RX_EDGE = 1 << BTSTACK_UART_SLEEP_RTS_LOW_WAKE_ON_RX_EDGE
} btstack_uart_sleep_mode_mask_t;
typedef struct {
/**
* init transport
* @param uart_config
*/
int (*init)(const btstack_uart_config_t *uart_config);
/**
* open transport connection
*/
int (*open)(void);
/**
* close transport connection
*/
int (*close)(void);
/**
* set callback for block received. NULL disables callback
*/
void (*set_block_received)(void (*block_handler)(void));
/**
* set callback for sent. NULL disables callback
*/
void (*set_block_sent)(void (*block_handler)(void));
/**
* set baudrate
*/
int (*set_baudrate)(uint32_t baudrate);
/**
* set parity
*/
int (*set_parity)(int parity);
/**
* set flowcontrol
*/
int (*set_flowcontrol)(int flowcontrol);
/**
* receive block
*/
void (*receive_block)(uint8_t *buffer, uint16_t len);
/**
* send block
*/
void (*send_block)(const uint8_t *buffer, uint16_t length);
// support for sleep modes in TI's H4 eHCILL and H5
/**
* query supported wakeup mechanisms
* @return supported_sleep_modes mask
*/
int (*get_supported_sleep_modes)(void);
/**
* set UART sleep mode - allows to turn off UART and it's clocks to save energy
* Supported sleep modes:
* - off: UART active, RTS low if receive_block was called and block not read yet
* - RTS high, wake on CTS: RTS should be high. On CTS pulse, UART gets enabled again and RTS goes to low
* - RTS low, wake on RX: data on RX will trigger UART enable, bytes might get lost
*/
void (*set_sleep)(btstack_uart_sleep_mode_t sleep_mode);
/**
* set wakeup handler - needed to notify hci transport of wakeup requests by Bluetooth controller
* Called upon CTS pulse or RX data. See sleep modes.
*/
void (*set_wakeup_handler)(void (*wakeup_handler)(void));
} btstack_uart_block_t;
// common implementations
const btstack_uart_block_t *btstack_uart_block_posix_instance(void);
const btstack_uart_block_t *btstack_uart_block_windows_instance(void);
const btstack_uart_block_t *btstack_uart_block_embedded_instance(void);
const btstack_uart_block_t *btstack_uart_block_freertos_instance(void);
/* HCI packet types */
typedef struct {
/**
* transport name
*/
const char *name;
/**
* init transport
* @param transport_config
*/
void (*init)(const void *transport_config);
/**
* open transport connection
*/
int (*open)(void);
/**
* close transport connection
*/
int (*close)(void);
/**
* register packet handler for HCI packets: ACL, SCO, and Events
*/
void (*register_packet_handler)(void (*handler)(int packet_type, const u8 *packet, int size));
/**
* support async transport layers, e.g. IRQ driven without buffers
*/
int (*can_send_packet_now)(uint8_t packet_type);
/**
* send packet
*/
int (*send_packet)(int packet_type, const u8 *packet, int size);
/**
* extension for UART transport implementations
*/
int (*set_baudrate)(uint32_t baudrate);
/**
* extension for UART H5 on CSR: reset BCSP/H5 Link
*/
void (*reset_link)(void);
/**
* extension for USB transport implementations: config SCO connections
*/
void (*set_sco_config)(uint16_t voice_setting, int num_connections);
} hci_transport_t;
typedef enum {
HCI_TRANSPORT_CONFIG_UART,
HCI_TRANSPORT_CONFIG_USB
} hci_transport_config_type_t;
typedef struct {
hci_transport_config_type_t type;
} hci_transport_config_t;
typedef struct {
hci_transport_config_type_t type; // == HCI_TRANSPORT_CONFIG_UART
uint32_t baudrate_init; // initial baud rate
uint32_t baudrate_main; // = 0: same as initial baudrate
int flowcontrol; //
const char *device_name;
} hci_transport_config_uart_t;
// inline various hci_transport_X.h files
/*
* @brief Setup H4 instance with uart_driver
* @param uart_driver to use
*/
const hci_transport_t *hci_transport_h4_instance(const btstack_uart_block_t *uart_driver);
/*
* @brief Setup H5 instance with uart_driver
* @param uart_driver to use
*/
const hci_transport_t *hci_transport_h5_instance(const btstack_uart_block_t *uart_driver);
/*
* @brief Enable H5 Low Power Mode: enter sleep mode after x ms of inactivity
* @param inactivity_timeout_ms or 0 for off
*/
void hci_transport_h5_set_auto_sleep(uint16_t inactivity_timeout_ms);
/*
* @brief Enable BSCP mode H5, by enabling event parity
*/
void hci_transport_h5_enable_bcsp_mode(void);
/*
* @brief
*/
const hci_transport_t *hci_transport_usb_instance(void);
const hci_transport_t *hci_transport_uart_instance(void);
const hci_transport_t *hci_transport_h4_controller_instance(void);
const hci_transport_t *hci_transport_h4_host_instance(void);
/**
* @brief Specify USB Bluetooth device via port numbers from root to device
*/
void hci_transport_usb_set_path(int len, uint8_t *port_numbers);
/* API_END */
extern const hci_transport_t *hci_transport;
#if defined __cplusplus
}
#endif
#endif // __HCI_TRANSPORT_H
@@ -0,0 +1,58 @@
/*********************************************************************************************
* Filename : btcontroller_config.h
* Description : 优化代码需要,libs 依赖app 定义变量,由app 定义变量值决定libs 优化
* Author : Bingquan
* Email : bingquan_cai@zh-jieli.com
* Last modifiled : 2018-12-19 16:10
* Copyright:(c)JIELI 2011-2017 @ , All Rights Reserved.
*********************************************************************************************/
#ifndef _BTCONTROLLER_CONFIG_H_
#define _BTCONTROLLER_CONFIG_H_
#include "btcontroller_modules.h"
#include "ble/ll_config.h"
// #define CONFIG_LE_FEATURES \
(\
LE_ENCRYPTION | \
LE_CORE_V50_FEATURES \
)
#define CONFIG_LE_FEATURES 0//(LE_ENCRYPTION)
// #define CONFIG_LE_ROLES (LE_ADV|LE_SCAN|LE_INIT|LE_SLAVE|LE_MASTER)
// #define CONFIG_LE_ROLES (LE_ADV|LE_SCAN)
#define CONFIG_LE_ROLES (LE_ADV)
#include "classic/lmp_config.h"
#define CONFIG_CL_FEATURES
#define CONFIG_CL_EX_FEATURES
#define TWS_BLE_ESCO_CONNECT //通话过程进行连接使能
/*
*-------------------
* 蓝牙基带运行的模式
*/
struct lp_ws_t {
u16 lrc_ws_inc;
u16 lrc_ws_init;
u16 bt_osc_ws_inc;
u16 bt_osc_ws_init;
u8 osc_change_mode;
};
#endif