Solaris Software
Toggle main menu visibility
Loading...
Searching...
No Matches
gpio.h
Go to the documentation of this file.
1
/**
2
* @file gpio.h
3
* @brief SPP GPIO HAL API — dispatches through the registered HAL port.
4
*
5
* Naming conventions used in this file:
6
* - Public functions: SPP_HAL_gpio*()
7
* - Pointer parameters: p_*
8
*/
9
10
#ifndef SPP_HAL_GPIO_H
11
#define SPP_HAL_GPIO_H
12
13
#include "
spp/core/types.h
"
14
#include "
spp/core/returnTypes.h
"
15
16
/* ----------------------------------------------------------------
17
* ISR context
18
* ---------------------------------------------------------------- */
19
20
/**
21
* @brief Context passed to the GPIO ISR handler.
22
*
23
* The ISR sets @c *p_flag to @c SPP_TRUE when the interrupt fires.
24
* The application superloop polls this flag to detect the event.
25
*/
26
typedef
struct
27
{
28
volatile
spp_bool_t
*
p_flag
;
/**< Flag set by the ISR on interrupt. */
29
}
SPP_GpioIsrCtx_t
;
30
31
/* ----------------------------------------------------------------
32
* Public API
33
* ---------------------------------------------------------------- */
34
35
/**
36
* @brief Configure a GPIO pin as an interrupt input.
37
*
38
* @param[in] pin GPIO pin number.
39
* @param[in] intrType Platform-specific interrupt trigger type value.
40
* @param[in] pull Pull resistor: 0 = none, 1 = pull-up, 2 = pull-down.
41
*
42
* @return K_SPP_OK on success.
43
*/
44
SPP_RetVal_t
SPP_HAL_GPIO_configInterrupt
(
spp_uint32_t
pin,
spp_uint32_t
intrType,
spp_uint32_t
pull);
45
46
/**
47
* @brief Register an ISR handler for a GPIO pin.
48
*
49
* The ISR sets @c *p_isrCtx->p_flag to @c SPP_TRUE whenever the configured
50
* interrupt fires.
51
*
52
* @param[in] pin GPIO pin number.
53
* @param[in] p_isrCtx Pointer to a @ref SPP_GpioIsrCtx_t for this pin.
54
*
55
* @return K_SPP_OK on success.
56
*/
57
SPP_RetVal_t
SPP_HAL_GPIO_registerIsr
(
spp_uint32_t
pin,
void
*p_isrCtx);
58
59
/**
60
* @brief Reads the logic level of a GPIO pin.
61
* @param pin GPIO pin number.
62
* @return Current logic level (0 or 1).
63
*/
64
spp_uint16_t
SPP_HAL_GPIO_read
(
spp_uint32_t
pin);
65
66
/**
67
* @brief Configures a GPIO as output and sets its logic level.
68
* @param pin GPIO pin number.
69
* @param level Logic level to set.
70
* @return K_SPP_OK on success, K_SPP_ERROR on failure.
71
*/
72
SPP_RetVal_t
SPP_HAL_GPIO_write
(
spp_uint32_t
pin,
spp_uint8_t
level);
73
74
#endif
/* SPP_HAL_GPIO_H */
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
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
SPP_GpioIsrCtx_t
Context passed to the GPIO ISR handler.
Definition
gpio.h:27
SPP_GpioIsrCtx_t::p_flag
volatile spp_bool_t * p_flag
Definition
gpio.h:28
types.h
Portable integer types and SPI/storage configuration types for SPP.
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
spp_bool_t
bool spp_bool_t
Definition
types.h:36
solaris-v2
spp
hal
gpio
gpio.h
Generated by
1.18.0