gpio.h File Reference

GPIO Routines. More...

#include "TIMotorLIB.h"

Go to the source code of this file.

Defines

#define QUAL_OFFSET   0x1
#define MUX_OFFSET   0x3
#define DIR_OFFSET   0x5
#define PUD_OFFSET   0x6
#define DAT_OFFSET   0x0
#define SET_OFFSET   0x1
#define CLEAR_OFFSET   0x2
#define TOGGLE_OFFSET   0x3
#define GPIO_BIT_2_NAME(bit)   GPIO ## bit
#define GPIO_PORT_BIT_2_NAME(port, bit)   GPIO ## bit + (port<<3)
#define GET_MUX_BIT(bit)   (bit < 16 ? bit : (bit-16))
#define _GPIO0   GPIOA, 0
#define _GPIO1   GPIOA, 1
#define _GPIO2   GPIOA, 2
#define _GPIO3   GPIOA, 3
#define _GPIO4   GPIOA, 4
#define _GPIO5   GPIOA, 5
#define _GPIO6   GPIOA, 6
#define _GPIO7   GPIOA, 7
#define _GPIO8   GPIOA, 8
#define _GPIO9   GPIOA, 9
#define _GPIO10   GPIOA, 10
#define _GPIO11   GPIOA, 11
#define _GPIO12   GPIOA, 12
#define _GPIO13   GPIOA, 13
#define _GPIO14   GPIOA, 14
#define _GPIO15   GPIOA, 15
#define _GPIO16   GPIOA, 16
#define _GPIO17   GPIOA, 17
#define _GPIO18   GPIOA, 18
#define _GPIO19   GPIOA, 19
#define _GPIO20   GPIOA, 20
#define _GPIO21   GPIOA, 21
#define _GPIO22   GPIOA, 22
#define _GPIO23   GPIOA, 23
#define _GPIO24   GPIOA, 24
#define _GPIO25   GPIOA, 25
#define _GPIO26   GPIOA, 26
#define _GPIO27   GPIOA, 27
#define _GPIO28   GPIOA, 28
#define _GPIO29   GPIOA, 29
#define _GPIO30   GPIOA, 30
#define _GPIO31   GPIOA, 31
#define _GPIO32   GPIOB, 0
#define _GPIO33   GPIOB, 1
#define _GPIO34   GPIOB, 2
#define _GPIO35   GPIOB, 3
#define _GPIO36   GPIOB, 4
#define _GPIO37   GPIOB, 5
#define _GPIO38   GPIOB, 6
#define _GPIO39   GPIOB, 7
#define _GPIO40   GPIOB, 8
#define _GPIO41   GPIOB, 9
#define _GPIO42   GPIOB, 10
#define _GPIO43   GPIOB, 11
#define _GPIO44   GPIOB, 12
#define _GPIO45   GPIOB, 13
#define _GPIO46   GPIOB, 14
#define _GPIO47   GPIOB, 15
#define _GPIO48   GPIOB, 16
#define _GPIO49   GPIOB, 17
#define _GPIO50   GPIOB, 18
#define _GPIO51   GPIOB, 19
#define _GPIO52   GPIOB, 20
#define _GPIO53   GPIOB, 21
#define _GPIO54   GPIOB, 22
#define _GPIO55   GPIOB, 23
#define _GPIO56   GPIOB, 24
#define _GPIO57   GPIOB, 25
#define _GPIO58   GPIOB, 26
#define _GPIO59   GPIOB, 27
#define _GPIO60   GPIOB, 28
#define _GPIO61   GPIOB, 29
#define _GPIO62   GPIOB, 30
#define _GPIO63   GPIOB, 31
#define _GPIO64   GPIOC, 0
#define _GPIO65   GPIOC, 1
#define _GPIO66   GPIOC, 2
#define _GPIO67   GPIOC, 3
#define _GPIO68   GPIOC, 4
#define _GPIO69   GPIOC, 5
#define _GPIO70   GPIOC, 6
#define _GPIO71   GPIOC, 7
#define _GPIO72   GPIOC, 8
#define _GPIO73   GPIOC, 9
#define _GPIO74   GPIOC, 10
#define _GPIO75   GPIOC, 11
#define _GPIO76   GPIOC, 12
#define _GPIO77   GPIOC, 13
#define _GPIO78   GPIOC, 14
#define _GPIO79   GPIOC, 15
#define _GPIO80   GPIOC, 16
#define _GPIO81   GPIOC, 17
#define _GPIO82   GPIOC, 18
#define _GPIO83   GPIOC, 19
#define _GPIO84   GPIOC, 20
#define _GPIO85   GPIOC, 21
#define _GPIO86   GPIOC, 22
#define _GPIO87   GPIOC, 23
#define GPIO_LOW   (Uint32)0
#define GPIO_HIGH   (Uint32)1

Enumerations

enum  GPIO_PORT { GPIOA = 0, GPIOB = 0x4, GPIOC = 0x8 }
 

enumeration for port selection

More...
enum  GPIO_DIR { GPIO_INPUT, GPIO_OUTPUT }
 

enumeration for port direction

More...
enum  GPIO_PUD { GPIO_PULL_EN, GPIO_PULL_DIS }
 

Disable/Enable internal pullup resistor.

More...
enum  GPIO_PERPH { GPIO, PERPH_1, PERPH_2, PERPH_3 }
 

Select peripheral.

More...

Functions

static void ConfigureGPIOPort (GPIO_PORT port, Uint16 bit, GPIO_DIR dir, GPIO_PERPH perPh, GPIO_PUD pud, Uint32 val)
 Configure pin as a GPIO.
static void WriteGPIOPort (GPIO_PORT port, Uint16 bit, Uint32 val)
static void ToggleGPIOPort (GPIO_PORT port, Uint16 bit)
static void SetGPIOPort (GPIO_PORT port, Uint16 bit)
static void ClearGPIOPort (GPIO_PORT port, Uint16 bit)
static unsigned ReadGPIOPort (GPIO_PORT port, Uint16 bit)

Detailed Description

GPIO Routines.

File Name: gpio.h Project: TIMotorLIB

TI Doc: SPRS439

SPRUFB

Author:
Pablo Garcia (pgarcia@isa.uniovi.es)

This module allows to easy configure and use GPIO ports. GPIO ports are multiplexed as shown in TI doc (SPRUFB, pp 61 to 65). Up to three different peripherals can use the same port (SPRUFB, pp 75 to 77). To configure a paricular GPIO line for a particular function, see TI doc (SPRUFB, pp 67).

Todo:
Input qualification (SPRUFB, pp 70), external interrupts.
Date:
2008

Definition in file gpio.h.


Define Documentation

#define CLEAR_OFFSET   0x2

Definition at line 51 of file gpio.h.

#define DAT_OFFSET   0x0

Definition at line 49 of file gpio.h.

#define DIR_OFFSET   0x5

Definition at line 47 of file gpio.h.

#define GET_MUX_BIT ( bit   )     (bit < 16 ? bit : (bit-16))

Definition at line 57 of file gpio.h.

#define GPIO_BIT_2_NAME ( bit   )     GPIO ## bit

Definition at line 54 of file gpio.h.

#define GPIO_HIGH   (Uint32)1
Examples:
TIMotorLIBExampleHrdw/main.c, and TIMotorLIBExampleSw/main.c.

Definition at line 158 of file gpio.h.

#define GPIO_LOW   (Uint32)0

Definition at line 157 of file gpio.h.

#define GPIO_PORT_BIT_2_NAME ( port,
bit   )     GPIO ## bit + (port<<3)

Definition at line 55 of file gpio.h.

#define MUX_OFFSET   0x3

Definition at line 46 of file gpio.h.

#define PUD_OFFSET   0x6

Definition at line 48 of file gpio.h.

#define QUAL_OFFSET   0x1

Definition at line 45 of file gpio.h.

#define SET_OFFSET   0x1

Definition at line 50 of file gpio.h.

#define TOGGLE_OFFSET   0x3

Definition at line 52 of file gpio.h.


Enumeration Type Documentation

enum GPIO_DIR

enumeration for port direction

Enumerator:
GPIO_INPUT 

configure port as input

GPIO_OUTPUT 

configure port as output

Definition at line 172 of file gpio.h.

enum GPIO_PERPH

Select peripheral.

Enumerator:
GPIO 

General input/output.

PERPH_1 

Peripheral 1.

PERPH_2 

Peripheral 2.

PERPH_3 

Peripheral 3.

Definition at line 184 of file gpio.h.

enum GPIO_PORT

enumeration for port selection

Enumerator:
GPIOA 

port A

GPIOB 

port B

GPIOC 

port C

Definition at line 165 of file gpio.h.

enum GPIO_PUD

Disable/Enable internal pullup resistor.

Enumerator:
GPIO_PULL_EN 

enable pullup

GPIO_PULL_DIS 

disable pullup

Definition at line 178 of file gpio.h.


Function Documentation

static void ClearGPIOPort ( GPIO_PORT  port,
Uint16  bit 
) [inline, static]

Clears value in selected line at given port

Parameters:
port Selected port (GPIOA/GPIOB/GPIOC)
bit Selected bit (0-31)

Definition at line 302 of file gpio.h.

static void ConfigureGPIOPort ( GPIO_PORT  port,
Uint16  bit,
GPIO_DIR  dir,
GPIO_PERPH  perPh,
GPIO_PUD  pud,
Uint32  val 
) [inline, static]

Configure pin as a GPIO.

If dir = GPIO_OUTPUT, generated code is equivalent to:

GpioCtrlRegs.GPYPUD.bit.GPIOX = pull; // Enable pullup on GPIOX

GpioDataRegs.GPYSET.bit.GPIOX = val; // Load output latch

GpioCtrlRegs.GPYMUXx.bit.GPIOX = 0; // General purpouse output

GpioCtrlRegs.GPYDIR.bit.GPIOX = 1; // GPIOX = output

If dir = GPIO_INPUT, generated code is equivalent to:

GpioCtrlRegs.GPYPUD.bit.GPIOX = pull; // Enable pullup on GPIOX

GpioCtrlRegs.GPYMUXx.bit.GPIOX = 0; // General purpouse input

GpioCtrlRegs.GPYDIR.bit.GPIOX = 0; // GPIOX = input

Parameters:
port Selected port (GPIOA/GPIOB/GPIOC)
bit Selected line (0-31)
dir Direction (GPIO_INPUT/GPIO_OUTPUT)
perPh Peripheral (GPIO/PERPH_1/PERPH_2/PERPH_3)
pud Disable/enable pullup resistor (GPIO_PULL_DIS/GPIO_PULL_EN)
val Default value to load in the latch register using GPIOxSET
Examples:
TIMotorLIBExampleHrdw/main.c, and TIMotorLIBExampleSw/main.c.

Definition at line 237 of file gpio.h.

static unsigned ReadGPIOPort ( GPIO_PORT  port,
Uint16  bit 
) [inline, static]

Reads value in selected line at given port

Parameters:
port Selected port (GPIOA/GPIOB/GPIOC)
bit Selected bit (0-31)
Returns:
readed value

Definition at line 316 of file gpio.h.

static void SetGPIOPort ( GPIO_PORT  port,
Uint16  bit 
) [inline, static]

Set value in selected line at given port using the set GPIOxSET register

Parameters:
port Selected port (GPIOA/GPIOB/GPIOC)
bit Selected bit (0-31)

Definition at line 288 of file gpio.h.

static void ToggleGPIOPort ( GPIO_PORT  port,
Uint16  bit 
) [inline, static]

Toggles value in selected line at given port

Parameters:
port Selected port (GPIOA/GPIOB/GPIOC)
bit Selected bit (0-31)
Examples:
TIMotorLIBExampleHrdw/main.c, and TIMotorLIBExampleSw/main.c.

Definition at line 274 of file gpio.h.

static void WriteGPIOPort ( GPIO_PORT  port,
Uint16  bit,
Uint32  val 
) [inline, static]

Write value in selected line at given port using the latch GPIOxDAT register

Parameters:
port Selected port (GPIOA/GPIOB/GPIOC)
bit Selected bit (0-31)
val 

Definition at line 261 of file gpio.h.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines
Generated on Mon Apr 23 12:59:21 2012 for TIMotorLIB by  doxygen 1.6.3