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

ble_lld_private.h « App « STM32_WPAN « BLE_LLD_Pressbutton « BLE_LLD « Applications « NUCLEO-WB15CC « Projects - github.com/Flipper-Zero/STM32CubeWB.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e2173dd708edf2ec7a64e605920fc82bee2b5b3a (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
/**
 ******************************************************************************
  * File Name          : app_ble_lld_private.h
  * Description        : Header for BLE LLD communication with M0.
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
  * All rights reserved.</center></h2>
  *
  * This software component is licensed by ST under Ultimate Liberty license
  * SLA0044, the "License"; You may not use this file except in compliance with
  * the License. You may obtain a copy of the License at:
  *                             www.st.com/SLA0044
  *
  ******************************************************************************
 */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef BLE_LLD_PRIVATE_H
#define BLE_LLD_PRIVATE_H

#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/

/* Private includes ----------------------------------------------------------*/

/* Exported types ------------------------------------------------------------*/

/* Exported constants --------------------------------------------------------*/

/* External variables --------------------------------------------------------*/

/* Exported macros ------------------------------------------------------------*/

/* Exported functions ------------------------------------------------------- */

/* ---------------------------------------------------------------------------*/
/* ------------------------------- BLE LLD -----------------------------------*/
/* ---------------------------------------------------------------------------*/

/* max payload length(255) + header (2) (257 bytes) aligned on 32-bit (65 word = 260 bytes) */
#define RADIO_PKT_RX_BUF_SIZE       260 
#define RADIO_PKT_TX_BUF_SIZE       260 

/* Commands to M0 */
typedef enum
{
  HAL_BLE_LLD_UNUSED_CMDCODE = 0,
  HAL_BLE_LLD_INIT_CMDCODE ,
  HAL_BLE_LLD_SETNETWORKID_CMDCODE,
  HAL_BLE_LLD_SENDPACKET_CMDCODE,
  HAL_BLE_LLD_SENDPACKETWITHACK_CMDCODE,
  HAL_BLE_LLD_RECEIVEPACKET_CMDCODE,
  HAL_BLE_LLD_RECEIVEPACKETWITHACK_CMDCODE,
  BLE_LLD_GETSTATUS_CMDCODE,
  BLE_LLD_SETCHANNELMAP_CMDCODE,
  BLE_LLD_SETCHANNEL_CMDCODE,
  BLE_LLD_SETTXATTRIBUTES_CMDCODE,
  BLE_LLD_SETBACKTOBACKTIME_CMDCODE,
  BLE_LLD_SETTXPOWER_CMDCODE,
  BLE_LLD_SETTX_RX_PHY_CMDCODE,
  BLE_LLD_STOPACTIVITY_CMDCODE,
  BLE_LLD_SETENCRYPTIONCOUNT_CMDCODE,
  BLE_LLD_SETENCRYPTIONATTRIBUTES_CMDCODE,
  BLE_LLD_SETENCRYPTFLAGS_CMDCODE,
  BLE_LLD_ENCRYPTPLAINDATA_CMDCODE,
  BLE_LLD_STARTTONE_CMDCODE,
  BLE_LLD_STOPTONE_CMDCODE,
  BLE_LLD_SETRESERVEDAREA_CMDCODE,
  BLE_LLD_MAKEACTIONPACKETPENDING_CMDCODE,
  BLE_LLD_INIT_CMDCODE,
} BLE_LLD_Code_t;

/* dataRoutine and condRoutine struct */
typedef PACKED_STRUCT
{
  uint8_t condCase;
  uint8_t dataCase;
} setCase_t;

/* Structure for Buffer */
typedef PACKED_STRUCT
{
  uint8_t txBuffer[RADIO_PKT_TX_BUF_SIZE]; /* __I */ /*txBuffer + Encrypt*/
  uint8_t rxBuffer[RADIO_PKT_RX_BUF_SIZE]; /* __O */ /*rxBuffer + radioPacketNb=rxBuffer[257] */
} buffer_BLE_LLD_t;

/* Generic structure for messages to M0, mostly used as a size reference.
   Only returnValue is used.
   A specialized structure (param_hal_BLE_xxx_t or param_BLE_LLD_xxx_t) should
   be used for actual messages. */
typedef PACKED_STRUCT
{
  uint8_t padding1[24];
  uint8_t returnValue;
  uint8_t padding2[5];
  setCase_t padding3;
  buffer_BLE_LLD_t padding4;
} param_BLE_LLD_t;

/** Parameters for command HAL_BLE_SETNETWORKID_CMDCODE */
typedef PACKED_STRUCT
{
  uint32_t padding1[2];
  uint32_t id;
} param_BLE_LLD_network_t;

/** Parameters for commands HAL_BLE_SENDPACKET_CMDCODE and
 *  HAL_BLE_LLD_SENDPACKETWITHACK_CMDCODE */
typedef PACKED_STRUCT
{
  uint32_t wakeupTime;
  uint32_t receiveTimeout;
  uint32_t packetNumber;
  uint8_t padding1[13];
  uint8_t channel;
  uint8_t padding2;
  uint8_t packetStopRx;
  uint8_t padding3[2];
  setCase_t setCase;
  buffer_BLE_LLD_t txrxBuffer;
} param_BLE_LLD_send_t;

/** Parameters for commands HAL_BLE_RECEIVEPACKET_CMDCODE and
 * HAL_BLE_LLD_RECEIVEPACKETWITHACK_CMDCODE */
typedef PACKED_STRUCT
{
  uint32_t wakeupTime;
  uint32_t receiveTimeout;
  uint32_t packetNumber;
  uint8_t padding1[14];
  uint8_t channel;
  uint8_t packetStopRx;
  uint8_t padding2[2];
  setCase_t setCase;
  buffer_BLE_LLD_t txrxBuffer;
} param_BLE_LLD_receive_t;

/** Parameters for command BLE_LLD_GETSTATUS_CMDCODE */
typedef PACKED_STRUCT
{
  uint32_t padding1[2];
  uint32_t time;
} param_BLE_LLD_status_t;

/** Parameters for command BLE_LLD_SETENCRYPTIONCOUNT_CMDCODE */
typedef PACKED_STRUCT
{
  uint8_t padding1[27];
  uint8_t stateMachineNo;
  uint8_t padding2[2];
  setCase_t padding3;
  uint8_t countTx[5];
  uint8_t countRcv[5];
} param_BLE_LLD_cryptCount_t;

/** Parameters for command BLE_LLD_SETENCRYPTIONATTRIBUTES_CMDCODE */
typedef PACKED_STRUCT
{
  uint8_t padding1[27];
  uint8_t stateMachineNo;
  uint8_t padding2[2];
  setCase_t padding3;
  uint8_t encIv[AES_IV_SIZE];
  uint8_t encKey[AES_KEY_SIZE];
} param_BLE_LLD_cryptAttr_t;

/** Parameters for command BLE_LLD_SETENCRYPTFLAGS_CMDCODE */
typedef PACKED_STRUCT
{
  uint8_t padding1[25];
  uint8_t encFlagTx;
  uint8_t encFlagRx;
  uint8_t StateMachineNo;
} param_BLE_LLD_cryptFlags_t;

/** Parameters for command BLE_LLD_ENCRYPTPLAINDATA_CMDCODE */
typedef PACKED_STRUCT
{
  uint8_t padding1[30];
  setCase_t padding2;
  uint8_t key[AES_KEY_SIZE];
  uint8_t padding3[112];
  uint8_t plainData[AES_BLOCK_SIZE];
  uint8_t padding[116];
  uint8_t cypherData[AES_BLOCK_SIZE];
} param_BLE_LLD_crypt_t;

/** Parameters for command BLE_LLD_STARTTONE_CMDCODE */
typedef PACKED_STRUCT
{
  uint8_t padding1[25];
  uint8_t channel;
  uint8_t padding2;
  uint8_t power;
} param_BLE_LLD_toneStart_t;

/** Parameters for command BLE_LLD_SETCHANNELMAP_CMDCODE */
typedef PACKED_STRUCT
{
  uint8_t padding1[27];
  uint8_t stateMachineNo;
  uint8_t padding2[2];
  setCase_t padding3;
  uint8_t map[CHAN_MAP_SIZE];
} param_BLE_LLD_chanMap_t;

/** Parameters for command BLE_LLD_SETCHANNEL_CMDCODE */
typedef PACKED_STRUCT
{
  uint8_t padding1[25];
  uint8_t channel;
  uint8_t channelInc;
  uint8_t stateMachineNo;
} param_BLE_LLD_chan_t;

/** Parameters for command BLE_LLD_SETTXATTRIBUTES_CMDCODE */
typedef PACKED_STRUCT
{
  uint32_t crcInit;
  uint32_t sca;
  uint32_t networkId;
  uint8_t padding1[15];
  uint8_t stateMachineNo;
} param_BLE_LLD_txAttr_t;

/** Parameters for command BLE_LLD_SETBACKTOBACKTIME_CMDCODE */
typedef PACKED_STRUCT
{
  uint32_t backToBackTime;
} param_BLE_LLD_b2b_t;

/** Parameters for command BLE_LLD_SETTXPOWER_CMDCODE */
typedef PACKED_STRUCT
{
  uint8_t padding1[27];
  uint8_t power;
} param_BLE_LLD_power_t;

/** Parameters for command BLE_LLD_SETTX_RX_PHY_CMDCODE */
typedef PACKED_STRUCT
{
  uint8_t padding1[25];
  uint8_t txPhy;
  uint8_t rxPhy;
  uint8_t stateMachineNo;
} param_BLE_LLD_phy_t;

/** Parameters for command BLE_LLD_SETRESERVEDAREA_CMDCODE */
typedef PACKED_STRUCT
{
  uint32_t wakeupTime;
  uint32_t receiveWindowLength;
  uint8_t padding1[17];
  uint8_t nextTrue;
  uint8_t nextFalse;
  uint8_t stateMachineNo;
  uint8_t actionTag;
  uint8_t actionPacketNb;
  setCase_t setCase;
  buffer_BLE_LLD_t txrxBuffer;
} param_BLE_LLD_reserved_t;

/** Parameters for command BLE_LLD_MAKEACTIONPACKETPENDING_CMDCODE */
typedef PACKED_STRUCT
{
  uint32_t padding1[2];
  uint32_t packetNumber;
  uint8_t padding2[15];
  uint8_t packetStopRx;
  uint8_t padding3;
  uint8_t actionPacketNb;
} param_BLE_LLD_mkPending_t;

/** Parameters for command BLE_LLD_INIT_CMDCODE */
typedef PACKED_STRUCT
{
  uint32_t startupTime;
  uint8_t padding1[24];
  uint8_t lowSpeedOsc;
  uint8_t whitening;
  setCase_t padding2;
  buffer_BLE_LLD_t txrxBuffer;
} param_BLE_LLD_init_t;

/** Parameters for replies */
typedef PACKED_STRUCT
{
  uint8_t padding1[12];
  uint32_t status;
  uint32_t timestampReceive;
  uint32_t rssi;
  uint8_t padding2[6];
  setCase_t padding3;
  buffer_BLE_LLD_t txrxBuffer;
} param_BLE_LLD_m0Reply_t;

/** Command to M0 */
typedef PACKED_STRUCT
{
  uint8_t id;
  param_BLE_LLD_t *params;
} bleCmd_t;

#endif /* BLE_LLD_PRIVATE_H */

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