Koduino
|
SPI library (call with global object SPI
)
More...
#include <SPI.h>
SPI library (call with global object SPI
)
SPI_CLOCK_DIV2
)MSBFIRST
)SPI_MODE0
)0
and record the returned valuePlease also see the MPU6000 library.
Public Member Functions | |
SPIClass (SPI_TypeDef *SPIx) | |
void | setPins (uint8_t SCK, uint8_t afSCK, uint8_t MISO, uint8_t afMISO, uint8_t MOSI, uint8_t afMOSI) |
Change default SCK, MISO and MOSI pins. More... | |
void | begin () |
Start SPI peripheral and configure pins. | |
void | end () |
Close SPI. | |
void | setDataSize (uint16_t sz) |
Sets data size. More... | |
void | setBitOrder (uint8_t ord) |
Sets the bit-order for data. More... | |
void | setDataMode (uint8_t mode) |
Sets the SPI mode. More... | |
void | setClockDivider (uint8_t div) |
Sets the clock divider (with respect to the system clock) More... | |
uint8_t | transfer (uint8_t _data) |
Transfers one byte over the SPI bus, both sending and receiving. More... | |
SPIClass::SPIClass | ( | SPI_TypeDef * | SPIx | ) |
This file is part of koduino https://github.com/avikde/koduino
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this library; if not, see http://www.gnu.org/licenses/.
void SPIClass::setBitOrder | ( | uint8_t | ord | ) |
Sets the bit-order for data.
ord | One of MSBFIRST , LSBFIRST |
void SPIClass::setClockDivider | ( | uint8_t | div | ) |
Sets the clock divider (with respect to the system clock)
div | One of SPI_CLOCK_DIV<x> where <x> can be 2, 4, 8, 16, 32, 64, 128, 256 |
void SPIClass::setDataMode | ( | uint8_t | mode | ) |
Sets the SPI mode.
See the Wikipedia SPI page for details on these modes
mode | One of SPI_MODE<x> , where <x> can be 0, 1, 2, 3 |
|
inline |
Sets data size.
default is SPI_DataSize_8b
one | of SPI_DataSize_Xb where X is from 4..16 |
void SPIClass::setPins | ( | uint8_t | SCK, |
uint8_t | afSCK, | ||
uint8_t | MISO, | ||
uint8_t | afMISO, | ||
uint8_t | MOSI, | ||
uint8_t | afMOSI | ||
) |
Change default SCK, MISO and MOSI pins.
You will need to look at the datasheet to fill in the alternate function (AF) numbers
SCK | Default is PA5 |
afSCK | |
MISO | Default is PB4 |
afMISO | |
MOSI | Default is PB5 |
afMOSI |
uint8_t SPIClass::transfer | ( | uint8_t | _data | ) |
Transfers one byte over the SPI bus, both sending and receiving.
Make sure you drive chip select low before calling this
_data | Byte to send |