Welcome to mirror list, hosted at ThFree Co, Russian Federation.

tl.h « tl « ble_thread « patterns « interface « STM32_WPAN « ST « Middlewares - github.com/Flipper-Zero/STM32CubeWB.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e7b006e4bf3cf8b2e26b3ff62a4c9bf1a90577e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
/**
 ******************************************************************************
 * @file    tl.h
 * @author  MCD Application Team
 * @brief   Header for tl module
 ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
  * All rights reserved.</center></h2>
  *
  * This software component is licensed by ST under BSD 3-Clause license,
  * the "License"; You may not use this file except in compliance with the
  * License. You may obtain a copy of the License at:
  *                        opensource.org/licenses/BSD-3-Clause
  *
  ******************************************************************************
 */


/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __TL_H
#define __TL_H

#ifdef __cplusplus
extern "C" {
#endif


/* Includes ------------------------------------------------------------------*/
#include "stm32_wpan_common.h"

/* Exported defines -----------------------------------------------------------*/
#define TL_BLECMD_PKT_TYPE                                              ( 0x01 )
#define TL_ACL_DATA_PKT_TYPE                                            ( 0x02 )
#define TL_BLEEVT_PKT_TYPE                                              ( 0x04 )
#define TL_OTCMD_PKT_TYPE                                               ( 0x08 )
#define TL_OTRSP_PKT_TYPE                                               ( 0x09 )
#define TL_CLICMD_PKT_TYPE                                              ( 0x0A )
#define TL_OTNOT_PKT_TYPE                                               ( 0x0C )
#define TL_OTACK_PKT_TYPE                                               ( 0x0D )
#define TL_CLINOT_PKT_TYPE                                              ( 0x0E )
#define TL_CLIACK_PKT_TYPE                                              ( 0x0F )
#define TL_SYSCMD_PKT_TYPE  	                                        ( 0x10 )
#define TL_SYSRSP_PKT_TYPE  	                                        ( 0x11 )
#define TL_SYSEVT_PKT_TYPE  	                                        ( 0x12 )
#define TL_LOCCMD_PKT_TYPE  	                                        ( 0x20 )
#define TL_LOCRSP_PKT_TYPE  	                                        ( 0x21 )
#define TL_TRACES_APP_PKT_TYPE                                          ( 0x40 )
#define TL_TRACES_WL_PKT_TYPE                                           ( 0x41 )

#define TL_CMD_HDR_SIZE                                                      (4)
#define TL_EVT_HDR_SIZE                                                      (3)
#define TL_EVT_CS_PAYLOAD_SIZE                                               (4)

#define TL_BLEEVT_CC_OPCODE                                               (0x0E)
#define TL_BLEEVT_CS_OPCODE                                               (0x0F)

#define TL_BLEEVT_CS_PACKET_SIZE        (TL_EVT_HDR_SIZE + sizeof(TL_CsEvt_t))
#define TL_BLEEVT_CS_BUFFER_SIZE        (sizeof(TL_PacketHeader_t) + TL_BLEEVT_CS_PACKET_SIZE)

/* Exported types ------------------------------------------------------------*/
/**< Packet header */
typedef PACKED_STRUCT
{
  uint32_t *next;
  uint32_t *prev;
} TL_PacketHeader_t;

/*******************************************************************************
 * Event type
 */

/**
 * This the payload of TL_Evt_t for a command status event
 */
typedef PACKED_STRUCT
{
  uint8_t   status;
  uint8_t   numcmd;
  uint16_t  cmdcode;
} TL_CsEvt_t;

/**
 * This the payload of TL_Evt_t for a command complete event
 */
typedef PACKED_STRUCT
{
  uint8_t   numcmd;
  uint16_t  cmdcode;
  uint8_t   payload[1];
} TL_CcEvt_t;

/**
 * This the payload of TL_Evt_t for an asynchronous event
 */
typedef PACKED_STRUCT
{
  uint16_t  subevtcode;
  uint8_t   payload[1];
} TL_AsynchEvt_t;

typedef PACKED_STRUCT
{
  uint8_t   evtcode;
  uint8_t   plen;
  uint8_t   payload[1];
} TL_Evt_t;

typedef PACKED_STRUCT
{
  uint8_t   type;
  TL_Evt_t  evt;
} TL_EvtSerial_t;

/**
 * This format shall be used for all events (asynchronous and command response) reported
 * by the CPU2 except for the command response of a system command where the header is not there
 * and the format to be used shall be TL_EvtSerial_t.
 * Note: Be careful that the asynchronous events reported by the CPU2 on the system channel do
 * include the header and shall use TL_EvtPacket_t format. Only the command response format on the
 * system channel is different.
 */
typedef PACKED_STRUCT
{
  TL_PacketHeader_t  header;
  TL_EvtSerial_t     evtserial;
} TL_EvtPacket_t;

/*****************************************************************************************
 * Command type
 */

typedef PACKED_STRUCT
{
  uint16_t   cmdcode;
  uint8_t   plen;
  uint8_t   payload[255];
} TL_Cmd_t;

typedef PACKED_STRUCT
{
  uint8_t   type;
  TL_Cmd_t  cmd;
} TL_CmdSerial_t;

typedef PACKED_STRUCT
{
  TL_PacketHeader_t  header;
  TL_CmdSerial_t     cmdserial;
} TL_CmdPacket_t;

/*****************************************************************************************
 * HCI ACL DATA type
 */
typedef PACKED_STRUCT
{
  uint8_t   type;
  uint16_t  handle;
  uint16_t  length;
  uint8_t   acl_data[1];
} TL_AclDataSerial_t;

typedef PACKED_STRUCT
{
  TL_PacketHeader_t  header;
  TL_AclDataSerial_t   AclDataSerial;
} TL_AclDataPacket_t;

typedef struct
{
  uint8_t  *p_BleSpareEvtBuffer;
  uint8_t  *p_SystemSpareEvtBuffer;
  uint8_t  *p_AsynchEvtPool;
  uint32_t AsynchEvtPoolSize;
  uint8_t  *p_TracesEvtPool;
  uint32_t TracesEvtPoolSize;
} TL_MM_Config_t;

typedef struct
{
  uint8_t *p_ThreadOtCmdRspBuffer;
  uint8_t *p_ThreadCliRspBuffer;
  uint8_t *p_ThreadNotAckBuffer;
} TL_TH_Config_t;

typedef struct
{
  uint8_t *p_LldTestsCliRspBuffer;
  uint8_t *p_LldTestsNotAckBuffer;
} TL_LLD_tests_Config_t;

typedef struct
{
  uint8_t *p_Mac_802_15_4_CmdRspBuffer;
  uint8_t *p_Mac_802_15_4_NotAckBuffer;
} TL_MAC_802_15_4_Config_t;

typedef struct
{
  uint8_t *p_ZigbeeOtCmdRspBuffer;
  uint8_t *p_ZigbeeNotAckBuffer;
  uint8_t *p_ZigbeeLoggingBuffer;
} TL_ZIGBEE_Config_t;

/**
 * @brief Contain the BLE HCI Init Configuration
 * @{
 */
typedef struct
{
  void (* IoBusEvtCallBack) ( TL_EvtPacket_t *phcievt );
  void (* IoBusAclDataTxAck) ( void );
  uint8_t *p_cmdbuffer;
  uint8_t *p_AclDataBuffer;
} TL_BLE_InitConf_t;

/**
 * @brief Contain the SYSTEM HCI Init Configuration
 * @{
 */
typedef struct
{
  void (* IoBusCallBackCmdEvt) (TL_EvtPacket_t *phcievt);
  void (* IoBusCallBackUserEvt) (TL_EvtPacket_t *phcievt);
  uint8_t *p_cmdbuffer;
} TL_SYS_InitConf_t;

/* Exported constants --------------------------------------------------------*/
/* External variables --------------------------------------------------------*/
/* Exported macros -----------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */

/******************************************************************************
 * GENERAL
 ******************************************************************************/
void TL_Enable( void );
void TL_Init( void );

/******************************************************************************
 * BLE
 ******************************************************************************/
int32_t TL_BLE_Init( void* pConf );
int32_t TL_BLE_SendCmd( uint8_t* buffer, uint16_t size );
int32_t TL_BLE_SendAclData( uint8_t* buffer, uint16_t size );

/******************************************************************************
 * SYSTEM
 ******************************************************************************/
int32_t TL_SYS_Init( void* pConf  );
int32_t TL_SYS_SendCmd( uint8_t* buffer, uint16_t size );

/******************************************************************************
 * THREAD
 ******************************************************************************/
void TL_THREAD_Init( TL_TH_Config_t *p_Config );
void TL_OT_SendCmd( void );
void TL_CLI_SendCmd( void );
void TL_OT_CmdEvtReceived( TL_EvtPacket_t * Otbuffer );
void TL_THREAD_NotReceived( TL_EvtPacket_t * Notbuffer );
void TL_THREAD_SendAck ( void );
void TL_THREAD_CliSendAck ( void );
void TL_THREAD_CliNotReceived( TL_EvtPacket_t * Notbuffer );

/******************************************************************************
 * LLD tests
 ******************************************************************************/
void TL_LLDTESTS_Init( TL_LLD_tests_Config_t *p_Config );
void TL_LLDTESTS_CliSendCmd( void );
void TL_LLDTESTS_NotReceived( TL_EvtPacket_t * Notbuffer );
void TL_LLDTESTS_CliSendAck ( void );
void TL_LLDTESTS_CliNotReceived( TL_EvtPacket_t * Notbuffer );

/******************************************************************************
 * MEMORY MANAGER
 ******************************************************************************/
void TL_MM_Init( TL_MM_Config_t *p_Config );
void TL_MM_EvtDone( TL_EvtPacket_t * hcievt );

/******************************************************************************
 * TRACES
 ******************************************************************************/
void TL_TRACES_Init( void );
void TL_TRACES_EvtReceived( TL_EvtPacket_t * hcievt );

/******************************************************************************
 * MAC 802.15.4
 ******************************************************************************/
void TL_MAC_802_15_4_Init( TL_MAC_802_15_4_Config_t *p_Config );
void TL_MAC_802_15_4_SendCmd( void );
void TL_MAC_802_15_4_CmdEvtReceived( TL_EvtPacket_t * Otbuffer );
void TL_MAC_802_15_4_NotReceived( TL_EvtPacket_t * Notbuffer );
void TL_MAC_802_15_4_SendAck ( void );

/******************************************************************************
 * ZIGBEE
 ******************************************************************************/
void TL_ZIGBEE_Init( TL_ZIGBEE_Config_t *p_Config );
void TL_ZIGBEE_SendAppliCmdToM0( void );
void TL_ZIGBEE_SendAckAfterAppliNotifFromM0 ( void );
void TL_ZIGBEE_NotReceived( TL_EvtPacket_t * Notbuffer );
void TL_ZIGBEE_CmdEvtReceived( TL_EvtPacket_t * Otbuffer );
void TL_ZIGBEE_LoggingReceived(TL_EvtPacket_t * Otbuffer );
void TL_ZIGBEE_SendAckAfterAppliLoggingFromM0 ( void );

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif /*__TL_H */

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/