summaryrefslogtreecommitdiff
path: root/nuttx/arch/arm/src/stm32/stm32_spi.c
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2013-08-16 11:35:22 -0600
committerGregory Nutt <gnutt@nuttx.org>2013-08-16 11:35:22 -0600
commit371f4b2a420fc5d335c8c30265c32299d0874ad5 (patch)
tree3bff56e143e3ffde5a2c14d3c89812a3e3ed6dc8 /nuttx/arch/arm/src/stm32/stm32_spi.c
parent5b14d5d128a35b8dc650bc1c4c113fad3a61e438 (diff)
downloadpx4-nuttx-371f4b2a420fc5d335c8c30265c32299d0874ad5.tar.gz
px4-nuttx-371f4b2a420fc5d335c8c30265c32299d0874ad5.tar.bz2
px4-nuttx-371f4b2a420fc5d335c8c30265c32299d0874ad5.zip
STM32 SPI: nbits interface extended to handle LSB- or MSB-first operation. From Teemu Pirinen
Diffstat (limited to 'nuttx/arch/arm/src/stm32/stm32_spi.c')
-rw-r--r--nuttx/arch/arm/src/stm32/stm32_spi.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/nuttx/arch/arm/src/stm32/stm32_spi.c b/nuttx/arch/arm/src/stm32/stm32_spi.c
index 9bb072419..1f50d9e23 100644
--- a/nuttx/arch/arm/src/stm32/stm32_spi.c
+++ b/nuttx/arch/arm/src/stm32/stm32_spi.c
@@ -200,7 +200,7 @@ struct stm32_spidev_s
sem_t exclsem; /* Held while chip is selected for mutual exclusion */
uint32_t frequency; /* Requested 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 */
#endif
};
@@ -1153,14 +1153,24 @@ static void spi_setbits(FAR struct spi_dev_s *dev, int nbits)
switch (nbits)
{
+ case -8:
+ setbits = SPI_CR1_LSBFIRST;
+ clrbits = SPI_CR1_DFF;
+ break;
+
case 8:
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;
case 16:
setbits = SPI_CR1_DFF;
- clrbits = 0;
+ clrbits = SPI_CR1_LSBFIRST;
break;
default: