Skip to content

Commit 9681c01

Browse files
HoZHelerwango
authored andcommitted
lib: stm32wb0: Add BLE controller implementation
Provide BLE controller implementation for STM32WB0x SOCs. Signed-off-by: Ali Hozhabri <[email protected]>
1 parent 1171c80 commit 9681c01

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+48769
-0
lines changed

lib/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,5 @@ if(CONFIG_HAS_STM32LIB)
7272
target_link_libraries(app PUBLIC stm32wba_ll_lib)
7373

7474
endif()
75+
add_subdirectory_ifdef(CONFIG_BT_STM32WB0 stm32wb0)
7576
endif()
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
/* USER CODE BEGIN Header */
2+
/**
3+
******************************************************************************
4+
* @file app_common.h
5+
* @author MCD Application Team
6+
* @brief App Common application configuration file for STM32WPAN Middleware.
7+
******************************************************************************
8+
* @attention
9+
*
10+
* Copyright (c) 2024 STMicroelectronics.
11+
* All rights reserved.
12+
*
13+
* This software is licensed under terms that can be found in the LICENSE file
14+
* in the root directory of this software component.
15+
* If no LICENSE file comes with this software, it is provided AS-IS.
16+
*
17+
******************************************************************************
18+
*/
19+
/* USER CODE END Header */
20+
/* Define to prevent recursive inclusion -------------------------------------*/
21+
#ifndef APP_COMMON_H
22+
#define APP_COMMON_H
23+
24+
#ifdef __cplusplus
25+
extern "C"{
26+
#endif
27+
28+
#include <stdint.h>
29+
#include <string.h>
30+
#include <stdio.h>
31+
#include <stdlib.h>
32+
#include <stdarg.h>
33+
34+
#include "app_conf.h"
35+
36+
/* -------------------------------- *
37+
* Basic definitions *
38+
* -------------------------------- */
39+
#undef NULL
40+
#define NULL 0
41+
42+
#undef FALSE
43+
#define FALSE 0
44+
45+
#undef TRUE
46+
#define TRUE (!0)
47+
48+
/* -------------------------------- *
49+
* Critical Section definition *
50+
* -------------------------------- */
51+
#define ATOMIC_SECTION_BEGIN() uint32_t uwPRIMASK_Bit = __get_PRIMASK(); \
52+
__disable_irq();
53+
/* Must be called in the same or in a lower scope of ATOMIC_SECTION_BEGIN */
54+
#define ATOMIC_SECTION_END() __set_PRIMASK(uwPRIMASK_Bit)
55+
56+
/* -------------------------------- *
57+
* Macro delimiters *
58+
* -------------------------------- */
59+
#define M_BEGIN do {
60+
61+
#define M_END } while(0)
62+
63+
/* -------------------------------- *
64+
* Some useful macro definitions *
65+
* -------------------------------- */
66+
#ifndef MAX
67+
#define MAX( x, y ) (((x)>(y))?(x):(y))
68+
#endif
69+
70+
#ifndef MIN
71+
#define MIN( x, y ) (((x)<(y))?(x):(y))
72+
#endif
73+
74+
#define MODINC( a, m ) M_BEGIN (a)++; if ((a)>=(m)) (a)=0; M_END
75+
76+
#define MODDEC( a, m ) M_BEGIN if ((a)==0) (a)=(m); (a)--; M_END
77+
78+
#define MODADD( a, b, m ) M_BEGIN (a)+=(b); if ((a)>=(m)) (a)-=(m); M_END
79+
80+
#define MODSUB( a, b, m ) MODADD( a, (m)-(b), m )
81+
82+
#define PAUSE( t ) M_BEGIN \
83+
__IO int _i; \
84+
for ( _i = t; _i > 0; _i -- ); \
85+
M_END
86+
87+
#define DIVF( x, y ) ((x)/(y))
88+
89+
#define DIVC( x, y ) (((x)+(y)-1)/(y))
90+
91+
#define DIVR( x, y ) (((x)+((y)/2))/(y))
92+
93+
#define SHRR( x, n ) ((((x)>>((n)-1))+1)>>1)
94+
95+
#define BITN( w, n ) (((w)[(n)/32] >> ((n)%32)) & 1)
96+
97+
#define BITNSET( w, n, b ) M_BEGIN (w)[(n)/32] |= ((U32)(b))<<((n)%32); M_END
98+
99+
#define INT(x) ((int)(x))
100+
101+
#define FRACTIONAL_1DIGIT(x) (x>0)? ((int) (((x) - INT(x)) * 10)) : ((int) ((INT(x) - (x)) * 10))
102+
103+
#define FRACTIONAL_2DIGITS(x) (x>0)? ((int) (((x) - INT(x)) * 100)) : ((int) ((INT(x) - (x)) * 100))
104+
105+
#define FRACTIONAL_3DIGITS(x) (x>0)? ((int) (((x) - INT(x)) * 1000)) : ((int) ((INT(x) - (x)) * 1000))
106+
107+
/** @brief Macro that returns a 16-bit value from a buffer where the value is stored in Little Endian Format */
108+
#define LE_TO_HOST_16(ptr) (uint16_t) ( ((uint16_t)*((uint8_t *)(ptr))) | \
109+
((uint16_t)*((uint8_t *)(ptr) + 1) << 8) )
110+
111+
/** @brief Macro that stores a 16-bit value into a buffer in Little Endian Format (2 bytes) */
112+
#define HOST_TO_LE_16(buf, val) ( ((buf)[0] = (uint8_t) (val) ) , \
113+
((buf)[1] = (uint8_t) ((val)>>8) ) )
114+
115+
/** @brief Macro that returns a 32-bit value from a buffer where the value is stored in Little Endian Format */
116+
#define LE_TO_HOST_32(ptr) (uint32_t) ( ((uint32_t)*((uint8_t *)(ptr))) | \
117+
((uint32_t)*((uint8_t *)(ptr) + 1) << 8) | \
118+
((uint32_t)*((uint8_t *)(ptr) + 2) << 16) | \
119+
((uint32_t)*((uint8_t *)(ptr) + 3) << 24) )
120+
121+
/* -------------------------------- *
122+
* Compiler *
123+
* -------------------------------- */
124+
#define PLACE_IN_SECTION( __x__ ) __attribute__((used, section (__x__)))
125+
126+
#ifdef __cplusplus
127+
} /* extern "C" */
128+
#endif
129+
130+
#endif /*APP_COMMON_H */

0 commit comments

Comments
 (0)