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 #ifndef BLE_FORMAT_H 19 #define BLE_FORMAT_H 20 21 22 #include "stack/ble/ble_common.h" 23 24 25 typedef struct { 26 u8 llid :2; 27 u8 nesn :1; 28 u8 sn :1; 29 u8 md :1; 30 u8 rfu1 :3; 31 u8 rf_len; 32 }rf_acl_data_head_t; 33 34 35 36 typedef struct { 37 u8 llid :2; 38 u8 nesn :1; 39 u8 sn :1; 40 u8 cie :1; 41 u8 rfu0 :1; 42 u8 npi :1; 43 u8 rfu1 :1; 44 u8 rf_len; 45 }rf_cis_data_hdr_t; 46 47 48 49 typedef struct { 50 u8 llid :2; 51 u8 cssn :3; 52 u8 cstf :1; 53 u8 rfu0 :2; 54 u8 rf_len; 55 }rf_bis_data_hdr_t; 56 57 58 59 typedef struct{ 60 u8 type; 61 u8 rf_len; 62 u8 opcode; 63 u8 cigId; 64 u8 cisId; 65 u8 phyM2S; 66 u8 phyS2M; 67 68 u32 maxSduM2S :12; 69 u32 rfu0 :3; 70 u32 framed :1; 71 u32 maxSduS2M :12; 72 u32 rfu1 :4; 73 74 u8 sduIntvlM2S[3]; //SDU_Interval_M_To_S(20 bits) + RFU(4 bits) 75 u8 sduIntvlS2M[3]; //SDU_Interval_S_To_M(20 bits) + RFU(4 bits) 76 77 u16 maxPduM2S; 78 u16 maxPduS2M; 79 u8 nse; 80 u8 subIntvl[3]; //unit: uS 81 82 u8 bnM2S:4; 83 u8 bnS2M:4; 84 u8 ftM2S; 85 u8 ftS2M; 86 u16 isoIntvl; //unit: 1.25 mS 87 88 u8 cisOffsetMin[3]; 89 u8 cisOffsetMax[3]; 90 u16 connEventCnt; //similar to instant 91 92 }rf_packet_ll_cis_req_t; 93 94 typedef struct{ 95 u8 type; //RA(1)_TA(1)_RFU(2)_TYPE(4) 96 u8 rf_len; //LEN(6)_RFU(2) 97 u8 opcode; 98 u8 cisOffsetMin[3]; 99 u8 cisOffsetMax[3]; 100 u16 connEventCnt; 101 }rf_packet_ll_cis_rsp_t; 102 103 typedef struct{ 104 u8 type; //RA(1)_TA(1)_RFU(2)_TYPE(4) 105 u8 rf_len; //LEN(6)_RFU(2) 106 u8 opcode; 107 u32 cisAccessAddr; //Access Address of the CIS 108 u8 cisOffset[3]; 109 u8 cigSyncDly[3]; 110 u8 cisSyncDly[3]; 111 u16 connEventCnt; 112 }rf_packet_ll_cis_ind_t; 113 114 typedef struct{ 115 u8 type; 116 u8 rf_len; 117 u8 opcode; 118 u8 cig_id; 119 u8 cis_id; 120 u8 errorCode; 121 }rf_packet_ll_cis_terminate_t; 122 123 124 125 typedef struct{ 126 union{ 127 rf_bis_data_hdr_t bisPduHdr; 128 rf_cis_data_hdr_t cisPduHdr; 129 rf_acl_data_head_t aclPduHdr; 130 struct{ 131 u8 type; 132 u8 rf_len; 133 }pduHdr; 134 }llPduHdr; /* LL PDU Header: 2 */ 135 u8 llPayload[1]; /* Max LL Payload length: 251 */ 136 }llPhysChnPdu_t; 137 138 typedef struct{ 139 u32 dma_len; 140 llPhysChnPdu_t llPhysChnPdu; 141 }rf_packet_ll_data_t; 142 143 144 145 146 147 148 149 150 typedef struct{ 151 u8 type; 152 u8 rf_len; 153 u16 l2capLen; 154 u16 chanId; 155 u8 opcode; 156 u16 handle; 157 u8 dat[20]; 158 }rf_packet_att_t; 159 160 161 typedef struct{ 162 u8 type; 163 u8 rf_len; 164 u16 l2cap; 165 u16 chanid; 166 167 u8 att; 168 u16 handle; 169 170 u8 dat[20]; 171 172 }rf_packet_att_data_t; 173 174 175 176 177 178 179 180 181 182 183 184 185 186 #endif /* BLE_FORMAT_H */ 187