Difference between revisions of "DESK-MP1-L/Peripherals/GPIOs"

From DAVE Developer's Wiki
Jump to: navigation, search
(Created page with "==Peripheral GPIOs == ETRA can handle external pins in many different ways and most of them can be configured as GPIOs. When a pin is set as a GPIO, it is possible to read it...")
 
 
(9 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
<section begin=History/>
 +
{| style="border-collapse:collapse; "
 +
!colspan="4" style="width:100%; text-align:left"; border-bottom:solid 2px #ededed"|History
 +
|-
 +
!style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#73B2C7; padding:5px; color:white"|Issue Date
 +
!style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#73B2C7; padding:5px; color:white"|Notes
 +
|-
 +
|style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#edf8fb; padding:5px; color:#000000"|2023/08/02
 +
|style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#edf8fb; padding:5px; color:#000000"|DESK-MP1-L-1.0.0 release
 +
|-
 +
|}
 +
<section end=History/>
 +
<section begin=Body/>
 +
 
==Peripheral GPIOs ==
 
==Peripheral GPIOs ==
  
ETRA can handle external pins in many different ways and most of them can be configured as GPIOs. When a pin is set as a GPIO, it is possible
+
In [[ETRA_SOM | ETRA SOM]] there is an I2C I/O Expander: in this way, ETRA can handle several pins in different ways and most of them can be configured as GPIOs. These GPIOs are available in J11 connector.
to read its value, change its direction or change output value directly from the shell.
 
  
===Accessing the peripheral===
+
To configure and write/read the GPIOs you need to configure the I/O expander via I2C commands.
  
==== Usage with i2c command ====
+
=== Accessing the peripheral ===
  
Set all GPIO on output mode, all pin low
+
==== Usage with I2C command ====
 +
 
 +
Set all GPIO on output mode, all pins low:
  
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
Line 16: Line 31:
 
</pre>
 
</pre>
  
set all pin to high, one by one
+
Set all pin to high, one by one:
  
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
Line 40: Line 55:
 
</pre>
 
</pre>
  
set all pin to high and set all to low one by one
+
Set all pin to high and set all to low one by one:
 +
 
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
 
root@desk-mp1:~# i2cset -y 1 0x34 0x2a 0xff
 
root@desk-mp1:~# i2cset -y 1 0x34 0x2a 0xff
Line 67: Line 83:
 
</pre>
 
</pre>
  
set gpio input mode, disable debounce
+
Set GPIO input mode, disable debounce:
  
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
Line 79: Line 95:
 
</pre>
 
</pre>
  
Read input value
+
Read input value:
  
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
Line 86: Line 102:
 
root@desk-mp1:~# i2cget -y 1 0x34 0x18
 
root@desk-mp1:~# i2cget -y 1 0x34 0x18
 
</pre>
 
</pre>
 +
 +
----
 +
 +
[[Category:ETRA]] [[Category:ETRA_SBC]]

Latest revision as of 11:14, 8 January 2024

History
Issue Date Notes
2023/08/02 DESK-MP1-L-1.0.0 release


Peripheral GPIOs[edit | edit source]

In ETRA SOM there is an I2C I/O Expander: in this way, ETRA can handle several pins in different ways and most of them can be configured as GPIOs. These GPIOs are available in J11 connector.

To configure and write/read the GPIOs you need to configure the I/O expander via I2C commands.

Accessing the peripheral[edit | edit source]

Usage with I2C command[edit | edit source]

Set all GPIO on output mode, all pins low:

root@desk-mp1:~# i2cset -y 1 0x34 0x30 0xff
root@desk-mp1:~# i2cset -y 1 0x34 0x31 0xff
root@desk-mp1:~# i2cset -y 1 0x34 0x32 0x07

Set all pin to high, one by one:

root@desk-mp1:~# i2cset -y 1 0x34 0x2a 0x01
root@desk-mp1:~# i2cset -y 1 0x34 0x2a 0x02
root@desk-mp1:~# i2cset -y 1 0x34 0x2a 0x04
root@desk-mp1:~# i2cset -y 1 0x34 0x2a 0x08
root@desk-mp1:~# i2cset -y 1 0x34 0x2a 0x10
root@desk-mp1:~# i2cset -y 1 0x34 0x2a 0x20
root@desk-mp1:~# i2cset -y 1 0x34 0x2a 0x40
root@desk-mp1:~# i2cset -y 1 0x34 0x2a 0x80
root@desk-mp1:~# i2cset -y 1 0x34 0x2b 0x01
root@desk-mp1:~# i2cset -y 1 0x34 0x2b 0x02
root@desk-mp1:~# i2cset -y 1 0x34 0x2b 0x04
root@desk-mp1:~# i2cset -y 1 0x34 0x2b 0x08
root@desk-mp1:~# i2cset -y 1 0x34 0x2b 0x10
root@desk-mp1:~# i2cset -y 1 0x34 0x2b 0x20
root@desk-mp1:~# i2cset -y 1 0x34 0x2b 0x40
root@desk-mp1:~# i2cset -y 1 0x34 0x2b 0x80
root@desk-mp1:~# i2cset -y 1 0x34 0x2c 0x01
root@desk-mp1:~# i2cset -y 1 0x34 0x2c 0x02
root@desk-mp1:~# i2cset -y 1 0x34 0x2c 0x04

Set all pin to high and set all to low one by one:

root@desk-mp1:~# i2cset -y 1 0x34 0x2a 0xff
root@desk-mp1:~# i2cset -y 1 0x34 0x2b 0xff
root@desk-mp1:~# i2cset -y 1 0x34 0x2c 0x07

root@desk-mp1:~# i2cset -y 1 0x34 0x2a 0xfe
root@desk-mp1:~# i2cset -y 1 0x34 0x2a 0xfd
root@desk-mp1:~# i2cset -y 1 0x34 0x2a 0xfb
root@desk-mp1:~# i2cset -y 1 0x34 0x2a 0xf7
root@desk-mp1:~# i2cset -y 1 0x34 0x2a 0xef
root@desk-mp1:~# i2cset -y 1 0x34 0x2a 0xdf
root@desk-mp1:~# i2cset -y 1 0x34 0x2a 0xbf
root@desk-mp1:~# i2cset -y 1 0x34 0x2a 0x7f
root@desk-mp1:~# i2cset -y 1 0x34 0x2b 0xfe
root@desk-mp1:~# i2cset -y 1 0x34 0x2b 0xfd
root@desk-mp1:~# i2cset -y 1 0x34 0x2b 0xfb
root@desk-mp1:~# i2cset -y 1 0x34 0x2b 0xf7
root@desk-mp1:~# i2cset -y 1 0x34 0x2b 0xef
root@desk-mp1:~# i2cset -y 1 0x34 0x2b 0xdf
root@desk-mp1:~# i2cset -y 1 0x34 0x2b 0xbf
root@desk-mp1:~# i2cset -y 1 0x34 0x2b 0x7f
root@desk-mp1:~# i2cset -y 1 0x34 0x2c 0x06
root@desk-mp1:~# i2cset -y 1 0x34 0x2c 0x05
root@desk-mp1:~# i2cset -y 1 0x34 0x2c 0x03

Set GPIO input mode, disable debounce:

root@desk-mp1:~# i2cset -y 1 0x34 0x30 0x00
root@desk-mp1:~# i2cset -y 1 0x34 0x31 0x00
root@desk-mp1:~# i2cset -y 1 0x34 0x32 0x00

root@desk-mp1:~# i2cset -y 1 0x34 0x27 0xff
root@desk-mp1:~# i2cset -y 1 0x34 0x28 0xff
root@desk-mp1:~# i2cset -y 1 0x34 0x29 0x07

Read input value:

root@desk-mp1:~# i2cget -y 1 0x34 0x16
root@desk-mp1:~# i2cget -y 1 0x34 0x17
root@desk-mp1:~# i2cget -y 1 0x34 0x18