samv7/spi: Allow 16-bit word size in spi_send
Signed-off-by: Jaroslav Beran <jara.beran@gmail.com>
This commit is contained in:
parent
69b3f034a4
commit
d13be4ea57
@ -1420,15 +1420,13 @@ static void spi_setbits(struct spi_dev_s *dev, int nbits)
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static uint32_t spi_send(struct spi_dev_s *dev, uint32_t wd)
|
static uint32_t spi_send(struct spi_dev_s *dev, uint32_t wd)
|
||||||
|
{
|
||||||
|
struct sam_spics_s *spics = (struct sam_spics_s *)dev;
|
||||||
|
if (spics->nbits <= 8)
|
||||||
{
|
{
|
||||||
uint8_t txbyte;
|
uint8_t txbyte;
|
||||||
uint8_t rxbyte;
|
uint8_t rxbyte;
|
||||||
|
|
||||||
/* spi_exchange can do this. Note: right now, this only deals with 8-bit
|
|
||||||
* words. If the SPI interface were configured for words of other sizes,
|
|
||||||
* this would fail.
|
|
||||||
*/
|
|
||||||
|
|
||||||
txbyte = (uint8_t)wd;
|
txbyte = (uint8_t)wd;
|
||||||
rxbyte = (uint8_t)0;
|
rxbyte = (uint8_t)0;
|
||||||
spi_exchange(dev, &txbyte, &rxbyte, 1);
|
spi_exchange(dev, &txbyte, &rxbyte, 1);
|
||||||
@ -1436,6 +1434,19 @@ static uint32_t spi_send(struct spi_dev_s *dev, uint32_t wd)
|
|||||||
spiinfo("Sent %02x received %02x\n", txbyte, rxbyte);
|
spiinfo("Sent %02x received %02x\n", txbyte, rxbyte);
|
||||||
return (uint32_t)rxbyte;
|
return (uint32_t)rxbyte;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
uint16_t txword;
|
||||||
|
uint16_t rxword;
|
||||||
|
|
||||||
|
txword = (uint16_t)wd;
|
||||||
|
rxword = (uint16_t)0;
|
||||||
|
spi_exchange(dev, &txword, &rxword, 1);
|
||||||
|
|
||||||
|
spiinfo("Sent %02x received %02x\n", txword, rxword);
|
||||||
|
return (uint32_t)rxword;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: spi_exchange (and spi_exchange_nodma)
|
* Name: spi_exchange (and spi_exchange_nodma)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user