• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 IAL_H_
19 #define IAL_H_
20 
21 #include "stack/ble/controller/ll/iso/iso.h"
22 
23 /*
24  * First fragment of sdu, data field
25  */
26 #define HCI_ISO_PKT_HDR_HANDLE_LEN     (2)
27 #define HCI_ISO_PKT_HDR_DATA_LEN       (2)
28 #define HCI_ISO_LOAD_HDR_TIMESTAMP_LEN (4)
29 #define HCI_ISO_LOAD_HDR_PACKET_SN_LEN (2)
30 #define HCI_ISO_LOAD_SDU_LEN           (2)
31 
32 #define HCI_ISO_PKT_HDR_LEN (HCI_ISO_PKT_HDR_HANDLE_LEN + HCI_ISO_PKT_HDR_DATA_LEN)
33 
34 #define HCI_ISO_LOAD_HDR_LEN_MAX                                                                                      \
35     (HCI_ISO_LOAD_HDR_TIMESTAMP_LEN + HCI_ISO_LOAD_HDR_PACKET_SN_LEN + HCI_ISO_LOAD_SDU_LEN)
36 #define HCI_ISO_LOAD_HDR_LEN_MIN (HCI_ISO_LOAD_HDR_PACKET_SN_LEN + HCI_ISO_LOAD_SDU_LEN)
37 
38 #define ISO_FRAMED_SEGM_HEADER_LEN (2)
39 #define ISO_FRAMED_TIMEOFFSET_LEN  (3)
40 
41 /*
42  * HCI ISO data packet
43  */
44 typedef struct {
45     // 0
46     u32 timestamp;
47     u16 offset;
48     u16 sn_offset;
49 
50     // 8
51     u16 connHandle : 12;
52     u16 pb : 2;
53     u16 ts : 1;
54     u16 RFU2 : 1;
55     // 10
56     u16 iso_dl_len : 14;  // iso_data_load_length
57     u16 RFU3 : 2;
58 
59     // 11
60     u8 data[1];
61 } iso_data_packet_t;
62 
63 /******************************* Macro & Enumeration & Structure Definition for Stack End ****************************/
64 
65 /******************************* Macro & Enumeration variables for User Begin ****************************************/
66 
67 /******************************* Macro & Enumeration variables for User End ******************************************/
68 
69 /******************************* User Interface  Begin ***************************************************************/
70 
71 /**
72  * @brief      This function is used to initialize the ISOAL module.
73  */
74 void blc_ial_initSdu_module(void);
75 
76 /**
77  * @brief      This function is used to initialize sdu buff.
78  * @param[in]  rx_fifo
79  * @param[in]  rx_fifo_size
80  * @param[in]  rx_fifo_num
81  * @param[in]  tx_fifo
82  * @param[in]  tx_fifo_size
83  * @param[in]  tx_fifo_num
84  */
85 void blc_ial_initCisSduBuff(u8 *rx_fifo, u16 rx_fifo_size, u8 rx_fifo_num, u8 *tx_fifo, u16 tx_fifo_size,
86                             u8 tx_fifo_num);
87 
88 /**
89  * @brief      This function is used to initialize cis sdu buff.
90  * @param[in]  rx_fifo
91  * @param[in]  rx_fifo_size
92  * @param[in]  rx_fifo_num
93  * @param[in]  tx_fifo
94  * @param[in]  tx_fifo_size
95  * @param[in]  tx_fifo_num
96  */
97 void blc_ial_initBisSduBuff(u8 *rx_fifo, u16 rx_fifo_size, u8 rx_fifo_num, u8 *tx_fifo, u16 tx_fifo_size,
98                             u8 tx_fifo_num);
99 
100 /**
101  * @brief      This function is used to pack HCI ISO data packet to SDU packet.
102  * @param[in]  cis_connHandle - point to handle of cis.
103  * @param[in]  pIsoData - point to hci ISO Data packet buff.
104  * @return     Status - 0x00: command succeeded; 0x01-0xFF: command failed
105  */
106 ble_sts_t blc_hci_packIsoData(u16 cis_connHandle, u8 *pIsoData);
107 
108 /**
109  * @brief      This function is used to setup ISO Data Path.
110  * @param[in]  refer to the structure 'hci_le_setupIsoDataPathCmdParams_t'
111  * @return     Status - 0x00: command succeeded; 0x01-0xFF: command failed
112  */
113 ble_sts_t blc_isoal_le_setupISODataPath_cmd(hci_le_setupIsoDataPathCmdParams_t *para);
114 
115 /**
116  * @brief      This function is used to segmentation SDU to one Framed PDUs.
117  * @param[in]  cis_connHandle
118  * @return      Status - 0x00: command succeeded; IAL_ERR_SDU_LEN_EXCEED_SDU_MAX
119  * 						 LL_ERR_INVALID_PARAMETER: command failed
120  */
121 ble_sts_t blc_ial_splitCisSdu2FramedPdu(u16 cis_connHandle);
122 
123 /**
124  * @brief      This function is used to fragmentation SDU to one or more Unframed PDUs.
125  * @param[in]  cis_connHandle
126  * @param[in]  sdu  point to sdu buff
127  * @return      Status - 0x00: command succeeded; IAL_ERR_SDU_LEN_EXCEED_SDU_MAX
128  * 						 LL_ERR_INVALID_PARAMETER: command failed
129  */
130 ble_sts_t blc_ial_cis_splitSdu2UnframedPdu(u16 cisHandle, iso_data_packet_t *sdu);
131 
132 /**
133  * @brief      This function is used to fragmentation SDU to one or more Unframed PDUs.
134  * @param[in]  bis_connHandle
135  * @param[in]  sdu  point to sdu buff
136  * @return      Status - 0x00: command succeeded; IAL_ERR_SDU_LEN_EXCEED_SDU_MAX
137  * 						 LL_ERR_INVALID_PARAMETER: command failed
138  */
139 ble_sts_t blc_ial_bis_splitSdu2UnframedPdu(u16 bis_connHandle, iso_data_packet_t *sdu);
140 
141 /******************************* User Interface  End  ****************************************************************/
142 
143 #endif
144