Ultra fast and direct SPI library for some STM32 micros.
Dependents: DirectSPI-test wave_player_super_lite
DirectSPI.h@4:f63f07d07d5a, 2017-02-28 (annotated)
- Committer:
- mimi3
- Date:
- Tue Feb 28 22:08:32 2017 +0900
- Revision:
- 4:f63f07d07d5a
- Parent:
- 3:63cc20b0895b
update
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mimi3 | 3:63cc20b0895b | 1 | #ifndef __DIRECTSPI_H_ |
mimi3 | 3:63cc20b0895b | 2 | #define __DIRECTSPI_H_ |
mimi3 | 3:63cc20b0895b | 3 | |
mimi3 | 1:576dbeb04958 | 4 | #include "mbed.h" |
mimi3 | 1:576dbeb04958 | 5 | #include "PeripheralPins.h" |
mimi3 | 1:576dbeb04958 | 6 | #define TODO 0 |
mimi3 | 1:576dbeb04958 | 7 | |
mimi3 | 1:576dbeb04958 | 8 | class DirectSPI : public SPI |
mimi3 | 1:576dbeb04958 | 9 | { |
mimi3 | 1:576dbeb04958 | 10 | public: |
mimi3 | 1:576dbeb04958 | 11 | DirectSPI(PinName mosi, PinName miso, PinName sclk); |
mimi3 | 1:576dbeb04958 | 12 | uint16_t directWrite8(uint16_t data); |
mimi3 | 1:576dbeb04958 | 13 | uint16_t directWrite16(uint16_t data); |
mimi3 | 2:1faa28f1a5bb | 14 | uint16_t directWrite(uint16_t data); |
mimi3 | 4:f63f07d07d5a | 15 | SPI_TypeDef *spi_get_id( PinName mosi, PinName miso, PinName sclk, PinName ssel); |
mimi3 | 3:63cc20b0895b | 16 | void operator = (uint8_t d8){ |
mimi3 | 3:63cc20b0895b | 17 | volatile uint16_t res; |
mimi3 | 3:63cc20b0895b | 18 | res = directWrite8( d8 ); |
mimi3 | 3:63cc20b0895b | 19 | } |
mimi3 | 2:1faa28f1a5bb | 20 | protected: |
mimi3 | 1:576dbeb04958 | 21 | SPI_TypeDef *spi; |
mimi3 | 1:576dbeb04958 | 22 | #if TODO |
mimi3 | 1:576dbeb04958 | 23 | uint16_t (DirectSPI::*spiSend)(uint16_t data); |
mimi3 | 2:1faa28f1a5bb | 24 | uint16_t spiSend8(uint16_t data){return 0;}; |
mimi3 | 2:1faa28f1a5bb | 25 | uint16_t spiSend16(uint16_t data){return 0;}; |
mimi3 | 1:576dbeb04958 | 26 | #endif |
mimi3 | 1:576dbeb04958 | 27 | }; |
mimi3 | 1:576dbeb04958 | 28 | |
mimi3 | 3:63cc20b0895b | 29 | #endif /* __DIRECTSPI_H_ */ |
mimi3 | 3:63cc20b0895b | 30 |