16 GPIO pins on the APU1

Support was added to FreeBSD 11 for an x86 boards GPIO pins. PC Engines -APU1 using the Nuvoton NCT5104D with a driver named nctgpio.c

I could not find instructions so here is what is needed:

kldload nctgpio or nctgpio_load="YES" in /boot/loader.conf

To check pin status:
gpioctl -lv

To set the first 3 pins for output and push/pull usage:
gpioctl -c 00 OUT PP
gpioctl -c 01 OUT PP
gpioctl -c 02 OUT PP



J19 GPIO HEADER TO NCTGPIO PIN TRANSLATION
pin 1, pin 2, pin 19 and pin 20 marked on board.

APU1 PIN 1--NEGATIVE
APU1 PIN 2--POSITIVE 3.3V-DC
APU1 PIN 3--GPIOCTL 00
APU1 PIN 4--GPIOCTL 01
APU1 PIN 5--GPIOCTL 02
APU1 PIN 6--GPIOCTL 03
APU1 PIN 7--GPIOCTL 04
APU1 PIN 8--GPIOCTL 05
APU1 PIN 9--GPIOCTL 06
APU1 PIN10--GPIOCTL 07
APU1 PIN11--GPIOCTL 08
APU1 PIN12--GPIOCTL 09
APU1 PIN13--GPIOCTL 10
APU1 PIN14--GPIOCTL 11
APU1 PIN15--GPIOCTL 12
APU1 PIN16--GPIOCTL 13
APU1 PIN17--GPIOCTL 14
APU1 PIN18--GPIOCTL 15
APU1 PIN19--NEGATIVE
APU1 PIN20--POSITIVE 5V-DC

 
Notice here that Pin 01 has an 1 state. That means ON.
Code:
root@APU1D:~ # gpioctl -lv
pin 00:   0   GPIO00<OUT,PP>, caps:<IN,OUT,OD,PP,II,IO>
pin 01:   1   GPIO01<OUT,PP>, caps:<IN,OUT,OD,PP,II,IO>
pin 02:   0   GPIO02<OUT,PP>, caps:<IN,OUT,OD,PP,II,IO>
pin 03:   0   GPIO03<OUT,PP>, caps:<IN,OUT,OD,PP,II,IO>
pin 04:   0   GPIO04<OUT,PP>, caps:<IN,OUT,OD,PP,II,IO>
pin 05:   0   GPIO05<OUT,PP>, caps:<IN,OUT,OD,PP,II,IO>
pin 06:   0   GPIO06<OUT,PP>, caps:<IN,OUT,OD,PP,II,IO>
pin 07:   0   GPIO07<OUT,PP>, caps:<IN,OUT,OD,PP,II,IO>
pin 08:   0   GPIO08<OUT,PP>, caps:<IN,OUT,OD,PP,II,IO>
pin 09:   0   GPIO09<OUT,PP>, caps:<IN,OUT,OD,PP,II,IO>
pin 10:   0   GPIO10<OUT,PP>, caps:<IN,OUT,OD,PP,II,IO>
pin 11:   0   GPIO11<OUT,PP>, caps:<IN,OUT,OD,PP,II,IO>
pin 12:   0   GPIO12<OUT,PP>, caps:<IN,OUT,OD,PP,II,IO>
pin 13:   0   GPIO13<OUT,PP>, caps:<IN,OUT,OD,PP,II,IO>
pin 14:   0   GPIO14<OUT,PP>, caps:<IN,OUT,OD,PP,II,IO>
pin 15:   0   GPIO15<OUT,PP>, caps:<IN,OUT,OD,PP,II,IO>
I have set all pins for output usage.
To turn on Pin 0 you would issue the command gpioctl 00 1
To turn off that same pin gpioctl 00 0
You can also toggle the state with gpioctl -t 00
 
From the above youtube video he shows this command for changing all pins to OUT and PP.
It fails on my machine. Is this due to a varible that needs to be set? Is 'jot' the varable name? Maybe he is using a different shell?
Code:
root@APU1D:~ # for pin in $(jot - 0 15); do gpioctl -c $pin OUT PP; done
Illegal variable name.

Could someone show me what is being used here? Is this a one-liner? Is this 3 different commands broken apart by the semicolon;?
 
please see jot(1), the syntax used relate to bash(1)

it is a for loop, the variable "pin" get the values from 0 to 15, probably better written using indentation:
Code:
for pin in $(jot - 0 15)
do
        gpioctl -c $pin OUT PP;
done
an equivalent code would be:
Code:
gpioctl -c 0 OUT PP;
gpioctl -c 1 OUT PP;
gpioctl -c 2 OUT PP;
gpioctl -c 3 OUT PP;
gpioctl -c 4 OUT PP;
gpioctl -c 5 OUT PP;
gpioctl -c 6 OUT PP;
gpioctl -c 7 OUT PP;
gpioctl -c 8 OUT PP;
gpioctl -c 9 OUT PP;
gpioctl -c 10 OUT PP;
gpioctl -c 11 OUT PP;
gpioctl -c 12 OUT PP;
gpioctl -c 13 OUT PP;
gpioctl -c 14 OUT PP;
gpioctl -c 15 OUT PP;
 
With that information in hand I can see making a blink.sh with many lines less.
GPIO's have been a good learning experience.
Thanks for the help.
 
This is what I ended up with
Code:
#!/usr/bin/env bash
for pin in $(jot - 0 15)
do
        gpioctl -c $pin OUT PP;
done
gpioctl -l
 
Back
Top