Functions | |
void | spi_master_setup_device (volatile avr32_spi_t *spi, struct spi_device *device, spi_flags_t flags, uint32_t baud_rate, board_spi_select_id_t sel_id) |
Setup a SPI device. More... | |
status_code_t | spi_read_packet (volatile avr32_spi_t *spi, uint8_t *data, size_t len) |
Receive a sequence of bytes from a SPI device. More... | |
status_code_t | spi_write_packet (volatile avr32_spi_t *spi, const uint8_t *data, size_t len) |
Send a sequence of bytes to a SPI device. More... | |
void spi_master_setup_device | ( | volatile avr32_spi_t * | spi, |
struct spi_device * | device, | ||
spi_flags_t | flags, | ||
uint32_t | 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 |
References CONFIG_SPI_MASTER_BITS_PER_TRANSFER, CONFIG_SPI_MASTER_DELAY_BCT, CONFIG_SPI_MASTER_DELAY_BS, getBaudDiv(), spi_device::id, spi_enable_active_mode(), spi_set_baudrate_register(), spi_set_bits_per_transfer(), spi_set_chipselect_delay_bct(), spi_set_chipselect_delay_bs(), spi_set_mode(), sysclk_get_peripheral_bus_hz(), vSemaphoreCreateBinary, and xSPIMutex.
status_code_t spi_read_packet | ( | volatile avr32_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 |
References CONFIG_SPI_MASTER_DUMMY, ERR_TIMEOUT, spi_is_rx_ready(), spi_is_tx_ready(), spi_read_single(), SPI_TIMEOUT, spi_write_single(), and STATUS_OK.
status_code_t spi_write_packet | ( | volatile avr32_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 |
References ERR_TIMEOUT, spi_is_tx_ready(), SPI_TIMEOUT, spi_write_single(), and STATUS_OK.