modm API documentation
|
#include <modm/platform/spi/bitbang_spi_master.hpp>
Public Typedefs | |
using | ConfigurationHandler = void (*)() |
The signature of the configuration function. | |
Public Types | |
enum | DataMode : uint8_t { DataMode::Mode0 = 0b00, DataMode::Mode1 = 0b01, DataMode::Mode2 = 0b10, DataMode::Mode3 = 0b11 } |
Spi Data Mode, Mode0 is the most common mode. More... | |
enum | DataOrder : uint8_t { MsbFirst = 0b0, LsbFirst = 0b1 } |
Spi Data Order, MsbFirst is the most common mode. | |
Static Public Member Functions | |
template<class... Signals> | |
static void | connect () |
template<class SystemClock , baudrate_t baudrate, percent_t tolerance = pct(5)> | |
static void | initialize () |
Baudrate is limited to 500kbps. | |
static void | setDataMode (DataMode mode) |
static void | setDataOrder (DataOrder order) |
static uint8_t | transferBlocking (uint8_t data) |
static void | transferBlocking (const uint8_t *tx, uint8_t *rx, std::size_t length) |
static modm::ResumableResult< uint8_t > | transfer (uint8_t data) |
static modm::ResumableResult< void > | transfer (const uint8_t *tx, uint8_t *rx, std::size_t length) |
static void | acknowledgeInterruptFlag () |
static uint8_t | acquire (void *ctx, ConfigurationHandler handler=nullptr) |
template<uint64_t available, uint64_t requested, percent_t tolerance> | |
static void | assertBaudrateInTolerance () |
template<double available, double requested, percent_t tolerance> | |
static void | assertDurationInTolerance () |
static void | configurePurpose () |
configures a peripheral for a specific purpose | |
template<class... Signals> | |
static void | connect () |
static bool | getInterruptFlag () |
Read an interrupt flag. | |
static void | getParameter () |
returns a parameter | |
template<class SystemClock , baudrate_t baudrate, percent_t tolerance = 5_pct> | |
static void | initialize () |
static void | initialize () |
initializes the peripheral, must be called before use. | |
static uint8_t | release (void *ctx) |
static void | setDataMode (DataMode mode) |
Sets a new data mode. | |
static void | setDataOrder (DataOrder order) |
Sets a new data order. | |
static void | setParameter () |
sets a parameter | |
static modm::ResumableResult< uint8_t > | transfer (uint8_t data) |
static modm::ResumableResult< void > | transfer (const uint8_t *tx, uint8_t *rx, std::size_t length) |
static uint8_t | acquire (void *ctx, Spi::ConfigurationHandler handler) |
static uint8_t | release (void *ctx) |
Software emulation of a Simple Spi.
Sck | clock pin [output] |
Mosi | master out slave in pin [output] |
Miso | master in slave out pin [input] |
|
inheritedstrong |
|
inheritedstatic |
Acknowledge an interrupt flag.
We use acknowledge here, since it describes the intention rather than the actual implementation.
|
inheritedstatic |
Request access to the SPI master within a context. You may acquire the SPI master multiple times within the same context.
The configuration handler will only be called when acquiring the SPI master for the first time (if it is not a nullptr
).
initialize()
!0
if another context is using the SPI master, otherwise >0
as the number of times this context acquired the master.
|
inheritedinlinestatic |
Since baudrates are usually generated by prescaling a system clock, only several distinct values can be generated. This method checks if the user requested baudrate is within error tolerance of the system achievable baudrate.
|
inheritedstatic |
Connect GPIOs to the peripheral and configure them.
This configures the Sck, Mosi and Miso signals and connects them.
Signals | One Scl and one Mosi signal are required (one Miso signal is optional) and can be passed out-of-order. |
|
inheritedstatic |
Initializes the hardware and sets the baudrate.
SystemClock | the currently active system clock |
baudrate | the desired baudrate in Hz |
tolerance | the allowed relative tolerance for the resulting baudrate |
|
inheritedstatic |
Release access to the SPI master within a context.
initialize()
!0
if nothing can be released anymore (for any context) >0
as the number of times this context can still release the master.
|
inheritedstatic |
Set the data buffers and length with options and starts a non-blocking transfer. This may be hardware accelerated (DMA or Interrupt), but not guaranteed.
acquire(ctx)
and release(ctx)
.[in] | tx | pointer to transmit buffer, set to nullptr to send dummy bytes |
[out] | rx | pointer to receive buffer, set to nullptr to discard received bytes |
length | number of bytes to be shifted out |
|
inheritedstatic |
Swap a single byte and wait for completion non-blocking!.
acquire(ctx)
and release(ctx)
.data | data to be sent |