Solaris Software
Loading...
Searching...
No Matches
spi.c File Reference

HAL SPI functions implementation. Calls the function pointer and returns the result. More...

#include "spp/core/returnTypes.h"
#include "spp/hal/hal.h"
#include "spp/hal/spi/spi.h"
Include dependency graph for spi.c:

Go to the source code of this file.

Functions

SPP_RetVal_t SPP_HAL_SPI_busInit (void)
 Initialise the SPI bus.
void * SPP_HAL_SPI_getHandle (spp_uint8_t deviceIdx)
 Obtain the SPI device handle for the given device index.
SPP_RetVal_t SPP_HAL_SPI_deviceInit (void *p_handle)
 Initialise a specific SPI device.
SPP_RetVal_t SPP_HAL_SPI_deviceSetSpeed (void *p_handle, spp_uint32_t speedHz)
 Remove and re-add a SPI device with a new clock speed.
SPP_RetVal_t SPP_HAL_SPI_transmit (void *p_handle, spp_uint8_t *p_data, spp_uint8_t length)
 Performs register-based SPI transactions.
SPP_RetVal_t SPP_HAL_SPI_transmitRaw (void *p_handle, spp_uint8_t *p_data, spp_uint8_t length)
 Performs a raw full-duplex SPI transaction.

Detailed Description

HAL SPI functions implementation. Calls the function pointer and returns the result.

Definition in file spi.c.

Function Documentation

◆ SPP_HAL_SPI_busInit()

SPP_RetVal_t SPP_HAL_SPI_busInit ( void )

Initialise the SPI bus.

Safe to call multiple times; subsequent calls are no-ops.

Returns
K_SPP_OK on success.

Definition at line 19 of file spi.c.

References K_SPP_ERROR, K_SPP_ERROR_NULL_POINTER, K_SPP_OK, SPP_HalPort_t::spi, SPP_HALSpi_t::spiBusInit, SPP_HAL_getPort(), and SPP_HAL_SPI_busInit().

Referenced by SPP_HAL_init(), and SPP_HAL_SPI_busInit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SPP_HAL_SPI_getHandle()

void * SPP_HAL_SPI_getHandle ( spp_uint8_t deviceIdx)

Obtain the SPI device handle for the given device index.

Parameters
[in]deviceIdxZero-based device index (0 = first device, etc.).
Returns
Opaque handle on success, NULL if index is out of range.

Definition at line 39 of file spi.c.

References SPP_HalPort_t::spi, SPP_HALSpi_t::spiGetHandle, SPP_HAL_getPort(), and SPP_HAL_SPI_getHandle().

Referenced by SPP_HAL_SPI_getHandle(), SPP_SERVICES_BMP390_init(), SPP_SERVICES_ICM20948_init(), and SPP_SERVICES_SX1262_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SPP_HAL_SPI_deviceInit()

SPP_RetVal_t SPP_HAL_SPI_deviceInit ( void * p_handle)

Initialise a specific SPI device.

Parameters
[in]p_handleHandle returned by SPP_HAL_SPI_getHandle().
Returns
K_SPP_OK on success, K_SPP_ERROR_NULL_POINTER if handle is NULL.

Definition at line 49 of file spi.c.

References K_SPP_ERROR, K_SPP_ERROR_NULL_POINTER, K_SPP_OK, SPP_HalPort_t::spi, SPP_HALSpi_t::spiDeviceInit, SPP_HAL_getPort(), and SPP_HAL_SPI_deviceInit().

Referenced by SPP_HAL_SPI_deviceInit(), SPP_SERVICES_BMP390_init(), SPP_SERVICES_ICM20948_init(), and SPP_SERVICES_SX1262_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SPP_HAL_SPI_deviceSetSpeed()

SPP_RetVal_t SPP_HAL_SPI_deviceSetSpeed ( void * p_handle,
spp_uint32_t speedHz )

Remove and re-add a SPI device with a new clock speed.

Intended for devices that require a lower speed during initialisation and a higher speed for normal operation (e.g. SD cards: 400 kHz init, up to 25 MHz normal operation).

Parameters
[in]p_handleHandle returned by SPP_HAL_SPI_getHandle().
[in]speedHzNew clock frequency in Hz.
Returns
K_SPP_OK on success, K_SPP_ERROR on failure.

Definition at line 69 of file spi.c.

References K_SPP_ERROR_NULL_POINTER, SPP_HalPort_t::spi, SPP_HALSpi_t::spiDeviceSetSpeed, SPP_HAL_getPort(), and SPP_HAL_SPI_deviceSetSpeed().

Referenced by SPP_HAL_SPI_deviceSetSpeed().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SPP_HAL_SPI_transmit()

SPP_RetVal_t SPP_HAL_SPI_transmit ( void * p_handle,
spp_uint8_t * p_data,
spp_uint8_t length )

Performs register-based SPI transactions.

The ESP32 port interprets bit 7 of each command byte to distinguish reads (3 bytes) from writes (2 bytes).

Parameters
p_handleSPI device handle.
p_dataTransaction buffer, overwritten during reads.
lengthBuffer length in bytes.
Returns
K_SPP_OK on success, K_SPP_ERROR on transaction failure, or K_SPP_ERROR_NULL_POINTER if the HAL port is unavailable.

Definition at line 79 of file spi.c.

References K_SPP_ERROR, K_SPP_ERROR_NULL_POINTER, K_SPP_OK, SPP_HalPort_t::spi, SPP_HALSpi_t::spiTransmit, SPP_HAL_getPort(), and SPP_HAL_SPI_transmit().

Referenced by readFifoBurst(), SPP_HAL_SPI_transmit(), SPP_SERVICES_BMP390_configCheck(), SPP_SERVICES_BMP390_enableSpiMode(), SPP_SERVICES_BMP390_intEnableDrdy(), SPP_SERVICES_BMP390_prepareMeasure(), SPP_SERVICES_BMP390_readRawPress(), SPP_SERVICES_BMP390_readRawPressCoeffs(), SPP_SERVICES_BMP390_readRawTemp(), SPP_SERVICES_BMP390_readRawTempCoeffs(), SPP_SERVICES_BMP390_softReset(), SPP_SERVICES_ICM20948_checkFifoData(), SPP_SERVICES_ICM20948_readReg(), and SPP_SERVICES_ICM20948_writeReg().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SPP_HAL_SPI_transmitRaw()

SPP_RetVal_t SPP_HAL_SPI_transmitRaw ( void * p_handle,
spp_uint8_t * p_data,
spp_uint8_t length )

Performs a raw full-duplex SPI transaction.

Transmitted data is overwritten by received data.

Parameters
p_handleSPI device handle.
p_dataTransmission and reception buffer.
lengthNumber of bytes to transfer.
Returns
K_SPP_OK on success, K_SPP_ERROR on transaction failure, or K_SPP_ERROR_NULL_POINTER if the HAL port is unavailable.

Definition at line 99 of file spi.c.

References K_SPP_ERROR, K_SPP_ERROR_NULL_POINTER, K_SPP_OK, SPP_HalPort_t::spi, SPP_HALSpi_t::spiTransmitRaw, SPP_HAL_getPort(), and SPP_HAL_SPI_transmitRaw().

Referenced by SPP_HAL_SPI_transmitRaw(), SX1262_Calibrate(), SX1262_CalibrateImage(), SX1262_ClearDeviceErrors(), SX1262_ClearIrqStatus(), SX1262_GetDeviceErrors(), SX1262_GetIrqStatus(), SX1262_SetBufferBaseAddress(), SX1262_SetDio3AsTcxoCtrl(), SX1262_SetDioIrqParams(), SX1262_SetModulationParams(), SX1262_SetPacketParams(), SX1262_SetPacketType(), SX1262_SetPaConfig(), SX1262_SetRegulatorMode(), SX1262_SetRfFrequency(), SX1262_SetStandby(), SX1262_SetTx(), SX1262_SetTxParams(), SX1262_WriteBuffer(), and SX1262_WriteRegister().

Here is the call graph for this function:
Here is the caller graph for this function: