ESP32-S3 SPI port implementation. More...
#include "spiPort.h"#include "macrosEsp32.h"#include "driver/spi_common.h"#include "driver/spi_master.h"#include "driver/gpio.h"#include "esp_log.h"#include <stdio.h>Go to the source code of this file.
Functions | |
| SPP_RetVal_t | SPP_PORTS_HAL_ESP32_spiBusInit (void) |
| void * | SPP_PORTS_HAL_ESP32_spiGetHandle (spp_uint8_t deviceIdx) |
| Returns the storage location of an SPI device handle. | |
| SPP_RetVal_t | SPP_PORTS_HAL_ESP32_spiDeviceInit (void *p_handle) |
| SPP_RetVal_t | SPP_PORTS_HAL_ESP32_spiTransmit (void *p_handle, spp_uint8_t *p_data, spp_uint8_t length) |
| Performs register-based SPI transactions. | |
| SPP_RetVal_t | SPP_PORTS_HAL_ESP32_spiDeviceSetSpeed (void *p_handle, spp_uint32_t speedHz) |
| Reconfigures an SPI device with a new clock frequency. | |
| spp_bool_t | SPP_PORTS_HAL_ESP32_spiIsBusInitialized (void) |
| Check whether the SPI bus has been initialised. | |
| SPP_RetVal_t | SPP_PORTS_HAL_ESP32_spiTransmitRaw (void *p_handle, spp_uint8_t *p_data, spp_uint8_t length) |
| Performs a raw full-duplex SPI transaction. | |
Variables | |
| static const char *const | k_tag = "SPP_HAL" |
| static spi_device_handle_t | s_spiHandles [K_ESP32_MAX_SPI_DEVICES] |
| static spp_bool_t | s_busInitialized = false |
ESP32-S3 SPI port implementation.
Definition in file spiPort.c.
| SPP_RetVal_t SPP_PORTS_HAL_ESP32_spiBusInit | ( | void | ) |
Definition at line 32 of file spiPort.c.
References K_ESP32_PIN_CLK, K_ESP32_PIN_MISO, K_ESP32_PIN_MOSI, K_ESP32_SPI_HOST, K_SPP_ERROR, K_SPP_OK, k_tag, s_busInitialized, and SPP_PORTS_HAL_ESP32_spiBusInit().
Referenced by SPP_PORTS_HAL_ESP32_spiBusInit().
| void * SPP_PORTS_HAL_ESP32_spiGetHandle | ( | spp_uint8_t | deviceIdx | ) |
Returns the storage location of an SPI device handle.
| deviceIdx | Index of the SPI device. |
Definition at line 70 of file spiPort.c.
References K_ESP32_MAX_SPI_DEVICES, s_spiHandles, and SPP_PORTS_HAL_ESP32_spiGetHandle().
Referenced by SPP_PORTS_HAL_ESP32_spiGetHandle().
| SPP_RetVal_t SPP_PORTS_HAL_ESP32_spiDeviceInit | ( | void * | p_handle | ) |
Definition at line 79 of file spiPort.c.
References K_ESP32_MAX_SPI_DEVICES, K_ESP32_PIN_CS_BMP, K_ESP32_PIN_CS_ICM, K_ESP32_PIN_CS_SX1262, K_ESP32_SPI_HOST, K_ESP32_SPI_IDX_BMP, K_ESP32_SPI_IDX_ICM, K_ESP32_SPI_IDX_SX1262, K_SPP_ERROR, K_SPP_ERROR_NULL_POINTER, K_SPP_OK, k_tag, s_spiHandles, and SPP_PORTS_HAL_ESP32_spiDeviceInit().
Referenced by SPP_PORTS_HAL_ESP32_spiDeviceInit().
| SPP_RetVal_t SPP_PORTS_HAL_ESP32_spiTransmit | ( | void * | p_handle, |
| spp_uint8_t * | p_data, | ||
| spp_uint8_t | length ) |
Performs register-based SPI transactions.
Uses bit 7 of each command byte to distinguish reads (3 bytes) from writes (2 bytes). Read responses overwrite the input buffer.
| p_handle | Pointer to the SPI device handle. |
| p_data | Transaction buffer. |
| length | Total buffer length in bytes. |
Definition at line 144 of file spiPort.c.
References K_SPP_ERROR_NULL_POINTER, K_SPP_ERROR_ON_SPI_TRANSACTION, K_SPP_OK, and SPP_PORTS_HAL_ESP32_spiTransmit().
Referenced by SPP_PORTS_HAL_ESP32_spiTransmit().
| SPP_RetVal_t SPP_PORTS_HAL_ESP32_spiDeviceSetSpeed | ( | void * | p_handle, |
| spp_uint32_t | speedHz ) |
Reconfigures an SPI device with a new clock frequency.
Removes and re-adds the device using the SD card CS pin.
| p_handle | Pointer to the SPI device handle. |
| speedHz | New SPI clock frequency in Hz. |
Definition at line 191 of file spiPort.c.
References K_ESP32_PIN_CS_SDC, K_ESP32_SPI_HOST, K_SPP_ERROR, K_SPP_ERROR_NULL_POINTER, K_SPP_OK, k_tag, and SPP_PORTS_HAL_ESP32_spiDeviceSetSpeed().
Referenced by SPP_PORTS_HAL_ESP32_spiDeviceSetSpeed().
| spp_bool_t SPP_PORTS_HAL_ESP32_spiIsBusInitialized | ( | void | ) |
Check whether the SPI bus has been initialised.
Definition at line 218 of file spiPort.c.
References s_busInitialized, and SPP_PORTS_HAL_ESP32_spiIsBusInitialized().
Referenced by SPP_PORTS_HAL_ESP32_spiIsBusInitialized(), and SPP_PORTS_HAL_ESP32_storageInit().
| SPP_RetVal_t SPP_PORTS_HAL_ESP32_spiTransmitRaw | ( | void * | p_handle, |
| spp_uint8_t * | p_data, | ||
| spp_uint8_t | length ) |
Performs a raw full-duplex SPI transaction.
Transmitted data is overwritten by the received data.
| p_handle | Pointer to the SPI device handle. |
| p_data | Transmission and reception buffer. |
| length | Number of bytes to transfer. |
Definition at line 223 of file spiPort.c.
References K_SPP_ERROR_NULL_POINTER, K_SPP_ERROR_ON_SPI_TRANSACTION, K_SPP_OK, and SPP_PORTS_HAL_ESP32_spiTransmitRaw().
Referenced by SPP_PORTS_HAL_ESP32_spiTransmitRaw().
|
static |
Definition at line 23 of file spiPort.c.
Referenced by SPP_PORTS_HAL_ESP32_spiBusInit(), SPP_PORTS_HAL_ESP32_spiDeviceInit(), and SPP_PORTS_HAL_ESP32_spiDeviceSetSpeed().
|
static |
Definition at line 25 of file spiPort.c.
Referenced by SPP_PORTS_HAL_ESP32_spiDeviceInit(), and SPP_PORTS_HAL_ESP32_spiGetHandle().
|
static |
Definition at line 26 of file spiPort.c.
Referenced by SPP_PORTS_HAL_ESP32_spiBusInit(), and SPP_PORTS_HAL_ESP32_spiIsBusInitialized().