SPI Host Device Interface Functions More...
#include <stdint.h>
#include "sw/device/lib/dif/autogen/dif_spi_host_autogen.h"
Go to the source code of this file.
Data Structures | |
struct | dif_spi_host_config |
Runtime configuration for SPI Host. More... | |
struct | dif_spi_host_segment |
Segment descriptor for each segment in a transaction. More... | |
struct | dif_spi_host_status |
struct | dif_spi_host_config.chip_select |
union | dif_spi_host_segment.__unnamed0__ |
struct | dif_spi_host_segment.__unnamed0__.opcode |
struct | dif_spi_host_segment.__unnamed0__.address |
struct | dif_spi_host_segment.__unnamed0__.dummy |
struct | dif_spi_host_segment.__unnamed0__.tx |
struct | dif_spi_host_segment.__unnamed0__.rx |
struct | dif_spi_host_segment.__unnamed0__.bidir |
Typedefs | |
typedef struct dif_spi_host_config | dif_spi_host_config_t |
Runtime configuration for SPI Host. | |
typedef enum dif_spi_host_width | dif_spi_host_width_t |
Width of SPI operations. | |
typedef enum dif_spi_host_direction | dif_spi_host_direction_t |
Direction of SPI operations. | |
typedef enum dif_spi_host_segment_type | dif_spi_host_segment_type_t |
Segment types for segments in a transaction. | |
typedef enum dif_spi_host_addr_mode | dif_spi_host_addr_mode_t |
Address mode for the address segment in a transaction. | |
typedef struct dif_spi_host_segment | dif_spi_host_segment_t |
Segment descriptor for each segment in a transaction. | |
typedef enum dif_spi_host_events | dif_spi_host_events_code_t |
typedef uint32_t | dif_spi_host_events_t |
Bitmask with the dif_spi_host_events_code_t values. | |
typedef struct dif_spi_host_status | dif_spi_host_status_t |
typedef enum dif_spi_host_error_code | dif_spi_host_error_code_t |
typedef uint32_t | dif_spi_host_errors_t |
Bitmask with the dif_spi_host_error_code_t values. | |
SPI Host Device Interface Functions
Definition in file dif_spi_host.h.
struct dif_spi_host_config |
Runtime configuration for SPI Host.
This struct describes (SOFTWARE) runtime information for one-time configuration of the hardware.
Definition at line 26 of file dif_spi_host.h.
Data Fields | ||
---|---|---|
struct dif_spi_host_config.chip_select | chip_select | |
bool | cpha | SPI clock phase. |
bool | cpol | SPI clock polarity. |
bool | full_cycle | Full-cycle sampling mode. |
uint32_t | peripheral_clock_freq_hz | Peripheral clock frequency (ie: kClockFreqPeripheralHz). |
size_t | rx_watermark |
If EVENT_ENABLE.RXWM is set, an interrupt will fire when the depth of the RX FIFO drops below RX_WATERMARK words (32b each). |
uint32_t | spi_clock | Desired SPI clock frequency (SCK). |
size_t | tx_watermark |
If EVENT_ENABLE.TXWM is set, an interrupt will fire when the depth of the TX FIFO drops below TX_WATERMARK words (32b each). |
struct dif_spi_host_segment |
Segment descriptor for each segment in a transaction.
This struct is a tagged union: the type
field determines which field of the union is relevant.
Definition at line 115 of file dif_spi_host.h.
Data Fields | ||
---|---|---|
union dif_spi_host_segment.__unnamed0__ | __unnamed__ | |
dif_spi_host_segment_type_t | type | The segment type for this segment. |
struct dif_spi_host_status |
Definition at line 293 of file dif_spi_host.h.
struct dif_spi_host_config.chip_select |
Definition at line 31 of file dif_spi_host.h.
Data Fields | ||
---|---|---|
uint8_t | idle | Minimum idle time between commands in SCK half-cycles. |
uint8_t | lead | Chip-select leading time in SCK half-cycles. |
uint8_t | trail | Chip-select trailing time in SCK half-cycles. |
union dif_spi_host_segment.__unnamed0__ |
Definition at line 118 of file dif_spi_host.h.
Data Fields | ||
---|---|---|
struct dif_spi_host_segment.__unnamed0__.address | address | |
struct dif_spi_host_segment.__unnamed0__.bidir | bidir | |
struct dif_spi_host_segment.__unnamed0__.dummy | dummy | |
struct dif_spi_host_segment.__unnamed0__.opcode | opcode | |
struct dif_spi_host_segment.__unnamed0__.rx | rx | |
struct dif_spi_host_segment.__unnamed0__.tx | tx |
struct dif_spi_host_segment.__unnamed0__.opcode |
Definition at line 119 of file dif_spi_host.h.
Data Fields | ||
---|---|---|
uint8_t | opcode | |
dif_spi_host_width_t | width |
struct dif_spi_host_segment.__unnamed0__.address |
Definition at line 123 of file dif_spi_host.h.
Data Fields | ||
---|---|---|
uint32_t | address | |
dif_spi_host_addr_mode_t | mode | |
dif_spi_host_width_t | width |
struct dif_spi_host_segment.__unnamed0__.dummy |
Definition at line 128 of file dif_spi_host.h.
Data Fields | ||
---|---|---|
size_t | length | |
dif_spi_host_width_t | width |
struct dif_spi_host_segment.__unnamed0__.tx |
Definition at line 132 of file dif_spi_host.h.
Data Fields | ||
---|---|---|
const void * | buf | |
size_t | length | |
dif_spi_host_width_t | width |
struct dif_spi_host_segment.__unnamed0__.rx |
Definition at line 137 of file dif_spi_host.h.
Data Fields | ||
---|---|---|
void * | buf | |
size_t | length | |
dif_spi_host_width_t | width |
struct dif_spi_host_segment.__unnamed0__.bidir |
Definition at line 142 of file dif_spi_host.h.
Data Fields | ||
---|---|---|
size_t | length | |
void * | rxbuf | |
const void * | txbuf | |
dif_spi_host_width_t | width |
typedef struct dif_spi_host_config dif_spi_host_config_t |
Runtime configuration for SPI Host.
This struct describes (SOFTWARE) runtime information for one-time configuration of the hardware.
typedef enum dif_spi_host_direction dif_spi_host_direction_t |
Direction of SPI operations.
This describes which direction a given SPI operation will use.
typedef uint32_t dif_spi_host_errors_t |
Bitmask with the dif_spi_host_error_code_t
values.
Definition at line 434 of file dif_spi_host.h.
typedef uint32_t dif_spi_host_events_t |
Bitmask with the dif_spi_host_events_code_t
values.
Definition at line 266 of file dif_spi_host.h.
typedef struct dif_spi_host_segment dif_spi_host_segment_t |
Segment descriptor for each segment in a transaction.
This struct is a tagged union: the type
field determines which field of the union is relevant.
Address mode for the address segment in a transaction.
Enumerator | |
---|---|
kDifSpiHostAddrMode3b | The address is a 3-byte address. |
kDifSpiHostAddrMode4b | The address is a 4-byte address. |
Definition at line 102 of file dif_spi_host.h.
Direction of SPI operations.
This describes which direction a given SPI operation will use.
Definition at line 70 of file dif_spi_host.h.
Definition at line 391 of file dif_spi_host.h.
enum dif_spi_host_events |
Definition at line 230 of file dif_spi_host.h.
Segment types for segments in a transaction.
Definition at line 84 of file dif_spi_host.h.
enum dif_spi_host_width |
Width of SPI operations.
Definition at line 56 of file dif_spi_host.h.
OT_WARN_UNUSED_RESULT dif_result_t dif_spi_host_configure | ( | const dif_spi_host_t * | spi_host, |
dif_spi_host_config_t | config ) |
Configures SPI Host with runtime information.
This function should only need to be called once for the lifetime of handle
.
spi_host | A SPI Host handle. |
config | Runtime configuration parameters. |
Definition at line 69 of file dif_spi_host.c.
OT_WARN_UNUSED_RESULT dif_result_t dif_spi_host_error_get_enabled | ( | const dif_spi_host_t * | spi_host, |
dif_spi_host_errors_t * | errors ) |
Get the enabled errors.
spi_host | A SPI Host handle. | |
[out] | errors | A bitmask that will contain all the errors that are enabled. |
Definition at line 533 of file dif_spi_host.c.
OT_WARN_UNUSED_RESULT dif_result_t dif_spi_host_error_set_enabled | ( | const dif_spi_host_t * | spi_host, |
dif_spi_host_errors_t | errors, | ||
bool | enable ) |
Set the enable state of the spi host errors.
spi_host | A SPI Host handle. |
errors | A bitmask with the errors to be enabled or disabled. |
enable | True to enable the events or false to disable. |
Definition at line 514 of file dif_spi_host.c.
OT_WARN_UNUSED_RESULT dif_result_t dif_spi_host_event_get_enabled | ( | const dif_spi_host_t * | spi_host, |
dif_spi_host_events_t * | events ) |
Get the enabled events.
spi_host | A SPI Host handle. | |
[out] | events | A bitmask that will contain all the events that are enabled. |
Definition at line 460 of file dif_spi_host.c.
OT_WARN_UNUSED_RESULT dif_result_t dif_spi_host_event_set_enabled | ( | const dif_spi_host_t * | spi_host, |
dif_spi_host_events_t | events, | ||
bool | enable ) |
Set the enable state of the spi host events.
spi_host | A SPI Host handle. |
events | A bitmask with the events to be enabled or disabled. |
enable | True to enable the events or false to disable. |
Definition at line 441 of file dif_spi_host.c.
OT_WARN_UNUSED_RESULT dif_result_t dif_spi_host_fifo_read | ( | const dif_spi_host_t * | spi_host, |
void * | dst, | ||
uint16_t | len ) |
Read from the SPI Host receive FIFO.
spi_host | A SPI Host handle. |
dst | A pointer to the buffer to receive the data. |
len | The length of the receive buffer. |
Definition at line 233 of file dif_spi_host.c.
OT_WARN_UNUSED_RESULT dif_result_t dif_spi_host_fifo_write | ( | const dif_spi_host_t * | spi_host, |
const void * | src, | ||
uint16_t | len ) |
Write to the SPI Host transmit FIFO.
spi_host | A SPI Host handle. |
src | A pointer to the buffer to transmit. |
len | The length of the transmit buffer. |
Definition at line 166 of file dif_spi_host.c.
OT_WARN_UNUSED_RESULT dif_result_t dif_spi_host_get_error | ( | const dif_spi_host_t * | spi_host, |
dif_spi_host_errors_t * | errors ) |
Read the current error status of the spi host.
spi_host | A SPI Host handle. | |
[out] | errors | The error status of the spi. |
Definition at line 544 of file dif_spi_host.c.
OT_WARN_UNUSED_RESULT dif_result_t dif_spi_host_get_status | ( | const dif_spi_host_t * | spi_host, |
dif_spi_host_status_t * | status ) |
Read the current status of the spi host.
spi_host | A SPI Host handle. | |
[out] | status | The status of the spi. |
Definition at line 471 of file dif_spi_host.c.
OT_WARN_UNUSED_RESULT dif_result_t dif_spi_host_output_set_enabled | ( | const dif_spi_host_t * | spi_host, |
bool | enabled ) |
Sets the enablement of the SPI host output buffers.
spi_host | A SPI Host handle. |
enabled | Enable or disable the output buffers. |
Definition at line 110 of file dif_spi_host.c.
OT_WARN_UNUSED_RESULT dif_result_t dif_spi_host_start_transaction | ( | const dif_spi_host_t * | spi_host, |
uint32_t | csid, | ||
dif_spi_host_segment_t * | segments, | ||
size_t | length ) |
Begins a SPI Host transaction without reading the FIFOs.
spi_host | A SPI Host handle. |
csid | The chip-select ID of the SPI target. |
segments | The SPI segments to send in this transaction. |
length | The number of SPI segments in this transaction. |
Definition at line 372 of file dif_spi_host.c.
OT_WARN_UNUSED_RESULT dif_result_t dif_spi_host_transaction | ( | const dif_spi_host_t * | spi_host, |
uint32_t | csid, | ||
dif_spi_host_segment_t * | segments, | ||
size_t | length ) |
Begins a SPI Host transaction.
spi_host | A SPI Host handle. |
csid | The chip-select ID of the SPI target. |
segments | The SPI segments to send in this transaction. |
length | The number of SPI segments in this transaction. |
Definition at line 415 of file dif_spi_host.c.
OT_WARN_UNUSED_RESULT dif_result_t dif_spi_host_wait_until_idle | ( | const dif_spi_host_t * | spi_host | ) |
Wait until the SPI Host is idle.
spi_host | A SPI Host handle. |
Definition at line 556 of file dif_spi_host.c.
OT_WARN_UNUSED_RESULT dif_result_t dif_spi_host_write_command | ( | const dif_spi_host_t * | spi_host, |
uint16_t | length, | ||
dif_spi_host_width_t | speed, | ||
dif_spi_host_direction_t | direction, | ||
bool | last_segment ) |
Issues a command segment to a spi_host.
spi_host | A SPI Host handle. |
length | The number of 1-byte burst for read and write segments, or the number of cycles for dummy segments. |
speed | Which speed the transmission should use. |
direction | Which direction the operation should use. |
last_segment | If true the chip select line is raised after the transmission, otherwise it is kept low. |
Definition at line 502 of file dif_spi_host.c.