stm32-async-1wire 3.2.0
Non-blocking 1-Wire master for STM32 with DS18B20 temperature and DS2431 EEPROM drivers
Loading...
Searching...
No Matches
ow_board.h
Go to the documentation of this file.
1
28
29#ifndef OW_BOARD_H
30#define OW_BOARD_H
31
32/* ------------------------------------------------------------------
33 * Removed public names: fail loudly instead of silently ignoring them.
34 *
35 * 3.0.0 renamed the public macros when the port layer became private and
36 * dropped every compatibility alias. A build that still passes an old name
37 * would otherwise compile with the renamed knob at its default, which is
38 * exactly the silent change the rename was meant to prevent - a build with
39 * the old low-power flag would quietly lose the WFE path. These guards make
40 * the migration explicit at the first compiler invocation.
41 * ------------------------------------------------------------------ */
42#if defined(OW_PORT_FAMILY_F0)
43#error "OW_PORT_FAMILY_F0 was renamed to OW_FAMILY_F0 in 3.0.0; select the family via the device macro (e.g. -DSTM32F030x6) or -DSTM32F0"
44#endif
45#if defined(OW_PORT_FAMILY_F1)
46#error "OW_PORT_FAMILY_F1 was renamed to OW_FAMILY_F1 in 3.0.0; select the family via the device macro (e.g. -DSTM32F103xB) or -DSTM32F1"
47#endif
48#if defined(OW_PORT_FAMILY_F3)
49#error "OW_PORT_FAMILY_F3 was renamed to OW_FAMILY_F3 in 3.0.0; select the family via the device macro (e.g. -DSTM32F303xC) or -DSTM32F3"
50#endif
51#if defined(OW_PORT_FAMILY_F4)
52#error "OW_PORT_FAMILY_F4 was renamed to OW_FAMILY_F4 in 3.0.0; select the family via the device macro (e.g. -DSTM32F407xx) or -DSTM32F4"
53#endif
54#if defined(OW_PORT_FAMILY_G0)
55#error "OW_PORT_FAMILY_G0 was renamed to OW_FAMILY_G0 in 3.0.0; select the family via the device macro (e.g. -DSTM32G031xx) or -DSTM32G0"
56#endif
57#if defined(OW_PORT_FAMILY_G4)
58#error "OW_PORT_FAMILY_G4 was renamed to OW_FAMILY_G4 in 3.0.0; select the family via the device macro (e.g. -DSTM32G474xx) or -DSTM32G4"
59#endif
60#if defined(OW_PORT_FAMILY_L4)
61#error "OW_PORT_FAMILY_L4 was renamed to OW_FAMILY_L4 in 3.0.0; select the family via the device macro (e.g. -DSTM32L476xx) or -DSTM32L4"
62#endif
63#if defined(OW_PORT_FAMILY_H5)
64#error "OW_PORT_FAMILY_H5 was renamed to OW_FAMILY_H5 in 3.0.0; select the family via the device macro (e.g. -DSTM32H503xx) or -DSTM32H5"
65#endif
66#if defined(OW_PORT_FAMILY_H7)
67#error "OW_PORT_FAMILY_H7 was renamed to OW_FAMILY_H7 in 3.0.0; select the family via the device macro (e.g. -DSTM32H743xx) or -DSTM32H7"
68#endif
69#if defined(OW_PORT_SYSCLK_MHZ)
70#error "OW_PORT_SYSCLK_MHZ was renamed to OW_SYSCLK_MHZ in 3.0.0; pass -DOW_SYSCLK_MHZ=<MHz>"
71#endif
72#if defined(OW_PORT_F4_MAX_SYSCLK_MHZ)
73#error "OW_PORT_F4_MAX_SYSCLK_MHZ was renamed to OW_F4_MAX_SYSCLK_MHZ in 3.0.0; pass -DOW_F4_MAX_SYSCLK_MHZ=<MHz>"
74#endif
75#if defined(OW_PORT_G4_MAX_SYSCLK_MHZ)
76#error "OW_PORT_G4_MAX_SYSCLK_MHZ was renamed to OW_G4_MAX_SYSCLK_MHZ in 3.0.0; pass -DOW_G4_MAX_SYSCLK_MHZ=<MHz>"
77#endif
78#if defined(OW_PORT_H5_MAX_SYSCLK_MHZ)
79#error "OW_PORT_H5_MAX_SYSCLK_MHZ was renamed to OW_H5_MAX_SYSCLK_MHZ in 3.0.0; pass -DOW_H5_MAX_SYSCLK_MHZ=<MHz>"
80#endif
81
82#include <stdint.h>
83
84/* ------------------------------------------------------------------
85 * Family selection: a single OW_FAMILY_* token resolved from
86 * the CMSIS device macro of the target (e.g. -DSTM32F030x6) or, for
87 * host-test mocks, PlatformIO and STM32CubeMX projects, from a family
88 * macro (STM32F0, STM32F1, STM32F3, STM32F4, STM32G0, STM32G4, STM32L4,
89 * STM32C5, STM32H5, STM32U5, STM32H7). Concrete device spellings are accepted for the parts this project
90 * supports (STM32F030x6 for F0; STM32F103xB for F1; STM32F303xC for F3;
91 * STM32F407xx / STM32F401xC / STM32F446xx for F4;
92 * STM32G031xx for G0; STM32G474xx for G4; STM32L476xx for L4;
93 * STM32C552xx for C5; STM32H503xx for H5; STM32U585xx for U5; STM32H743xx for H7).
94 * ------------------------------------------------------------------ */
95#if defined(STM32F030x6) || defined(STM32F0)
96#define OW_FAMILY_F0
97#elif defined(STM32F103xB) || defined(STM32F1)
98#define OW_FAMILY_F1
99#elif defined(STM32F303xC) || defined(STM32F3)
100#define OW_FAMILY_F3
101#elif defined(STM32F407xx) || defined(STM32F401xC) || \
102 defined(STM32F446xx) || defined(STM32F4)
103#define OW_FAMILY_F4
104#elif defined(STM32G031xx) || defined(STM32G0)
105#define OW_FAMILY_G0
106#elif defined(STM32G474xx) || defined(STM32G4)
107#define OW_FAMILY_G4
108#elif defined(STM32L476xx) || defined(STM32L4)
109#define OW_FAMILY_L4
110#elif defined(STM32C552xx) || defined(STM32C5)
111#define OW_FAMILY_C5
112#elif defined(STM32H503xx) || defined(STM32H5)
113#define OW_FAMILY_H5
114#elif defined(STM32U585xx) || defined(STM32U5)
115#define OW_FAMILY_U5
116#elif defined(STM32H743xx) || defined(STM32H7)
117#define OW_FAMILY_H7
118#else
119#error "ow_board: no MCU selected. Pass your part's STMicroelectronics device macro (e.g. -DSTM32H743xx) or its family macro (e.g. -DSTM32H7). This is the ONLY define the library requires; OW_SYSCLK_MHZ is optional (the port core reads CMSIS SystemCoreClock when it is absent). -DSTM32F030x6/STM32F103xB/STM32F303xC/STM32F407xx/STM32F401xC/STM32F446xx/STM32G031xx/STM32G474xx/STM32L476xx/STM32C552xx/STM32H503xx/STM32U585xx/STM32H743xx or -DSTM32F0/F1/F3/F4/G0/G4/L4/C5/H5/U5/H7 are accepted. The Make/CMake builds supply it from OW_MCU/chips/<part>.mk."
120#endif
121
132#if defined(OW_FAMILY_F4) || defined(OW_FAMILY_H7)
133typedef uint16_t ow_pulse_t;
134#else
135typedef uint8_t ow_pulse_t;
136#endif
137/* ------------------------------------------------------------------
138 * Board clock defaults. The external crystal belongs to the board and
139 * the system clock to the application, so they are separate knobs; the
140 * build passes OW_SYSCLK_MHZ for the part, and app.c reads these.
141 * A wrong OW_HSE_MHZ is not a compile error - the PLL simply never
142 * locks. The *_MAX_SYSCLK_MHZ ceilings let app.c reject a request
143 * above what the concrete part can take.
144 * ------------------------------------------------------------------ */
145#if defined(OW_FAMILY_F3)
146/* No HSI16 on this family: the 72MHz PLL multiplies the crystal by 9. */
147#if !defined(OW_HSE_MHZ)
148#define OW_HSE_MHZ 8
149#endif
150#elif defined(OW_FAMILY_F4)
151#if !defined(OW_F4_MAX_SYSCLK_MHZ)
152#if defined(STM32F446xx)
153#define OW_F4_MAX_SYSCLK_MHZ 180 /* F446: the only part here that needs the over-drive sequence */
154#elif defined(STM32F401xC)
155#define OW_F4_MAX_SYSCLK_MHZ 84 /* F401 parts top out at 84MHz */
156#else
157#define OW_F4_MAX_SYSCLK_MHZ 168 /* F405/F407 cap */
158#endif
159#endif
160#if !defined(OW_HSE_MHZ)
161#define OW_HSE_MHZ 8
162#endif
163#elif defined(OW_FAMILY_G4)
164#if !defined(OW_G4_MAX_SYSCLK_MHZ)
165#define OW_G4_MAX_SYSCLK_MHZ 170 /* G474 ceiling, voltage Range 1 Boost */
166#endif
167#if !defined(OW_HSE_MHZ)
168#define OW_HSE_MHZ 8 /* WeAct STM32G474CBT6 Long: 8MHz crystal */
169#endif
170#elif defined(OW_FAMILY_L4)
171#if !defined(OW_L4_MAX_SYSCLK_MHZ)
172#define OW_L4_MAX_SYSCLK_MHZ 80 /* L476 ceiling, voltage Range 1 */
173#endif
174/* No OW_HSE_MHZ default: the NUCLEO-L476RG has no crystal populated and this
175 * backend is HSI16-only by design, so there is no external-oscillator knob to
176 * get wrong. */
177#elif defined(OW_FAMILY_H5)
178#if !defined(OW_H5_MAX_SYSCLK_MHZ)
179#define OW_H5_MAX_SYSCLK_MHZ 250 /* H503 ceiling */
180#endif
181#if !defined(OW_HSE_MHZ)
182#define OW_HSE_MHZ 8 /* WeAct STM32H503Cx Core Board: 8MHz crystal (Y2) */
183#endif
184#elif defined(OW_FAMILY_C5)
185#if !defined(OW_C5_MAX_SYSCLK_MHZ)
186#define OW_C5_MAX_SYSCLK_MHZ 144 /* C552 ceiling */
187#endif
188#if !defined(OW_HSE_MHZ)
189#define OW_HSE_MHZ 8 /* WeAct STM32C5 48-pin Core Board: 8MHz crystal (Y2) */
190#endif
191#elif defined(OW_FAMILY_U5)
192#if !defined(OW_U5_MAX_SYSCLK_MHZ)
193#define OW_U5_MAX_SYSCLK_MHZ 160 /* U585 ceiling */
194#endif
195#if !defined(OW_HSE_MHZ)
196#define OW_HSE_MHZ 25 /* bench board: 25MHz crystal on PH0/PH1 */
197#endif
198#elif defined(OW_FAMILY_H7)
199#if !defined(OW_H7_MAX_SYSCLK_MHZ)
200#define OW_H7_MAX_SYSCLK_MHZ 480 /* Rev V H743 core ceiling; 480MHz requires VOS0 */
201#endif
202#if !defined(OW_H7_MAX_TIM1_MHZ)
203#define OW_H7_MAX_TIM1_MHZ 240 /* APB2 <=120MHz, timer x2; this is the 1-Wire timing ceiling */
204#endif
205#if !defined(OW_HSE_MHZ)
206#define OW_HSE_MHZ 25 /* WeAct Studio STM32H7XX board: 25MHz crystal */
207#endif
208#endif
209
210#endif /* OW_BOARD_H */
uint8_t ow_pulse_t
DMA feed entry width of the active family.
Definition ow_board.h:135