Contiki 3.x
Files | Functions | Variables
Zoul User Button Driver

Driver for the Zoul user button. More...

Files

file  button-sensor.c
 Driver for the Zoul user button.
 
file  button-sensor.h
 Header file for the Zoul User Button Driver.
 

Functions

static int value (int type)
 Retrieves the value of the button pin. More...
 
static void btn_callback (uint8_t port, uint8_t pin)
 Callback registered with the GPIO module. More...
 
static int config_user (int type, int value)
 Init function for the User button. More...
 

Variables

const struct sensors_sensor button_sensor
 Copyright (c) 2014, Analog Devices, Inc. More...
 

Detailed Description

Driver for the Zoul user button.

The user button (on Zoul-based platforms like the RE-Mote and the Firefly) will generate a sensors_changed event on press as well as on release.

Unlike many other platforms, the user button has the ability to generate events when the user keeps the button pressed. The user can configure the button driver with a timer interval in clock ticks. When the button is kept pressed, the driver will then generate a broadcast event each time the interval passes. For example the driver can be configured to generate an event every second while the button is kept pressed. This functionality can be enabled through the configure() function, by passing BUTTON_SENSOR_CONFIG_TYPE_INTERVAL as the type argument.

Function Documentation

static void btn_callback ( uint8_t  port,
uint8_t  pin 
)
static

Callback registered with the GPIO module.

Gets fired with a button port/pin generates an interrupt

Parameters
portThe port number that generated the interrupt
pinThe pin number that generated the interrupt. This is the pin absolute number (i.e. 0, 1, ..., 7), not a mask

Definition at line 105 of file button-sensor.c.

References button_sensor, ctimer_set(), ctimer_stop(), DEBOUNCE_DURATION, NULL, timer_expired(), timer_set(), and value().

Referenced by config_user().

static int config_user ( int  type,
int  value 
)
static

Init function for the User button.

Parameters
typeSENSORS_ACTIVE: Activate / Deactivate the sensor (value == 1 or 0 respectively)
valueDepends on the value of the type argument
Returns
Depends on the value of the type argument

Definition at line 135 of file button-sensor.c.

References btn_callback(), BUTTON_USER_PORT, GPIO_DETECT_EDGE, GPIO_DISABLE_INTERRUPT, GPIO_ENABLE_INTERRUPT, gpio_register_callback(), GPIO_SET_INPUT, GPIO_SOFTWARE_CONTROL, GPIO_TRIGGER_BOTH_EDGES, IOC_OVERRIDE_PUE, ioc_set_over(), nvic_interrupt_disable(), nvic_interrupt_enable(), process_alloc_event(), and value().

static int value ( int  type)
static

Retrieves the value of the button pin.

Parameters
typeReturns the pin level or the counter of press duration events. type == BUTTON_SENSOR_VALUE_TYPE_LEVEL or type == BUTTON_SENSOR_VALUE_TYPE_PRESS_DURATION respectively

Definition at line 85 of file button-sensor.c.

References GPIO_READ_PIN.

Referenced by btn_callback(), and config_user().

Variable Documentation

const struct sensors_sensor button_sensor

Copyright (c) 2014, Analog Devices, Inc.

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted (subject to the limitations in the disclaimer below) provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of Analog Devices, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Author
Jim Paris jim.p.nosp@m.aris.nosp@m.@riga.nosp@m.do.c.nosp@m.om
Ian Martin marti.nosp@m.ni@r.nosp@m.edwir.nosp@m.ellc.nosp@m..com

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted (subject to the limitations in the disclaimer below) provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of Analog Devices, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Author
Jim Paris jim.p.nosp@m.aris.nosp@m.@riga.nosp@m.do.c.nosp@m.om
Ian Martin marti.nosp@m.ni@r.nosp@m.edwir.nosp@m.ellc.nosp@m..com

Copyright (c) 2014, Analog Devices, Inc.

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted (subject to the limitations in the disclaimer below) provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of Analog Devices, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Author
Jim Paris jim.p.nosp@m.aris.nosp@m.@riga.nosp@m.do.c.nosp@m.om
Ian Martin marti.nosp@m.ni@r.nosp@m.edwir.nosp@m.ellc.nosp@m..com

Copyright (c) 2014, Analog Devices, Inc.

Definition at line 5 of file button-sensor.c.

Referenced by btn_callback(), and main().