This commit is contained in:
lmx
2025-10-29 13:10:02 +08:00
commit 49a07fa419
2284 changed files with 642060 additions and 0 deletions

View File

@ -0,0 +1,278 @@
/*********************************************************************************************
* 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"
// LE CONTROLLER COMMANDS
#define HCI_LE_SET_CIG_PARAMS 0x0062
#define HCI_LE_SETUP_ISO_DATA_PATH 0x006E
#define HCI_LE_CREATE_BIG 0x0068
#define HCI_LE_SET_EXTENDED_ADVERTISING_ENABLE 0x0039
// LE EVENTS
#define HCI_LE_CIS_ESTABLISHED_EVENT 0x19
#define HCI_LE_CIS_REQUEST_EVENT 0x1A
#define HCI_LE_CREATE_BIG_COMPLETE_EVENT 0x1B
#define HCI_SUBEVENT_LE_BIG_INFO_ADV_REPORT_EVT 0x22
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 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 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 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 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;
//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);
int le_controller_set_mac(void *addr);
#endif

View File

@ -0,0 +1,213 @@
/*********************************************************************************************
* 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 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;
/*-----------------------------------------------------------*/
/*
*-------------------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_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_rf_oob;
/*-----------------------------------------------------------*/
/*
*-------------------LE close wait
*/
extern const int ble_disable_wait_enable;
/*-----------------------------------------------------------*/
#endif //_LL_CONFIG_H_

View File

@ -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

View File

@ -0,0 +1,279 @@
/*********************************************************************************************
* 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))
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

View File

@ -0,0 +1,130 @@
#ifndef BTCTRLER_TASK_H
#define BTCTRLER_TASK_H
#include "typedef.h"
#include "system/task.h"
enum {
LMP_EVENT = Q_USER + 1,
LMP_HCI_CMD,
LMP_HCI_CMD_TO_CONN,
HCI_COMMON_CMD,
LL_EVENT,
HCI_CMD_TO_LL,
TWS_LMP_EVENT,
MSG_BT_UPDATA_START,
MSG_BT_UPDATE_LOADER_DOWNLOAD_START,
MSG_BLE_TEST_UPDATA_START,
MSG_BLE_TEST_OTA_LOADER_DOWNLOAD_START,
MSG_TASK_READY,
MSG_TASK_DEL,
};
enum {
BTCTRLER_EVENT_RESUME_REQ = 1,
};
#define SYS_EVENT_FROM_CTRLER (('C' << 24) | ('T' << 16) | ('R' << 8) | '\0')
int bredr_link_event(void *link, int argc, ...);
int bredr_tws_link_event(void *link, int argc, ...);
int btctrler_hci_cmd_to_task(int cmd, int argc, ...);
int lmp_hci_cmd_to_conn_for_handle(u16 handle, int argc, ...);
int lmp_hci_cmd_to_conn_for_addr(u8 *addr, int argc, ...);
int lmp_hci_cmd_to_conn(void *conn, int argc, ...);
#define lmp_hci_cmd_to_task(argc, ...) btctrler_hci_cmd_to_task(LMP_HCI_CMD, argc, ## __VA_ARGS__)
#define ll_hci_cmd_to_task(argc, ...) btctrler_hci_cmd_to_task(HCI_CMD_TO_LL, argc, ## __VA_ARGS__)
int btctrler_task_init(const void *transport, const void *config);
void btctrler_resume_req();
void btctrler_resume();
int btctrler_suspend(u8 suepend_rx_bulk);
int btctrler_task_ready();
int btctrler_task_exit();
int btctrler_task_close_bredr();
void btctrler_task_init_bredr();
void set_idle_period_slot(u16 slot);
enum {
TESTBOX_INFO_VBAT_VALUE = 0, //(u16 (*handle)(void))
TESTBOX_INFO_VBAT_PERCENT, //(u8 (*handle)(void))
TESTBOX_INFO_BURN_CODE, //(u8 *(*handle)(u8 *len))
TESTBOX_INFO_SDK_VERSION, //(u8 *(*handle)(u8 *len))
};
void bt_testbox_ex_info_get_handle_register(u8 info_type, void *handle);
u8 bredr_bulk_change_rx_bulk(u8 mode);
void lmp_set_features_req_step(u8 *addr);
struct ble_dut_tx_param_t {
u8 ch_index; //data[0]
u8 payload_len; //data[1]
u8 payload_type;//data[2]
u8 phy_type; //data[3]
};
struct ble_dut_rx_param_t {
u8 ch_index; //data[0]
u8 phy_type; //data[1]
};
enum BLE_DUT_CTRL_TYPE {
BLE_DUT_SET_RX_MODE = 0, //param1:struct ble_dut_rx_param_t *param;
BLE_DUT_SET_TX_MODE, //param1:struct ble_dut_tx_param_t *param;
BLE_DUT_SET_TEST_END, //param1:u16 *pkt_valid_cnt,param2:u16 *pkt_err_cnt;
};
struct ble_dut_ops_t {
/* *****************************************************************************/
/**
* @brief : initialize the ble dut test module
*
* @param : void
*
* @return : pointer to instance of test module
*/
/* *****************************************************************************/
void *(*init)(void);
/* *****************************************************************************/
/**
* @brief : ble dut test control api,such as setting rx/tx mode,stop testing
*
* @param : control type,using enum BLE_DUT_CTRL_TYPE value;
* @param : vary from different control type;
*/
/* *****************************************************************************/
int (*ioctrl)(int ctrl, ...);
/* *****************************************************************************/
/**
* @brief : exit the ble dut test module
*
* @param : poniter to instance of test module
*/
/* *****************************************************************************/
void (*exit)(void *priv);
};
extern const struct ble_dut_ops_t *__ble_dut_ops;
#endif

View File

@ -0,0 +1,220 @@
#ifndef LMP_API_H
#define LMP_API_H
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_open_sbc_channel(u8 *addr, u16 channel, u8 codec_type);
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);
int lmp_private_get_sbc_packet(void *_conn, u8 **frame, int block);
u8 *lmp_private_get_tx_packet_buffer(int size);
int lmp_private_clear_a2dp_packet(void *_conn, u16 seqn_number);
int lmp_private_send_esco_packet(void *priv, u8 *packet, int len);
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);
extern int a2dp_media_clear_packet_before_seqn(u16 seqn_number);
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();
#endif

View File

@ -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

View File

@ -0,0 +1,243 @@
#ifndef TWS_API_H
#define TWS_API_H
#include "typedef.h"
#include "classic/tws_event.h"
#include "classic/tws_local_media_sync.h"
#include "classic/tws_data_trans.h"
#define TWS_ROLE_MASTER 0
#define TWS_ROLE_SLAVE 1
/*
* tws 状态
*/
#define TWS_STA_SIBLING_DISCONNECTED 0x00000001 //tws未连接
#define TWS_STA_SIBLING_CONNECTED 0x00000002 //tws已连接
#define TWS_STA_PHONE_DISCONNECTED 0x00000004 //手机未连接
#define TWS_STA_PHONE_CONNECTED 0x00000008 //手机已连接
#define TWS_STA_ESCO_OPEN 0x00000010 //正在打电话
#define TWS_STA_SBC_OPEN 0x00000020 //正在播歌
#define TWS_STA_MONITOR_START 0x00000040 //tws从机开始监听手机链路
#define TWS_STA_LOCAL_TWS_OPEN 0x00000080 //开启local_tws
#define TWS_STA_ESCO_OPEN_LINK 0x00000100 //正在打电话create link
#define TWS_STA_MONITOR_ING 0x00000200 //tws主从收到监听信息
#define TWS_SYNC_CALL_TX 1
#define TWS_SYNC_CALL_RX 2
struct tws_sync_call {
int uuid;
void (*func)(int priv, int err);
const char *task_name;
};
extern const struct tws_sync_call tws_sync_call_begin[];
extern const struct tws_sync_call tws_sync_call_end[];
#define list_for_each_tws_sync_call(p) \
for (p = tws_sync_call_begin; p < tws_sync_call_end; p++)
#define TWS_SYNC_CALL_REGISTER(sync_call) \
static const struct tws_sync_call __tws_##sync_call sec(.tws_sync_call)
#define TWS_FUNC_ID(a, b, c, d) (((a) << 24) | ((b) << 16) | ((c) << 8) | (d))
typedef void (*tws_func_t)(void *data, u16 len, bool rx);
struct tws_func_stub {
u32 func_id;
tws_func_t func; //call from irq
};
#define REGISTER_TWS_FUNC_STUB(stub) \
static const struct tws_func_stub stub sec(.tws_func_stub)
extern const struct tws_func_stub tws_func_stub_begin[];
extern const struct tws_func_stub tws_func_stub_end[];
static inline tws_func_t tws_function_get_by_id(u32 id)
{
const struct tws_func_stub *p;
for (p = tws_func_stub_begin; p < tws_func_stub_end; p++) {
if (p->func_id == id) {
return p->func;
}
}
return NULL;
}
static inline void tws_function_call_by_id(u32 id, void *data, u16 len, bool rx)
{
const struct tws_func_stub *p;
for (p = tws_func_stub_begin; p < tws_func_stub_end; p++) {
if (p->func_id == id) {
p->func(data, len, rx);
break;
}
}
}
/*
* 通过搜索码搜索tws设备
*/
int tws_api_search_sibling_by_code(u16 code, int timeout_ms);
/*
*打开可发现, 可连接可被手机和tws搜索到
*/
int tws_api_wait_pair_by_code(u16 code, const char *name, int timeout_ms);
int tws_api_wait_pair_by_ble(u16 code, const char *name, int timeout_ms);
int tws_api_wait_tws_pair(int code, const char *name);
int tws_api_wait_phone_pair(int code, const char *name);
int tws_wait_tws_pair(u16 code, const char *name);
int tws_wait_phone_pair(u16 code, const char *name);
/*
*取消可发现, 可连接可被tws搜索到
*/
int tws_api_cancle_wait_pair();
/*
* 搜索并连接已经配对过的tws
* timeout: 单位ms 0 表示不超时
* 返回值: 0: 函数调用成功
*/
int tws_api_create_connection(int timeout);
/*
* 取消搜索已配对的tws
*/
int tws_api_cancle_create_connection();
/*
* 打开可发现,可连接, 可以被手机和已配对过的tws连接
*/
int tws_api_wait_connection();
/*
* 断开tws直接的连接
* reason: 断开原因
*/
int tws_api_detach(enum tws_detach_reason reason);
/*
* 获取主从, 播歌和打电话状态下结果不可靠,请勿调用
*/
int tws_api_get_role();
/*
* 获取tws 连接的状态
* 返回值: 详见顶部TWS_STA_**
*/
int tws_api_get_tws_state();
/*
* 设置tws对方地址
*/
int tws_api_set_sibling_addr(u8 *addr);
/*
* 获取tws对方地址
*/
int tws_api_get_sibling_addr(u8 *addr);
/*
* 获取tws本地地址
*/
int tws_api_get_local_addr(u8 *addr);
/*
*发送解除配对命令给对方, 成功后会收到TWS_EVENT_REMOVE_PAIRS事件
*/
int tws_api_remove_pairs();
/*
* 设置本地声道
* 'L': 左声道
* 'R': 右声道
* 'U': 双声道合并
*/
void tws_api_set_local_channel(char channel);
/*
* 获取本地声道
*/
char tws_api_get_local_channel();
/*
* 通过uuid主从同步调用相同函数
*/
int tws_api_sync_call_by_uuid(int uuid, int priv, int delay_ms);
/*
* tws 数据发送函数, 要求 len <= 512
*/
int tws_api_send_data_to_sibling(void *data, u16 len, u32 func_id);
int tws_api_send_data_to_slave(void *data, int len, u32 func_id);
int tws_profile_init();
int tws_profile_exit();
int tws_api_connect_in_esco();
int tws_api_cancle_connect_in_esco();
int tws_disconnect();
/*
* 使能对耳自动主从切换
*/
void tws_api_auto_role_switch_enable();
/*
* 关闭对耳自动主从切换
*/
void tws_api_auto_role_switch_disable();
int tws_api_get_low_latency_state();
int tws_api_low_latency_enable(bool enable);
void tws_api_set_quick_connect_addr(u8 *addr);
u8 *tws_api_get_quick_connect_addr();
void tws_api_common_addr_en(u8 en);
void tws_api_pair_all_way(u8 en);
int tws_api_power_saving_mode_enable();
int tws_api_power_saving_mode_disable();
int tws_api_enter_pure_monitor_mode();
void tws_try_connect_disable(void);
void tws_conn_switch_role();
void tws_api_role_switch();
#endif

View File

@ -0,0 +1,47 @@
#ifndef TWS_DATA_TRANS_H
#define TWS_DATA_TRANS_H
#include "generic/typedef.h"
enum {
TWS_DATA_TRANS_SOURCE,
TWS_DATA_TRANS_SINK,
};
enum tws_data_trans_attr {
TWS_DTC_LOCAL_MEDIA,
TWS_DTC_MIC_REC,
};
u8 tws_api_data_trans_open(u8 channel, enum tws_data_trans_attr attr, u16 buf_size);
int tws_api_data_trans_start(u8 channel, u8 *arg, u8 len);
int tws_api_data_trans_stop(u8 channel);
int tws_api_data_trans_close(u8 channel);
void tws_api_data_trans_auto_drop(u8 channel, int enable);
int tws_api_data_trans_send(u8 channel, u8 *buf, int len);
void *tws_api_data_trans_buf_alloc(u8 channel, int len);
int tws_api_data_trans_push(u8 channel, void *_frame, int len);
void *tws_api_data_trans_pop(u8 channel, int *len);
void tws_api_data_trans_free(u8 channel, void *_frame);
void *tws_api_data_trans_fetch(u8 channel, void *_prev, int *len);
void tws_api_data_trans_clear(u8 channel);
int tws_api_data_trans_check(u8 channel, u16 *ready_len, u16 *total_len);
#endif

View File

@ -0,0 +1,95 @@
#ifndef TWS_EVENT_H
#define TWS_EVENT_H
#define KEY_EVENT_FROM_TWS (('T' << 24) | ('W' << 16) | ('S' << 8) | '\0')
#define SYS_BT_EVENT_FROM_TWS (('T' << 24) | ('W' << 16) | ('S' << 8) | '\0')
enum {
TWS_STA_WAIT_SIBLING_PAIR = 1,
TWS_STA_SEARCH_SIBLING,
TWS_STA_CREATE_CONNECTION_BREDR,
TWS_STA_CREATE_CONNECTION_BLE,
TWS_STA_WAIT_CONNECTION_BREDR,
TWS_STA_WAIT_CONNECTION_BLE,
TWS_STA_DISCONNECTION,
TWS_STA_CONNECTION,
TWS_STA_START_MONITOR,
TWS_STA_MONITOR,
TWS_STA_WAIT_PHONE_PAIR,
TWS_STA_WAIT_PAIR,
};
enum {
LOCAL_REMOTE_ADDR = 0,
TWS_PAIR_REMOTE_ADDR_STATE_OK,
TWS_PAIR_REMOTE_ADDR_STATE_NOT,
};
enum tws_detach_reason {
TWS_DETACH_BY_SUPER_TIMEOUT = 8,
TWS_DETACH_BY_LOCAL,
TWS_DETACH_BY_REMOTE,
TWS_DETACH_BY_POWEROFF,
TWS_DETACH_BY_REMOVE_PAIRS,
TWS_DETACH_BY_TESTBOX_CON,
TWS_DETACH_BY_REMOVE_NO_RECONN,
};
#define TWS_CONN_CHANNEL 0
#define TWS_LINK_SYNC_CHANNEL 1
#define TWS_LMP_SYNC_CHANNEL 2
#define TWS_AFH_SYNC_CHANNEL 3
#define TWS_TX_SYNC_CHANNEL 4
#define TWS_LOW_LATENCY_CHANNEL 5
#define TWS_DATA_SYNC_CHANNEL 6
#define TWS_SBC_SYNC_CHANNEL 7
#define TWS_EVENT_SYNC_CHANNEL 8
#define TWS_SYNC_CALL_CHANNEL 9
#define TWS_POWER_BALANCE_CHANNEL 10
#define TWS_CI_DATA_SYNC_CHANNEL 11
#define TWS_LOCAL_MEIDA_SYNC_CHANNEL 12
#define TWS_LMP_SLOT_CHANNEL 13
#define TWS_DATA_TRANS_CHANNEL 14
enum {
TWS_EVENT_SEARCH_TIMEOUT = 1,
TWS_EVENT_CONNECTED,
TWS_EVENT_CONNECTION_TIMEOUT,
TWS_EVENT_CONNECTION_DETACH,
TWS_EVENT_REMOVE_PAIRS,
TWS_EVENT_PHONE_LINK_DETACH,
TWS_EVENT_SYNC_FUN_CMD,
TWS_EVENT_SYNC_FUN_TRANID,
TWS_EVENT_CONNECT_TEST,
TWS_EVENT_ROLE_SWITCH,
TWS_EVENT_LOCAL_MEDIA_START,
TWS_EVENT_LOCAL_MEDIA_STOP,
TWS_EVENT_ESCO_ADD_CONNECT,
TWS_EVENT_SETUP_MONITOR_LINK,
TWS_EVENT_MONITOR_START,
TWS_EVENT_DATA_TRANS_OPEN,
TWS_EVENT_DATA_TRANS_START,
TWS_EVENT_DATA_TRANS_STOP,
TWS_EVENT_DATA_TRANS_CLOSE,
TWS_EVENT_MODE_CHANGE, //sniff without phone
TWS_EVENT_ROLE_SWITCH_START,
TWS_EVENT_TONE_TEST = 0xff,
};
#endif

View File

@ -0,0 +1,48 @@
#ifndef TWS_LOCAL_MEDIA_SYNC_H
#define TWS_LOCAL_MEDIA_SYNC_H
#include "generic/list.h"
#include "generic/typedef.h"
void tws_api_local_media_trans_start();
void tws_api_local_media_trans_set_buf(void *buf, int size);
void *tws_api_local_media_trans_alloc(int len);
void tws_api_local_media_trans_free(void *frame);
void tws_api_local_media_trans_push(void *frame, int len);
void *tws_api_local_media_trans_pop(int *len);
void *tws_api_local_media_trans_fetch(void *prev, int *len);
void tws_api_local_media_trans_stop();
void tws_api_local_media_trans_packet_del(void *_frame);
int tws_api_local_media_trans_check_total(u8 head);
int tws_api_local_media_trans_check_ready_total(void);
void tws_api_local_media_trans_clear(void);
int tws_api_local_media_packet_cnt(u8 *rx_packet_cnt, u8 *wait_send_pcaket_cnt);
// 填数超过了一定值才可以发送
void tws_api_local_media_set_limit_size(int size);
int tws_api_local_media_trans_bulk_push(u8 *buf, int len);
int tws_api_local_media_push_with_sequence(u8 *buf, int len, u16 seqn);
int tws_api_local_media_push_with_timestamp(u8 *buf, int len, u32 timestamp);
int tws_api_local_media_trans_open(u16 buf_size);
int tws_api_local_media_dec_start(u8 *arg, u8 len);
int tws_api_local_media_dec_stop();
void tws_api_auto_drop_frame_enable(int enable);
#endif

View File

@ -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

View File

@ -0,0 +1,56 @@
/*********************************************************************************************
* 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

View File

@ -0,0 +1,209 @@
SECTIONS
{
.data : ALIGN(4)
{
btctler_data_start = .;
BTCTLER_CONTROLLER_DATA_START = .;
*(.bt_rf_data)
*(.vendor_manager_data)
*(.device_manager_data)
*(.hci_controller_data)
*(.hci_interface_data)
BTCTLER_CONTROLLER_DATA_SIZE = ABSOLUTE(. - BTCTLER_CONTROLLER_DATA_START);
BTCTLER_LE_CONTROLLER_DATA_START = .;
*(.ble_ll_data)
*(.ble_hci_data)
*(.ble_rf_data)
BTCTLER_LE_CONTROLLER_DATA_SIZE = ABSOLUTE(. - BTCTLER_LE_CONTROLLER_DATA_START);
BTCTLER_CL_DATA_START = .;
*(.classic_hci_data)
*(.classic_lmp_data)
*(.classic_lmp_auth_data)
*(.classic_lmp_bigint_data)
*(.classic_lmp_crypt_data)
*(.classic_lmp_ecdh_data)
*(.classic_lmp_linkbulk_data)
*(.classic_lmp_hmac_data)
*(.classic_rf_data)
*(.classic_bb_data)
BTCTLER_CL_DATA_SIZE = ABSOLUTE(. - BTCTLER_CL_DATA_START);
btctler_data_end = .;
} > ram0
.bss (NOLOAD) :ALIGN(4)
{
btctler_bss_start = .;
BTCTLER_CONTROLLER_BSS_START = .;
*(.bd_base)
*(.bredr_rxtx_bulk)
*(.bredr_tx_bulk)
*(.bt_rf_bss)
*(.hci_controller_bss)
*(.hci_interface_bss)
*(.device_manager_bss)
*(.vendor_manager_bss)
BTCTLER_CONTROLLER_BSS_SIZE = ABSOLUTE(. - BTCTLER_CONTROLLER_BSS_START);
BTCTLER_LE_CONTROLLER_BSS_START = .;
*(.ble_hci_bss)
*(.ble_ll_bss)
*(.ble_rf_bss)
BTCTLER_LE_CONTROLLER_BSS_SIZE = ABSOLUTE(. - BTCTLER_LE_CONTROLLER_BSS_START);
BTCTLER_CL_BSS_START = .;
*(.classic_rf_bss)
*(.classic_lmp_bss)
*(.classic_lmp_auth_bss)
*(.classic_lmp_bigint_bss)
*(.classic_lmp_crypt_bss)
*(.classic_lmp_ecdh_bss)
*(.classic_lmp_linkbulk_bss)
*(.classic_lmp_hmac_bss)
*(.classic_bb_bss)
*(.classic_hci_bss)
BTCTLER_CL_BSS_SIZE = ABSOLUTE(. - BTCTLER_CL_BSS_START);
btctler_bss_end = .;
} > ram0
.text : ALIGN(4)
{
btctler_code_start = .;
BTCTLER_CONTROLLER_CODE_START = .;
*(.bt_rf_const)
*(.bt_rf_code)
*(.vendor_manager_const)
*(.vendor_manager_code)
*(.device_manager_const)
*(.device_manager_code)
*(.hci_controller_const)
*(.hci_controller_code)
*(.hci_interface_const)
*(.hci_interface_code)
BTCTLER_CONTROLLER_CODE_SIZE = ABSOLUTE(. - BTCTLER_CONTROLLER_CODE_START);
BTCTLER_LE_CONTROLLER_CODE_START = .;
*(.ble_rf_const)
*(.ble_rf_code)
*(.ble_ll_const)
*(.ble_ll_code)
*(.ble_hci_const)
*(.ble_hci_code)
BTCTLER_LE_CONTROLLER_CODE_SIZE = ABSOLUTE(. - BTCTLER_LE_CONTROLLER_CODE_START);
BTCTLER_CL_CODE_START = .;
*(.bredr_irq)
*(.bredr_irq_code)
*(.bredr_irq_const)
*(.classic_hci_const)
*(.classic_hci_code)
*(.classic_lmp_const)
*(.classic_lmp_auth_const)
*(.classic_lmp_bigint_const)
*(.classic_lmp_crypt_const)
*(.classic_lmp_ecdh_const)
*(.classic_lmp_hmac_const)
*(.classic_lmp_code)
*(.classic_lmp_auth_code)
*(.classic_lmp_bigint_code)
*(.classic_lmp_crypt_code)
*(.classic_lmp_ecdh_code)
*(.classic_lmp_hmac_code)
*(.classic_rf_const)
*(.classic_rf_code)
*(.classic_bb_const)
*(.classic_bb_code)
BTCTLER_CL_CODE_SIZE = ABSOLUTE(. - BTCTLER_CL_CODE_START);
*(.classic_tws_const)
*(.classic_tws_code)
*(.classic_tws_code.esco)
. = ALIGN(4);
} > code0
.data_code ALIGN(32):
{
. = ALIGN(4);
*(.lmp_irq_code)
*(.link_bulk_code)
*(.frame_irq_code)
. = ALIGN(4);
*(.link_task_const)
*(.link_task_code)
. = ALIGN(4);
*(.classic_irq_const)
*(.classic_irq_code)
. = ALIGN(4);
*(.tws_irq_code)
. = ALIGN(4);
tws_sync_call_begin = .;
KEEP(*(.tws_sync_call))
tws_sync_call_end = .;
. = ALIGN(4);
tws_func_stub_begin = .;
KEEP(*(.tws_func_stub))
tws_func_stub_end = .;
*(.tws_media_sync_code)
*(.tws_media_sync_const)
*(.tws_data_forward_code)
*(.tws_data_forward_const)
. = ALIGN(4);
tws_sync_channel_begin = .;
KEEP(*(.tws_sync_channel.0))
KEEP(*(.tws_sync_channel.1))
KEEP(*(.tws_sync_channel.2))
KEEP(*(.tws_sync_channel.3))
KEEP(*(.tws_sync_channel.4))
KEEP(*(.tws_sync_channel.5))
KEEP(*(.tws_sync_channel.6))
KEEP(*(.tws_sync_channel.7))
KEEP(*(.tws_sync_channel.8))
KEEP(*(.tws_sync_channel.9))
KEEP(*(.tws_sync_channel.10))
KEEP(*(.tws_sync_channel.11))
KEEP(*(.tws_sync_channel.12))
KEEP(*(.tws_sync_channel.13))
tws_sync_channel_end = .;
btctler_code_end = .;
. = ALIGN(4);
} > ram0
/*代码统计 Code & RAM : 蓝牙协议栈*/
BTCTLER_LE_RAM_TOTAL = BTCTLER_LE_CONTROLLER_DATA_SIZE + BTCTLER_LE_CONTROLLER_BSS_SIZE;
BTCTLER_LE_CODE_TOTAL = BTCTLER_LE_CONTROLLER_CODE_SIZE;
BTCTLER_CL_RAM_TOTAL = BTCTLER_CL_DATA_SIZE + BTCTLER_CL_BSS_SIZE;
BTCTLER_CL_CODE_TOTAL = BTCTLER_CL_CODE_SIZE;
BTCTLER_COMMON_RAM_TOTAL = BTCTLER_CONTROLLER_BSS_SIZE + BTCTLER_CONTROLLER_DATA_SIZE;
BTCTLER_COMMON_CODE_TOTAL = BTCTLER_CONTROLLER_CODE_SIZE ;
BTCTLER_RAM_TOTAL = (btctler_data_end - btctler_data_start) + (btctler_bss_end - btctler_bss_start);
BTCTLER_CODE_TOTAL = (btctler_code_end - btctler_code_start);
}