1 /****************************************************************************** 2 * Copyright (c) 2022 Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK") 3 * All rights reserved. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 *****************************************************************************/ 18 19 #ifndef AOA_AOD_H_ 20 #define AOA_AOD_H_ 21 22 #if (LL_FEATURE_EANBLE_LE_AOA_AOD) 23 24 #define ANTENNA_MAX_NUM 0x07 //confirm with YeYang,our device can support 7 antennas. 25 //75;reference period only use 1 antenna; (160us-4-8)/2 = 74 antenna. so max 75 antennas 26 #define SWITCH_PATTERN_MAX_LEN 0x4b 27 28 #define CTE_SET_PARAM_ADVHANDLE0_DONE_FLAG BIT(0) 29 #define CTE_SET_PARAM_ADVHANDLE1_DONE_FLAG BIT(1) 30 #define CTE_SET_PARAM_ADVHANDLE2_DONE_FLAG BIT(2) 31 #define CTE_SET_PARAM_ADVHANDLE3_DONE_FLAG BIT(3) ///now only support 4 adv set. 32 #define PRD_ADV_SET_PARAM_DONE_FLAG BIT(4) 33 34 35 #define CTE_SET_TRANSMIT_PARAM_CONNHANDLE0 BIT(0) /// 36 #define CTE_SET_TRANSMIT_PARAM_CONNHANDLE1 BIT(1) 37 #define CTE_SET_TRANSMIT_PARAM_CONNHANDLE2 BIT(2) 38 #define CTE_SET_TRANSMIT_PARAM_CONNHANDLE3 BIT(3) 39 #define CTE_SET_TRANSMIT_PARAM_CONNHANDLE4 BIT(4) 40 #define CTE_SET_TRANSMIT_PARAM_CONNHANDLE5 BIT(5) 41 #define CTE_SET_TRANSMIT_PARAM_CONNHANDLE6 BIT(6) 42 #define CTE_SET_TRANSMIT_PARAM_CONNHANDLE7 BIT(7) ///now support 8 connection device:4 master and 4 slave. 43 44 #define CTE_SET_RECEIVE_PARAM_CONNHANDLE0 BIT(0) 45 #define CTE_SET_RECEIVE_PARAM_CONNHANDLE1 BIT(1) 46 #define CTE_SET_RECEIVE_PARAM_CONNHANDLE2 BIT(2) 47 #define CTE_SET_RECEIVE_PARAM_CONNHANDLE3 BIT(3) 48 49 typedef struct{ 50 u8 AOA_type; 51 u8 AOD_type_1us; 52 u8 AOD_type_2us; 53 u8 rsvd; 54 }CTE_type_t; 55 56 57 enum{ 58 Antenna_ID0 = 0, 59 Antenna_ID1 = 1, 60 Antenna_ID2 = 2, 61 Antenna_ID3 = 3, 62 Antenna_ID4 = 4, 63 Antenna_ID5 = 5, 64 Antenna_ID6 = 6, 65 }; 66 67 enum{ 68 AOD_1US_TRANSMIT = BIT(0), 69 AOD_1US_RECEIVE = BIT(1), 70 AOA_1US_SWITCH_SAMPLE = BIT(2), 71 }; 72 73 enum{ 74 SWITCH_SAMPLE_SLOT_1US = 0x01, //confirm with YeYang, our device support 1us sample. 75 SWITCH_SAMPLE_SLOT_2US = 0x02, 76 }; 77 78 enum{ 79 CTE_NOT_EXIST = 0x00, 80 CTE_TRANSMIT = 0x01, 81 CTE_RECEIVE = 0x02, 82 }; 83 84 85 typedef struct{ 86 //transmit and receive setting 87 u8 cte_switch_pattern_len; 88 u8 cte_swtich_pattern[SWITCH_PATTERN_MAX_LEN]; 89 90 //transmit setting 91 u8 cte_len; 92 u8 cte_type; //for transmit. AOA/AOD_1US/AOD_2US 93 u8 cte_count; 94 u8 cte_transmit_en; 95 96 //receive setting 97 u8 cte_slot_duration; //for receive; 1us/2us 98 u8 Max_Sampled_CTEs; //for receive; max CTE count per period adv interval. 99 u8 cte_sample_en; //sample enable 100 u8 cte_trsmitRev_flag; //transmit or receive flag. just for operate more convenient. 101 102 u8 cte_req_en; 103 u8 cte_rsp_en; 104 u16 cte_req_intvl; 105 106 u8 sequence_ctrl; 107 u8 rsvd[3]; 108 }switch_pattern_t; 109 110 extern _attribute_data_retention_ _attribute_aligned_(4) switch_pattern_t cte_connLess_switchPattern[]; 111 extern _attribute_data_retention_ _attribute_aligned_(4) switch_pattern_t cte_conn_switchPattern[]; 112 113 114 ble_sts_t blc_hci_le_setConnectionless_CTETransmitParams(hci_le_setConnectionless_CTETransmitParam_t* connLessTxParams); 115 ble_sts_t blc_hci_le_setConnectionless_CTETransmit_Enable(hci_le_CTE_enable_type* connLessTxCtr); 116 ble_sts_t blc_hci_le_setConnectionless_IQsample_Enable(hci_le_setConnectionless_IQsampleEn_t* IQsampleEn); 117 ble_sts_t blc_hci_le_setConnection_CTEReceiveParams(hci_le_setConnection_CTERevParams_t* cteRevParam); 118 ble_sts_t blc_hci_le_setConnection_CTETransmitParams(hci_le_setConnection_CTETransmitParams_t* cteTransmitParams); 119 ble_sts_t blc_hci_le_connection_CTEReq_Enable(hci_le_cteReqEn_t* connCTEReqEn); 120 ble_sts_t blc_hci_le_connection_CTERsp_Enable(hci_le_cteRspEn_t* connCTERspEn); 121 ble_sts_t blc_hci_le_ReadAntennaInfor(u8* inforBuff); 122 bool blc_le_setAntennaInfor(cte_antenna_infor_t* antennaInfor); 123 124 #endif ///#if (LL_FEATURE_EANBLE_LE_AOA_AOD) 125 126 #endif ///AOA_AOD_H_ 127