Alex Borisevich
/
OpenBCI
PlatformSPI.cpp@1:4683702d7ad8, 2017-01-22 (annotated)
- Committer:
- akpc806a
- Date:
- Sun Jan 22 04:10:11 2017 +0000
- Revision:
- 1:4683702d7ad8
- Parent:
- 0:2cb59ea20ace
OpenBCI 32bit board variation with STM32L476 mircocontroller and mbed support. Version V2 of firmware, forked from the same official version for the PIC32 board.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
akpc806a | 0:2cb59ea20ace | 1 | // interface for SPI implemented with mbed framework |
akpc806a | 0:2cb59ea20ace | 2 | |
akpc806a | 0:2cb59ea20ace | 3 | #include "PlatformSPI.h" |
akpc806a | 0:2cb59ea20ace | 4 | #include "mbed.h" |
akpc806a | 0:2cb59ea20ace | 5 | |
akpc806a | 0:2cb59ea20ace | 6 | SPI spi_adc(PA_7, PA_6, PA_5); // PinName mosi, PinName miso, PinName sclk, PinName ssel=NC |
akpc806a | 0:2cb59ea20ace | 7 | |
akpc806a | 0:2cb59ea20ace | 8 | void DSPI0::begin() |
akpc806a | 0:2cb59ea20ace | 9 | { |
akpc806a | 1:4683702d7ad8 | 10 | |
akpc806a | 0:2cb59ea20ace | 11 | } |
akpc806a | 0:2cb59ea20ace | 12 | |
akpc806a | 0:2cb59ea20ace | 13 | void DSPI0::setSpeed(int speed_hz) |
akpc806a | 0:2cb59ea20ace | 14 | { |
akpc806a | 0:2cb59ea20ace | 15 | spi_adc.frequency(speed_hz); |
akpc806a | 0:2cb59ea20ace | 16 | } |
akpc806a | 0:2cb59ea20ace | 17 | |
akpc806a | 0:2cb59ea20ace | 18 | void DSPI0::setMode(int mode) |
akpc806a | 0:2cb59ea20ace | 19 | { |
akpc806a | 0:2cb59ea20ace | 20 | spi_adc.format(8,mode); |
akpc806a | 0:2cb59ea20ace | 21 | } |
akpc806a | 0:2cb59ea20ace | 22 | |
akpc806a | 0:2cb59ea20ace | 23 | int DSPI0::transfer(int data) |
akpc806a | 0:2cb59ea20ace | 24 | { |
akpc806a | 0:2cb59ea20ace | 25 | return spi_adc.write(data); |
akpc806a | 0:2cb59ea20ace | 26 | } |
akpc806a | 0:2cb59ea20ace | 27 |