Struct capsules::button::Button
[−]
[src]
pub struct Button<'a, G: Pin + 'a> { pins: &'a [(&'a G, GpioMode)], apps: Grant<(Option<Callback>, SubscribeMap)>, }
Manages the list of GPIO pins that are connected to buttons and which apps are listening for interrupts from which buttons.
Fields
pins: &'a [(&'a G, GpioMode)]
apps: Grant<(Option<Callback>, SubscribeMap)>
Methods
impl<'a, G: Pin + PinCtl> Button<'a, G>
[src]
pub fn new(
pins: &'a [(&'a G, GpioMode)],
grant: Grant<(Option<Callback>, SubscribeMap)>
) -> Button<'a, G>
[src]
pins: &'a [(&'a G, GpioMode)],
grant: Grant<(Option<Callback>, SubscribeMap)>
) -> Button<'a, G>
[src]
Trait Implementations
impl<'a, G: Pin + PinCtl> Driver for Button<'a, G>
[src]
fn subscribe(&self, subscribe_num: usize, callback: Callback) -> ReturnCode
[src]
Set callbacks.
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/not pressed state of the button.
fn command(
&self,
command_num: usize,
data: usize,
_: usize,
appid: AppId
) -> ReturnCode
[src]
&self,
command_num: usize,
data: usize,
_: usize,
appid: AppId
) -> ReturnCode
Configure interrupts and read state for buttons.
data
is the index of the button in the button array as passed to
Button::new()
.
All commands greater than zero return EINVAL
if an invalid button
number is passed in.
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.
fn allow(
&self,
app: AppId,
minor_num: usize,
slice: AppSlice<Shared, u8>
) -> ReturnCode
[src]
&self,
app: AppId,
minor_num: usize,
slice: AppSlice<Shared, u8>
) -> ReturnCode
allow
lets an application give the driver access to a buffer in the application's memory. This returns ENOSUPPORT
if not used. Read more