Solaris Software
Loading...
Searching...
No Matches
gpio.c
Go to the documentation of this file.
1/**
2 * @file gpio.c
3 * @brief HAL GPIO functions implementation. Dispatches calls through the registered HAL port.
4 */
5
6/* ----------------------------------------------------------------
7 * INCLUDES
8 * ---------------------------------------------------------------- */
10#include "spp/hal/hal.h"
11#include "spp/hal/gpio/gpio.h"
12
13
14/* ----------------------------------------------------------------
15 * PUBLIC FUNCTIONS
16 * ---------------------------------------------------------------- */
17
19{
21 const SPP_HalPort_t *p_port = SPP_HAL_getPort();
22 if ((p_port == NULL) || (p_port->gpio.gpioConfigInterrupt == NULL))
23 {
25 }
26 else
27 {
28 ret = p_port->gpio.gpioConfigInterrupt(pin, intrType, pull);
29 if (ret != K_SPP_OK)
30 {
31 ret = K_SPP_ERROR;
32 }
33 }
34 return ret;
35}
36
38{
40 const SPP_HalPort_t *p_port = SPP_HAL_getPort();
41 if ((p_port == NULL) || (p_port->gpio.gpioRegisterIsr == NULL))
42 {
44 }
45 else
46 {
47 ret = p_port->gpio.gpioRegisterIsr(pin, p_isrCtx);
48 if (ret != K_SPP_OK)
49 {
50 ret = K_SPP_ERROR;
51 }
52 }
53
54 return ret;
55}
56
58{
59 const SPP_HalPort_t *p_port = SPP_HAL_getPort();
60
61 return p_port->gpio.gpioRead(pin);
62}
63
65{
66 const SPP_HalPort_t *p_port = SPP_HAL_getPort();
67
68 SPP_RetVal_t ret = p_port->gpio.gpioWrite(pin, level);
69 if (ret != K_SPP_OK)
70 {
71 return K_SPP_ERROR;
72 }
73
74 return ret;
75}
SPP_RetVal_t SPP_HAL_GPIO_write(spp_uint32_t pin, spp_uint8_t level)
Configures a GPIO as output and sets its logic level.
Definition gpio.c:64
SPP_RetVal_t SPP_HAL_GPIO_registerIsr(spp_uint32_t pin, void *p_isrCtx)
Register an ISR handler for a GPIO pin.
Definition gpio.c:37
SPP_RetVal_t SPP_HAL_GPIO_configInterrupt(spp_uint32_t pin, spp_uint32_t intrType, spp_uint32_t pull)
Configure a GPIO pin as an interrupt input.
Definition gpio.c:18
spp_uint16_t SPP_HAL_GPIO_read(spp_uint32_t pin)
Reads the logic level of a GPIO pin.
Definition gpio.c:57
SPP GPIO HAL API — dispatches through the registered HAL port.
const SPP_HalPort_t * SPP_HAL_getPort(void)
Returns the registered HAL port.
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(*) gpioConfigInterrupt(spp_uint32_t pin, spp_uint32_t intrType, spp_uint32_t pull)
Configure a GPIO pin as an interrupt input.
Definition hal.h:139
spp_uint16_t(*) gpioRead(spp_uint32_t pin)
Reads the logic level of a GPIO pin.
Definition hal.h:156
SPP_RetVal_t(*) gpioWrite(spp_uint32_t pin, spp_uint8_t level)
Configures a GPIO as output and sets its logic level.
Definition hal.h:164
SPP_RetVal_t(*) gpioRegisterIsr(spp_uint32_t pin, void *p_isrCtx)
Register an ISR handler for a GPIO pin.
Definition hal.h:149
Ports struct that contains all the pointers to the Ports functions.
Definition hal.h:234
SPP_HALGpio_t gpio
Definition hal.h:236
uint16_t spp_uint16_t
Definition types.h:29
uint32_t spp_uint32_t
Definition types.h:31
uint8_t spp_uint8_t
Definition types.h:27