STM32 SPI: nbits interface extended to handle LSB- or MSB-first operation. From Teemu Pirinen
This commit is contained in:
parent
94bcdc66b0
commit
ddc93e1da3
@ -200,7 +200,7 @@ struct stm32_spidev_s
|
|||||||
sem_t exclsem; /* Held while chip is selected for mutual exclusion */
|
sem_t exclsem; /* Held while chip is selected for mutual exclusion */
|
||||||
uint32_t frequency; /* Requested clock frequency */
|
uint32_t frequency; /* Requested clock frequency */
|
||||||
uint32_t actual; /* Actual clock frequency */
|
uint32_t actual; /* Actual clock frequency */
|
||||||
uint8_t nbits; /* Width of word in bits (8 or 16) */
|
int8_t nbits; /* Width of word in bits (8 or 16) */
|
||||||
uint8_t mode; /* Mode 0,1,2,3 */
|
uint8_t mode; /* Mode 0,1,2,3 */
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
@ -1153,14 +1153,24 @@ static void spi_setbits(FAR struct spi_dev_s *dev, int nbits)
|
|||||||
|
|
||||||
switch (nbits)
|
switch (nbits)
|
||||||
{
|
{
|
||||||
|
case -8:
|
||||||
|
setbits = SPI_CR1_LSBFIRST;
|
||||||
|
clrbits = SPI_CR1_DFF;
|
||||||
|
break;
|
||||||
|
|
||||||
case 8:
|
case 8:
|
||||||
setbits = 0;
|
setbits = 0;
|
||||||
clrbits = SPI_CR1_DFF;
|
clrbits = SPI_CR1_DFF|SPI_CR1_LSBFIRST;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case -16:
|
||||||
|
setbits = SPI_CR1_DFF|SPI_CR1_LSBFIRST;
|
||||||
|
clrbits = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 16:
|
case 16:
|
||||||
setbits = SPI_CR1_DFF;
|
setbits = SPI_CR1_DFF;
|
||||||
clrbits = 0;
|
clrbits = SPI_CR1_LSBFIRST;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user