|
Contiki 3.x
|
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... | |
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.
|
static |
Callback registered with the GPIO module.
Gets fired with a button port/pin generates an interrupt
| port | The port number that generated the interrupt |
| pin | The 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 |
Init function for the User button.
| type | SENSORS_ACTIVE: Activate / Deactivate the sensor (value == 1 or 0 respectively) |
| value | 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 |
Retrieves the value of the button pin.
| type | Returns 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().
| 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:
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.
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:
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.
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:
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.
Copyright (c) 2014, Analog Devices, Inc.
Definition at line 5 of file button-sensor.c.
Referenced by btn_callback(), and main().
1.8.6