Module capsules_core::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::button::Button<'static>,
    capsules::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§

  • This capsule keeps track for each app of which buttons it has a registered interrupt for. SubscribeMap is a bit array where bits are set to one if that app has an interrupt registered for that button.
  • Manages the list of GPIO pins that are connected to buttons and which apps are listening for interrupts from which buttons.

Constants§

Type Aliases§

  • This capsule keeps track for each app of which buttons it has a registered interrupt for. SubscribeMap is a bit array where bits are set to one if that app has an interrupt registered for that button.