GPIO lines

This article explains how to manage the general purpose input output (GPIO) lines on the CORE9G25 boards

All the examples are written in Python using the ablib module available on our CD. With this library it is possible to manage the GPIO using directly the board pin names.

CORE9G25 examples

Using this basic example of wiring:


CORE9G25 gpio example

it is possible to define the W9 line as an output and turn on/off the red led with the following code:

from ablib import Pin

led = Pin('W9','OUTPUT')
led.on()
led.off()

to read the button state it is possible to follow two methods:

  • Polling mode
  • Event mode

Polling mode

This mode consists to check the actual state of the line calling the get_value() method.

from ablib import Pin

PB=Pin('W15','INPUT')

#Never ending loop
while True:
    if (PB.digitalRead()==0):
        print "Pressed"
        while digitalRead()==0:
            pass        

Event mode

This mode consists to register a callback function with the set_edge() method that will call when the GPIO lines changes its state.

from ablib import Pin
from time import sleep

def pressed():
    print "Pressed"

PB=Pin('W15','INPUT')
PB.set_edge("falling",pressed)

#Never ending loop
i=0
while True:
    print i
    i=i+1
    sleep(0.5)

One of three conditions can be checked:

  • falling: the callback function is called when the signal goes from 1 to 0
  • rising: the callback function is called when the signal goes from 0 to 1
  • both: the callback function is called on any status change

Related links

 

Documentation Terms of Use
The Acme Systems srl provides this Debian system development and user manual.
The origin of these doc came from the website: http://www.acmesystems.it
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
Creative Commons License


Market Mail : market@armdevs.com
Support Mail: support@armdevs.com Sales Phone: +86-755-29638421


CoreWind Online Chat>
Work time: 09:00-18:00
Copyright @ 2014 to 2020 - CoreWind Tech.