GPIO Driver

From ArmadeusWiki
Revision as of 21:14, 27 March 2007 by JulienB (Talk | contribs) (Module compilation & installation)

Jump to: navigation, search

On this page, you will find all the informations needed to use the Armadeus GPIO driver.

Module compilation & installation

The first thing you have to do is to compile the driver. The only way to do that actually is to compile it as a module:

[host]$ cd armadeus/
[host]$ make linux-menuconfig

Then Go in menu: Device Drivers ---> Armadeus specific drivers and choose <M> Armadeus GPIO driver + <M> Armadeus Parallel Port driver Exit and save your kernel configuration Compile it:

[host]$ make linux

When compiled, you will obtain 3 modules in armadeus/target/linux/modules/gpio/:

  • gpio.ko: this is the main driver. It should be loaded first and will allow you to easily control gpio pin from user space.
  • ppdev.ko: this is an extension driver to add PPDEV emulation. This way you will be able to emulate a standard parallel port on one GPIO port (and then for example connect a LCD)
  • loadfpga.ko: this is an extension driver to add the possibility to load the fpga on APF boards from linux userspace -> fpga reprogrammation after linux boot.

Then, you have to:

  • copy these modules on your rootfs in /lib/modules/2.6.18.1/extra/gpio (dont forget modules.dep) or reflash your rootfs
  • copy loadgpio.sh script on your rootfs in /etc/

After that you can launch:

# sh /etc/loadgpio.sh

or look inside this script if you want to manually enter the module parameters

# modprobe gpio portB_init=0,0,0x00FFFF00,0,0,0,0,0,0x0FF00000,0,0,0,0,0,0,0x0FF00000

gpio module parameters are values for PORTA, PORTB, PORTC, PORTD configuration registers in following order: DDIR, OCR1, OCR2, ICONFA1, ICONFA2, ICONFB1, ICONFB2, DR, GIUS, SSR, ICR1, ICR2, IMR, GPR, SWR, PUEN,

Driver usage

GPIO driver is usable through 2 interfaces:

  • use /proc/drivers/gpio/portXdir to read (cat) or write (echo) pin direction
  • use /proc/drivers/gpio/portX to read (cat) or write (echo) pin status

Examples: See which IO-Pins of PortD are configured as inputs, and which are outputs ('1' = output, '0' = input):

# cat /proc/driver/gpio/portDdir##

Configure the IO-Pins 30, 28, 23, 22 and 21 of PortB as outputs, all others are inputs:

# echo 01010000111000000000000000000000 >/proc/driver/gpio/portBdir

Read the status of the IOs of PortB:

# cat /proc/driver/gpio/portB

Set bits 30, 28 and 23 of PortB to '1', all other outputs to '0':

# echo 01010000100000000000000000000000 > /proc/driver/gpio/portB

Links