Create platform-independent SPI select and deselect
This commit is contained in:
parent
a7fbdfa274
commit
e71ef49c04
@ -281,27 +281,6 @@ spi_arch_close_and_unlock(const spi_device_t *dev)
|
||||
return SPI_DEV_STATUS_OK;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
spi_status_t
|
||||
spi_arch_select(const spi_device_t *dev)
|
||||
{
|
||||
|
||||
if(!spi_arch_has_lock(dev)) {
|
||||
return SPI_DEV_STATUS_BUS_NOT_OWNED;
|
||||
}
|
||||
|
||||
SPIX_CS_CLR(PIN_TO_PORT(dev->pin_spi_cs), PIN_TO_NUM(dev->pin_spi_cs));
|
||||
|
||||
return SPI_DEV_STATUS_OK;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
spi_status_t
|
||||
spi_arch_deselect(const spi_device_t *dev)
|
||||
{
|
||||
SPIX_CS_SET(PIN_TO_PORT(dev->pin_spi_cs), PIN_TO_NUM(dev->pin_spi_cs));
|
||||
|
||||
return SPI_DEV_STATUS_OK;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Assumes that checking dev and bus is not NULL before calling this */
|
||||
spi_status_t
|
||||
spi_arch_transfer(const spi_device_t *dev,
|
||||
|
@ -230,22 +230,3 @@ spi_arch_transfer(const spi_device_t *dev,
|
||||
return SPI_DEV_STATUS_OK;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
spi_status_t
|
||||
spi_arch_select(const spi_device_t *dev)
|
||||
{
|
||||
|
||||
if(!spi_arch_has_lock(dev)) {
|
||||
return SPI_DEV_STATUS_BUS_NOT_OWNED;
|
||||
}
|
||||
|
||||
ti_lib_gpio_clear_dio(dev->pin_spi_cs);
|
||||
|
||||
return SPI_DEV_STATUS_OK;
|
||||
}
|
||||
spi_status_t
|
||||
spi_arch_deselect(const spi_device_t *dev)
|
||||
{
|
||||
ti_lib_gpio_set_dio(dev->pin_spi_cs);
|
||||
|
||||
return SPI_DEV_STATUS_OK;
|
||||
}
|
||||
|
@ -235,30 +235,6 @@ spi_arch_transfer(const spi_device_t *dev,
|
||||
return SPI_DEV_STATUS_OK;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
spi_status_t
|
||||
spi_arch_select(const spi_device_t *dev)
|
||||
{
|
||||
if(!spi_arch_has_lock(dev)) {
|
||||
return SPI_DEV_STATUS_BUS_NOT_OWNED;
|
||||
}
|
||||
|
||||
PINCC26XX_setOutputValue(dev->pin_spi_cs, 0);
|
||||
|
||||
return SPI_DEV_STATUS_OK;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
spi_status_t
|
||||
spi_arch_deselect(const spi_device_t *dev)
|
||||
{
|
||||
if(!spi_arch_has_lock(dev)) {
|
||||
return SPI_DEV_STATUS_BUS_NOT_OWNED;
|
||||
}
|
||||
|
||||
PINCC26XX_setOutputValue(dev->pin_spi_cs, 1);
|
||||
|
||||
return SPI_DEV_STATUS_OK;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
|
12
os/dev/spi.c
12
os/dev/spi.c
@ -67,13 +67,21 @@ spi_release(const spi_device_t *dev)
|
||||
spi_status_t
|
||||
spi_select(const spi_device_t *dev)
|
||||
{
|
||||
return spi_arch_select(dev);
|
||||
if(!spi_arch_has_lock(dev)) {
|
||||
return SPI_DEV_STATUS_BUS_NOT_OWNED;
|
||||
}
|
||||
|
||||
gpio_hal_arch_clear_pin(dev->pin_spi_cs);
|
||||
|
||||
return SPI_DEV_STATUS_OK;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
spi_status_t
|
||||
spi_deselect(const spi_device_t *dev)
|
||||
{
|
||||
return spi_arch_deselect(dev);
|
||||
gpio_hal_arch_set_pin(dev->pin_spi_cs);
|
||||
|
||||
return SPI_DEV_STATUS_OK;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
bool
|
||||
|
Loading…
Reference in New Issue
Block a user