Module button

Source
Expand description

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_core::button::Button<'static>,
    capsules_core::button::Button::new(button_pins, board_kernel.create_grant(&grant_cap)));
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 existence 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.

Structs§

App
Keeps track for each app of which buttons it has a registered interrupt for.
Button
Manages the list of GPIO pins that are connected to buttons and which apps are listening for interrupts from which buttons.

Constants§

DRIVER_NUM

Type Aliases§

SubscribeMap
Keeps track which buttons each app has a registered interrupt for.