HiKey(LeMaker version):HiKey LED Board User Manual
- 1 Instruction
- 2 Hardware interface
- 3 Software Control
The LED board is a fittings used for HiKey board. It is connected with 40 pins low speed expansion connector on HiKey board. We can control the 40 pins interfaces as GPIO (General Purpose Input Output). There're also three serial ports for debugging, including UART2, UART3 and a USB to serial port.
How to connect with HiKey board
40 Pin Header
On LED board, 40 pins header (J1) are designed to be corresponding to the 40 pins connector on HiKey board. The following tables show the Low Speed Expansion Connector pin out to LED board:
If we connect the LED board to HiKey board, the LED board will directly connect to the 40 pins connector. And these pins can be used as GPIO controls, if one pin is pulled to high voltage, the corresponding LED will light up. Of course, the VCC and GND pins can’t be controlled, and can’t be used as GPIO. VCC pins include SYSDC_IN, PMU_PWRON_N, EXP_RSTOUT_N, SYS_5V and LDO21_1V8.
If we use the LED board, we can’t use the UART2/3 pins for debugging in 40 pins header; in this case, we can only use the USB to serial port for debugging, where UART2/3 pins will be connected to the USB to serial port, and we can switch to the UART2 or UART3 by J4.
The UART2/UART3 have been leaded to J4 on the 40 pins header, if they are not used as GPIO, you can use them for debugging.
If short out 1 and 3, 2 and 4 on J4, then UART2 will be connected to CH340 (USB to serial port chip) by Q7 and Q8, that is to say, the USB to serial port will use the UART2 for debugging.
If short out 5 and 3, 2 and 6 on J4, then UART3 will be connected to CH340 (USB to serial port chip) by Q7 and Q8, that is to say, the USB to serial port will use the UART3 for debugging.
USB to Serial Port
If these pins are used for GPIO controls, we can do programming by software.
How to control the GPIO and LED
In “Table A”, it describes the mapping relationships among the “LED index”, “Pin Number”, “Pin Definition”, “GPIO CHIP” and “GPIO PORT”. For example, GPIO_13_6 is the bit 6 of GPIO13, GPIO chip is gpiochip400, where the “Pin Number” is 406, “LED index” is D22, and it’s number 3 in 40 pin header.
Notice：if these GPIOs are used by multiplex functions, we can’t control it as GPIO at the same time. And we can use command “cat /sys/kernel/debug/gpio” to check whether they're occupied. E.g. the pin number 458 and 459 are used in the OS version HiKey-jessie_alip_20151130-387-8g.emmc.img.
Use sysfs to control the GPIO
By serial port, we can dive into filesystem and run some commands to control the GPIO. If you use the Debian terminal, please run “sudo -i” to get root authority first.
To access a GPIO pin such as GPIO_13_6 (pin number is 406) you first need to export it with
echo XX > /sys/class/gpio/export
With XX being the numbering index of the desired pin, here XX = 406. If succeed, you would find the sys file system node
ls #! /sys/class/gpio/gpioXX is generated
To set a GPIO pin as output you have to change the input/output direction with
echo out > /sys/class/gpio/gpioXX/direction
To set a GPIO pin as input you have to change the input/output direction with
echo in > /sys/class/gpio/gpioXX/direction
You can read a GPIO pin with /sys/class/gpio/gpioXX/value using
When the direction is set to out, you can write 1 or 0 to a GPIO pin with /sys/class/gpio/gpioXX/value using
echo 1 /sys/class/gpio/gpioXX/value
Control the LED by GPIO
In the above section #Use sysfs to control the GPIO, if write 1 to value, the corresponding LED will light up, if write 0, it will light off. E.g. if you control the GPIO_13_6 with high/low voltage, LED(D22) will light on/off. We can check up Table A Pin definition in section #How to control the GPIO and LED for the 40 pins mapping details.