17 #ifndef LIBBSP_SHARED_GPIO_H 18 #define LIBBSP_SHARED_GPIO_H 27 #if !defined(BSP_GPIO_PIN_COUNT) || !defined(BSP_GPIO_PINS_PER_BANK) 28 #error "BSP_GPIO_PIN_COUNT or BSP_GPIO_PINS_PER_BANK is not defined." 31 #if BSP_GPIO_PIN_COUNT <= 0 || BSP_GPIO_PINS_PER_BANK <= 0 32 #error "Invalid BSP_GPIO_PIN_COUNT or BSP_GPIO_PINS_PER_BANK." 35 #if BSP_GPIO_PINS_PER_BANK > 32 36 #error "Invalid BSP_GPIO_PINS_PER_BANK. Must be in the range of 1 to 32." 39 #define GPIO_LAST_BANK_PINS BSP_GPIO_PIN_COUNT % BSP_GPIO_PINS_PER_BANK 41 #if GPIO_LAST_BANK_PINS > 0 42 #define GPIO_BANK_COUNT (BSP_GPIO_PIN_COUNT / BSP_GPIO_PINS_PER_BANK) + 1 44 #define GPIO_BANK_COUNT BSP_GPIO_PIN_COUNT / BSP_GPIO_PINS_PER_BANK 45 #undef GPIO_LAST_BANK_PINS 46 #define GPIO_LAST_BANK_PINS BSP_GPIO_PINS_PER_BANK 49 #if defined(BSP_GPIO_PINS_PER_SELECT_BANK) && BSP_GPIO_PINS_PER_SELECT_BANK > 32 50 #error "Invalid BSP_GPIO_PINS_PER_SELECT_BANK. Must under and including 32." 51 #elif defined(BSP_GPIO_PINS_PER_SELECT_BANK) <= 32 52 #define GPIO_SELECT_BANK_COUNT \ 53 BSP_GPIO_PINS_PER_BANK / BSP_GPIO_PINS_PER_SELECT_BANK 56 #define INTERRUPT_SERVER_PRIORITY 1 57 #define INTERRUPT_SERVER_STACK_SIZE 2 * RTEMS_MINIMUM_STACK_SIZE 58 #define INTERRUPT_SERVER_MODES RTEMS_TIMESLICE | RTEMS_PREEMPT 59 #define INTERRUPT_SERVER_ATTRIBUTES RTEMS_DEFAULT_ATTRIBUTES 61 #define GPIO_INPUT_ERROR ~0 144 uint32_t io_function;
159 bool threaded_interrupts;
171 uint32_t debounce_clock_tick_interval;
221 uint32_t io_function;
234 uint32_t input_count;
237 uint32_t output_count;
240 uint32_t bsp_specific_pin_count;
379 uint32_t *pin_numbers,
396 uint32_t *pin_numbers,
411 uint32_t *pin_numbers,
650 bool threaded_handling,
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:1149
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:905
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:192
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:941
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:179
rtems_gpio_irq_state
The set of possible handled states an user-defined interrupt handler can return.
Definition: gpio.h:117
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:128
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:1008
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:81
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:112
Object containing configuration information regarding interrupts.
Definition: gpio.h:153
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:1498
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:137
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:1383
int rtems_gpio_get_value(uint32_t pin_number)
Returns the value (level) of a GPIO input pin.
Definition: gpio-support.c:1253
rtems_gpio_group * rtems_gpio_create_pin_group(void)
Instantiates a GPIO pin group. To define the group.
Definition: gpio-support.c:680
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:1428
rtems_status_code rtems_gpio_set(uint32_t pin_number)
Sets an output GPIO pin with the logical high.
Definition: gpio-support.c:1173
ISR_Vector_number rtems_vector_number
Control block type used to manage the vectors.
Definition: intr.h:47
Object containing configuration information to request/update a GPIO pin.
Definition: gpio.h:178
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:93
rtems_status_code
Classic API Status.
Definition: status.h:43
Object containing configuration information to assign GPIO functions to multiple pins at the same tim...
Definition: gpio.h:212
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:100
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:1602
rtems_gpio_function
The set of possible functions a pin can have.
Definition: gpio.h:87
Object containing relevant information for assigning a BSP specific function to a pin.
Definition: gpio.h:141
rtems_gpio_interrupt
The set of possible interrupts a GPIO pin can generate.
Definition: gpio.h:100
rtems_gpio_pull_mode
The set of possible configurations for a GPIO pull-up resistor.
Definition: gpio.h:75
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:174
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:236
Assigns a certain function to a GPIO pin.
Definition: gpio.h:90
Object containing relevant information about a GPIO group.
Definition: gpio-support.c:55
rtems_status_code rtems_gpio_initialize(void)
Initializes the GPIO API.
Definition: gpio-support.c:640
rtems_status_code rtems_gpio_clear(uint32_t pin_number)
Sets an output GPIO pin with the logical low.
Definition: gpio-support.c:1213
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:107
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:1888
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:88
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:74
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:120
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:840
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:1826
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:1103
rtems_gpio_handler_flag
The set of flags to specify an user-defined interrupt handler uniqueness on a GPIO pin.
Definition: gpio.h:129
rtems_status_code rtems_gpio_request_configuration(const rtems_gpio_pin_conf *conf)
Requests a GPIO pin configuration.
Definition: gpio-support.c:980
Object containing configuration information to request a GPIO pin group.
Definition: gpio.h:231
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:1567
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:1466
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:1126