Module capsules::led
[−]
[src]
Provides userspace access to LEDs on a board.
This allows for much more cross platform controlling of LEDs without having to know which of the GPIO pins exposed across the syscall interface are LEDs.
This capsule takes an array of pins and the polarity of the LED (active high or active low). This allows the board to configure how the underlying GPIO must be controlled to turn on and off LEDs, such that the syscall driver interface can be agnostic to the LED polarity.
Usage
let led_pins = static_init!( [(&'static sam4l::gpio::GPIOPin, capsules::led::ActivationMode); 3], [(&sam4l::gpio::PA[13], capsules::led::ActivationMode::ActiveLow), // Red (&sam4l::gpio::PA[15], capsules::led::ActivationMode::ActiveLow), // Green (&sam4l::gpio::PA[14], capsules::led::ActivationMode::ActiveLow)]); // Blue let led = static_init!( capsules::led::LED<'static, sam4l::gpio::GPIOPin>, capsules::led::LED::new(led_pins));
Syscall Interface
- Stability: 2 - Stable
Command
All LED operations are synchronous, so this capsule only uses the command
syscall.
command_num
0
: Return the number of LEDs on this platform.data
: Unused.- Return: Number of LEDs.
1
: Turn the LED on.data
: The index of the LED. Starts at 0.- Return:
SUCCESS
if the LED index was valid,EINVAL
otherwise.
2
: Turn the LED off.data
: The index of the LED. Starts at 0.- Return:
SUCCESS
if the LED index was valid,EINVAL
otherwise.
3
: Toggle the on/off state of the LED.data
: The index of the LED. Starts at 0.- Return:
SUCCESS
if the LED index was valid,EINVAL
otherwise.
Reexports
use kernel::AppId; |
use kernel::Driver; |
use kernel::ReturnCode; |
use kernel::hil; |
Structs
LED |
Holds the array of GPIO pins attached to the LEDs and implements a |
Enums
ActivationMode |
Whether the LEDs are active high or active low on this platform. |
Constants
DRIVER_NUM |
Syscall driver number. |