🍇 Blogger homepage: Systemcall Tavern
🍇 About the blogger: Neutionwei, one of the new creators in the embedded field of station C, is a geek who loves open source technology and likes to share technical experience. He pays attention to simple style and is keen to tell complex technology with simple cases. "Fake ten thousand books, true one case", which is a sentence said by an academician teaching mathematics at Xiamen University. In addition, "achievement is the best teacher". Technology should be precipitated and shared, The positive feedback of my sense of achievement is the driving force to support my continuous cultivation!
🍇 Column contents: Firefly rk356x board
🍇 Column Description: this column is mainly based on the RK356x board of Firefly. Welcome to subscribe and the blogger will keep updating!
1, Pin condition
There are two LED lights on ROC-RK3568-PC development board, as shown in the table below:
LED | Pin name | Pin number |
---|---|---|
Blue | GPIO1_B1 | 41 |
Yellow | GPIO1_B2 | 42 |
2, Control the LED as a device
The following controls these two LEDs through the / sys/class/leds / directory.
The default status of the LED on the development board is:
- Blue: always on when the system is powered on
- Yellow: Custom
Control each LED by entering a command into its brightness attribute through the echo command:
:/ # Echo 0 > / sys / class / LEDs / fire: Blue: power / brightness / / the light is off :/ # Echo 1 > / sys / class / LEDs / fire: Blue: power / brightness / / the light is on
3, Control LED in trigger mode
Trigger contains many ways to control LED s. Here are two examples to illustrate.
- Simple trigger LED
- Complex trigger LED
For more details, please refer to kernel / documentation / LEDs / LEDs class txtleds-class. txt .
First, we need to know how many LEDs are defined and what the corresponding LED attributes are.
Note: the value of compatible should be the same as kernel / Drivers / LEDs / LEDs GPIO C The value of compatible should be consistent.
3.1 Simple trigger LED
This is a simple trigger method to control the LED. The yellow light will be turned on by default as follows. The yellow light will be on after ROC-RK3568-PC is turned on.
(1) Define LED triggers.
In kernel / Drivers / LEDs / trigger / LED firefly demo C the following is added in the document:
DEFINE_LED_TRIGGER(ledtrig_default_control);
(2) Register the trigger
led_trigger_register_simple("ir-user-click", &ledtrig_default_control);
(3) Control the lighting of LED.
led_trigger_event(ledtrig_default_control, LED_FULL); // led on
(4) Open LED demo
Led firefly demo is not turned on by default. Use the following patch to turn on the demo driver:
--- a/kernel/arch/arm64/boot/dts/rockchip/rk356x-firefly-demo.dtsi +++ b/kernel/arch/arm64/boot/dts/rockchip/rk356x-firefly-demo.dtsi @@ -52,7 +52,7 @@ led_demo: led_demo { - status = "disabled"; + status = "okay"; compatible = "firefly,rk356x-led"; };
3.2 Complex trigger LED
Using timer trigger can make the LED continuously on and off:
Configure timer on the kernel first.
In the kernel path, use make arch=arm64 menuconfig and select the following configuration:
CONFIG_LEDS_TRIGGER_TIMER
Save the configuration and compile the kernel Burn img to ROC-RK3568-PC and input the following commands through serial port or ADB. You can see that the blue light flickers at intervals.
:/ # echo "timer" > sys/class/leds/firefly\:blue\:power/trigger
You can also use the cat command to obtain the available values of trigger:
:/ # cat sys/class/leds/firefly\:blue\:power/trigger none rc-feedback test_ac-online test_battery-charging-or-full test_battery-charging test_battery-full test_battery-charging-blink-full-solid test_usb-online mmc0 mmc1 ir-user-click [timer] heartbeat backlight default-on rfkill0 mmc2 rfkill1 rfkill2