change for use
SPIRawHandler.cpp@1:b138ec359bfe, 2021-12-16 (annotated)
- Committer:
- katoshunsuke
- Date:
- Thu Dec 16 15:53:27 2021 +0000
- Revision:
- 1:b138ec359bfe
- Parent:
- 0:e882606c8174
change for use;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dank | 0:e882606c8174 | 1 | #include "SPIRawHandler.h" |
dank | 0:e882606c8174 | 2 | |
dank | 0:e882606c8174 | 3 | #include "mbed.h" |
dank | 0:e882606c8174 | 4 | |
dank | 0:e882606c8174 | 5 | #define SS_PIN PA_4 |
dank | 0:e882606c8174 | 6 | |
dank | 0:e882606c8174 | 7 | DigitalOut ss(SS_PIN); |
katoshunsuke | 1:b138ec359bfe | 8 | SPI spi(PA_7,PA_6,PA_5); |
dank | 0:e882606c8174 | 9 | |
dank | 0:e882606c8174 | 10 | void SpiRawInitialize(){ |
dank | 0:e882606c8174 | 11 | ss = 1; |
dank | 0:e882606c8174 | 12 | spi.format(8,0); |
katoshunsuke | 1:b138ec359bfe | 13 | spi.frequency(125000); |
dank | 0:e882606c8174 | 14 | } |
dank | 0:e882606c8174 | 15 | |
dank | 0:e882606c8174 | 16 | void SpiRawWrite(uint8_t data){ |
dank | 0:e882606c8174 | 17 | spi.write(data); |
dank | 0:e882606c8174 | 18 | } |
dank | 0:e882606c8174 | 19 | |
dank | 0:e882606c8174 | 20 | uint8_t SpiRawRead(){ |
dank | 0:e882606c8174 | 21 | return spi.write(0xFF); |
dank | 0:e882606c8174 | 22 | } |
dank | 0:e882606c8174 | 23 | |
dank | 0:e882606c8174 | 24 | void SpiRawWriteMulti(uint8_t *data,uint16_t count){ |
dank | 0:e882606c8174 | 25 | for(unsigned int i = 0;i < count;i++)spi.write(data[i]); |
dank | 0:e882606c8174 | 26 | } |
dank | 0:e882606c8174 | 27 | |
dank | 0:e882606c8174 | 28 | void SpiRawReadMulti(uint8_t *data,uint16_t count){ |
dank | 0:e882606c8174 | 29 | for(unsigned int i = 0;i < count;i++)data[i] = spi.write(0xFF); |
dank | 0:e882606c8174 | 30 | } |
dank | 0:e882606c8174 | 31 | |
dank | 0:e882606c8174 | 32 | void SpiRawAsertSS(){ |
dank | 0:e882606c8174 | 33 | ss = 0; |
dank | 0:e882606c8174 | 34 | } |
dank | 0:e882606c8174 | 35 | |
dank | 0:e882606c8174 | 36 | void SpiRawDeAsertSS(){ |
dank | 0:e882606c8174 | 37 | ss = 1; |
dank | 0:e882606c8174 | 38 | } |