Hanna
Sourcecode Batteriemanagementsystem |
SPI Master driver header file. Mehr ...
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 ... | |
SPI Master driver header file.
Definiert in Datei spi_master.h.
enum status_code |
Status code that may be returned by shell commands and protocol implementations.
Definiert in Zeile 62 der Datei spi_master.h.
|
inlinestatic |
Activate SPI master mode of a SPI peripheral.
spi | Base address of the SPI instance. |
Definiert in Zeile 180 der Datei spi_master.h.
|
inlinestatic |
Get one data byte to a SPI peripheral.
spi | Base address of the SPI instance. |
Definiert in Zeile 158 der Datei spi_master.h.
|
inlinestatic |
Tests if the SPI contains a received character.
spi | Base address of the SPI instance. |
1
if the SPI Receive Holding Register is full, otherwise 0
. Definiert in Zeile 169 der Datei spi_master.h.
|
inlinestatic |
Put one data byte to a SPI peripheral.
spi | Base address of the SPI instance. |
data | The data byte to be loaded |
Definiert in Zeile 147 der Datei spi_master.h.
int8_t spi_xmega_set_baud_div | ( | SPI_t * | spi, |
uint32_t | baudrate, | ||
uint32_t | clkper_hz | ||
) |
Calculates the SPI baudrate divider.
baudrate | The expected baudrate on the SPI. |
clkper_hz | SPI module input clock frequency (Peripheral clock, Hz). |
spi | The SPI module address |
>=0 | Success. |
<0 | Error. |
baudrate | The expected baudrate on the SPI. |
clkper_hz | SPI module input clock frequency (Peripheral clock, Hz). |
spi | The SPI module address |
>=0 | Success. |
<0 | Error. |
Definiert in Zeile 59 der Datei spi_master.c.