libopencm3/libopencm3 — pull request #351 by amirhammad (2014-10-05 18:19:59+00:00)
Title: stm32: SPI_I2S common definitions (LSB)

Definitions for I2S in _include/libopencm3/stm32/common/spi_common_all.h_ have the following style:

> #define SPI_I2SCFGR_I2SCFG_LSB 8
> #define SPI_I2SCFGR_I2SCFG_SLAVE_TRANSMIT	0x0
> #define SPI_I2SCFGR_I2SCFG_SLAVE_RECEIVE	0x1
> #define SPI_I2SCFGR_I2SCFG_MASTER_TRANSMIT	0x2
> #define SPI_I2SCFGR_I2SCFG_MASTER_RECEIVE	0x3

So when one want to use one of those defines, he must also shift this definition left by the value of SPI_I2SCFGR_*_LSB.

I see workaround by including this LSB into bitmask definitions

> #define SPI_I2SCFGR_I2SCFG_SLAVE_TRANSMIT	(0x0 << 8)
> #define SPI_I2SCFGR_I2SCFG_SLAVE_RECEIVE	(0x1 << 8)
> #define SPI_I2SCFGR_I2SCFG_MASTER_TRANSMIT	(0x2 << 8)
> #define SPI_I2SCFGR_I2SCFG_MASTER_RECEIVE	(0x3 << 8)

I don't see any reason to have *_LSB separated.