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_config.h
Go to the documentation of this file.
1
24
25
#ifndef OW_CONFIG_H
26
#define OW_CONFIG_H
27
28
/* Removed public names from earlier releases. They used to be presence-style
29
* flags, so passing one now would compile and silently leave the feature at
30
* its default; fail loudly instead. See the migration table in README.md. */
31
#if defined(OW_PORT_LOW_POWER)
32
#error "OW_PORT_LOW_POWER was renamed to OW_LOW_POWER in 3.0.0; pass -DOW_LOW_POWER=1"
33
#endif
34
#if defined(PARASITE_POWER)
35
#error "PARASITE_POWER was renamed to OW_PARASITE_POWER; pass -DOW_PARASITE_POWER=1"
36
#endif
37
38
#include <stdint.h>
39
40
/* Backwards-compatible default: on existing builds the TIM1 kernel clock is
41
* the same as SYSCLK. A split-clock target (for example H7 CPU=480/TIM1=240)
42
* explicitly supplies OW_TIM1_MHZ. */
43
#if defined(OW_SYSCLK_MHZ) && !defined(OW_TIM1_MHZ)
44
#define OW_TIM1_MHZ OW_SYSCLK_MHZ
45
#endif
46
47
/* -------------------------------------------------------------------
48
* Parasite bus timing
49
* ------------------------------------------------------------------- */
50
62
#ifndef OW_PARASITE_POWER
63
#define OW_PARASITE_POWER 0
64
#endif
65
66
/* -------------------------------------------------------------------
67
* 1-Wire bit-slot timing
68
*
69
* The values below are fixed constants valid on every supported clock.
70
* They are NOT clock-derived — a single universal duration is sufficient
71
* because every supported frequency has been bench-validated.
72
* ------------------------------------------------------------------- */
73
94
#ifndef ONEWIRE_ONE_PULSE
95
#define ONEWIRE_ONE_PULSE 5
96
#endif
97
99
#ifndef ONEWIRE_ZERO_PULSE
100
#define ONEWIRE_ZERO_PULSE 60
101
#endif
102
112
#ifndef ONEWIRE_GUARD_BAND
113
#if OW_PARASITE_POWER
114
#define ONEWIRE_GUARD_BAND 100
/* parasite-powered bus: wider release margin */
115
#else
116
#define ONEWIRE_GUARD_BAND 5
117
#endif
118
#endif
119
121
#ifndef ONEWIRE_SHORT_PULSE_MAX
122
#define ONEWIRE_SHORT_PULSE_MAX 10
123
#endif
124
125
/* -------------------------------------------------------------------
126
* GPIO bus-pin drive strength
127
* ------------------------------------------------------------------- */
128
150
#define OW_BUS_DRIVE_WEAK 0
151
#define OW_BUS_DRIVE_MEDIUM 1
152
#define OW_BUS_DRIVE_STRONG 2
153
#define OW_BUS_DRIVE_MAX 3
154
155
#ifndef OW_BUS_DRIVE
156
#define OW_BUS_DRIVE OW_BUS_DRIVE_MAX
157
#endif
158
#if (OW_BUS_DRIVE) > OW_BUS_DRIVE_MAX
159
#error "OW_BUS_DRIVE must be 0..3 (GPIO drive-strength class)"
160
#endif
161
162
/* -------------------------------------------------------------------
163
* DMA arbitration priority
164
* ------------------------------------------------------------------- */
165
192
#ifndef OW_DMA_PRIO
193
#define OW_DMA_PRIO 0
194
#endif
195
#if (OW_DMA_PRIO) > 3
196
#error "OW_DMA_PRIO must be 0..3 (DMA arbitration priority class)"
197
#endif
198
199
/* -------------------------------------------------------------------
200
* Feature flags (value-style: 0 = off, 1 = on)
201
* ------------------------------------------------------------------- */
202
219
#ifndef OW_LOW_POWER
220
#define OW_LOW_POWER 0
221
#endif
222
230
#ifndef OW_DRIVE_ACTIVE
231
#define OW_DRIVE_ACTIVE 0
232
#endif
233
244
#ifndef OW_STATS_ENABLE
245
#define OW_STATS_ENABLE 0
246
#endif
247
248
/* -------------------------------------------------------------------
249
* DS18B20 driver configuration
250
* ------------------------------------------------------------------- */
251
259
#ifndef DS18B20_MAX_DEVICES
260
#define DS18B20_MAX_DEVICES 8
261
#endif
262
272
#if defined(OW_SYSCLK_MHZ)
273
#define OW_CONFIG_SYSCLK_MHZ (OW_SYSCLK_MHZ)
274
#else
275
#define OW_CONFIG_SYSCLK_MHZ 0u
276
#endif
277
#if defined(OW_TIM1_MHZ)
278
#define OW_CONFIG_TIM1_MHZ (OW_TIM1_MHZ)
279
#else
280
#define OW_CONFIG_TIM1_MHZ 0u
281
#endif
282
#define OW_CONFIG_TOKEN \
283
((uint32_t)(OW_PARASITE_POWER & 1u) | ((uint32_t)(OW_LOW_POWER & 1u) << 1) | \
284
((uint32_t)(OW_DRIVE_ACTIVE & 1u) << 2) | ((uint32_t)(OW_STATS_ENABLE & 1u) << 3) | \
285
((uint32_t)(OW_BUS_DRIVE & 3u) << 4) | ((uint32_t)(DS18B20_MAX_DEVICES & 0xFFu) << 6) | \
286
((uint32_t)(OW_CONFIG_SYSCLK_MHZ & 0x1FFu) << 14) | \
287
((uint32_t)(OW_CONFIG_TIM1_MHZ & 0x1FFu) << 23))
288
289
#endif
/* OW_CONFIG_H */
inc
ow_config.h
Generated by
1.15.0