Hanna
Sourcecode Batteriemanagementsystem
Datenstrukturen | Makrodefinitionen | Typdefinitionen | Aufzählungen | Funktionen
spi_master.h-Dateireferenz

SPI Master driver header file. Mehr ...

#include "compiler.h"
#include "port_driver.h"
Include-Abhängigkeitsdiagramm für spi_master.h:
Dieser Graph zeigt, welche Datei direkt oder indirekt diese Datei enthält:

gehe zum Quellcode dieser Datei

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.
 
Spi Master Management Configuration
#define CONFIG_SPI_MASTER_DUMMY   0xFF
 Default Config Spi Master Dummy Field.
 

Typdefinitionen

typedef uint32_t board_spi_select_id_t
 
typedef uint8_t spi_flags_t
 
typedef enum status_code status_code_t
 

Aufzählungen

enum  status_code {
  STATUS_OK = 0, ERR_IO_ERROR = -1, ERR_FLUSHED = -2, ERR_TIMEOUT = -3,
  ERR_BAD_DATA = -4, ERR_PROTOCOL = -5, ERR_UNSUPPORTED_DEV = -6, ERR_NO_MEMORY = -7,
  ERR_INVALID_ARG = -8, ERR_BAD_ADDRESS = -9, ERR_BUSY = -10, ERR_BAD_FORMAT = -11,
  ERR_NO_TIMER = -12, ERR_TIMER_ALREADY_RUNNING = -13, ERR_TIMER_NOT_RUNNING = -14, OPERATION_IN_PROGRESS = -128
}
 

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 void spi_enable_master_mode (SPI_t *spi)
 Activate SPI master mode of a SPI peripheral. Mehr ...
 
static uint8_t spi_get (SPI_t *spi)
 Get one data byte to a SPI peripheral. 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_ok (SPI_t *spi)
 Tests if the SPI contains a received character. 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 ...
 
static void spi_put (SPI_t *spi, uint8_t data)
 Put one data byte to a SPI peripheral. 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 ...
 
int8_t spi_xmega_set_baud_div (SPI_t *spi, uint32_t baudrate, uint32_t clkper_hz)
 Calculates the SPI baudrate divider. Mehr ...
 

Ausführliche Beschreibung

SPI Master driver header file.

Autor
Copyright (c) 2009-2015 Atmel Corporation. All rights reserved.

Definiert in Datei spi_master.h.

Dokumentation der Aufzählungstypen

Status code that may be returned by shell commands and protocol implementations.

Zu beachten
Any change to these status codes and the corresponding message strings is strictly forbidden. New codes can be added, however, but make sure that any message string tables are updated at the same time.
Aufzählungswerte
STATUS_OK 

Success.

ERR_IO_ERROR 

I/O error.

ERR_FLUSHED 

Request flushed from queue.

ERR_TIMEOUT 

Operation timed out.

ERR_BAD_DATA 

Data integrity check failed.

ERR_PROTOCOL 

Protocol error.

ERR_UNSUPPORTED_DEV 

Unsupported device.

ERR_NO_MEMORY 

Insufficient memory.

ERR_INVALID_ARG 

Invalid argument.

ERR_BAD_ADDRESS 

Bad address.

ERR_BUSY 

Resource is busy.

ERR_BAD_FORMAT 

Data format not recognized.

ERR_NO_TIMER 

No timer available.

ERR_TIMER_ALREADY_RUNNING 

Timer already running.

ERR_TIMER_NOT_RUNNING 

Timer not running.

OPERATION_IN_PROGRESS 

Operation in progress.

This status code is for driver-internal use when an operation is currently being performed.

Zu beachten
Drivers should never return this status code to any callers. It is strictly for internal use.

Definiert in Zeile 62 der Datei spi_master.h.

Dokumentation der Funktionen

static void spi_enable_master_mode ( SPI_t *  spi)
inlinestatic

Activate SPI master mode of a SPI peripheral.

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

Definiert in Zeile 180 der Datei spi_master.h.

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

static uint8_t spi_get ( SPI_t *  spi)
inlinestatic

Get one data byte to a SPI peripheral.

Parameter
spiBase address of the SPI instance.
Rückgabe
The data byte

Definiert in Zeile 158 der Datei spi_master.h.

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

static bool spi_is_tx_ok ( 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 169 der Datei spi_master.h.

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

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

Put one data byte to a SPI peripheral.

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

Definiert in Zeile 147 der Datei spi_master.h.

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

int8_t spi_xmega_set_baud_div ( SPI_t *  spi,
uint32_t  baudrate,
uint32_t  clkper_hz 
)

Calculates the SPI baudrate divider.

Parameter
baudrateThe expected baudrate on the SPI.
clkper_hzSPI module input clock frequency (Peripheral clock, Hz).
spiThe SPI module address
Rückgabe
Divider or error code.
Rückgabewerte
>=0Success.
<0Error.
Parameter
baudrateThe expected baudrate on the SPI.
clkper_hzSPI module input clock frequency (Peripheral clock, Hz).
spiThe SPI module address
Rückgabe
Status of operation.
Rückgabewerte
>=0Success.
<0Error.

Definiert in Zeile 59 der Datei spi_master.c.

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