summaryrefslogtreecommitdiff
path: root/spi
diff options
context:
space:
mode:
Diffstat (limited to 'spi')
-rw-r--r--spi/spi.h10
1 files changed, 6 insertions, 4 deletions
diff --git a/spi/spi.h b/spi/spi.h
index 1f9e0eb..1b35b89 100644
--- a/spi/spi.h
+++ b/spi/spi.h
@@ -7,7 +7,10 @@ struct SPI_reg_t {
volatile uint32_t CR1;
volatile uint32_t CR2;
volatile uint32_t SR;
- volatile uint32_t DR;
+ union {
+ volatile uint32_t DR;
+ volatile uint8_t DR8;
+ };
volatile uint32_t CRCPR;
volatile uint32_t RXCRCR;
volatile uint32_t TXCRCR;
@@ -22,13 +25,12 @@ class SPI_t {
SPI_t(uint32_t reg_addr) : reg(*(SPI_reg_t*)reg_addr) {}
uint8_t transfer_byte(uint8_t out = 0) {
- reg.DR = out;
+ reg.DR8 = out;
while(!(reg.SR & 0x01)) {
Thread::yield();
}
-
- return reg.DR;
+ return reg.DR8;
}
};