Module capsules::button
[−]
[src]
Provides userspace control of buttons on a board.
This allows for much more cross platform controlling of buttons without having to know which of the GPIO pins exposed across the syscall interface are buttons.
Usage
let button_pins = static_init!( [&'static sam4l::gpio::GPIOPin; 1], [&sam4l::gpio::PA[16]]); let button = static_init!( capsules::button::Button<'static, sam4l::gpio::GPIOPin>, capsules::button::Button::new(button_pins, kernel::Grant::create())); for btn in button_pins.iter() { btn.set_client(button); }
Syscall Interface
- Stability: 2 - Stable
Command
Enable or disable button interrupts and read the current button state.
command_num
0
: Driver check and get number of buttons on the board.1
: Enable interrupts for a given button. This will enable both press and depress events.2
: Disable interrupts for a button. No affect or reliance on registered callback.3
: Read the current state of the button.
Subscribe
Setup a callback for button presses.
subscribe_num
0
: Set callback for pin interrupts. Note setting this callback has no reliance on individual pins being configured as interrupts. The interrupt will be called with two parameters: the index of the button that triggered the interrupt and the pressed (1) or not pressed (0) state of the button.
Reexports
use core::cell::Cell; |
use kernel::AppId; |
use kernel::Callback; |
use kernel::Driver; |
use kernel::Grant; |
use kernel::ReturnCode; |
use kernel::hil; |
use kernel::hil::gpio::Client; |
use kernel::hil::gpio::InterruptMode; |
Structs
Button |
Manages the list of GPIO pins that are connected to buttons and which apps are listening for interrupts from which buttons. |
Enums
ButtonState |
Values that are passed to userspace to identify if the button is pressed or not. |
GpioMode |
Whether the GPIOs for the buttons on this platform are low when the button is pressed or high. |
Constants
DRIVER_NUM |
Syscall driver number. |
Type Definitions
SubscribeMap |
This capsule keeps track for each app of which buttons it has a registered
interrupt for. |