diff options
author | Perry Hung <iperry@alum.mit.edu> | 2010-04-24 03:16:35 -0400 |
---|---|---|
committer | Perry Hung <iperry@alum.mit.edu> | 2010-04-24 03:56:21 -0400 |
commit | bf4fc3bf6bc02342ae508b52fb4515d361d626f6 (patch) | |
tree | b1d7778af188d004f8c1b528acf7744bd74980b8 /libmaple | |
parent | 17e0e5edde60e9bf2aa4d52173ad7d47d6d6da75 (diff) | |
download | librambutan-bf4fc3bf6bc02342ae508b52fb4515d361d626f6.tar.gz librambutan-bf4fc3bf6bc02342ae508b52fb4515d361d626f6.zip |
Upper level libmaple interface
Added a C++ HardwareSPI class to access the SPI interface. See
HardwareSPI.cpp and HardwareSPI.h for documentation.
Diffstat (limited to 'libmaple')
-rw-r--r-- | libmaple/spi.h | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/libmaple/spi.h b/libmaple/spi.h index 457f39b..cde3b42 100644 --- a/libmaple/spi.h +++ b/libmaple/spi.h @@ -48,7 +48,7 @@ extern "C" { #define CR1_BR_PRESCALE_128 0x00000030 #define CR1_BR_PRESCALE_256 0x00000038 -#define CR1_LSBFIRST BIT(7 // data frame format +#define CR1_LSBFIRST BIT(7) // data frame format #define CR1_MSTR BIT(2) // master selection #define CR1_SSM BIT(9) // software slave management #define CR1_SSI BIT(8) // internal slave select @@ -98,6 +98,15 @@ void spi_init(uint32 spi_num, uint32 mode); void spi_tx(uint32 spi_num, uint8 data); +static inline uint8 spi_rx(uint32 spi_num) { + SPI *spi; + + ASSERT(spi_num == 1 || spi_num == 2); + spi = (spi_num == 1) ? (SPI*)SPI1_BASE : (SPI*)SPI2_BASE; + + return spi->DR; +} + #ifdef __cplusplus } #endif |