Solaris Software
Toggle main menu visibility
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
* ---------------------------------------------------------------- */
9
#include "
spp/core/returnTypes.h
"
10
#include "
spp/hal/hal.h
"
11
#include "
spp/hal/gpio/gpio.h
"
12
13
14
/* ----------------------------------------------------------------
15
* PUBLIC FUNCTIONS
16
* ---------------------------------------------------------------- */
17
18
SPP_RetVal_t
SPP_HAL_GPIO_configInterrupt
(
spp_uint32_t
pin,
spp_uint32_t
intrType,
spp_uint32_t
pull)
19
{
20
SPP_RetVal_t
ret =
K_SPP_ERROR
;
21
const
SPP_HalPort_t
*p_port =
SPP_HAL_getPort
();
22
if
((p_port == NULL) || (p_port->
gpio
.
gpioConfigInterrupt
== NULL))
23
{
24
ret =
K_SPP_ERROR_NULL_POINTER
;
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
37
SPP_RetVal_t
SPP_HAL_GPIO_registerIsr
(
spp_uint32_t
pin,
void
*p_isrCtx)
38
{
39
SPP_RetVal_t
ret =
K_SPP_ERROR
;
40
const
SPP_HalPort_t
*p_port =
SPP_HAL_getPort
();
41
if
((p_port == NULL) || (p_port->
gpio
.
gpioRegisterIsr
== NULL))
42
{
43
ret =
K_SPP_ERROR_NULL_POINTER
;
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
57
spp_uint16_t
SPP_HAL_GPIO_read
(
spp_uint32_t
pin)
58
{
59
const
SPP_HalPort_t
*p_port =
SPP_HAL_getPort
();
60
61
return
p_port->
gpio
.
gpioRead
(pin);
62
}
63
64
SPP_RetVal_t
SPP_HAL_GPIO_write
(
spp_uint32_t
pin,
spp_uint8_t
level)
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_HAL_GPIO_write
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_HAL_GPIO_registerIsr
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_HAL_GPIO_configInterrupt
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_HAL_GPIO_read
spp_uint16_t SPP_HAL_GPIO_read(spp_uint32_t pin)
Reads the logic level of a GPIO pin.
Definition
gpio.c:57
gpio.h
SPP GPIO HAL API — dispatches through the registered HAL port.
SPP_HAL_getPort
const SPP_HalPort_t * SPP_HAL_getPort(void)
Returns the registered HAL port.
Definition
hal.c:52
hal.h
This file contains the structs that contain all the pointers to the functions that are used by the SP...
returnTypes.h
Standard return-value type used across all SPP modules.
SPP_RetVal_t
SPP_RetVal_t
Unified return type for all SPP API functions.
Definition
returnTypes.h:24
K_SPP_OK
@ K_SPP_OK
Definition
returnTypes.h:25
K_SPP_ERROR
@ K_SPP_ERROR
Definition
returnTypes.h:26
K_SPP_ERROR_NULL_POINTER
@ K_SPP_ERROR_NULL_POINTER
Definition
returnTypes.h:30
SPP_HALGpio_t::gpioConfigInterrupt
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_HALGpio_t::gpioRead
spp_uint16_t(*) gpioRead(spp_uint32_t pin)
Reads the logic level of a GPIO pin.
Definition
hal.h:156
SPP_HALGpio_t::gpioWrite
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_HALGpio_t::gpioRegisterIsr
SPP_RetVal_t(*) gpioRegisterIsr(spp_uint32_t pin, void *p_isrCtx)
Register an ISR handler for a GPIO pin.
Definition
hal.h:149
SPP_HalPort_t
Ports struct that contains all the pointers to the Ports functions.
Definition
hal.h:234
SPP_HalPort_t::gpio
SPP_HALGpio_t gpio
Definition
hal.h:236
spp_uint16_t
uint16_t spp_uint16_t
Definition
types.h:29
spp_uint32_t
uint32_t spp_uint32_t
Definition
types.h:31
spp_uint8_t
uint8_t spp_uint8_t
Definition
types.h:27
solaris-v2
spp
hal
gpio
gpio.c
Generated by
1.18.0