Loading...
Searching...
No Matches
soft_spi.h File Reference

Software SPI port descriptor definition. More...

Detailed Description

Software SPI port descriptor definition.

Author
Markus Blechschmidt Marku.nosp@m.s.Bl.nosp@m.echsc.nosp@m.hmid.nosp@m.t@haw.nosp@m.-ham.nosp@m.burg..nosp@m.de

Definition in file soft_spi.h.

#include "periph/gpio.h"
#include "periph/spi.h"
#include "mutex.h"
+ Include dependency graph for soft_spi.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  soft_spi_conf_t
 Software SPI port descriptor. More...
 

Macros

#define SOFT_SPI_DEV(x)   (x)
 Default SPI device access macro.
 
#define SOFT_SPI_UNDEF   (UINT_MAX)
 Define global value for undefined SPI device.
 
#define SOFT_SPI_CS_UNDEF   (GPIO_UNDEF)
 Define value for unused CS line.
 

Typedefs

typedef unsigned int soft_spi_t
 Default type for SPI devices.
 
typedef gpio_t soft_spi_cs_t
 Chip select pin type overlaps with gpio_t so it can be casted to this.
 

Enumerations

enum  {
  SOFT_SPI_OK = 0 , SOFT_SPI_NODEV = -1 , SOFT_SPI_NOCS = -2 , SOFT_SPI_NOMODE = -3 ,
  SOFT_SPI_NOCLK = -4
}
 Status codes used by the SPI driver interface. More...
 
enum  soft_spi_mode_t { SOFT_SPI_MODE_0 = 0 , SOFT_SPI_MODE_1 , SOFT_SPI_MODE_2 , SOFT_SPI_MODE_3 }
 Available SPI modes, defining the configuration of clock polarity and clock phase. More...
 
enum  soft_spi_clk_t { SOFT_SPI_CLK_100KHZ = 5 , SOFT_SPI_CLK_1MHZ = 1 , SOFT_SPI_CLK_DEFAULT = 0 }
 Available SPI clock speeds. More...
 

Functions

void soft_spi_init (soft_spi_t bus)
 Basic initialization of the given SPI bus.
 
void soft_spi_init_pins (soft_spi_t bus)
 Initialize the used SPI bus pins, i.e.
 
int soft_spi_init_cs (soft_spi_t bus, soft_spi_cs_t cs)
 Initialize the given chip select pin.
 
void soft_spi_acquire (soft_spi_t bus, soft_spi_cs_t cs, soft_spi_mode_t mode, soft_spi_clk_t clk)
 Start a new SPI transaction.
 
void soft_spi_release (soft_spi_t bus)
 Finish an ongoing SPI transaction by releasing the given SPI bus.
 
uint8_t soft_spi_transfer_byte (soft_spi_t bus, soft_spi_cs_t cs, bool cont, uint8_t out)
 Transfer one byte on the given SPI bus Currently only the use of MOSI in master mode is implemented.
 
void soft_spi_transfer_bytes (soft_spi_t bus, soft_spi_cs_t cs, bool cont, const void *out, void *in, size_t len)
 Transfer a number bytes using the given SPI bus.
 
uint8_t soft_spi_transfer_reg (soft_spi_t bus, soft_spi_cs_t cs, uint8_t reg, uint8_t out)
 Transfer one byte to/from a given register address.
 
void soft_spi_transfer_regs (soft_spi_t bus, soft_spi_cs_t cs, uint8_t reg, const void *out, void *in, size_t len)
 Transfer a number of bytes to/from a given register address.