MityDSP Documentation Index

tcDspGpio

Introduction

The tcDspGpio class may be used to provide access to a single GPIO core. Each instance of DspGpio provides access to 32 GPIO pins, and installs an ISR at the specified interrupt level to report changes in values (rising or falling edge) for any input pins thus configured.

When created, the constructor requires a valid base address for the GPIO core. Individual pin direction, interrupt enables, and semaphores used to count interrupts are all set via the configurePins method.

Current pin values are retrieved via readPins. These represent the values currently being read/written for each pin.

Current pin values are set via writePins. For pins configured as output, these values are immediately implemented. For pins configured as input, these values become the defaults used if/when the pin is ever reconfigured as an output (used to avoid glitches prior to enabling an output).

There is no limit to the number of instances of tcDspGpio that may be created.

An instance of the tcDspGpio class is created by specifying the firmware base address of the core and the interrupt level used. This core supports specifying a level of gnAutoLevel (which is the default if no level is provided), which automatically installs a vectored interrupt.

See also:
MityDSP::tcDspInterruptDispatch Class Reference
MityDSP::tcDspGpio Class Reference

Example

This is a simple example of tcDspGpio creation and usage:

 {
     unsigned int values;
     unsigned int my_base_addr = 0xB0000300;
     tcDspGPIO    *my_gpio;
     SEM_Handle   my_sem = SEM_create(0, NULL);

     // create a GPIO interface
     my_gpio = new tcDspGpio((void *)my_base_addr);

     // configure a couple pins... pins 20 and 21 as an output
     my_gpio->configurePins(gnGPIO_20|gnGPIO_21, gnGpioOutput);
     // ... pin 12 as an interrupt with rising edge interrupts enabled
     my_gpio->configurePins(gnGPIO_12, gnGpioInput, true, false, my_sem);

     for (int i=0; i<10; i++)
     {
        ...
        // send something...
        my_gpio->writePins(gnGPIO_20, gnGPIO_ALL);
        my_gpio->writePins(gnGPIO_21, 0);
        ...
        // read value
        values = my_gpio->readPins(gnGPIO_12);
        ...
        // wait for rising edge of pin 12
        SEM_pend(my_sem, SYS_FOREVER);
        ...
     }

     ...
  } 

  
Generated on Fri Sep 23 16:33:44 2011 for MityDSP Core by  Doxygen Version 1.6.1
Copyright © 2009, Critical Link LLC, All rights reserved.