RTEMS 6.1-rc5
Loading...
Searching...
No Matches
Macros | Functions | Variables
rpi-gpio.c File Reference

Support for the Raspberry PI GPIO. More...

#include <bsp.h>
#include <bsp/raspberrypi.h>
#include <bsp/irq-generic.h>
#include <bsp/gpio.h>
#include <bsp/rpi-gpio.h>
#include <stdlib.h>
#include "gpio-interfaces-pi1-rev2.c"

Macros

#define SELECT_PIN_FUNCTION(fn, pn)   (fn << ((pn % 10) * 3))
 

Functions

 RTEMS_INTERRUPT_LOCK_DEFINE (static, rtems_gpio_bsp_lock, "rtems_gpio_bsp_lock")
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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 corresponding pin as a pending interrupt, or 0 if otherwise. The function should clear the interrupt event line before returning. This must be implemented by each BSP.
 
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.
 
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.
 
rtems_status_code rpi_gpio_select_jtag (void)
 Setups a JTAG interface.
 
rtems_status_code rpi_gpio_select_spi (void)
 Setups a SPI interface.
 
rtems_status_code rpi_gpio_select_i2c (void)
 Setups a I2C interface.
 
rtems_status_code rtems_gpio_bsp_multi_select (rtems_gpio_multiple_pin_select *pins, uint32_t pin_count, uint32_t select_bank)
 
rtems_status_code rtems_gpio_bsp_specific_group_operation (uint32_t bank, uint32_t *pins, uint32_t pin_count, void *arg)
 

Variables

rtems_gpio_specific_data alt_func_def []
 

Detailed Description

Support for the Raspberry PI GPIO.

Function Documentation

◆ rpi_gpio_select_i2c()

rtems_status_code rpi_gpio_select_i2c ( void  )

Setups a I2C interface.

Return values
RTEMS_SUCCESSFULI2C interface successfully configured.
*At least one of the required pins is currently occupied,
See also
rtems_gpio_request_pin_group().

◆ rpi_gpio_select_jtag()

rtems_status_code rpi_gpio_select_jtag ( void  )

Setups a JTAG interface.

Return values
RTEMS_SUCCESSFULJTAG interface successfully configured.
*At least one of the required pins is currently occupied,
See also
rtems_gpio_request_pin_group().

◆ rpi_gpio_select_spi()

rtems_status_code rpi_gpio_select_spi ( void  )

Setups a SPI interface.

Return values
RTEMS_SUCCESSFULSPI interface successfully configured.
*At least one of the required pins is currently occupied,
See also
rtems_gpio_request_pin_group().

◆ rtems_gpio_bsp_clear()

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.

Parameters
[in]bankGPIO bank number.
[in]pinGPIO pin number within the given bank.
Return values
RTEMS_SUCCESSFULPin was cleared successfully.
RTEMS_UNSATISFIEDCould not clear the given pin.

◆ rtems_gpio_bsp_disable_interrupt()

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.

Parameters
[in]bankGPIO bank number.
[in]pinGPIO pin number within the given bank.
[in]active_interruptInterrupt type currently active on this pin.
Return values
RTEMS_SUCCESSFULInterrupt successfully disabled for this pin.
RTEMS_UNSATISFIEDCould not disable interrupts on this pin.

◆ rtems_gpio_bsp_enable_interrupt()

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.

Parameters
[in]bankGPIO bank number.
[in]pinGPIO pin number within the given bank.
[in]interruptType of interrupt to enable for the pin.
Return values
RTEMS_SUCCESSFULInterrupt successfully enabled for this pin.
RTEMS_UNSATISFIEDCould not enable the interrupt on the pin.

◆ rtems_gpio_bsp_get_value()

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.

Parameters
[in]bankGPIO bank number.
[in]pinGPIO pin number within the given bank.
Return values
Thefunction must return 0 if the pin level is a logical low, or non zero if it has a logical high.
GPIO_INPUT_ERRORCould not read the pin level.

◆ rtems_gpio_bsp_get_vector()

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.

Parameters
[in]bankGPIO bank number.
Return values
Thecorresponding rtems_vector_number.

◆ rtems_gpio_bsp_interrupt_line()

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 corresponding pin as a pending interrupt, or 0 if otherwise. The function should clear the interrupt event line before returning. This must be implemented by each BSP.

Parameters
[in]vectorGPIO vector/bank.
Return values
Bitmask(max 32-bit) representing a GPIO bank, where a bit set indicates an active interrupt on that pin.

◆ rtems_gpio_bsp_multi_clear()

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.

Parameters
[in]bankGPIO bank number.
[in]bitmaskBitmask of GPIO pins to clear in the given bank.
Return values
RTEMS_SUCCESSFULAll pins were cleared successfully.
RTEMS_UNSATISFIEDCould not clear at least one of the pins.

◆ rtems_gpio_bsp_multi_read()

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.

Parameters
[in]bankGPIO bank number.
[in]bitmaskBitmask of GPIO pins to read in the given bank.
Return values
Thefunction must return a bitmask with the values of the corresponding pins. 0 for logical low and 1 for logical high.
GPIO_INPUT_ERRORCould not read at least one pin level.

◆ rtems_gpio_bsp_multi_set()

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.

Parameters
[in]bankGPIO bank number.
[in]bitmaskBitmask of GPIO pins to set in the given bank.
Return values
RTEMS_SUCCESSFULAll pins were set successfully.
RTEMS_UNSATISFIEDCould not set at least one of the pins.

◆ rtems_gpio_bsp_select_input()

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.

Parameters
[in]bankGPIO bank number.
[in]pinGPIO pin number within the given bank.
[in]bsp_specificPointer to a BSP defined structure with BSP-specific data.
Return values
RTEMS_SUCCESSFULFunction was assigned successfully.
RTEMS_UNSATISFIEDCould not assign the function to the pin.

◆ rtems_gpio_bsp_select_output()

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.

Parameters
[in]bankGPIO bank number.
[in]pinGPIO pin number within the given bank.
[in]bsp_specificPointer to a BSP defined structure with BSP-specific data.
Return values
RTEMS_SUCCESSFULFunction was assigned successfully.
RTEMS_UNSATISFIEDCould not assign the function to the pin.

◆ rtems_gpio_bsp_select_specific_io()

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.

Parameters
[in]bankGPIO bank number.
[in]pinGPIO pin number within the given bank.
[in]functionBSP defined GPIO function.
[in]pin_dataPointer to a BSP defined structure with BSP-specific data.
Return values
RTEMS_SUCCESSFULFunction was assigned successfully.
RTEMS_UNSATISFIEDCould not assign the function to the pin.

◆ rtems_gpio_bsp_set()

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.

Parameters
[in]bankGPIO bank number.
[in]pinGPIO pin number within the given bank.
Return values
RTEMS_SUCCESSFULPin was set successfully.
RTEMS_UNSATISFIEDCould not set the given pin.

◆ rtems_gpio_bsp_set_resistor_mode()

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.

Parameters
[in]bankGPIO bank number.
[in]pinGPIO pin number within the given bank.
[in]modeThe pull resistor mode.
Return values
RTEMS_SUCCESSFULPull resistor successfully configured.
RTEMS_UNSATISFIEDCould not set the pull mode.

Variable Documentation

◆ alt_func_def

rtems_gpio_specific_data alt_func_def[]
Initial value:
= {
{.io_function = RPI_ALT_FUNC_0, .pin_data = NULL},
{.io_function = RPI_ALT_FUNC_1, .pin_data = NULL},
{.io_function = RPI_ALT_FUNC_2, .pin_data = NULL},
{.io_function = RPI_ALT_FUNC_3, .pin_data = NULL},
{.io_function = RPI_ALT_FUNC_4, .pin_data = NULL},
{.io_function = RPI_ALT_FUNC_5, .pin_data = NULL}
}