summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2016-08-14 18:39:43 +0200
committerVegard Storheil Eriksen <zyp@jvnv.net>2016-08-14 18:39:43 +0200
commit9c5c5c9243975b20b097dfb65409a3bae31f9d97 (patch)
tree7dcbb363553662b29d565d6247a7d21850e679f6
parent49012588461f1a43e9e476f676d946d91c3df9e7 (diff)
STM32L0: Added SPI1.
-rw-r--r--spi/spi.h11
1 files changed, 8 insertions, 3 deletions
diff --git a/spi/spi.h b/spi/spi.h
index 1f9e0eb..c781a56 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,13 @@ 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;
}
};
@@ -44,6 +47,8 @@ static SPI_t SPI3(0x40003c00);
static SPI_t SPI1(0x40013000);
static SPI_t SPI2(0x40003800);
static SPI_t SPI3(0x40003c00);
+#elif defined(STM32L0)
+static SPI_t SPI1(0x40013000);
#endif
#endif