Solaris Software
Loading...
Searching...
No Matches
spi.c
Go to the documentation of this file.
1/**
2 * @file spi.c
3 * @brief HAL SPI functions implementation. Calls the function pointer and returns the result.
4 */
5
6
7/* ----------------------------------------------------------------
8 * INCLUDES
9 * ---------------------------------------------------------------- */
11#include "spp/hal/hal.h"
12#include "spp/hal/spi/spi.h"
13
14
15/* ----------------------------------------------------------------
16 * PUBLIC FUNCTIONS
17 * ---------------------------------------------------------------- */
18
20{
22 const SPP_HalPort_t *p_port = SPP_HAL_getPort();
23 if ((p_port == NULL) || (p_port->spi.spiBusInit == NULL))
24 {
26 }
27 else
28 {
29 ret = p_port->spi.spiBusInit();
30 if (ret != K_SPP_OK)
31 {
32 ret = K_SPP_ERROR;
33 }
34 }
35
36 return ret;
37}
38
40{
41 const SPP_HalPort_t *p_port = SPP_HAL_getPort();
42 if ((p_port == NULL) || (p_port->spi.spiGetHandle == NULL))
43 {
44 return NULL;
45 }
46 return p_port->spi.spiGetHandle(deviceIdx);
47}
48
50{
52 const SPP_HalPort_t *p_port = SPP_HAL_getPort();
53 if ((p_port == NULL) || (p_port->spi.spiDeviceInit == NULL))
54 {
56 }
57 else
58 {
59 ret = p_port->spi.spiDeviceInit(p_handle);
60 if (ret != K_SPP_OK)
61 {
62 ret = K_SPP_ERROR;
63 }
64 }
65
66 return ret;
67}
68
70{
71 const SPP_HalPort_t *p_port = SPP_HAL_getPort();
72 if ((p_port == NULL) || (p_port->spi.spiDeviceSetSpeed == NULL))
73 {
75 }
76 return p_port->spi.spiDeviceSetSpeed(p_handle, speedHz);
77}
78
80{
82
83 const SPP_HalPort_t *p_port = SPP_HAL_getPort();
84 if ((p_port == NULL) || (p_port->spi.spiTransmit == NULL))
85 {
87 }
88 else
89 {
90 ret = p_port->spi.spiTransmit(p_handle, p_data, length);
91 if (ret != K_SPP_OK)
92 {
93 ret = K_SPP_ERROR;
94 }
95 }
96 return ret;
97}
const SPP_HalPort_t * SPP_HAL_getPort(void)
This function is used to get the pointers to the functions that are used by the SPP library....
Definition hal.c:52
This file contains the structs that contain all the pointers to the functions that are used by the SP...
Standard return-value type used across all SPP modules.
SPP_RetVal_t
Unified return type for all SPP API functions.
Definition returnTypes.h:24
@ K_SPP_OK
Definition returnTypes.h:25
@ K_SPP_ERROR
Definition returnTypes.h:26
@ K_SPP_ERROR_NULL_POINTER
Definition returnTypes.h:30
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.
Definition spi.c:69
void * SPP_HAL_SPI_getHandle(spp_uint8_t deviceIdx)
Obtain the SPI device handle for the given device index.
Definition spi.c:39
SPP_RetVal_t SPP_HAL_SPI_deviceInit(void *p_handle)
Initialise a specific SPI device.
Definition spi.c:49
SPP_RetVal_t SPP_HAL_SPI_transmit(void *p_handle, spp_uint8_t *p_data, spp_uint8_t length)
Perform a full-duplex SPI transaction.
Definition spi.c:79
SPP_RetVal_t SPP_HAL_SPI_busInit(void)
Initialise the SPI bus.
Definition spi.c:19
SPP SPI HAL API — dispatches through the registered HAL port.
SPP_RetVal_t(*) spiDeviceInit(void *p_handle)
Initialise a specific SPI device.
Definition hal.h:51
SPP_RetVal_t(*) spiBusInit(void)
Initialise the SPI bus.
Definition hal.h:30
SPP_RetVal_t(*) spiTransmit(void *p_handle, spp_uint8_t *p_data, spp_uint8_t length)
Perform a full-duplex SPI transaction.
Definition hal.h:65
SPP_RetVal_t(*) spiDeviceSetSpeed(void *p_handle, spp_uint32_t speedHz)
Remove and re-add a SPI device with a new clock speed.
Definition hal.h:78
void *(*) spiGetHandle(spp_uint8_t deviceIdx)
Obtain the handle for the next SPI device slot.
Definition hal.h:42
Ports struct that contains all the pointers to the Ports functions.
Definition hal.h:215
SPP_HALSpi_t spi
Definition hal.h:216
uint32_t spp_uint32_t
Definition types.h:31
uint8_t spp_uint8_t
Definition types.h:27