Skip to content

Commit b5a1453

Browse files
committed
Merge branch 'main' into feat/add-ble-headers
2 parents e1da737 + 136f49a commit b5a1453

File tree

5 files changed

+346
-32
lines changed

5 files changed

+346
-32
lines changed

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
//"rust-analyzer.cargo.target": "thumbv7m-none-eabi",
1818
// "rust-analyzer.cargo.target": "thumbv7em-none-eabi",
1919
//"rust-analyzer.cargo.target": "thumbv7em-none-eabihf",
20-
// "rust-analyzer.cargo.target": "thumbv8m.main-none-eabihf",
20+
"rust-analyzer.cargo.target": "thumbv8m.main-none-eabihf",
2121
"rust-analyzer.cargo.features": [],
2222
"rust-analyzer.linkedProjects": [
2323
"stm32-bindings-gen/Cargo.toml",
Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,210 @@
1+
#define __PACKED_STRUCT struct __attribute__((packed))
2+
#define __PACKED_UNION union __attribute__((packed))
3+
#define __STATIC_INLINE static
4+
#define __ALIGNED(x) __attribute__((aligned(x)))
5+
6+
/* USER CODE BEGIN Header */
7+
/**
8+
******************************************************************************
9+
* @file app_ble.h
10+
* @author MCD Application Team
11+
* @brief Header for ble application
12+
******************************************************************************
13+
* @attention
14+
*
15+
* Copyright (c) 2022 STMicroelectronics.
16+
* All rights reserved.
17+
*
18+
* This software is licensed under terms that can be found in the LICENSE file
19+
* in the root directory of this software component.
20+
* If no LICENSE file comes with this software, it is provided AS-IS.
21+
*
22+
******************************************************************************
23+
*/
24+
/* USER CODE END Header */
25+
26+
/* Define to prevent recursive inclusion -------------------------------------*/
27+
#ifndef APP_BLE_H
28+
#define APP_BLE_H
29+
30+
#ifdef __cplusplus
31+
extern "C"
32+
{
33+
#endif
34+
35+
/* Includes ------------------------------------------------------------------*/
36+
37+
/* Private includes ----------------------------------------------------------*/
38+
#include "ble_types.h"
39+
/* USER CODE BEGIN Includes */
40+
41+
/* USER CODE END Includes */
42+
43+
/* Exported types ------------------------------------------------------------*/
44+
45+
typedef enum
46+
{
47+
APP_BLE_IDLE,
48+
APP_BLE_LP_CONNECTING,
49+
APP_BLE_CONNECTED_SERVER,
50+
APP_BLE_CONNECTED_CLIENT,
51+
APP_BLE_ADV_FAST,
52+
APP_BLE_ADV_LP,
53+
APP_BLE_ADV_NON_CONN_FAST,
54+
APP_BLE_ADV_NON_CONN_LP,
55+
/* USER CODE BEGIN APP_BLE_ConnStatus_t */
56+
57+
/* USER CODE END APP_BLE_ConnStatus_t */
58+
} APP_BLE_ConnStatus_t;
59+
60+
/**
61+
* HCI Event Packet Types
62+
*/
63+
typedef __PACKED_STRUCT
64+
{
65+
uint32_t *next;
66+
uint32_t *prev;
67+
}
68+
BleEvtPacketHeader_t;
69+
70+
typedef __PACKED_STRUCT
71+
{
72+
uint8_t evtcode;
73+
uint8_t plen;
74+
uint8_t payload[1];
75+
}
76+
BleEvt_t;
77+
78+
typedef __PACKED_STRUCT
79+
{
80+
uint8_t type;
81+
BleEvt_t evt;
82+
}
83+
BleEvtSerial_t;
84+
85+
typedef __PACKED_STRUCT __ALIGNED(4)
86+
{
87+
BleEvtPacketHeader_t header;
88+
BleEvtSerial_t evtserial;
89+
}
90+
BleEvtPacket_t;
91+
92+
typedef enum
93+
{
94+
PROC_GAP_GEN_PHY_TOGGLE,
95+
PROC_GAP_GEN_CONN_TERMINATE,
96+
PROC_GATT_EXCHANGE_CONFIG,
97+
/* USER CODE BEGIN ProcGapGeneralId_t */
98+
99+
/* USER CODE END ProcGapGeneralId_t */
100+
} ProcGapGeneralId_t;
101+
102+
typedef enum
103+
{
104+
PROC_GAP_PERIPH_ADVERTISE_START_LP,
105+
PROC_GAP_PERIPH_ADVERTISE_START_FAST,
106+
PROC_GAP_PERIPH_ADVERTISE_NON_CONN_START_LP,
107+
PROC_GAP_PERIPH_ADVERTISE_NON_CONN_START_FAST,
108+
PROC_GAP_PERIPH_ADVERTISE_STOP,
109+
PROC_GAP_PERIPH_ADVERTISE_DATA_UPDATE,
110+
PROC_GAP_PERIPH_CONN_PARAM_UPDATE,
111+
/* USER CODE BEGIN ProcGapPeripheralId_t */
112+
113+
/* USER CODE END ProcGapPeripheralId_t */
114+
} ProcGapPeripheralId_t;
115+
116+
typedef enum
117+
{
118+
PROC_GAP_CENTRAL_SCAN_START,
119+
PROC_GAP_CENTRAL_SCAN_TERMINATE,
120+
/* USER CODE BEGIN ProcGapCentralId_t */
121+
122+
/* USER CODE END ProcGapCentralId_t */
123+
} ProcGapCentralId_t;
124+
125+
/* USER CODE BEGIN ET */
126+
127+
/* USER CODE END ET */
128+
129+
/* Exported constants --------------------------------------------------------*/
130+
/* USER CODE BEGIN EC */
131+
/* ST Manufacturer ID */
132+
#define ST_MANUF_ID 0x30
133+
134+
/* BlueSTSDK Version */
135+
enum
136+
{
137+
BLUESTSDK_V1 = 0x01,
138+
BLUESTSDK_V2 = 0x02
139+
};
140+
141+
/* BOARD ID */
142+
enum
143+
{
144+
BOARD_ID_NUCLEO_WBA5X = 0x8B,
145+
BOARD_ID_DK_WBA5X = 0x91,
146+
BOARD_ID_B_WBA5M_WPAN = 0x8D,
147+
BOARD_ID_NUCLEO_WBA6X = 0x8E,
148+
BOARD_ID_DK_WBA6X = 0x92,
149+
BOARD_ID_B_WBA6M_WPAN = 0x93
150+
};
151+
152+
/* FIRMWARE ID */
153+
enum
154+
{
155+
FW_ID_P2P_SERVER = 0x83,
156+
FW_ID_P2P_ROUTER = 0x85,
157+
FW_ID_DT_SERVER = 0x88,
158+
FW_ID_COC_PERIPH = 0x87,
159+
FW_ID_HEART_RATE = 0x89,
160+
FW_ID_HEALTH_THERMO = 0x8A,
161+
FW_ID_HID = 0x8B,
162+
FW_ID_SENSOR = 0x9C,
163+
FW_ID_GENERIC_HEALTH_SENSOR = 0x9D
164+
};
165+
166+
/* USER CODE END EC */
167+
168+
/* External variables --------------------------------------------------------*/
169+
/* USER CODE BEGIN EV */
170+
171+
/* USER CODE END EV */
172+
173+
/* Exported macro ------------------------------------------------------------*/
174+
#define ADV_INT_MS(x) ((uint16_t)((x) / 0.625f))
175+
#define SCAN_WIN_MS(x) ((uint16_t)((x) / 0.625f))
176+
#define SCAN_INT_MS(x) ((uint16_t)((x) / 0.625f))
177+
#define CONN_INT_MS(x) ((uint16_t)((x) / 1.25f))
178+
#define CONN_SUP_TIMEOUT_MS(x) ((uint16_t)((x) / 10.0f))
179+
#define CONN_CE_LENGTH_MS(x) ((uint16_t)((x) / 0.625f))
180+
181+
#define HCI_LE_ADVERTISING_REPORT_RSSI(p) \
182+
(*(int8_t *)((&((hci_le_advertising_report_event_rp0 *)(p))->Advertising_Report[0].Length_Data) + 1 + \
183+
((hci_le_advertising_report_event_rp0 *)(p))->Advertising_Report[0].Length_Data))
184+
/* USER CODE BEGIN EM */
185+
186+
/* USER CODE END EM */
187+
188+
/* Exported functions prototypes ---------------------------------------------*/
189+
void APP_BLE_Init(void);
190+
void BleStack_Process_BG(void);
191+
APP_BLE_ConnStatus_t APP_BLE_Get_Server_Connection_Status(void);
192+
void APP_BLE_Procedure_Gap_General(ProcGapGeneralId_t ProcGapGeneralId);
193+
void APP_BLE_Procedure_Gap_Peripheral(ProcGapPeripheralId_t ProcGapPeripheralId);
194+
const uint8_t *BleGetBdAddress(void);
195+
tBleStatus SetGapAppearance(uint16_t appearance);
196+
tBleStatus SetGapDeviceName(uint8_t *devicename, uint8_t devicename_len);
197+
void Ble_UserEvtRx(void);
198+
void APP_BLE_HostNvmStore(void);
199+
/* USER CODE BEGIN EFP */
200+
201+
/* USER CODE END EFP */
202+
203+
#ifdef __cplusplus
204+
}
205+
#endif
206+
207+
#endif /*APP_BLE_H */
208+
209+
#include "ble_core.h"
210+
#include "blestack.h"

stm32-bindings-gen/res/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ cortex-m-rt = { version = ">=0.6.15,<0.8", optional = true }
5151
defmt = { version = "0.3.0", optional = true }
5252

5353
[features]
54-
default = ["pac"]
54+
default = ["pac", "wba_wpan_mac", "wba_wpan_ble"]
5555

5656
wba_wpan_mac = []
5757
wba_wpan_ble = []
Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1+
#[cfg(feature = "wba_wpan_ble")]
2+
pub mod ble_stack;
13
#[cfg(feature = "wba_wpan_mac")]
24
pub mod wba_wpan_mac;
3-
#[cfg(feature = "wba_wpan_mac")]
4-
pub use self::wba_wpan_mac as mac_802_15_4;
5-
#[cfg(feature = "wba_wpan_mac")]
6-
pub use self::wba_wpan_mac as wpan_wba;
75

8-
#[cfg(feature = "wba_wpan_ble")]
9-
pub mod ble_stack;
106
#[cfg(feature = "wba_wpan_ble")]
117
pub use self::ble_stack as ble;
128
#[cfg(feature = "wba_wpan_ble")]
139
pub use self::ble_stack as ble_wba;
10+
#[cfg(feature = "wba_wpan_mac")]
11+
pub use self::wba_wpan_mac as mac;
12+
#[cfg(feature = "wba_wpan_mac")]
13+
pub use self::wba_wpan_mac as mac_802_15_4;
14+
#[cfg(feature = "wba_wpan_mac")]
15+
pub use self::wba_wpan_mac as wpan_wba;

0 commit comments

Comments
 (0)