Hanna
Sourcecode Batteriemanagementsystem
Datenstrukturen | Makrodefinitionen | Typdefinitionen | Funktionen
XMEGA SPI master service.

Datenstrukturen

struct  spi_device
 Polled SPI device definition. Mehr ...
 

Makrodefinitionen

#define SPI_CPHA   (1 << 0)
 Clock phase.
 
#define SPI_CPOL   (1 << 1)
 Clock polarity.
 
#define SPI_MODE_0   0
 SPI mode 0.
 
#define SPI_MODE_1   (SPI_CPHA)
 SPI mode 1.
 
#define SPI_MODE_2   (SPI_CPOL)
 SPI mode 2.
 
#define SPI_MODE_3   (SPI_CPOL | SPI_CPHA)
 SPI mode 3.
 

Typdefinitionen

typedef uint32_t board_spi_select_id_t
 
typedef uint8_t spi_flags_t
 

Funktionen

void spi_deselect_device (SPI_t *spi, struct spi_device *device)
 Deselect given device on the SPI bus. Mehr ...
 
static void spi_disable (SPI_t *spi)
 Disables the SPI. Mehr ...
 
static void spi_enable (SPI_t *spi)
 Enables the SPI. Mehr ...
 
static bool spi_is_enabled (SPI_t *spi)
 Tests if the SPI is enabled. Mehr ...
 
static bool spi_is_rx_full (SPI_t *spi)
 Tests if the SPI contains a received character. Mehr ...
 
static bool spi_is_rx_ready (SPI_t *spi)
 Checks if all reception is ready. Mehr ...
 
static bool spi_is_tx_empty (SPI_t *spi)
 Checks if all transmissions are complete. Mehr ...
 
static bool spi_is_tx_ready (SPI_t *spi)
 Checks if all transmissions is ready. Mehr ...
 
void spi_master_init (SPI_t *spi)
 Initializes the SPI in master mode. Mehr ...
 
void spi_master_setup_device (SPI_t *spi, struct spi_device *device, spi_flags_t flags, unsigned long baud_rate, board_spi_select_id_t sel_id)
 Setup a SPI device. Mehr ...
 
status_code_t spi_read_packet (SPI_t *spi, uint8_t *data, size_t len)
 Receive a sequence of bytes from a SPI device. Mehr ...
 
static void spi_read_single (SPI_t *spi, uint8_t *data)
 Receive one byte from a SPI device. Mehr ...
 
void spi_select_device (SPI_t *spi, struct spi_device *device)
 Select given device on the SPI bus. Mehr ...
 
status_code_t spi_write_packet (SPI_t *spi, const uint8_t *data, size_t len)
 Send a sequence of bytes to a SPI device. Mehr ...
 
static __always_inline void spi_write_single (SPI_t *spi, uint8_t data)
 Write one byte to a SPI device. Mehr ...
 

Spi Master Management Configuration

#define CONFIG_SPI_MASTER_DUMMY   0xFF
 Default Config Spi Master Dummy Field.
 

Ausführliche Beschreibung

This is the API for SPI master service on XMEGA.

Quick Start Guide

See common_spi_master_quickstart

Dokumentation der Funktionen

void spi_deselect_device ( SPI_t *  spi,
struct spi_device device 
)

Deselect given device on the SPI bus.

Calls board chip deselect.

Parameter
spiBase address of the SPI instance.
deviceSPI device
Vorbedingung
SPI device must be selected with spi_select_device() first

Definiert in Zeile 261 der Datei spi_master.c.

void spi_disable ( SPI_t *  spi)
inlinestatic

Disables the SPI.

Ensures that nothing is transferred while setting up buffers.

Parameter
spiBase address of the SPI instance.
Warnung
This may cause data loss if used on a slave SPI.

Definiert in Zeile 125 der Datei spi_master.h.

void spi_enable ( SPI_t *  spi)
inlinestatic

Enables the SPI.

Parameter
spiBase address of the SPI instance.

Definiert in Zeile 112 der Datei spi_master.h.

Hier ist ein Graph der zeigt, wo diese Funktion aufgerufen wird:

bool spi_is_enabled ( SPI_t *  spi)
inlinestatic

Tests if the SPI is enabled.

Parameter
spiBase address of the SPI instance.
Rückgabe
1 if the SPI is enabled, otherwise 0.

Definiert in Zeile 136 der Datei spi_master.h.

static bool spi_is_rx_full ( SPI_t *  spi)
inlinestatic

Tests if the SPI contains a received character.

Parameter
spiBase address of the SPI instance.
Rückgabe
1 if the SPI Receive Holding Register is full, otherwise 0.

Definiert in Zeile 409 der Datei spi_master.h.

Hier ist ein Graph, der zeigt, was diese Funktion aufruft:

Hier ist ein Graph der zeigt, wo diese Funktion aufgerufen wird:

static bool spi_is_rx_ready ( SPI_t *  spi)
inlinestatic

Checks if all reception is ready.

Parameter
spiBase address of the SPI instance.
Rückgabe
1 if the SPI Receiver is ready, otherwise 0.

Definiert in Zeile 420 der Datei spi_master.h.

Hier ist ein Graph, der zeigt, was diese Funktion aufruft:

static bool spi_is_tx_empty ( SPI_t *  spi)
inlinestatic

Checks if all transmissions are complete.

Parameter
spiBase address of the SPI instance.
Rückgabe
Status.
Rückgabewerte
1All transmissions complete.
0Transmissions not complete.

Definiert in Zeile 385 der Datei spi_master.h.

Hier ist ein Graph, der zeigt, was diese Funktion aufruft:

Hier ist ein Graph der zeigt, wo diese Funktion aufgerufen wird:

static bool spi_is_tx_ready ( SPI_t *  spi)
inlinestatic

Checks if all transmissions is ready.

Parameter
spiBase address of the SPI instance.
Rückgabe
Status.
Rückgabewerte
1All transmissions complete.
0Transmissions not complete.

Definiert in Zeile 398 der Datei spi_master.h.

Hier ist ein Graph, der zeigt, was diese Funktion aufruft:

void spi_master_init ( SPI_t *  spi)

Initializes the SPI in master mode.

Parameter
spiBase address of the SPI instance.

Definiert in Zeile 126 der Datei spi_master.c.

Hier ist ein Graph, der zeigt, was diese Funktion aufruft:

Hier ist ein Graph der zeigt, wo diese Funktion aufgerufen wird:

void spi_master_setup_device ( SPI_t *  spi,
struct spi_device device,
spi_flags_t  flags,
unsigned long  baud_rate,
board_spi_select_id_t  sel_id 
)

Setup a SPI device.

The returned device descriptor structure must be passed to the driver whenever that device should be used as current slave device.

Parameter
spiBase address of the SPI instance.
devicePointer to SPI device struct that should be initialized.
flagsSPI configuration flags. Common flags for all implementations are the SPI modes SPI_MODE_0 ... SPI_MODE_3.
baud_rateBaud rate for communication with slave device in Hz.
sel_idBoard specific select id
status_code_t spi_read_packet ( SPI_t *  spi,
uint8_t *  data,
size_t  len 
)

Receive a sequence of bytes from a SPI device.

All bytes sent out on SPI bus are sent as value 0.

Parameter
spiBase address of the SPI instance.
datadata buffer to read
lenLength of data
Vorbedingung
SPI device must be selected with spi_select_device() first

Definiert in Zeile 223 der Datei spi_master.c.

Hier ist ein Graph, der zeigt, was diese Funktion aufruft:

Hier ist ein Graph der zeigt, wo diese Funktion aufgerufen wird:

static void spi_read_single ( SPI_t *  spi,
uint8_t *  data 
)
inlinestatic

Receive one byte from a SPI device.

Parameter
spiBase address of the SPI instance.
dataPointer to the data byte where to store the received data.

Definiert in Zeile 359 der Datei spi_master.h.

Hier ist ein Graph, der zeigt, was diese Funktion aufruft:

Hier ist ein Graph der zeigt, wo diese Funktion aufgerufen wird:

void spi_select_device ( SPI_t *  spi,
struct spi_device device 
)

Select given device on the SPI bus.

Set device specific setting and calls board chip select.

Parameter
spiBase address of the SPI instance.
deviceSPI device

Definiert in Zeile 247 der Datei spi_master.c.

status_code_t spi_write_packet ( SPI_t *  spi,
const uint8_t *  data,
size_t  len 
)

Send a sequence of bytes to a SPI device.

Received bytes on the SPI bus are discarded.

Parameter
spiBase address of the SPI instance.
datadata buffer to write
lenLength of data
Vorbedingung
SPI device must be selected with spi_select_device() first

Definiert in Zeile 200 der Datei spi_master.c.

Hier ist ein Graph, der zeigt, was diese Funktion aufruft:

Hier ist ein Graph der zeigt, wo diese Funktion aufgerufen wird:

static __always_inline void spi_write_single ( SPI_t *  spi,
uint8_t  data 
)
static

Write one byte to a SPI device.

Parameter
spiBase address of the SPI instance.
dataThe data byte to be loaded

Definiert in Zeile 334 der Datei spi_master.h.

Hier ist ein Graph, der zeigt, was diese Funktion aufruft:

Hier ist ein Graph der zeigt, wo diese Funktion aufgerufen wird: