Hanna
Sourcecode Batteriemanagementsystem |
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. | |
This is the API for SPI master service on XMEGA.
See common_spi_master_quickstart
void spi_deselect_device | ( | SPI_t * | spi, |
struct spi_device * | device | ||
) |
Deselect given device on the SPI bus.
Calls board chip deselect.
spi | Base address of the SPI instance. |
device | SPI device |
Definiert in Zeile 261 der Datei spi_master.c.
|
inlinestatic |
Disables the SPI.
Ensures that nothing is transferred while setting up buffers.
spi | Base address of the SPI instance. |
Definiert in Zeile 125 der Datei spi_master.h.
|
inlinestatic |
Enables the SPI.
spi | Base address of the SPI instance. |
Definiert in Zeile 112 der Datei spi_master.h.
|
inlinestatic |
Tests if the SPI is enabled.
spi | Base address of the SPI instance. |
1
if the SPI is enabled, otherwise 0
. Definiert in Zeile 136 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 409 der Datei spi_master.h.
|
inlinestatic |
Checks if all reception is ready.
spi | Base address of the SPI instance. |
1
if the SPI Receiver is ready, otherwise 0
. Definiert in Zeile 420 der Datei spi_master.h.
|
inlinestatic |
Checks if all transmissions are complete.
spi | Base address of the SPI instance. |
1 | All transmissions complete. |
0 | Transmissions not complete. |
Definiert in Zeile 385 der Datei spi_master.h.
|
inlinestatic |
Checks if all transmissions is ready.
spi | Base address of the SPI instance. |
1 | All transmissions complete. |
0 | Transmissions not complete. |
Definiert in Zeile 398 der Datei spi_master.h.
void spi_master_init | ( | SPI_t * | spi | ) |
Initializes the SPI in master mode.
spi | Base address of the SPI instance. |
Definiert in Zeile 126 der Datei spi_master.c.
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.
spi | Base address of the SPI instance. |
device | Pointer to SPI device struct that should be initialized. |
flags | SPI configuration flags. Common flags for all implementations are the SPI modes SPI_MODE_0 ... SPI_MODE_3. |
baud_rate | Baud rate for communication with slave device in Hz. |
sel_id | Board 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.
spi | Base address of the SPI instance. |
data | data buffer to read |
len | Length of data |
Definiert in Zeile 223 der Datei spi_master.c.
|
inlinestatic |
Receive one byte from a SPI device.
spi | Base address of the SPI instance. |
data | Pointer to the data byte where to store the received data. |
Definiert in Zeile 359 der Datei spi_master.h.
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.
spi | Base address of the SPI instance. |
device | SPI 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.
spi | Base address of the SPI instance. |
data | data buffer to write |
len | Length of data |
Definiert in Zeile 200 der Datei spi_master.c.
|
static |
Write one byte to a SPI device.
spi | Base address of the SPI instance. |
data | The data byte to be loaded |
Definiert in Zeile 334 der Datei spi_master.h.