Skip to content

Commit 89d76e9

Browse files
Jordan Yatesbbilas
authored andcommitted
spi: use gpio_dt_spec in struct spi_cs_control
Use the standard `struct gpio_dt_spec` type in the chip select control. The anonymous struct and union allows previous instantiations to continue working while letting functions operate on the new type. Signed-off-by: Jordan Yates <[email protected]> Co-authored-by: Jordan Yates <[email protected]> Signed-off-by: Bartosz Bilas <[email protected]> Co-authored-by: Bartosz Bilas <[email protected]>
1 parent 4d1c90e commit 89d76e9

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

include/drivers/spi.h

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -124,22 +124,28 @@ extern "C" {
124124
* This can be used to control a CS line via a GPIO line, instead of
125125
* using the controller inner CS logic.
126126
*
127-
* @param gpio_dev is a valid pointer to an actual GPIO device. A NULL pointer
128-
* can be provided to full inhibit CS control if necessary.
129-
* @param gpio_pin is a number representing the gpio PIN that will be used
130-
* to act as a CS line
131-
* @param delay is a delay in microseconds to wait before starting the
132-
* transmission and before releasing the CS line
133-
* @param gpio_dt_flags is the devicetree flags corresponding to how the CS
134-
* line should be driven. GPIO_ACTIVE_LOW/GPIO_ACTIVE_HIGH should be
135-
* equivalent to SPI_CS_ACTIVE_HIGH/SPI_CS_ACTIVE_LOW options in struct
136-
* spi_config.
137127
*/
138128
struct spi_cs_control {
139-
const struct device *gpio_dev;
140-
uint32_t delay;
141-
gpio_pin_t gpio_pin;
142-
gpio_dt_flags_t gpio_dt_flags;
129+
/**
130+
* GPIO devicetree specification of CS GPIO.
131+
* The device pointer can be set to NULL to fully inhibit CS control if
132+
* necessary. The GPIO flags GPIO_ACTIVE_LOW/GPIO_ACTIVE_HIGH should be
133+
* equivalent to SPI_CS_ACTIVE_HIGH/SPI_CS_ACTIVE_LOW options in struct
134+
* spi_config.
135+
*/
136+
union {
137+
struct gpio_dt_spec gpio;
138+
struct {
139+
const struct device *gpio_dev;
140+
gpio_pin_t gpio_pin;
141+
gpio_dt_flags_t gpio_dt_flags;
142+
};
143+
};
144+
/**
145+
* Delay in microseconds to wait before starting the
146+
* transmission and before releasing the CS line.
147+
*/
148+
uint32_t delay;
143149
};
144150

145151
#ifndef __cplusplus

0 commit comments

Comments
 (0)