Skip to main content
The Dragonwing IQ9-EVK contains one low-speed connector (JLS1) that provides access to various GPIOs, CAN, QUPs, and other interfaces.

Pinout

The figure below shows the default functions of the IQ-9075 EVK 40-pin LS connector.

GPIOs

The following commands require root privileges. Use sudo su to switch to the root user.

Identify GPIO Subsystem Numbers

Identify the base GPIO number by running the following command and looking for platform/f000000.pinctrl (gpiochip4). For IQ-9075, the base is 560.
cat /sys/kernel/debug/gpio
Example: For LS connector Pin 5, GPIO number is 54. The GPIO subsystem number is: 560 + 54 = 614.

Control GPIOs via sysfs

1

Export the GPIO

cd /sys/class/gpio
echo 614 > export
2

Configure direction and value

cd gpio614
echo out > direction
echo 1 > value
AttributeValues
directionin (input), out (output)
value0 (low), 1 (high)
edgerising, falling, both, none
3

Unexport when done

cd ..
echo 614 > unexport

GPIO Code Examples

The following example sets pin 5 as output, pin 7 as input, and loops to check the level of pin 7.
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int out_gpio = 614;
int in_gpio = 615;

int main() {
    char export_path[50] = {};
    char export_command[100] = {};
    snprintf(export_path, sizeof(export_path), "/sys/class/gpio/export");
    snprintf(export_command, sizeof(export_command), "echo %d > %s ", out_gpio, export_path);
    system(export_command);
    snprintf(export_command, sizeof(export_command), "echo %d > %s ", in_gpio, export_path);
    system(export_command);

    char direction_path[50] = {};
    snprintf(direction_path, sizeof(direction_path), "/sys/class/gpio/gpio%d/direction", out_gpio);
    FILE *direction_file = fopen(direction_path, "w");
    if (direction_file == NULL) { perror("Failed to open GPIO direction file"); return -1; }
    fprintf(direction_file, "out");
    fclose(direction_file);

    snprintf(direction_path, sizeof(direction_path), "/sys/class/gpio/gpio%d/direction", in_gpio);
    direction_file = fopen(direction_path, "w");
    if (direction_file == NULL) { perror("Failed to open GPIO direction file"); return -1; }
    fprintf(direction_file, "in");
    fclose(direction_file);

    char value_in_path[50] = {};
    char value_out_path[50] = {};
    char cat_command[100] = {};
    snprintf(value_out_path, sizeof(value_out_path), "/sys/class/gpio/gpio%d/value", out_gpio);
    snprintf(value_in_path, sizeof(value_in_path), "/sys/class/gpio/gpio%d/value", in_gpio);
    snprintf(cat_command, sizeof(cat_command), "cat %s", value_in_path);

    FILE *value_out_file = fopen(value_out_path, "w");
    if (value_out_file == NULL) { perror("Failed to open GPIO value file"); return -1; }

    for (int i = 0; i < 5; i++) {
        fprintf(value_out_file, "1"); fflush(value_out_file);
        system(cat_command); sleep(1);
        fprintf(value_out_file, "0"); fflush(value_out_file);
        system(cat_command); sleep(1);
    }
    fclose(value_out_file);

    char unexport_path[50] = {};
    char unexport_command[100] = {};
    snprintf(unexport_path, sizeof(unexport_path), "/sys/class/gpio/unexport");
    snprintf(unexport_command, sizeof(unexport_command), "echo %d > %s ", out_gpio, unexport_path);
    system(unexport_command);
    snprintf(unexport_command, sizeof(unexport_command), "echo %d > %s ", in_gpio, unexport_path);
    system(unexport_command);
    return 0;
}
1

Compile

gcc gpio.c -o gpio
2

Connect pins

Short pin 5 and pin 7 with a Dupont wire.
Pay attention to pin order. Do not short power and ground pins — this may damage the board.
3

Run

./gpio

UART

Pins 5 and 7 are configured for UART by default (GPIO lines 54 and 55, mapping to uart12 = qup1_se5 (0xa98000)). Follow the Modify serial engine node procedure to enable the UART interface. After enabling, the device node appears at /dev/ttyHS3.
ubuntu@ubuntu:/dev$ ls -al ttyHS3
crw-rw---- 1 root dialout 236, 2 Nov 25 18:16 ttyHS3
1

Connect pins

Short pin 5 and pin 7 with a Dupont wire.
Pay attention to pin order. Do not short power and ground pins — this may damage the board.
2

Configure UART

sudo stty -F /dev/ttyHS3 ispeed 115200 ospeed 115200
sudo stty -F /dev/ttyHS3 115200 -echo -icanon -isig -iexten -icrnl -ixon -opost
3

Open two SSH terminals

Terminal 1 (RX):
sudo cat /dev/ttyHS3
Terminal 2 (TX):
sudo su
echo "hello world!" > /dev/ttyHS3

I2C

I2C (Inter-Integrated Circuit) is a bidirectional 2-wire bus for inter-IC control. Every device on the bus has a unique address. The I2C core supports multi-controller mode, 10-bit target addressing, and 10-bit extendable addressing. Pins 8 and 10 are configured for I2C by default (GPIO lines 32 and 33, mapping to i2c4 = qup0_se4 (0x990000)). Follow the Modify serial engine node procedure to enable the I2C interface. After enabling, verify the device nodes:
ls /dev/i2c*
# Expected: /dev/i2c-18  /dev/i2c-19  /dev/i2c-20  /dev/i2c-21  /dev/i2c-22  /dev/i2c-23  /dev/i2c-24  /dev/i2c-25
1

Install i2c-tools

sudo apt install -y i2c-tools
2

List I2C adapters

i2cdetect -l
3

Map adapters to device tree nodes

ls -l /sys/class/i2c-adapter/i2c-*
4

Scan for devices on bus 20

i2cdetect -a -y -r 20
5

Read/write device registers

# Read all registers of device at address 0x38
i2cdump -f -y 1 0x38

# Write 0xaa to register 0x01
i2cset -f -y 1 0x38 0x01 0xaa

# Read register 0x01
i2cget -f -y 1 0x38 0x01

SPI

SPI (Serial Peripheral Interface) is a synchronous full-duplex 4-wire serial bus. Pins 11 and 13 are configured for SPI by default (GPIO lines 44 and 45, mapping to spi10 = qup1_se3 (0xa8c000)). Follow the Modify serial engine node procedure to enable the SPI interface.
The following example sends and receives data over SPI with loopback.
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <fcntl.h>
#include <unistd.h>
#include <linux/spi/spidev.h>
#include <sys/ioctl.h>

#define SPI_DEVICE_PATH "/dev/spidev12.0"

int main() {
    int spi_file;
    uint8_t tx_buffer[50] = "hello world!";
    uint8_t rx_buffer[50];

    if ((spi_file = open(SPI_DEVICE_PATH, O_RDWR)) < 0) {
        perror("Failed to open SPI device");
        return -1;
    }

    uint8_t mode = SPI_MODE_0, bits = 8;
    ioctl(spi_file, SPI_IOC_WR_MODE, &mode);
    ioctl(spi_file, SPI_IOC_WR_BITS_PER_WORD, &bits);

    struct spi_ioc_transfer transfer = {
        .tx_buf = (unsigned long)tx_buffer,
        .rx_buf = (unsigned long)rx_buffer,
        .len = sizeof(tx_buffer),
        .speed_hz = 1000000,
        .bits_per_word = 8,
    };

    if (ioctl(spi_file, SPI_IOC_MESSAGE(1), &transfer) < 0) {
        perror("Failed to perform SPI transfer");
        close(spi_file);
        return -1;
    }

    printf("tx_buffer:\n %s\n", tx_buffer);
    printf("rx_buffer:\n %s\n", rx_buffer);
    close(spi_file);
    return 0;
}
1

Compile

gcc spi.c -o spi
2

Short pin 11 and pin 13 with a Dupont wire (loopback), then run

./spi