19#ifndef LIBBSP_SHARED_GPIO_H
20#define LIBBSP_SHARED_GPIO_H
29#if !defined(BSP_GPIO_PIN_COUNT) || !defined(BSP_GPIO_PINS_PER_BANK)
30 #error "BSP_GPIO_PIN_COUNT or BSP_GPIO_PINS_PER_BANK is not defined."
33#if BSP_GPIO_PIN_COUNT <= 0 || BSP_GPIO_PINS_PER_BANK <= 0
34 #error "Invalid BSP_GPIO_PIN_COUNT or BSP_GPIO_PINS_PER_BANK."
37#if BSP_GPIO_PINS_PER_BANK > 32
38 #error "Invalid BSP_GPIO_PINS_PER_BANK. Must be in the range of 1 to 32."
41#define GPIO_LAST_BANK_PINS BSP_GPIO_PIN_COUNT % BSP_GPIO_PINS_PER_BANK
43#if GPIO_LAST_BANK_PINS > 0
44 #define GPIO_BANK_COUNT (BSP_GPIO_PIN_COUNT / BSP_GPIO_PINS_PER_BANK) + 1
46 #define GPIO_BANK_COUNT BSP_GPIO_PIN_COUNT / BSP_GPIO_PINS_PER_BANK
47 #undef GPIO_LAST_BANK_PINS
48 #define GPIO_LAST_BANK_PINS BSP_GPIO_PINS_PER_BANK
51#if defined(BSP_GPIO_PINS_PER_SELECT_BANK) && BSP_GPIO_PINS_PER_SELECT_BANK > 32
52 #error "Invalid BSP_GPIO_PINS_PER_SELECT_BANK. Must under and including 32."
53#elif defined(BSP_GPIO_PINS_PER_SELECT_BANK) <= 32
54 #define GPIO_SELECT_BANK_COUNT \
55 BSP_GPIO_PINS_PER_BANK / BSP_GPIO_PINS_PER_SELECT_BANK
58#define INTERRUPT_SERVER_PRIORITY 1
59#define INTERRUPT_SERVER_STACK_SIZE 2 * RTEMS_MINIMUM_STACK_SIZE
60#define INTERRUPT_SERVER_MODES RTEMS_TIMESLICE | RTEMS_PREEMPT
61#define INTERRUPT_SERVER_ATTRIBUTES RTEMS_DEFAULT_ATTRIBUTES
63#define GPIO_INPUT_ERROR ~0
146 uint32_t io_function;
161 bool threaded_interrupts;
173 uint32_t debounce_clock_tick_interval;
223 uint32_t io_function;
236 uint32_t input_count;
239 uint32_t output_count;
242 uint32_t bsp_specific_pin_count;
381 uint32_t *pin_numbers,
398 uint32_t *pin_numbers,
413 uint32_t *pin_numbers,
652 bool threaded_handling,
rtems_status_code rtems_gpio_resistor_mode(uint32_t pin_number, rtems_gpio_pull_mode mode)
Configures a single GPIO pin pull resistor.
Definition: gpio-support.c:1384
rtems_gpio_function
The set of possible functions a pin can have.
Definition: gpio.h:90
@ DIGITAL_OUTPUT
Assigns a certain function to a GPIO pin.
Definition: gpio.h:92
rtems_status_code rtems_gpio_group_bsp_specific_operation(rtems_gpio_group *group, void *arg)
Performs a BSP specific operation on a group of pins. The pins order is as defined in the group defin...
Definition: gpio-support.c:942
rtems_status_code rtems_gpio_bsp_select_specific_io(uint32_t bank, uint32_t pin, uint32_t function, void *pin_data)
Assigns a BSP specific function to the given pin. This must be implemented by each BSP.
Definition: rpi-gpio.c:148
rtems_gpio_irq_state
The set of possible handled states an user-defined interrupt handler can return.
Definition: gpio.h:120
rtems_status_code rtems_gpio_bsp_select_input(uint32_t bank, uint32_t pin, void *bsp_specific)
Assigns the digital input function to the given pin. This must be implemented by each BSP.
Definition: rpi-gpio.c:128
uint32_t rtems_gpio_read_group(rtems_gpio_group *group)
Reads the value/level of the group's digital inputs. The pins order is as defined in the group defini...
Definition: gpio-support.c:906
rtems_status_code rtems_gpio_release_pin(uint32_t pin_number)
Releases a GPIO pin, making it available to be used again.
Definition: gpio-support.c:1429
rtems_status_code rtems_gpio_disable_interrupt(uint32_t pin_number)
Stops interrupts from being generated on a given GPIO pin and removes the corresponding handler.
Definition: gpio-support.c:1889
rtems_status_code rtems_gpio_multi_set(uint32_t *pin_numbers, uint32_t pin_count)
Sets multiple output GPIO pins with the logical high.
Definition: gpio-support.c:1104
rtems_status_code rtems_gpio_bsp_enable_interrupt(uint32_t bank, uint32_t pin, rtems_gpio_interrupt interrupt)
Enables interrupts to be generated on a given GPIO pin. This must be implemented by each BSP.
Definition: rpi-gpio.c:220
rtems_status_code rtems_gpio_initialize(void)
Initializes the GPIO API.
Definition: gpio-support.c:641
rtems_status_code rtems_gpio_bsp_clear(uint32_t bank, uint32_t pin)
Sets an output GPIO pin with the logical low. This must be implemented by each BSP.
Definition: rpi-gpio.c:112
rtems_gpio_handler_flag
The set of flags to specify an user-defined interrupt handler uniqueness on a GPIO pin.
Definition: gpio.h:132
rtems_status_code rtems_gpio_interrupt_handler_remove(uint32_t pin_number, rtems_gpio_irq_state(*handler)(void *arg), void *arg)
Disconnects an user-defined interrupt handler from the given pin. If in the end there are no more use...
Definition: gpio-support.c:1827
int rtems_gpio_get_value(uint32_t pin_number)
Returns the value (level) of a GPIO input pin.
Definition: gpio-support.c:1254
uint32_t rtems_gpio_bsp_get_value(uint32_t bank, uint32_t pin)
Returns the value (level) of a GPIO input pin. This must be implemented by each BSP.
Definition: rpi-gpio.c:121
rtems_status_code rtems_gpio_bsp_multi_set(uint32_t bank, uint32_t bitmask)
Sets multiple output GPIO pins with the logical high. This must be implemented by each BSP.
Definition: rpi-gpio.c:78
rtems_status_code rtems_gpio_update_configuration(const rtems_gpio_pin_conf *conf)
Updates the current configuration of a GPIO pin .
Definition: gpio-support.c:1009
rtems_status_code rtems_gpio_bsp_set_resistor_mode(uint32_t bank, uint32_t pin, rtems_gpio_pull_mode mode)
Configures a single GPIO pin pull resistor. This must be implemented by each BSP.
Definition: rpi-gpio.c:159
rtems_gpio_group * rtems_gpio_create_pin_group(void)
Instantiates a GPIO pin group. To define the group.
Definition: gpio-support.c:681
rtems_status_code rtems_gpio_bsp_disable_interrupt(uint32_t bank, uint32_t pin, rtems_gpio_interrupt interrupt)
Stops interrupts from being generated on a given GPIO pin. This must be implemented by each BSP.
Definition: rpi-gpio.c:266
rtems_gpio_interrupt
The set of possible interrupts a GPIO pin can generate.
Definition: gpio.h:103
rtems_status_code rtems_gpio_bsp_select_output(uint32_t bank, uint32_t pin, void *bsp_specific)
Assigns the digital output function to the given pin. This must be implemented by each BSP.
Definition: rpi-gpio.c:138
uint32_t rtems_gpio_bsp_multi_read(uint32_t bank, uint32_t bitmask)
Returns the value (level) of multiple GPIO input pins. This must be implemented by each BSP.
Definition: rpi-gpio.c:96
rtems_status_code rtems_gpio_write_group(uint32_t data, rtems_gpio_group *group)
Writes a value to the group's digital outputs. The pins order is as defined in the group definition.
Definition: gpio-support.c:841
uint32_t rtems_gpio_bsp_interrupt_line(rtems_vector_number vector)
Reads and returns a vector/bank interrupt event line. The bitmask should indicate with a 1 if the cor...
Definition: rpi-gpio.c:205
rtems_status_code rtems_gpio_debounce_switch(uint32_t pin_number, int ticks)
Attaches a debouncing function to a given pin/switch. Debouncing is done by requiring a certain numbe...
Definition: gpio-support.c:1568
rtems_status_code rtems_gpio_release_pin_group(rtems_gpio_group *group)
Releases a GPIO pin group, making the pins used available to be repurposed.
Definition: gpio-support.c:1499
rtems_status_code rtems_gpio_request_configuration(const rtems_gpio_pin_conf *conf)
Requests a GPIO pin configuration.
Definition: gpio-support.c:981
uint32_t rtems_gpio_multi_read(uint32_t *pin_numbers, uint32_t pin_count)
Returns the value (level) of multiple GPIO input pins.
Definition: gpio-support.c:1150
rtems_status_code rtems_gpio_clear(uint32_t pin_number)
Sets an output GPIO pin with the logical low.
Definition: gpio-support.c:1214
rtems_status_code rtems_gpio_interrupt_handler_install(uint32_t pin_number, rtems_gpio_irq_state(*handler)(void *arg), void *arg)
Connects a new user-defined interrupt handler to a given pin.
Definition: gpio-support.c:1603
rtems_status_code rtems_gpio_bsp_set(uint32_t bank, uint32_t pin)
Sets an output GPIO pin with the logical high. This must be implemented by each BSP.
Definition: rpi-gpio.c:103
rtems_gpio_pull_mode
The set of possible configurations for a GPIO pull-up resistor.
Definition: gpio.h:78
rtems_status_code rtems_gpio_release_configuration(const rtems_gpio_pin_conf *conf)
Releases a GPIO pin, making it available to be used again.
Definition: gpio-support.c:1467
rtems_status_code rtems_gpio_bsp_multi_clear(uint32_t bank, uint32_t bitmask)
Sets multiple output GPIO pins with the logical low. This must be implemented by each BSP.
Definition: rpi-gpio.c:87
rtems_status_code rtems_gpio_set(uint32_t pin_number)
Sets an output GPIO pin with the logical high.
Definition: gpio-support.c:1174
rtems_vector_number rtems_gpio_bsp_get_vector(uint32_t bank)
Calculates a vector number for a given GPIO bank. This must be implemented by each BSP.
Definition: rpi-gpio.c:198
rtems_status_code rtems_gpio_multi_clear(uint32_t *pin_numbers, uint32_t pin_count)
Sets multiple output GPIO pins with the logical low.
Definition: gpio-support.c:1127
ISR_Vector_number rtems_vector_number
This integer type represents interrupt vector numbers.
Definition: intr.h:102
rtems_status_code
This enumeration provides status codes for directives of the Classic API.
Definition: status.h:85
This header file defines the RTEMS Classic API.
Object containing configuration information to request a GPIO pin group.
Definition: gpio.h:234
Object containing relevant information about a GPIO group.
Definition: gpio-support.c:58
Object containing configuration information regarding interrupts.
Definition: gpio.h:156
Object containing configuration information to assign GPIO functions to multiple pins at the same tim...
Definition: gpio.h:215
Object containing configuration information to request/update a GPIO pin.
Definition: gpio.h:181
Object containing relevant information for assigning a BSP specific function to a pin.
Definition: gpio.h:144