Mixtile Blade 3 (hereinafter referred to as Blade 3) provides a row of GPIO (general-purpose input/output) pins along the lower edge of the board for extended interfacing. These pins can be used for a wide range of applications. Among these pins, some are defined as I2C, I2S, USB, SPI, ADC, and PWM interfaces.
This document describes how to use some of the pins for specific tasks, including:
- Connect an OLED display module via the I2C interface.
- Connect an OLED display module via the SPI interface.
- Connect a fan module.
For more information about pin assignments and definitions, see “Connectors & Pin Assignments” in Mixtile Blade 3 User Manual.
I2C
This section describes how to connect an OLED display module via the I2C interface.
Preparations
- Set up connections of Blade 3.
- Log in to Blade 3 using one of the following methods:
- An OLED display module
- An OLED package: oled.tar
Steps
Step 1. Connect the OLED display module to the 30-pin header. The pin matching is as follows:
Step 2. Check whether the OLED module has been connected to Blade 3 by running the following command:
i2cdetect -y -r 5
The command output is as follows. 0x3c is the address of the OLED display module.
0 1 2 3 4 5 6 7 8 9 a b c d e f00: -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- 3c -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
Step 3. Install a compilation tool by running the following command:
apt update && apt install build-essential
Step 4. Download the oled.tar file, decompress it, and copy it to the Blade 3 directory.
- Using the ADB tool:
adb push oled.tar /home/mixtile
- Using a serial communication tool or via SSH:
scp oled.tar mixtile@Blade 3 IP address:/home/mixtile
Step 5. Configure the OLED module and generate an executable file.
Navigate to the oled folder and open the sources/oled.c file by using the vim editor.
5.1 Locate the line //#define IIC_MODE and change it as #define IIC_MODE. Save and exit the vim editor.
5.2 Under the oled directory, run the make command to generate an executable file.
Step 6. Execute the file that is generated in the previous step by running the following command:
./oled
You can see that the OLED display module shows text blade3, as shown below.
SPI
Preparations
- Set up connections of Blade 3.
- Log in to Blade 3 using one of the following methods:
- An OLED display module
- OLED package: oled.tar
Steps
Step 1. Connect the OLED display module to the 30-pin header. The pin matching is as follows:
Step 2. Install the compilation tool by running the following command:
apt update && apt install build-essential
Step 3. Download the oled.tar file, decompress it, and copy it to the Blade 3 directory.
- Using the ADB tool:
adb push oled.tar /home/mixtile
- Using a serial communication tool or via SSH:
scp oled.tar mixtile@Blade 3 IP address:/home/mixtile
Step 4. Configure the OLED module and generate an executable file.
4.1 Navigate to the oled folder and open the sources/oled.c file by using the vim editor.
4.2 Locate the line //#define SPI_MODE and change it as #define SPI_MODE. Save and exit the vim editor.
4.3 Under the oled directory, run the make command to generate an executable file.
Step 5. Execute the file that is generated in the previous step by running the following command:
./oled
You can see that the OLED display module shows text blade3, as shown below.
Connect a fan module
Preparations
- Set up connections of Blade 3.
- Log in to Blade 3 using one of the following methods:
- A fan module
Steps
Connect the fan module to Blade 3. The pin matching is as follows:
Note: You can connect the pwm pin to PWM14 or PWM15.
After connection is done, the fan starts running.
(Optional) Adjust the running speed of the fan.
- Under the Blade 3 directory, run the following command:
cd /sys/class/pwm/pwmchip1/
Note: If you connect the pwm pin of the fan to PWM14, the directory is /sys/class/pwm/pwmchip1/. If you connect the pwm pin of the fan to PWM15, the directory is /sys/class/pwm/pwmchip2/.
2. Enable PWM timer 0 by running the following command:
echo 0 > export
3. Navigate to PWM timer 0 by running the following command:
cd pwm0
4. Configure parameters of PWM timer 0 and make the parameters effective:
echo 20000 > period #Set PWM period to 20 ms.
echo 10000 > duty_cycle #Set the duty cycle of the fan to 50%.
echo normal > polarity #Two parameters are available: normal or inversed, indicating whether the output pin level is inverted.
echo 1 > enable #Enable PWM.
5. To increase the fan speed, change duty_cycle to a greater value. The following command makes the fan run at full speed:
echo 20000 > duty_cycle
6. To reduce the fan speed, change duty_cycle to a smaller value. The following command makes the fun run 20% of the full speed:
echo 5000 > duty_cycle