#include <modm/architecture/interface/spi_master.hpp>
|
template<class... Signals> |
static void | connect () |
|
template<class SystemClock , baudrate_t baudrate, percent_t tolerance = 5_pct> |
static void | initialize () |
|
static void | setDataMode (DataMode mode) |
| Sets a new data mode.
|
|
static void | setDataOrder (DataOrder order) |
| Sets a new data order.
|
|
static uint8_t | acquire (void *ctx, ConfigurationHandler handler=nullptr) |
|
static uint8_t | release (void *ctx) |
|
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 () |
|
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
|
|
static bool | getInterruptFlag () |
| Read an interrupt flag.
|
|
static void | getParameter () |
| returns a parameter
|
|
static void | initialize () |
| initializes the peripheral, must be called before use.
|
|
static void | setParameter () |
| sets a parameter
|
|
Interface for a Spi Master with resource management, which allows to synchronize multiple drivers requesting hardware access.
- Author
- Niklas Hauser
Spi Data Mode, Mode0 is the most common mode.
Enum Values | Documentation |
---|
Mode0 | clock normal, sample on rising edge
|
Mode1 | clock normal, sample on falling edge
|
Mode2 | clock inverted, sample on falling edge
|
Mode3 | clock inverted, sample on rising edge
|
static void modm::PeripheralDriver::acknowledgeInterruptFlag |
( |
| ) |
|
|
inheritedstatic |
Acknowledge an interrupt flag.
We use acknowledge here, since it describes the intention rather than the actual implementation.
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
).
- Warning
- Acquires must be balanced with releases of the same context!
-
Acquires are persistent even after calling
initialize()
!
- Returns
0
if another context is using the SPI master, otherwise >0
as the number of times this context acquired the master.
template<uint64_t available, uint64_t requested, percent_t tolerance>
static void modm::PeripheralDriver::assertBaudrateInTolerance |
( |
| ) |
|
|
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.
template<class... Signals>
static void modm::SpiMaster::connect |
( |
| ) |
|
|
static |
Connect GPIOs to the peripheral and configure them.
This configures the Sck, Mosi and Miso signals and connects them.
- Template Parameters
-
Signals | One Scl and one Mosi signal are required (one Miso signal is optional) and can be passed out-of-order. |
template<class SystemClock , baudrate_t baudrate, percent_t tolerance = 5_pct>
static void modm::SpiMaster::initialize |
( |
| ) |
|
|
static |
Initializes the hardware and sets the baudrate.
- Template Parameters
-
SystemClock | the currently active system clock |
baudrate | the desired baudrate in Hz |
tolerance | the allowed relative tolerance for the resulting baudrate |
static uint8_t modm::SpiMaster::release |
( |
void * |
ctx | ) |
|
|
static |
Release access to the SPI master within a context.
- Warning
- Releases must be balanced with acquires of the same context!
-
Releases are persistent even after calling
initialize()
!
- Returns
0
if nothing can be released anymore (for any context) >0
as the number of times this context can still release the master.
static modm::ResumableResult<void> modm::SpiMaster::transfer |
( |
const uint8_t * |
tx, |
|
|
uint8_t * |
rx, |
|
|
std::size_t |
length |
|
) |
| |
|
static |
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.
- Warning
- You must ensure that only one driver is accessing this resumable function by using
acquire(ctx)
and release(ctx)
.
- Parameters
-
[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 |
Swap a single byte and wait for completion non-blocking!.
- Warning
- You must ensure that only one driver is accessing this resumable function by using
acquire(ctx)
and release(ctx)
.
- Parameters
-
- Returns
- received data
The documentation for this class was generated from the following file:
- modm/src/modm/architecture/interface/spi_master.hpp