Direct APIs
APIs for directly accessing SPI master peripheral. More...
Functions |
|
gos_result_t | gos_spi_master_init (const gos_spi_device_t *spi) |
Initialize SPI master device.
More...
|
|
gos_result_t | gos_spi_master_deinit (const gos_spi_device_t *spi) |
De-initialize SPI master device.
More...
|
|
gos_result_t | gos_spi_master_transfer (const gos_spi_device_t *spi, const gos_spi_message_t *messages, uint16_t message_count) |
Transfer data messages to SPI slave.
More...
|
|
gos_result_t | gos_spi_master_lock_bus (const gos_spi_device_t *spi, uint32_t timeout_ms) |
Lock the SPI bus's mutex.
More...
|
|
gos_result_t | gos_spi_master_unlock_bus (const gos_spi_device_t *spi) |
Unlock the SPI bus's mutex.
More...
|
|
gos_result_t | gos_spi_master_deassert (const gos_spi_device_t *spi) |
De-assert the SPI slave select GPIO.
More...
|
|
Detailed Description
APIs for directly accessing SPI master peripheral.
Function Documentation
◆ gos_spi_master_deassert()
gos_result_t gos_spi_master_deassert | ( | const gos_spi_device_t * |
spi
|
) |
De-assert the SPI slave select GPIO.
This de-selects the slave-select signal. The signal-select can remain asserted based on the supplied flags.
- Parameters
-
[in] spi
SPI bus to lock
- Returns
- gos_result_t result of api call
◆ gos_spi_master_deinit()
gos_result_t gos_spi_master_deinit | ( | const gos_spi_device_t * |
spi
|
) |
De-initialize SPI master device.
This de-initialized the SPI master device and CS GPIO
- Parameters
-
[in] spi
SPI master device to de-initialize
- Returns
- gos_result_t result of api call
◆ gos_spi_master_init()
gos_result_t gos_spi_master_init | ( | const gos_spi_device_t * |
spi
|
) |
Initialize SPI master device.
This initializes the SPI master device peripheral and given CS GPIO.
Refer to gos_spi_device_t for more details.
- Parameters
-
[in] spi
SPI master device to initialize
- Returns
- gos_result_t result of api call
◆ gos_spi_master_lock_bus()
gos_result_t gos_spi_master_lock_bus | ( | const gos_spi_device_t * |
spi,
|
uint32_t |
timeout_ms
|
||
) |
Lock the SPI bus's mutex.
If the SPI bus is shared with the extended flash, the mutex ensures exclusive access to the bus.
- Note
- Use gos_spi_master_unlock_bus() to release the lock.
- Parameters
-
[in] spi
SPI bus to lock [in] timeout_ms
Maximum amount of time to wait for the lock
- Returns
- gos_result_t result of api call
◆ gos_spi_master_transfer()
gos_result_t gos_spi_master_transfer | ( | const gos_spi_device_t * |
spi,
|
const gos_spi_message_t * |
messages,
|
||
uint16_t |
message_count
|
||
) |
Transfer data messages to SPI slave.
This API is separate from the 'spi stream' APIs. This API directly writes the SPI master driver. The driver is automatically configured based on the settings in gos_spi_device_t upon calling this API.
- Note
- You must call gos_spi_master_init() to initialize the CS GPIO before invoking this API.
- Parameters
-
[in] spi
SPI driver configuration, see gos_spi_device_t [in,out] messages
Array of messages to read/write data, see gos_spi_message_t [in] message_count
Number of messages to transfer to SPI slave device
- Returns
- gos_result_t result of api call
- Examples:
- test/spi_loop_back/main.c .
◆ gos_spi_master_unlock_bus()
gos_result_t gos_spi_master_unlock_bus | ( | const gos_spi_device_t * |
spi
|
) |
Unlock the SPI bus's mutex.
See gos_spi_master_lock_bus() for more info.
- Parameters
-
[in] spi
SPI bus to lock
- Returns
- gos_result_t result of api call