example of how to use GPIO

  • Hello,


    We are migrating some app from a NetDCU10 to a PicoMOD6, and we need to handle the GPIO of the board. In the NetDCU10 we used some modules and headers (fsio.h) examples, but we don't have the same example addapted to the picomod6.


    The question is, how can we manage the digital inputs and outputs of the picomod6? There is some sample code we can use?


    Thank you very much in advance.

  • I had to do this to get the RS485 TX ENABLE
    working on the picomod.


    Essentially I had to look up all the register locations in the
    samsung processor manual and then write C code to directly manipulate
    the alternate function, direction and state bits.


    Here is some code that sets the GPIO20 output line to true.


    Hope it helps.


  • Quote from "robin48gx"

    Essentially I had to look up all the register locations in the
    samsung processor manual and then write C code to directly manipulate
    the alternate function, direction and state bits.


    No no no no no!!! This is most probably fatal, because other device drivers will access the GPIO registers, too, and then your register access won't work reliably if interrupted by some driver.


    We have an example for GPIO access here in the forum and also in our examples directory on the download server (<!-- m --><a class="postlink" href="http://www.fs-net.de/download/linux">http://www.fs-net.de/download/linux</a><!-- m --> -> Linux -> PicoMOD6-V1.0 -> examples -> gpio.tar.bz2).

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

  • As I said GPIOs are used all over the drivers. Therefore they need some care (i.e. synchronization) so that different drivers do not interfere with each other while competing for the GPIO access. This means that access to the GPIO registers can only be done from a driver. And using sysfs is in fact using a driver. There is no way of "reserving" pins and accessing them from user space.


    By the way how did you implement getmem() and putmem()?

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

  • I fully appreciate the need to reserve GPIO registers, but I needed
    to control the output pin to a resolution of about 500 micro seconds
    in order to comply with the RS485 modbus protocol.


    I implemented getmem and putmem by mapping the register
    space to my processes virtual space.