RTEMS  5.1
Typedefs | Enumerations | Functions

Typedefs

typedef enum ALT_GPIO_PIN_DIR_e ALT_GPIO_PIN_DIR_t
 
typedef enum ALT_GPIO_PIN_TYPE_e ALT_GPIO_PIN_TYPE_t
 
typedef enum ALT_GPIO_PIN_POL_e ALT_GPIO_PIN_POL_t
 
typedef enum ALT_GPIO_PIN_DEBOUNCE_e ALT_GPIO_PIN_DEBOUNCE_t
 
typedef enum ALT_GPIO_PIN_SYNC_e ALT_GPIO_PIN_SYNC_t
 
typedef enum ALT_GPIO_PIN_DATA_e ALT_GPIO_PIN_DATA_t
 
typedef enum ALT_GPIO_PORT_e ALT_GPIO_PORT_t
 
typedef enum ALT_GPIO_PORTBIT_e ALT_GPIO_PORTBIT_t
 

Enumerations

enum  ALT_GPIO_PIN_DIR_e { ALT_GPIO_PIN_INPUT, ALT_GPIO_PIN_OUTPUT }
 
enum  ALT_GPIO_PIN_TYPE_e { ALT_GPIO_PIN_LEVEL_TRIG_INT, ALT_GPIO_PIN_EDGE_TRIG_INT }
 
enum  ALT_GPIO_PIN_POL_e { ALT_GPIO_PIN_ACTIVE_LOW, ALT_GPIO_PIN_ACTIVE_HIGH }
 
enum  ALT_GPIO_PIN_DEBOUNCE_e { ALT_GPIO_PIN_NODEBOUNCE, ALT_GPIO_PIN_DEBOUNCE }
 
enum  ALT_GPIO_PIN_SYNC_e { ALT_GPIO_PIN_NOSYNC, ALT_GPIO_PIN_SYNC }
 
enum  ALT_GPIO_PIN_DATA_e { ALT_GPIO_PIN_DATAZERO, ALT_GPIO_PIN_DATAONE }
 
enum  ALT_GPIO_PORT_e { ALT_GPIO_PORTA, ALT_GPIO_PORTB, ALT_GPIO_PORTC, ALT_GPIO_PORT_UNKNOWN }
 
enum  ALT_GPIO_PORTBIT_e {
  ALT_GPIO_BIT0 = ALT_TWO_TO_POW0, ALT_GPIO_BIT1 = ALT_TWO_TO_POW1, ALT_GPIO_BIT2 = ALT_TWO_TO_POW2, ALT_GPIO_BIT3 = ALT_TWO_TO_POW3,
  ALT_GPIO_BIT4 = ALT_TWO_TO_POW4, ALT_GPIO_BIT5 = ALT_TWO_TO_POW5, ALT_GPIO_BIT6 = ALT_TWO_TO_POW6, ALT_GPIO_BIT7 = ALT_TWO_TO_POW7,
  ALT_GPIO_BIT8 = ALT_TWO_TO_POW8, ALT_GPIO_BIT9 = ALT_TWO_TO_POW9, ALT_GPIO_BIT10 = ALT_TWO_TO_POW10, ALT_GPIO_BIT11 = ALT_TWO_TO_POW11,
  ALT_GPIO_BIT12 = ALT_TWO_TO_POW12, ALT_GPIO_BIT13 = ALT_TWO_TO_POW13, ALT_GPIO_BIT14 = ALT_TWO_TO_POW14, ALT_GPIO_BIT15 = ALT_TWO_TO_POW15,
  ALT_GPIO_BIT16 = ALT_TWO_TO_POW16, ALT_GPIO_BIT17 = ALT_TWO_TO_POW17, ALT_GPIO_BIT18 = ALT_TWO_TO_POW18, ALT_GPIO_BIT19 = ALT_TWO_TO_POW19,
  ALT_GPIO_BIT20 = ALT_TWO_TO_POW20, ALT_GPIO_BIT21 = ALT_TWO_TO_POW21, ALT_GPIO_BIT22 = ALT_TWO_TO_POW22, ALT_GPIO_BIT23 = ALT_TWO_TO_POW23,
  ALT_GPIO_BIT24 = ALT_TWO_TO_POW24, ALT_GPIO_BIT25 = ALT_TWO_TO_POW25, ALT_GPIO_BIT26 = ALT_TWO_TO_POW26, ALT_GPIO_BIT27 = ALT_TWO_TO_POW27,
  ALT_GPIO_BIT28 = ALT_TWO_TO_POW28, ALT_GPIO_BIT29 = ALT_TWO_TO_POW29, ALT_GPIO_BIT30 = ALT_TWO_TO_POW30, ALT_GPIO_BIT31 = (int32_t) (1UL<<31),
  ALT_GPIO_BITNUM_MAX = (28), ALT_GPIO_BIT_MAX = (1 << ALT_GPIO_BITNUM_MAX), ALT_END_OF_GPIO_PORT_SIGNALS = (32)
}
 

Functions

ALT_STATUS_CODE alt_gpio_init (void)
 
ALT_STATUS_CODE alt_gpio_uninit (void)
 
ALT_STATUS_CODE alt_gpio_port_datadir_set (ALT_GPIO_PORT_t gpio_pid, uint32_t mask, uint32_t config)
 
uint32_t alt_gpio_port_datadir_get (ALT_GPIO_PORT_t gpio_pid, uint32_t mask)
 
ALT_STATUS_CODE alt_gpio_port_data_write (ALT_GPIO_PORT_t gpio_pid, uint32_t mask, uint32_t val)
 
uint32_t alt_gpio_port_data_read (ALT_GPIO_PORT_t gpio_pid, uint32_t mask)
 
ALT_STATUS_CODE alt_gpio_port_debounce_set (ALT_GPIO_PORT_t gpio_pid, uint32_t mask, uint32_t config)
 
uint32_t alt_gpio_port_debounce_get (ALT_GPIO_PORT_t gpio_pid, uint32_t mask)
 
ALT_STATUS_CODE alt_gpio_port_sync_set (ALT_GPIO_PORT_t gpio_pid, uint32_t config)
 
ALT_STATUS_CODE alt_gpio_port_sync_get (ALT_GPIO_PORT_t gpio_pid)
 
ALT_STATUS_CODE alt_gpio_port_config (ALT_GPIO_PORT_t gpio_pid, uint32_t mask, ALT_GPIO_PIN_DIR_t dir, ALT_GPIO_PIN_TYPE_t type, ALT_GPIO_PIN_POL_t pol, ALT_GPIO_PIN_DEBOUNCE_t debounc, uint32_t data)
 

Detailed Description

This functional group contains functions to control, configure and manage the general-purpose IO signals as individual signals or as groups of signals. This group of functions can operate on multiple bits within the same GPIO port and accepts a bit mask to specify which bits an operation will operate on. Other bits within the same GPIO port are not changed.

This example shows how multiple drivers or applications can use this feature to easily prevent conflict while accessing the same GPIO port:

#define DRIVER_0_GPIO_MSK   0x0010FF03;
#define DRIVER_1_GPIO_MSK   0x002000F8;
#define DRIVER_2_GPIO_MSK   0x03C00004;
#define DRIVER_3_GPIO_MSK   0x000F0000;

   alt_gpio_port_data_write(ALT_GPIO_PORTA, DRIVER_0_GPIO_MSK, init_val0);
   alt_gpio_port_data_write(ALT_GPIO_PORTA, DRIVER_1_GPIO_MSK, init_val1);
   alt_gpio_port_data_write(ALT_GPIO_PORTA, DRIVER_2_GPIO_MSK, init_val2);
   alt_gpio_port_data_write(ALT_GPIO_PORTA, DRIVER_3_GPIO_MSK, init_val3);
   alt_gpio_port_int_type_set(ALT_GPIO_PORTA, DRIVER_1_GPIO_MSK, config_val1);

Typedef Documentation

◆ ALT_GPIO_PIN_DATA_t

This type definition enumerates the possible data states of the GPIO bits.

◆ ALT_GPIO_PIN_DEBOUNCE_t

This type definition enumerates whether or not the debounce metastability flip-flops are inserted or not. These are used to debounce signals presented to the GPIO inputs. A signal must be steady for two periods of the gpio_db_clk clock before it is considered valid. The frequency of the gpio_db_clk clock may be set using the Clock Manager API.

◆ ALT_GPIO_PIN_DIR_t

This type definition enumerates the data direction (input or output) of the GPIO signals.

◆ ALT_GPIO_PIN_POL_t

This type definition enumerates the polarity of the interrupt sources (falling-edge or rising-edge for edge-triggered interrupts, active-low or active-high for level-triggered interrupts) of the GPIO signals.

◆ ALT_GPIO_PIN_SYNC_t

This type definition enumerates whether or not level-sensitive interrupts are synchronized to the internal pclk_intr clock. It has no effect for GPIO signals that are selected as outputs, or if the interrupt is not enabled, or if the interrupt is set to be edge-triggered. This is a port-wide option.

◆ ALT_GPIO_PIN_TYPE_t

This type definition enumerates the type of interrupt source (level-triggered or edge-triggered) of the GPIO signals.

◆ ALT_GPIO_PORT_t

This type definition enumerates the GPIO ports that the GPIO manager handles.

◆ ALT_GPIO_PORTBIT_t

This type definition enumerates the individual bits within the GPIO ports used by the GPIO manager. The bit-ordering must match the hardware bit-ordering. Since the ordering and packing of bitfields is not standardized in C/C++, the following are defined as masks.
For example, to set bits 3 and 4 of GPIO port B outputs (assuming the bits had previously been set to outputs), the user could use the syntax:

alt_gpio_port_data_write(ALT_GPIO_PORTB, ALT_GPIO_BIT3 | ALT_GPIO_BIT4);

Enumeration Type Documentation

◆ ALT_GPIO_PIN_DATA_e

This type definition enumerates the possible data states of the GPIO bits.

Enumerator
ALT_GPIO_PIN_DATAZERO 

ALT_GPIO_PIN_DATAONE 

◆ ALT_GPIO_PIN_DEBOUNCE_e

This type definition enumerates whether or not the debounce metastability flip-flops are inserted or not. These are used to debounce signals presented to the GPIO inputs. A signal must be steady for two periods of the gpio_db_clk clock before it is considered valid. The frequency of the gpio_db_clk clock may be set using the Clock Manager API.

Enumerator
ALT_GPIO_PIN_NODEBOUNCE 

ALT_GPIO_PIN_DEBOUNCE 

◆ ALT_GPIO_PIN_DIR_e

This type definition enumerates the data direction (input or output) of the GPIO signals.

Enumerator
ALT_GPIO_PIN_INPUT 

ALT_GPIO_PIN_OUTPUT 

◆ ALT_GPIO_PIN_POL_e

This type definition enumerates the polarity of the interrupt sources (falling-edge or rising-edge for edge-triggered interrupts, active-low or active-high for level-triggered interrupts) of the GPIO signals.

Enumerator
ALT_GPIO_PIN_ACTIVE_LOW 

Indicates active-low for level-triggered interrupts and falling-edge for edge-triggered interrupts

ALT_GPIO_PIN_ACTIVE_HIGH 

Indicates active-high for level-triggered interrupts and rising-edge for edge-triggered interrupt

◆ ALT_GPIO_PIN_SYNC_e

This type definition enumerates whether or not level-sensitive interrupts are synchronized to the internal pclk_intr clock. It has no effect for GPIO signals that are selected as outputs, or if the interrupt is not enabled, or if the interrupt is set to be edge-triggered. This is a port-wide option.

Enumerator
ALT_GPIO_PIN_NOSYNC 

ALT_GPIO_PIN_SYNC 

◆ ALT_GPIO_PIN_TYPE_e

This type definition enumerates the type of interrupt source (level-triggered or edge-triggered) of the GPIO signals.

Enumerator
ALT_GPIO_PIN_LEVEL_TRIG_INT 

ALT_GPIO_PIN_EDGE_TRIG_INT 

◆ ALT_GPIO_PORT_e

This type definition enumerates the GPIO ports that the GPIO manager handles.

Enumerator
ALT_GPIO_PORTA 

Port A - 29-bit GPIO port A.

ALT_GPIO_PORTB 

Port B - 29-bit GPIO port B.

ALT_GPIO_PORTC 

Port C - 29-bit GPIO port C.
13 bits are used for GPIO signals, 14 bits are used for GPI-only signals that are shared with the DDR interface, 2 bits are not used. Some signals may not be connected on some versions. See the relevant pin mux data.

ALT_GPIO_PORT_UNKNOWN 

Unknown Port - Used to indicate an error.

◆ ALT_GPIO_PORTBIT_e

This type definition enumerates the individual bits within the GPIO ports used by the GPIO manager. The bit-ordering must match the hardware bit-ordering. Since the ordering and packing of bitfields is not standardized in C/C++, the following are defined as masks.
For example, to set bits 3 and 4 of GPIO port B outputs (assuming the bits had previously been set to outputs), the user could use the syntax:

alt_gpio_port_data_write(ALT_GPIO_PORTB, ALT_GPIO_BIT3 | ALT_GPIO_BIT4);
Enumerator
ALT_GPIO_BIT0 

ALT_GPIO_BIT1 

ALT_GPIO_BIT2 

ALT_GPIO_BIT3 

ALT_GPIO_BIT4 

ALT_GPIO_BIT5 

ALT_GPIO_BIT6 

ALT_GPIO_BIT7 

ALT_GPIO_BIT8 

ALT_GPIO_BIT9 

ALT_GPIO_BIT10 

ALT_GPIO_BIT11 

ALT_GPIO_BIT12 

ALT_GPIO_BIT13 

ALT_GPIO_BIT14 

ALT_GPIO_BIT15 

ALT_GPIO_BIT16 

ALT_GPIO_BIT17 

ALT_GPIO_BIT18 

ALT_GPIO_BIT19 

ALT_GPIO_BIT20 

ALT_GPIO_BIT21 

ALT_GPIO_BIT22 

ALT_GPIO_BIT23 

ALT_GPIO_BIT24 

ALT_GPIO_BIT25 

ALT_GPIO_BIT26 

ALT_GPIO_BIT27 

ALT_GPIO_BIT28 

Function Documentation

◆ alt_gpio_init()

ALT_STATUS_CODE alt_gpio_init ( void  )

Initialize the GPIO modules before use

Return values
ALT_E_SUCCESSThe operation was successful.
ALT_E_ERRORThe operation failed.

◆ alt_gpio_port_config()

ALT_STATUS_CODE alt_gpio_port_config ( ALT_GPIO_PORT_t  gpio_pid,
uint32_t  mask,
ALT_GPIO_PIN_DIR_t  dir,
ALT_GPIO_PIN_TYPE_t  type,
ALT_GPIO_PIN_POL_t  pol,
ALT_GPIO_PIN_DEBOUNCE_t  debounc,
uint32_t  data 
)

Configures a group of GPIO signals with identical setup parameters. Allows for configuring all parameters of a given port at one time.

Parameters
gpio_pidThe GPIO port identifier.
maskThe group of bits to apply this operation to. Other bits (mask set to zero) are not changed.
dirData direction.
typeEdge-triggered or level-triggered interrupts.
polActive-high or active-low polarity.
debouncDebounce signals or not.
dataSet the data output to this value.
Return values
ALT_E_SUCCESSThe operation was successful.
ALT_E_ERRORThe operation failed.
ALT_E_BAD_ARGInvalid input argument.

◆ alt_gpio_port_data_read()

uint32_t alt_gpio_port_data_read ( ALT_GPIO_PORT_t  gpio_pid,
uint32_t  mask 
)

Returns the value of the data inputs of the specified GPIO module. This is the current logic value of the pin, whether set to be an input or an output.
If a given signal is set to be an output, this input value can be read to determine if the pin is grounded, pulled high, or is floating.

Parameters
gpio_pidThe GPIO port identifier.
maskThe group of bits (where mask bits equal one) to return. Other bits (where mask bits equal zero) are returned as zero. Specify mask = ALT_GPIO_BITMASK (0x1FFFFFFF) to return all data bits of the port.
Return values
uint32_tThe current value of the GPIO module input signals.

◆ alt_gpio_port_data_write()

ALT_STATUS_CODE alt_gpio_port_data_write ( ALT_GPIO_PORT_t  gpio_pid,
uint32_t  mask,
uint32_t  val 
)

Sets the GPIO data outputs of the specified GPIO module to a logic one or zero. Outputs are only set if the data direction for those bits is also set to configure them as outputs.

Parameters
gpio_pidThe GPIO port identifier.
maskThe group of bits (mask bits equal one) to apply this operation to. Other bits (mask bits equal zero) are not changed.
valThe 32-bit word to write to the GPIO outputs. Only the 29 LSBs are used. Setting the three MSBs causes an error.
Return values
ALT_E_SUCCESSThe operation was successful.
ALT_E_ERRORThe operation failed.
ALT_E_BAD_ARGBad input argument.

◆ alt_gpio_port_datadir_get()

uint32_t alt_gpio_port_datadir_get ( ALT_GPIO_PORT_t  gpio_pid,
uint32_t  mask 
)

Returns the data direction configuration of selected bits of the specified GPIO module.

Parameters
gpio_pidThe GPIO port identifier.
maskThe group of bits (where mask bits equal one) to read and return. Other bits (where mask bits equal zero) are returned as zero. Specify mask = ALT_GPIO_BITMASK (0x1FFFFFFF) to return all data direction bits of the port.
Return values
uint32_t
Individual bits are:
0 - The signal is configured as an input.
1 - The signal is configured as an output.

◆ alt_gpio_port_datadir_set()

ALT_STATUS_CODE alt_gpio_port_datadir_set ( ALT_GPIO_PORT_t  gpio_pid,
uint32_t  mask,
uint32_t  config 
)

Sets the specified GPIO data bits to use the data direction(s) specified.

Parameters
gpio_pidThe GPIO port identifier.
maskThe group of bits (where mask bits equal one) to apply this operation to. Other bits (where mask bits equal zero) are not changed. Specify mask = ALT_GPIO_BITMASK (0x1FFFFFFF) to configure all data direction bits of the port.
configThe data-directions of the bits to be set in this operation. Individual bits are:
0 - Use as an input (default).
1 - Use as an output.
Return values
ALT_E_SUCCESSThe operation was successful.
ALT_E_ERRORThe operation failed.
ALT_E_BAD_ARGBad input argument.

◆ alt_gpio_port_debounce_get()

uint32_t alt_gpio_port_debounce_get ( ALT_GPIO_PORT_t  gpio_pid,
uint32_t  mask 
)

Returns the debounce configuration for the input signals of the specified GPIO register. If debounce is selected, metastability flip-flops are inserted to debounce signals presented to the GPIO inputs.

Parameters
gpio_pidThe GPIO port identifier.
maskThe group of bits (where mask bits equal one) to return. Other bits (where mask bits equal zero) are returned as zero. Specify mask = ALT_GPIO_BITMASK (0x1FFFFFFF) to return all debounce configuration bits of the port.
Return values
uint32_tThe current debounce configuration.Individual bits are:
0 - Debounce is not selected for this signal.
1 - Debounce is selected for this signal.

◆ alt_gpio_port_debounce_set()

ALT_STATUS_CODE alt_gpio_port_debounce_set ( ALT_GPIO_PORT_t  gpio_pid,
uint32_t  mask,
uint32_t  config 
)

Sets the debounce configuration for input signals of the specified GPIO module. If debounce is selected, metastability flip-flops are inserted to debounce signals presented to the GPIO inputs. A signal must be steady for two periods of the gpio_db_clk clock before it is considered valid. The frequency of the gpio_db_clk clock may be set using the Clock Manager API.

Parameters
gpio_pidThe GPIO port identifier.
maskThe group of bits (where mask bits equal one) to apply this operation to. Other bits (where mask bits equal zero) are not changed. Specify mask = ALT_GPIO_BITMASK (0x1FFFFFFF) to configure the debounce setting for all bits of the port.
configThe debounce configuration to set. Individual bits are:
0 - Debounce is not selected for this signal (default).
1 - Debounce is selected for this signal.
Return values
ALT_E_SUCCESSThe operation was successful.
ALT_E_ERRORThe operation failed.
ALT_E_BAD_ARGInvalid input data.

◆ alt_gpio_port_sync_get()

ALT_STATUS_CODE alt_gpio_port_sync_get ( ALT_GPIO_PORT_t  gpio_pid)

Returns the synchronization configuration for the signals of the specified GPIO register. This allows for synchronizing level-sensitive interrupts to the internal clock signal. This is a port-wide option that controls all level-sensitive interrupt signals of that GPIO port.

Parameters
gpio_pidThe GPIO port identifier.
Return values
ALT_E_TRUESynchronization to clock is enabled for level-sensitive interrupts.
ALT_E_FALSESynchronization to clock is disabled for level-sensitive interrupts.
ALT_E_BAD_ARGInvalid input argument.

◆ alt_gpio_port_sync_set()

ALT_STATUS_CODE alt_gpio_port_sync_set ( ALT_GPIO_PORT_t  gpio_pid,
uint32_t  config 
)

Sets the synchronization configuration for the signals of the specified GPIO register. This allows for synchronizing level-sensitive interrupts to an internal clock signal. This is a port-wide option that controls all level-sensitive interrupt signals of that GPIO port.

Parameters
gpio_pidThe GPIO port identifier.
config
Any non-zero value - Synchronize to internal clock signal.
Zero - Do not synchronize to internal clock signal.
Return values
ALT_E_SUCCESSThe operation was successful.
ALT_E_ERRORThe operation failed.
ALT_E_BAD_ARGInvalid input data.

◆ alt_gpio_uninit()

ALT_STATUS_CODE alt_gpio_uninit ( void  )

Uninitialize the GPIO modules & return to reset state

Return values
ALT_E_SUCCESSThe operation was successful.
ALT_E_ERRORThe operation failed.