MiraOS  1.22
Functions
mira_spi.h File Reference

MiraOS SPI driver. More...

#include <stdint.h>

Go to the source code of this file.

Functions

void mira_spi_init (uint32_t clock_speed)
 Initialize the SPI driver. More...
 
void mira_spi_set_clock_speed (uint32_t clock_speed)
 Updates SPI clock speed. More...
 
uint32_t mira_spi_get_clock_speed (void)
 Gets current clock speed. More...
 
void mira_spi_write (uint8_t data)
 Writes a byte to the SPI bus. More...
 
uint8_t mira_spi_read (void)
 Reads a byte from the SPI bus. More...
 
void mira_spi_transfer (uint8_t *source, uint8_t *destination, uint16_t src_length, uint16_t dest_length)
 A full SPI transfer. More...
 
void mira_spi_flush (void)
 Flush the SPI driver FIFO. More...
 

Detailed Description

MiraOS SPI driver.

Author
LumenRadio AB
Date
17 Jan 2016 The MiraOS library provides functions for controlling the Mira radio module, sending/receiving messages, controlling peripherals, etc.
See also
http://docs.lumenrad.io/mira

Function Documentation

void mira_spi_flush ( void  )

Flush the SPI driver FIFO.

Returns
void
uint32_t mira_spi_get_clock_speed ( void  )

Gets current clock speed.

Returns
current clock speed in Hz
void mira_spi_init ( uint32_t  clock_speed)

Initialize the SPI driver.

Parameters
clock_speedSPI maximum clock speed in Hz
Returns
void
uint8_t mira_spi_read ( void  )

Reads a byte from the SPI bus.

Sends 0x00 on the SPI bus to clock in a byte from a slave device

Returns
byte read from spi bus
void mira_spi_set_clock_speed ( uint32_t  clock_speed)

Updates SPI clock speed.

Parameters
clock_speedSPI maximum clock speed in Hz
Returns
void
void mira_spi_transfer ( uint8_t *  source,
uint8_t *  destination,
uint16_t  src_length,
uint16_t  dest_length 
)

A full SPI transfer.

This function performs a full SPI transfer (both write and read). To total number of bytes written to the bus is MAX(src_length, dest_length), if needed the write data is padded with 0x00. No more than dest_bytes of data will be written to destination. source or destination MAY be NULL.

Parameters
sourcepointer to the source data buffer
destinationpointer to the destination data buffer
src_lengththe number of bytes to read from the source buffer
dest_lengththe number of bytes to write into the destination buffer
Returns
void
void mira_spi_write ( uint8_t  data)

Writes a byte to the SPI bus.

Any received data is discarded

Parameters
dataa byte to write to the SPI bus
Returns
void