drivers: spi: add opaque type to encode SPI operation flags
Since flags can use either 16/32-bit depending on CONFIG_SPI_EXTENDED_MODES, add a new opaque type that uses the correct bit-width depending on that option. This allows us to simplify the structure layout. Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
parent
8ce048b8e1
commit
2c3165d187
1 changed files with 11 additions and 8 deletions
|
|
@ -268,6 +268,16 @@ struct spi_cs_control {
|
|||
#define SPI_CS_CONTROL_INIT_INST(inst, delay_) \
|
||||
SPI_CS_CONTROL_INIT(DT_DRV_INST(inst), delay_)
|
||||
|
||||
/**
|
||||
* @typedef spi_operation_t
|
||||
* Opaque type to hold the SPI operation flags.
|
||||
*/
|
||||
#if defined(CONFIG_SPI_EXTENDED_MODES)
|
||||
typedef uint32_t spi_operation_t;
|
||||
#else
|
||||
typedef uint16_t spi_operation_t;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief SPI controller configuration structure
|
||||
*
|
||||
|
|
@ -296,15 +306,8 @@ struct spi_cs_control {
|
|||
*/
|
||||
struct spi_config {
|
||||
uint32_t frequency;
|
||||
#if defined(CONFIG_SPI_EXTENDED_MODES)
|
||||
uint32_t operation;
|
||||
spi_operation_t operation;
|
||||
uint16_t slave;
|
||||
uint16_t _unused;
|
||||
#else
|
||||
uint16_t operation;
|
||||
uint16_t slave;
|
||||
#endif /* CONFIG_SPI_EXTENDED_MODES */
|
||||
|
||||
struct spi_cs_control cs;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue