Search by Tags

GPIO Lib API

 

Compare with Revision




Subscribe for this article updates

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

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] gpioNum GPIO 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
Alternative Function 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] gpioNum GPIO Pin Number
Return values
GPIO Direction (0: Input, 1: Output)
DWORD GetGPIOEdgeDetect ( DWORD  gpioNum )

Get the GPIO Edge detect

Parameters
[in] gpioNum GPIO 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] gpioNum GPIO Pin Number
Return values
Edge Status (0: Cleared, 1: Set)
BOOL GetGPIOFromPin ( DWORD  pin,
BOOL  extensionConnector,
PIN_INSTANCE gpio
)

Gets GPIO from SODIMM or Extension Pin.

Parameters
[in] pin Pin Number (SODIMM pin or extension connector pin)
[in] extensionConnector FALSE:SODIMM pin, TRUE:pin on Colibri PXA's FFC connector
[out] gpio gpio Number with second instance
Return values
TRUE Success
FALSE Error
DWORD GetGPIOFunctionalityAltFn ( DWORD  gpioNum )

Gets the Alternative Function Status of a GPIO Pin

Parameters
[in] gpioNum,: GPIO Pin Number
Return values
Alternative Function Status Code
Normal case 0;
No GPIO Function: -1;
BOOL GetGPIOLevel ( DWORD  gpioNum )

Get the logic level of the specified GPIO Pin Number

Parameters
[in] gpioNum GPIO Pin Number
Return values
GPIO Level (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
MFPReg data
DWORD GetPinAltFn ( DWORD  pinNum )

Get the Alternative Function setting of the specified SODIMM Pin Number

Parameters
[in] pinNum SODIMM Pin Number
Return values
Alternative Function 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] pinNum SODIMM Pin Number
Return values
GPIO Direction (0: Input, 1: Output)
BOOL GetPinLevel ( DWORD  pinNum )

Get the logic level of the specified SODIMM Pin Number

Parameters
[in] pinNum Sodimm Pin Number
Return values
Pin Level (False: Logic Low, True: Logic High)
void GPIOGetLibVersion ( DWORD *  pVerMaj,
DWORD *  pVerMin,
DWORD *  pBuild
)

Outputs library version

Parameters
[out] verMaj Major version number. Set this parameter to NULL if not required
[out] verMin Minor version number. Set this parameter to NULL if not required
[out] build Build 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] dirOut Direction (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] gpioNum GPIO 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] gpioNum GPIO 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
TRUE Success
FALSE Error
void SetPinDir ( DWORD  gpioNum,
BOOL  dirOut
)

Set the Input/Output direction of the specified SODIMM Pin Number

Parameters
[in] ponNum SODIMM Pin Number
[in] dirOut Direction (0: Input, 1:Output)
BOOL SetPinLevel ( DWORD  pinNum,
DWORD  val
)

Set the logic level of the specified SODIMM Pin Number

Parameters
[in] pinNum SODIMM Pin. Number
[in] val [0: Logic Low >0: Logic High]
Return values
TRUE Success
FALSE Error
BOOL TegraGetPinGroupName ( DWORD  gpioNum,
char *  groupName
)

Get the Pin Group Name of a GPIO pin.

Parameters
[in] gpioNum GPIO Pin Number
[out] *groupName Ascii string containing the name of the Pin group max TEGRA_MAX_GROUPNAME characters.
Return values
TRUE Success
FALSE Error
DWORD TegraGetPullStatePinGroup ( DWORD  gpioNum )

Get the Pullup/Pulldown setting of a GPIO pin group

Parameters
[in] gpioNum GPIO Pin Number
Return values
Pull status (0:floating, 1:pulldown, 2:pullup)
DWORD TegraGetTristatePinGroup ( DWORD  gpioNum )

Get the Tristate setting of a pin group of GPIO pins.

Parameters
[in] gpioNum GPIO Pin Number
Return values
1 Tristated
0 Active
BOOL TegraSetPullStatePinGroup ( DWORD  gpioNum,
DWORD  pullState
)

Set the Pullup/Pulldown setting of a pin group of GPIO pins.

Parameters
[in] gpioNum GPIO Pin Number
[in] pullState (0:floating, 1:pulldown, 2:pullup)
Return values
TRUE Success
FALSE Error

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] gpioNum GPIO Pin Number
[in] tristate (1:tristated, 0:detristated)
Return values
TRUE Success
FALSE Error

Remarks: Please note - this affects the whole pin group.