Peripheral Adaptation¶
CAM-CRV1126S2U/CAM-C1109S2U
retains a wealth of expansion interfaces, including Ethernet
, USB
, Serial port
, GPIO
, I2C
, I2S
, SPI
, SDIO
, etc. Basically meet all the expansion needs of customers. This chapter mainly describes some simple peripherals that may be used by the gates.
Relay¶
The essence of the relay is to operate GPIO
, here is how to operate GPIO
in the system.
Check the interface definition and select the
GPIO
to be manipulated, such asGPIO3_D6
Calculate GPIO number
# GPIO3_D6
3 x 32 + 3 x 8 + 6 = 126
# Formula GPIO(X)_(Y)(Z)
# Where the variable Y :A = 0,B = 1,C = 2,D = 3
X x 32 + Y x 8 + Z
Register GPIO
echo 126 > /sys/class/gpio/export
# Need to confirm that the GPIO is not occupied and not initialized other functions
# If GPIO3_D6 is also the I2S_m0 port, I2S needs to be disabled in the kernel
vim sdk/kernel/arch/arm/boot/dts/rv1109-firefly-ai-cam.dts (rv1126-firefly-ai-cam.dts)
# Add the following code at the end
&i2s0 {
status = "disabled";
};
# Compile and upgrade the kernel
Set GPIO to output mode
echo out > /sys/class/gpio/gpio126/direction
Set GPIO output high/low level
echo 1 > /sys/class/gpio/gpio126/value # high level
echo 0 > /sys/class/gpio/gpio126/value # low level
LED¶
Select the
GPIO
port, modify the kernel device tree, and add a customLED
device node.
vim sdk/kernel/arch/arm/boot/dts/rv1109-firefly-ai-cam.dts (rv1126-firefly-ai-cam.dts)
# Refer to the following configuration to add LED nodes.
leds {
compatible = "gpio-leds";
user_led: user {
label = "firefly:yellow:user";
linux,default-trigger = "ir-user-click";
default-state = "off";
gpios = <&gpio3 RK_PD6 GPIO_ACTIVE_HIGH>;
pinctrl-names = "default";
pinctrl-0 = <&led_user>;
};
};
# pinctrl needs to add GPIO multiplexing control
led_user: led-user {
rockchip,pins = <3 RK_PD6 RK_FUNC_GPIO &pcfg_pull_none>;
};
# Compile and upgrade the kernel after modification
Control LED
echo 1 > /sys/class/leds/firefly:yellow:user/brightness # Light up
echo 0 > /sys/class/leds/firefly:yellow:user/brightness # Light off