Zephyr Project API 4.3.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
gpio_bl61x_wo.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2026 MASSDRIVER EI (massdriver.space)
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
12
13#ifndef ZEPHYR_DRIVERS_GPIO_GPIO_BL61X_WO_H_
14#define ZEPHYR_DRIVERS_GPIO_GPIO_BL61X_WO_H_
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
29
30#include <zephyr/drivers/gpio.h>
32
33#define BL61X_WO_PIN_CNT 16
34
36
38BUILD_ASSERT(IS_ENABLED(CONFIG_GPIO_BL61X_WO),
39 "BFLB Wire Out must be activated to use this header");
40
42#define BL61X_WO_VALIDATE_TIME(_node) \
43 BUILD_ASSERT((DT_PROP(_node, time_t0h) < DT_PROP(_node, time_total)), \
44 "BFLB WO device time-t0h must be smaller than time-total"); \
45 BUILD_ASSERT((DT_PROP(_node, time_t1h) < DT_PROP(_node, time_total)), \
46 "BFLB WO device time-t1h must be smaller than time-total")
48#define BL61X_WO_VALIDATE_FREQ(_node) \
49 BUILD_ASSERT((DT_PROP(_node, time_t0h) < (Z_HZ_ns / DT_PROP(_node, frequency))), \
50 "BFLB WO device time-t0h must be smaller than the frequency's period"); \
51 BUILD_ASSERT((DT_PROP(_node, time_t1h) < (Z_HZ_ns / DT_PROP(_node, frequency))), \
52 "BFLB WO device time-t1h must be smaller than the frequency's period")
53
55#define BL61X_WO_VALIDATE(_node) \
56 BUILD_ASSERT((DT_PROP_OR(_node, frequency, 0) | DT_PROP_OR(_node, time_total, 0)) != 0, \
57 "BFLB WO device must have frequency or time_total set"); \
58 BUILD_ASSERT(DT_NODE_HAS_PROP(_node, time_t0h), \
59 "BFLB WO device must have time-t0h, device binding is bad if this was allowed");\
60 BUILD_ASSERT(DT_NODE_HAS_PROP(_node, time_t1h), \
61 "BFLB WO device must have time-t1h, device binding is bad if this was allowed");\
62 IF_ENABLED(DT_NODE_HAS_PROP(_node, time_total), (BL61X_WO_VALIDATE_TIME(_node))); \
63 IF_ENABLED(DT_NODE_HAS_PROP(_node, frequency), (BL61X_WO_VALIDATE_FREQ(_node)))
65#define BL61X_WO_VALIDATE_INST(_inst, _compat) BL61X_WO_VALIDATE(DT_INST(_inst, _compat))
66
68
78typedef void (*bl61x_wo_callback_t) (void *user_data);
79
119};
120
128uint16_t bl61x_wo_frequency_to_cycles(const uint32_t frequency, const bool exact);
129
137uint16_t bl61x_wo_time_to_cycles(const uint32_t time, const bool exact);
138
149int bl61x_wo_configure(const struct bl61x_wo_config *const config,
150 const uint8_t *pins, const gpio_flags_t *flags, const size_t pin_cnt);
151
161int bl61x_wo_configure_dt(const struct bl61x_wo_config *const config,
162 const struct gpio_dt_spec *pins, const size_t pin_cnt);
163
172int bl61x_wo_write(const uint16_t *const data, const size_t len);
173
184int bl61x_wo_write_async(const uint16_t *const data, const size_t len,
185 bl61x_wo_callback_t cb, void *user_data);
186
190
191#ifdef __cplusplus
192}
193#endif
194
195#endif /* ZEPHYR_DRIVERS_GPIO_GPIO_BL61X_WO_H_ */
Main header file for GPIO driver API.
int bl61x_wo_write_async(const uint16_t *const data, const size_t len, bl61x_wo_callback_t cb, void *user_data)
Write to GPIO FIFO Asynchronously.
uint16_t bl61x_wo_time_to_cycles(const uint32_t time, const bool exact)
Convert a time to WO clock cycles.
int bl61x_wo_write(const uint16_t *const data, const size_t len)
Write to GPIO FIFO.
int bl61x_wo_configure_dt(const struct bl61x_wo_config *const config, const struct gpio_dt_spec *pins, const size_t pin_cnt)
Configure GPIO FIFO using devicetree.
uint16_t bl61x_wo_frequency_to_cycles(const uint32_t frequency, const bool exact)
Convert a frequency to WO clock cycles.
void(* bl61x_wo_callback_t)(void *user_data)
Callback type used to inform user async write has completed.
Definition gpio_bl61x_wo.h:78
int bl61x_wo_configure(const struct bl61x_wo_config *const config, const uint8_t *pins, const gpio_flags_t *flags, const size_t pin_cnt)
Configure GPIO FIFO.
uint32_t gpio_flags_t
Provides a type to hold GPIO configuration flags.
Definition gpio.h:282
#define IS_ENABLED(config_macro)
Check for macro definition in compiler-visible expressions.
Definition util_macro.h:154
#define BUILD_ASSERT(EXPR, MSG...)
Definition llvm.h:51
time_t time(time_t *tloc)
flags
Definition parser.h:97
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
Structure holding the configuration for the GPIO FIFO pulse width, polarity, and pins.
Definition gpio_bl61x_wo.h:111
bool park_high
Park pins high instead of low at the end of a sequence.
Definition gpio_bl61x_wo.h:117
bool unset_invert
Same but when bit is unset.
Definition gpio_bl61x_wo.h:116
uint16_t total_cycles
Total clock cycles length of a toggling cycles (9 bits)
Definition gpio_bl61x_wo.h:112
uint8_t unset_cycles
Number of clock cycles a pin is toggled when its bit is unset.
Definition gpio_bl61x_wo.h:114
uint8_t set_cycles
Number of clock cycles a pin is toggled when its bit is set.
Definition gpio_bl61x_wo.h:113
bool set_invert
Go from low to high instead of high to low when bit is set.
Definition gpio_bl61x_wo.h:115
Container for GPIO pin information specified in devicetree.
Definition gpio.h:296
Macro utilities.