Skip to main content

GPIO Lib API

This library allows easy access to the GPIO pins. More...

danger

this is a legacy library and thus not supported by Toradex anymore. We recommend that you use the new libraries for all Toradex modules. Please see the Toradex CE Libraries and Code Samples for up-to-date information.


Data Structures

struct  PIN_INSTANCE 

Macros

#define GPIO_VER_MAJ   2
 
#define GPIO_VER_MIN   3
 
#define GPIO_VER_BUILD   0
 
#define DIR_IN   0
 
#define DIR_OUT   1
 
#define GPIO_EDGE_RISING   1
 
#define EDGE_RISING   1
 
#define GPIO_EDGE_FALLING   2
 
#define EDGE_FALLING   2
 
#define GPIO_EDGE_BOTH   3
 
#define EDGE_BOTH   3
 
#define MFP_PULLUP   (MFP_PULL_SEL | MFP_PULLUP_EN)
 
#define MFP_PULLDOWN   (MFP_PULL_SEL | MFP_PULLDOWN_EN)
 
#define MFP_NOPULL   MFP_PULL_SEL
 
#define MFP_EDGE_DISABLE   MFP_EDGE_CLEAR
 
#define MFP_PULL_SEL   0x8000
 
#define MFP_PULLUP_EN   0x4000
 
#define MFP_PULLDOWN_EN   0x2000
 
#define MFP_SLEEP_SEL   0x0200
 
#define MFP_SLEEP_DATA   0x0100
 
#define MFP_SLEEP_OE_N   0x0080
 
#define MFP_EDGE_CLEAR   0x0040
 
#define MFP_EDGE_FALL_EN   0x0020
 
#define MFP_EDGE_RISE_EN   0x0010
 
Tegra Specific Defines
#define TEGRA_GPIONUM(x, y)   ((((x) - 'a') * 8) + y)
 
#define TEGRA_MAX_GROUPNAME   6
 
#define TEGRA_MAX_GROUPNUM   115
 
#define TEGRA_NOPULL   0x00
 
#define TEGRA_PULLDOWN   0x01
 
#define TEGRA_PULLUP   0x02
 
#define TEGRA_TRISTATE_ENABLED   0x01
 
#define TEGRA_TRISTATE_DISABLED   0x00
 

Functions

void InitGPIOLib ()
 
BOOL InitGPIOLibEx (void *pRegAdress)
 
BOOL InitGPIOLibTegraEx (void *pRegAddress, void *pRegTegraAPBMisc)
 
void DeInitGPIOLib ()
 
Tegra Specific Functions
BOOL TegraSetTristatePinGroup (DWORD gpioNum, BOOL tristate)
 
DWORD TegraGetTristatePinGroup (DWORD gpioNum)
 
BOOL TegraSetPullStatePinGroup (DWORD gpioNum, DWORD pullState)
 
DWORD TegraGetPullStatePinGroup (DWORD gpioNum)
 
BOOL TegraGetPinGroupName (DWORD gpioNum, char *groupName)
 
General Functions
DWORD GetPinDir (DWORD pinNum)
 
DWORD GetGPIODir (DWORD gpioNum)
 
void SetPinDir (DWORD gpioNum, BOOL dirOut)
 
void SetGPIODir (DWORD gpioNum, BOOL dirOut)
 
DWORD GetGPIOAltFn (DWORD gpioNum)
 
DWORD GetPinAltFn (DWORD pinNum)
 
BOOL SetPinAltFn (DWORD pinNum, DWORD altFn, BOOL dirOut)
 
void SetGPIOAltFn (DWORD gpioNum, DWORD altFn, BOOL dirOut)
 
DWORD GetGPIOMFPReg (DWORD gpioNum)
 
void SetGPIOMFPReg (DWORD gpioNum, DWORD mfpRegVal)
 
BOOL GetPinLevel (DWORD pinNum)
 
BOOL GetGPIOLevel (DWORD gpioNum)
 
BOOL SetPinLevel (DWORD pinNum, DWORD val)
 
void SetGPIOLevel (DWORD gpioNum, DWORD val)
 
DWORD GetGPIOEdgeDetect (DWORD gpioNum)
 
void SetGPIOEdgeDetect (DWORD gpioNum, DWORD edge)
 
BOOL GetGPIOEdgeStatus (DWORD gpioNum)
 
void ClearGPIOEdgeStatus (DWORD gpioNum)
 
BOOL GetGPIOFromPin (DWORD pin, BOOL extensionConnector, PIN_INSTANCE *gpio)
 
DWORD GetGPIOFunctionalityAltFn (DWORD gpioNum)
 
void GPIOGetLibVersion (DWORD *pVerMaj, DWORD *pVerMin, DWORD *pBuild)
 

Detailed Description

This library allows easy access to the GPIO pins.
Author:
kia
Rev:
1965
Date:
2014-01-24 10:57:47 +0100 (Fr, 24 Jan 2014)
Target Platforms:
PXAxx, T20

Macro Definition Documentation

#define DIR_IN   0
 
#define DIR_OUT   1
 
#define EDGE_BOTH   3
 
#define EDGE_FALLING   2
 
#define EDGE_RISING   1
 
#define GPIO_EDGE_BOTH   3
 
#define GPIO_EDGE_FALLING   2
 
#define GPIO_EDGE_RISING   1
 
#define GPIO_VER_BUILD   0
 
#define GPIO_VER_MAJ   2
 
#define GPIO_VER_MIN   3
 
#define MFP_EDGE_CLEAR   0x0040
 
#define MFP_EDGE_DISABLE   MFP_EDGE_CLEAR
 
#define MFP_EDGE_FALL_EN   0x0020
 
#define MFP_EDGE_RISE_EN   0x0010
 
#define MFP_NOPULL   MFP_PULL_SEL
 
#define MFP_PULL_SEL   0x8000
 
#define MFP_PULLDOWN   (MFP_PULL_SEL | MFP_PULLDOWN_EN)
 
#define MFP_PULLDOWN_EN   0x2000
 
#define MFP_PULLUP   (MFP_PULL_SEL | MFP_PULLUP_EN)
 
#define MFP_PULLUP_EN   0x4000
 
#define MFP_SLEEP_DATA   0x0100
 
#define MFP_SLEEP_OE_N   0x0080
 
#define MFP_SLEEP_SEL   0x0200
 
#define TEGRA_GPIONUM( x,
   
 )    ((((x) - 'a') * 8) + y)
 
#define TEGRA_MAX_GROUPNAME   6
 
#define TEGRA_MAX_GROUPNUM   115
 
#define TEGRA_NOPULL   0x00
 
#define TEGRA_PULLDOWN   0x01
 
#define TEGRA_PULLUP   0x02
 
#define TEGRA_TRISTATE_DISABLED   0x00
 
#define TEGRA_TRISTATE_ENABLED   0x01
 

Function Documentation

void ClearGPIOEdgeStatus(DWORD gpioNum) 
Clears GPIO Pin Edge Status
Parameters
[in]gpioNumGPIO Pin Number
void DeInitGPIOLib( ) 
 
DWORD GetGPIOAltFn(DWORD gpioNum) 
Get the Alternative Function setting of the specified GPIO Pin Number
Parameters
[in]gpioNum,:GPIO Pin Number
Return values
AlternativeFunction Setting Number
Remarks: On the Tegra, function can return -1 (0xFFFFFFFF)
DWORD GetGPIODir(DWORD gpioNum) 
Get the Input/Output direction of the specified GPIO Pin Number
Parameters
[in]gpioNumGPIO Pin Number
Return values
GPIODirection (0: Input, 1: Output)
DWORD GetGPIOEdgeDetect(DWORD gpioNum) 
Get the GPIO Edge detect
Parameters
[in]gpioNumGPIO Pin Number
Return values
[EDGE_RISING(1),:rising edge, EDGE_FALLING(2): falling edge]
BOOL GetGPIOEdgeStatus(DWORD gpioNum) 
Get GPIO Pin Edge Status
Parameters
[in]gpioNumGPIO Pin Number
Return values
EdgeStatus (0: Cleared, 1: Set)
BOOL GetGPIOFromPin(DWORD pin,
  BOOL extensionConnector,
  PIN_INSTANCEgpio 
 )  
Gets GPIO from SODIMM or Extension Pin.
Parameters
[in]pinPin Number (SODIMM pin or extension connector pin)
[in]extensionConnectorFALSE:SODIMM pin, TRUE:pin on Colibri PXA's FFC connector
[out]gpiogpio Number with second instance
Return values
TRUESuccess
FALSEError
DWORD GetGPIOFunctionalityAltFn(DWORD gpioNum) 
Gets the Alternative Function Status of a GPIO Pin
Parameters
[in]gpioNum,:GPIO Pin Number
Return values
AlternativeFunction Status Code
Normalcase 0;
NoGPIO Function: -1;
BOOL GetGPIOLevel(DWORD gpioNum) 
Get the logic level of the specified GPIO Pin Number
Parameters
[in]gpioNumGPIO Pin Number
Return values
GPIOLevel (False: Logic Low, True: Logic High)
DWORD GetGPIOMFPReg(DWORD gpioNum) 
Get the MRPReg setting of the specified GPIO Pin Number
Parameters
[in]gpioNum,:GPIO Number
Return values
MFPRegdata
DWORD GetPinAltFn(DWORD pinNum) 
Get the Alternative Function setting of the specified SODIMM Pin Number
Parameters
[in]pinNumSODIMM Pin Number
Return values
AlternativeFunction Setting Number
Remarks: On the Tegra, function can return -1 (0xFFFFFFFF)
DWORD GetPinDir(DWORD pinNum) 
Get the Input/Output direction of the specified SODIMM Pin Number
Parameters
[in]pinNumSODIMM Pin Number
Return values
GPIODirection (0: Input, 1: Output)
BOOL GetPinLevel(DWORD pinNum) 
Get the logic level of the specified SODIMM Pin Number
Parameters
[in]pinNumSodimm Pin Number
Return values
PinLevel (False: Logic Low, True: Logic High)
void GPIOGetLibVersion(DWORD * pVerMaj,
  DWORD * pVerMin,
  DWORD * pBuild 
 )  
Outputs library version
Parameters
[out]verMajMajor version number. Set this parameter to NULL if not required
[out]verMinMinor version number. Set this parameter to NULL if not required
[out]buildBuild number. Set this parameter to NULL if not required
void InitGPIOLib( ) 
 
BOOL InitGPIOLibEx(void * pRegAdress) 
 
BOOL InitGPIOLibTegraEx(void * pRegAddress,
  void * pRegTegraAPBMisc 
 )  
 
void SetGPIOAltFn(DWORD gpioNum,
  DWORD altFn,
  BOOL dirOut 
 )  
Set the Alternative Function setting of the specified GPIO Pin Number
Parameters
[in]gpioNum,:GPIO Number
[in]altFn,:Alternative Function Setting, use -1 to configure as GPIO.
[in]dirOut,:GPIO Direction [False: Input, True: Output]
void SetGPIODir(DWORD gpioNum,
  BOOL dirOut 
 )  
Set the Input/Output direction of the specified GPIO Pin Number
Parameters
[in]gpioNum,:GPIO Pin Number
[in]dirOutDirection (0: Input, 1:Output)
void SetGPIOEdgeDetect(DWORD gpioNum,
  DWORD edge 
 )  
Set the GPIO Pin Edge Detect - deprecated, Please use SetGPIOIrqEdge() in IntLib.
Deprecated:
Please use SetGPIOIrqEdge() in IntLib.
Parameters
[in]gpioNumGPIO Pin Number
[in]edge[EDGE_RISING(1): rising edge, EDGE_FALLING(2): falling edge]
void SetGPIOLevel(DWORD gpioNum,
  DWORD val 
 )  
Set the Logic level of a GPIO Pin
Parameters
[in]gpioNumGPIO Pin Number
[in]val[0: Logic Low >0: Logic High]
void SetGPIOMFPReg(DWORD gpioNum,
  DWORD mfpRegVal 
 )  
Set the MRPReg setting of the specified GPIO Pin Number
Parameters
[in]gpioNum,:GPIO Number
[in]mfpRegVal,:MFPREg Data
BOOL SetPinAltFn(DWORD pinNum,
  DWORD altFn,
  BOOL dirOut 
 )  
Set the Alternative Function setting of the specified SODIMM Pin Number
Parameters
[in]pinNum,:SODIMM Pin Number
[in]altFn,:Alternative Function Setting, use -1 to configure as GPIO.
[in]dirOut,:GPIO Direction [False: Input, True: Output]
Return values
TRUESuccess
FALSEError
void SetPinDir(DWORD gpioNum,
  BOOL dirOut 
 )  
Set the Input/Output direction of the specified SODIMM Pin Number
Parameters
[in]ponNumSODIMM Pin Number
[in]dirOutDirection (0: Input, 1:Output)
BOOL SetPinLevel(DWORD pinNum,
  DWORD val 
 )  
Set the logic level of the specified SODIMM Pin Number
Parameters
[in]pinNumSODIMM Pin. Number
[in]val[0: Logic Low >0: Logic High]
Return values
TRUESuccess
FALSEError
BOOL TegraGetPinGroupName(DWORD gpioNum,
  char * groupName 
 )  
Get the Pin Group Name of a GPIO pin.
Parameters
[in]gpioNumGPIO Pin Number
[out]*groupNameAscii string containing the name of the Pin group max TEGRA_MAX_GROUPNAME characters.
Return values
TRUESuccess
FALSEError
DWORD TegraGetPullStatePinGroup(DWORD gpioNum) 
Get the Pullup/Pulldown setting of a GPIO pin group
Parameters
[in]gpioNumGPIO Pin Number
Return values
Pullstatus (0:floating, 1:pulldown, 2:pullup)
DWORD TegraGetTristatePinGroup(DWORD gpioNum) 
Get the Tristate setting of a pin group of GPIO pins.
Parameters
[in]gpioNumGPIO Pin Number
Return values
1Tristated
0Active
BOOL TegraSetPullStatePinGroup(DWORD gpioNum,
  DWORD pullState 
 )  
Set the Pullup/Pulldown setting of a pin group of GPIO pins.
Parameters
[in]gpioNumGPIO Pin Number
[in]pullState(0:floating, 1:pulldown, 2:pullup)
Return values
TRUESuccess
FALSEError
Remarks: Please note - this affects the whole pin group.
BOOL TegraSetTristatePinGroup(DWORD gpioNum,
  BOOL tristate 
 )  
Updates the Tristate setting of a pin group of GPIO pins.
Parameters
[in]gpioNumGPIO Pin Number
[in]tristate(1:tristated, 0:detristated)
Return values
TRUESuccess
FALSEError
Remarks: Please note - this affects the whole pin group.


Send Feedback!