oveRTOS C API
Embedded RTOS framework — build system, configuration, and portable C API
Loading...
Searching...
No Matches
bsp.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2026 Kamil Lulko <kamil.lulko@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-3.0-or-later
5 *
6 * This file is part of oveRTOS.
7 */
8
9/*
10 * Backward-compatibility shim — maps old ove_bsp_*() API to the new
11 * split modules (board, gpio, led). Existing application code continues
12 * to compile unchanged.
13 */
14
15#ifndef OVE_BSP_H
16#define OVE_BSP_H
17
33#include "ove_config.h"
34#include "ove/board.h"
35#include "ove/gpio.h"
36#include "ove/led.h"
37
38#ifdef __cplusplus
39extern "C" {
40#endif
41
42/* Re-export the IRQ types so callers that only included bsp.h still see them */
43#ifndef OVE_GPIO_H
54
62typedef void (*ove_gpio_irq_cb)(unsigned int port, unsigned int pin, void *user_data);
63#endif
64
65#ifdef CONFIG_OVE_BSP
66
74static inline int ove_bsp_board_init(void)
75{
76 return ove_board_init();
77}
78
87static inline void ove_bsp_led_set(unsigned int led, int on)
88{
89 ove_led_set(led, on);
90}
91
99static inline void ove_bsp_led_toggle(unsigned int led)
100{
101 ove_led_toggle(led);
102}
103
114static inline int ove_bsp_gpio_set(unsigned int port, unsigned int pin, int value)
115{
116 return ove_gpio_set(port, pin, value);
117}
118
128static inline int ove_bsp_gpio_get(unsigned int port, unsigned int pin)
129{
130 return ove_gpio_get(port, pin);
131}
132
145static inline int ove_bsp_gpio_irq_register(unsigned int port, unsigned int pin,
147 void *user_data)
148{
149 return ove_gpio_irq_register(port, pin, mode, callback, user_data);
150}
151
161static inline int ove_bsp_gpio_irq_enable(unsigned int port, unsigned int pin)
162{
163 return ove_gpio_irq_enable(port, pin);
164}
165
175static inline int ove_bsp_gpio_irq_disable(unsigned int port, unsigned int pin)
176{
177 return ove_gpio_irq_disable(port, pin);
178}
179
185static inline int ove_bsp_gpio_irq_unregister(unsigned int port, unsigned int pin)
186{
187 return ove_gpio_irq_unregister(port, pin);
188}
189
190#else /* !CONFIG_OVE_BSP */
191
192static inline int ove_bsp_board_init(void)
193{
194 return OVE_OK;
195}
196static inline void ove_bsp_led_set(unsigned int led, int on)
197{
198 (void)led;
199 (void)on;
200}
201static inline void ove_bsp_led_toggle(unsigned int led)
202{
203 (void)led;
204}
205static inline int ove_bsp_gpio_set(unsigned int port, unsigned int pin, int value)
206{
207 (void)port;
208 (void)pin;
209 (void)value;
211}
212static inline int ove_bsp_gpio_get(unsigned int port, unsigned int pin)
213{
214 (void)port;
215 (void)pin;
217}
218static inline int ove_bsp_gpio_irq_register(unsigned int port, unsigned int pin,
220 void *user_data)
221{
222 (void)port;
223 (void)pin;
224 (void)mode;
225 (void)callback;
226 (void)user_data;
228}
229static inline int ove_bsp_gpio_irq_enable(unsigned int port, unsigned int pin)
230{
231 (void)port;
232 (void)pin;
234}
235static inline int ove_bsp_gpio_irq_disable(unsigned int port, unsigned int pin)
236{
237 (void)port;
238 (void)pin;
240}
241static inline int ove_bsp_gpio_irq_unregister(unsigned int port, unsigned int pin)
242{
243 (void)port;
244 (void)pin;
246}
247
248#endif /* CONFIG_OVE_BSP */
249
250#ifdef __cplusplus
251}
252#endif
253
256#endif /* OVE_BSP_H */
int ove_board_init(void)
Initialise the board hardware.
static int ove_bsp_gpio_get(unsigned int port, unsigned int pin)
Read the current level of a GPIO pin (BSP compatibility wrapper).
Definition bsp.h:128
static void ove_bsp_led_toggle(unsigned int led)
Toggle the current state of a board LED (BSP compatibility wrapper).
Definition bsp.h:99
static void ove_bsp_led_set(unsigned int led, int on)
Turn a board LED on or off (BSP compatibility wrapper).
Definition bsp.h:87
static int ove_bsp_gpio_irq_disable(unsigned int port, unsigned int pin)
Disable a GPIO interrupt without unregistering it (BSP compatibility wrapper).
Definition bsp.h:175
static int ove_bsp_gpio_set(unsigned int port, unsigned int pin, int value)
Set the output level of a GPIO pin (BSP compatibility wrapper).
Definition bsp.h:114
static int ove_bsp_gpio_irq_enable(unsigned int port, unsigned int pin)
Enable a registered GPIO interrupt (BSP compatibility wrapper).
Definition bsp.h:161
static int ove_bsp_gpio_irq_register(unsigned int port, unsigned int pin, ove_gpio_irq_mode_t mode, ove_gpio_irq_cb callback, void *user_data)
Register a GPIO interrupt callback (BSP compatibility wrapper).
Definition bsp.h:145
void(* ove_gpio_irq_cb)(unsigned int port, unsigned int pin, void *user_data)
GPIO interrupt callback type (re-exported for BSP-only callers).
Definition bsp.h:62
static int ove_bsp_gpio_irq_unregister(unsigned int port, unsigned int pin)
Unregister a GPIO interrupt (BSP compatibility wrapper).
Definition bsp.h:185
static int ove_bsp_board_init(void)
Initialise the board hardware (BSP compatibility wrapper).
Definition bsp.h:74
ove_gpio_irq_mode_t
GPIO interrupt trigger edge selection (re-exported for BSP-only callers).
Definition bsp.h:49
@ OVE_GPIO_IRQ_RISING
Definition bsp.h:50
@ OVE_GPIO_IRQ_FALLING
Definition bsp.h:51
@ OVE_GPIO_IRQ_BOTH
Definition bsp.h:52
int ove_gpio_irq_disable(unsigned int port, unsigned int pin)
Disable a previously enabled GPIO interrupt without unregistering it.
int ove_gpio_irq_register(unsigned int port, unsigned int pin, ove_gpio_irq_mode_t mode, ove_gpio_irq_cb callback, void *user_data)
Register an interrupt callback for a GPIO pin.
int ove_gpio_irq_enable(unsigned int port, unsigned int pin)
Enable a previously registered GPIO interrupt.
int ove_gpio_irq_unregister(unsigned int port, unsigned int pin)
Unregister a GPIO interrupt, freeing its slot.
int ove_gpio_set(unsigned int port, unsigned int pin, int value)
Set the output level of a GPIO pin.
int ove_gpio_get(unsigned int port, unsigned int pin)
Read the current logical level of a GPIO pin.
void ove_led_toggle(unsigned int led)
Toggle the current state of a board LED.
void ove_led_set(unsigned int led, int on)
Turn a board LED on or off.
@ OVE_ERR_NOT_SUPPORTED
Definition types.h:98
@ OVE_OK
Definition types.h:83