7600 EVGPIO: Difference between revisions

From embeddedTS Manuals
(Created page with "This board features the EVGPIO core (Event Driven GPIO) which allows a low bandwidth mechanism to monitor all FPGA DIO on a shared interrupt. All DIO are accessed atomically ...")
 
(Fixed typos)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
This board features the EVGPIO core (Event Driven GPIO) which allows a low bandwidth mechanism to monitor all FPGA DIO on a shared interrupt.  All DIO are accessed atomically through two registers.  The Data/IRQ En. register is used to read DIO state changes, set output values, and enable IRQ on DIO state changes.  The Data Direction Register is used to set a DIO to an input or output.  The Data/IRQ En. Register will only return data on reads when the IRQ En. bit is set on a DIO Number, a DIO pin has changed state since the IRQ En. was set, and all previous state changes of DIO have been read.  The Data Direction Register will never read back anything other than 0x0.   
This board features the EVGPIO core (Event Driven GPIO) which allows a low bandwidth mechanism to monitor all FPGA DIO on a shared interrupt.  All DIO are accessed atomically through two registers.  The Data/IRQ En. register is used to read DIO state changes, set output values, and enable IRQ on DIO state changes.  The Data Direction Register is used to set a DIO to an input or output.  The Data/IRQ En. Register will only return data on reads when the IRQ En. bit is set on a DIO Number, a DIO pin has changed state since the IRQ En. was set, and all previous state changes of DIO have been read.  The Data Direction Register will never read back anything other than 0x0.   
<br><br>
Once the EVGPIO core senses a state change it will wait to be read before updating other pin states.  What this means is, DIO_X changes state and the EVGPIO core generates an interrupt; if DIO_Y changes state and then reverts back before the first DIO_X change is read, then the DIO_Y state change is never seen.  That being said, if DIO_X changes state, then DIO_Y changes state once, and DIO_X changes back before the first DIO_X state change is read, all three events will be reported by the EVPGIO core.  At most, the core will retain two state changes per DIO.  Pin states are only updated while the EVGPIO core is idling waiting for a state change, or once a reported state change is read.  Once a state change has been read for a particular DIO, then the EVGPIO core can queue up another change.  If however a particular DIO cycles multiple times before it is read, the number of times it changed state will be lost and the EVGPIO core will return at most 2 state changes.  Because of this it, is beneficial to use the userspace IRQ examples or evgpioctl to watch pin states and read them quickly to an end applicaiton.  See the [[#Interrupts|Interrupts]] section for more information on IRQ latency with userspace IRQs and the NBUS. 
<br><br>


We provide "evgpioctl" which can be used to access these registers easily from the command line:


<pre>
Once the EVGPIO core senses a state change it will wait to be read before updating other pin states.  What this means is, DIO_X changes state and the EVGPIO core generates an interrupt; if DIO_Y changes state and then reverts back before the first DIO_X change is read, then the DIO_Y state change is never seen.  That being said, if DIO_X changes state, then DIO_Y changes state once, and DIO_X changes back before the first DIO_X state change is read, all three events will be reported by the EVGPIO core.  At most, the core will retain two state changes per DIO.  Pin states are only updated while the EVGPIO core is idling waiting for a state change, or once a reported state change is read.  Once a state change has been read for a particular DIO, then the EVGPIO core can queue up another change.  If however a particular DIO cycles multiple times before it is read, the number of times it changed state will be lost and the EVGPIO core will return at most 2 state changes.  Because of this it, is beneficial to use the userspace IRQ examples or evgpioctl to watch pin states and read them quickly to an end application.  See the [[#Interrupts|Interrupts]] section for more information on IRQ latency with userspace IRQs and the NBUS.
# evgpioctl --help
Usage: evgpioctl [OPTIONS] ...
EVGPIO utility


  -i, --getin  <dio>    Returns the input value of a DIO
  -s, --setout <dio>    Sets a DIO output value high
  -l, --clrout <dio>    Sets a DIO output value low
  -o, --ddrout <dio>    Set DIO to an output
  -d, --ddrin <dio>    Set DIO to an input
  -m, --setmask <dio>  Mask out a DIO so it does not provide input
                        event changes and trigger the shared IRQ
  -c, --clrmask <dio>  Clear the mask from a DIO so it provides input
                        event changes and trigger the shared IRQ
  -w, --watch          Prints csv output when any unmasked DIO changes
                        <dio>,<1=high,0=low>
</pre>


This provides a simple interface that can be used in scripts, or wrapped for higher level software access.
The EVGPIO data and mask registers can be used directly in your application. Setting a pin direction, output value, and reading input changes are accessed through the EVGPIO data register.
<source lang=bash>
# Set DIO 31 to a high output
evgpioctl --ddrout 31 --setout 31


# Set DIO 31 to a low output
evgpioctl --setout 31
# Read the value of DIO 30
evgpioctl --ddrin 30 --getin 30
# The input return values are parsable and can be used easily in scripts:
eval $(evgpioctl --getin 30)
echo $dio30
</source>
The sources for this utility are available here:
* [ftp://ftp.embeddedarm.com/ts-arm-sbc/ts-7600-linux/sources/evgpio.c evgpio.c]
* [ftp://ftp.embeddedarm.com/ts-arm-sbc/ts-7600-linux/sources/evgpio.h evgpio.h]
* [ftp://ftp.embeddedarm.com/ts-arm-sbc/ts-7600-linux/sources/evgpioctl.c evgpioctl.c]
You can also manipulate the EVGPIO data and mask registers directly in your application.
Setting a pin direction, output value, and reading input changes are accessed through the EVPGIO data register.<br>
Using Number 0 to 69 will set Value to DIO_Number.  Using Number 70 to 127 will set IRQ Enable for DIO_(Number - 70).  Note that this scheme will only allow interrupts on DIO 0 to 57.  See [[#Interrupts|Interrupts]] for more information on using these interrupts, and see [[#Syscon|Syscon]] for information on where this EVGPIO core is located in address space.<br>
Using Number 0 to 69 will set Value to DIO_Number.  Using Number 70 to 127 will set IRQ Enable for DIO_(Number - 70).  Note that this scheme will only allow interrupts on DIO 0 to 57.  See [[#Interrupts|Interrupts]] for more information on using these interrupts, and see [[#Syscon|Syscon]] for information on where this EVGPIO core is located in address space.<br>
{| class=wikitable
{| class=wikitable

Latest revision as of 14:24, 27 October 2016

This board features the EVGPIO core (Event Driven GPIO) which allows a low bandwidth mechanism to monitor all FPGA DIO on a shared interrupt. All DIO are accessed atomically through two registers. The Data/IRQ En. register is used to read DIO state changes, set output values, and enable IRQ on DIO state changes. The Data Direction Register is used to set a DIO to an input or output. The Data/IRQ En. Register will only return data on reads when the IRQ En. bit is set on a DIO Number, a DIO pin has changed state since the IRQ En. was set, and all previous state changes of DIO have been read. The Data Direction Register will never read back anything other than 0x0.


Once the EVGPIO core senses a state change it will wait to be read before updating other pin states. What this means is, DIO_X changes state and the EVGPIO core generates an interrupt; if DIO_Y changes state and then reverts back before the first DIO_X change is read, then the DIO_Y state change is never seen. That being said, if DIO_X changes state, then DIO_Y changes state once, and DIO_X changes back before the first DIO_X state change is read, all three events will be reported by the EVGPIO core. At most, the core will retain two state changes per DIO. Pin states are only updated while the EVGPIO core is idling waiting for a state change, or once a reported state change is read. Once a state change has been read for a particular DIO, then the EVGPIO core can queue up another change. If however a particular DIO cycles multiple times before it is read, the number of times it changed state will be lost and the EVGPIO core will return at most 2 state changes. Because of this it, is beneficial to use the userspace IRQ examples or evgpioctl to watch pin states and read them quickly to an end application. See the Interrupts section for more information on IRQ latency with userspace IRQs and the NBUS.


The EVGPIO data and mask registers can be used directly in your application. Setting a pin direction, output value, and reading input changes are accessed through the EVGPIO data register.

Using Number 0 to 69 will set Value to DIO_Number. Using Number 70 to 127 will set IRQ Enable for DIO_(Number - 70). Note that this scheme will only allow interrupts on DIO 0 to 57. See Interrupts for more information on using these interrupts, and see Syscon for information on where this EVGPIO core is located in address space.

EVGPIO Data/IRQ En. Register
Bits Description
15:9 Reserved (Write 0)
8 Valid Read Data [1]
7 Value
6:0 DIO/Mask Number
  1. When writing, write 0. During a read this indicates if this read includes new valid changes. After an interrupt this register should be read until this bit returns 0.


The second register is Data Direction Register. DIO Number is set to an Output when bit 7 is set, and set to an Input when bit7 is cleared.

EVGPIO Data Direction Register
Bits Description
15:8 Reserved (Write 0)
7 Output/Input
6:0 DIO number