summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-12-14 11:42:28 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-12-14 13:09:30 +0100
commit9686c6140f11268c52735b62fa3353c32b47460e (patch)
treee920e0e5d18e917a25eed4786f4cf0ef15ee0315
parentde7c17192a7592a27f68c0143f28cb8003c790f8 (diff)
downloadrtems-9686c6140f11268c52735b62fa3353c32b47460e.tar.bz2
bsp/atsam: Simplify SPI transfer status
-rw-r--r--c/src/lib/libbsp/arm/atsam/spi/atsam_spi_bus.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/c/src/lib/libbsp/arm/atsam/spi/atsam_spi_bus.c b/c/src/lib/libbsp/arm/atsam/spi/atsam_spi_bus.c
index 7dee4d599f..7c3855de44 100644
--- a/c/src/lib/libbsp/arm/atsam/spi/atsam_spi_bus.c
+++ b/c/src/lib/libbsp/arm/atsam/spi/atsam_spi_bus.c
@@ -36,6 +36,10 @@
#define MAX_SPI_FREQUENCY 50000000
+#define TX_IN_PROGRESS 0x1
+
+#define RX_IN_PROGRESS 0x2
+
typedef struct {
spi_bus base;
bool msg_cs_change;
@@ -47,8 +51,7 @@ typedef struct {
Spid SpiDma;
uint32_t dma_tx_channel;
uint32_t dma_rx_channel;
- bool rx_transfer_done;
- bool tx_transfer_done;
+ int transfer_status;
bool chip_select_active;
} atsam_spi_bus;
@@ -269,8 +272,7 @@ static void atsam_spi_setup_transfer(atsam_spi_bus *bus)
{
uint32_t msg_todo = bus->msg_todo;
- bus->rx_transfer_done = false;
- bus->tx_transfer_done = false;
+ bus->transfer_status = RX_IN_PROGRESS | TX_IN_PROGRESS;
if (bus->msg_cs_change) {
bus->chip_select_active = false;
@@ -355,14 +357,14 @@ static void atsam_spi_interrupt(void *arg)
}
if (bExec == 1 && (channel == bus->dma_rx_channel)) {
- bus->rx_transfer_done = true;
+ bus->transfer_status &= ~RX_IN_PROGRESS;
XDMAC_DisableGIt(spid->pXdmad->pXdmacs, bus->dma_rx_channel);
} else if (bExec == 1 && (channel == bus->dma_tx_channel)) {
- bus->tx_transfer_done = true;
+ bus->transfer_status &= ~TX_IN_PROGRESS;
XDMAC_DisableGIt(spid->pXdmad->pXdmacs, bus->dma_tx_channel);
}
- if (bus->rx_transfer_done && bus->tx_transfer_done) {
+ if (bus->transfer_status == 0) {
atsam_spi_setup_transfer(bus);
}
}