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