Lehrstuhl für Informatik 4
SPiC
Vorlesung
-
UnivIS-Infos
-
Inhalt
-
Folien
Übungen
-
Inhalt
-
Folien
-
Aufgaben
-
UnivIS-Infos
-
SPiCboard
-
libspicboard-Doku
-
FAQ
-
FSI-Forum für Fragen
Prüfung
Evaluation
Intern
Department Informatik
>
Informatik 4
>
Lehre
>
SS 2016
>
SPiC
>
Übungen
>
libspicboard-Doku
>
button.h Source File
SPiCboard library (libspicboard, revision 12428) API documentation
Found a bug or something ambiguous?
Mail us
to get it fixed!
Main Page
Related Pages
Modules
Files
File List
Globals
libspicboard
button.h
Go to the documentation of this file.
1
#ifndef BUTTON_H
2
#define BUTTON_H
3
4
#include <stdint.h>
5
6
7
/**
8
9
*
10
* \addtogroup Button
11
*
12
* \brief The button module enables event-driven and polling access
13
* to the buttons of the SPiCboard.
14
*
15
* The SPiCboard is equipped with two buttons. Button 0 is debounced in
16
* hardware, whereas Button 1 needs to be debounced in software by the
17
* button module. Debouncing is transparent to the application, that
18
* can use both buttons through the provided interface without the
19
* need to care about debouncing.
20
*
21
* The debouncing code makes use of the timer module. When no listeners
22
* are registered for Button 1, the debouncing code is disabled and all
23
* alarms registered at the timer should be canceled.
24
*
25
* The button module uses dynamic memory management to maintain the
26
* listener queues.
27
*
28
* @{
29
* \file button.h
30
* \version \$Rev: 7715 $
31
*/
32
33
/**
34
* \brief Identifiers for all available buttons.
35
*
36
*/
37
typedef
enum
{
38
BUTTON0
= 4,
/**< Button 0 */
39
BUTTON1
= 8
/**< Button 1 */
40
}
BUTTON
;
41
42
/**
43
* \brief Events for buttons.
44
*
45
* Pressed and released events for buttons.
46
*/
47
typedef
enum
{
48
BTNPRESSED
= 1,
/**< Button was pressed */
49
BTNRELEASED
= 2
/**< Button was released */
50
}
BUTTONEVENT
;
51
52
/**
53
* \brief Type for button event callback functions.
54
*
55
* A button callback function is called on the interrupt level whenever
56
* an event at a button occurs that the function was registered for.
57
* The callback function is passed the button id and the type of event
58
* that occurred. This way, the same callback function can be registered
59
* for different buttons and events.
60
*/
61
typedef
void (*
buttoncallback_t
) (
BUTTON
,
BUTTONEVENT
);
62
63
/**
64
* \brief Register a callback function for a button event.
65
*
66
* \param btn the id of the button
67
* \param eve the type of event that the callback function should be invoked for.
68
* event types can be bitwise or'd to register a callback for both
69
* pressed and released events.
70
* \param callback pointer to the callback function. This function is called from the
71
* interrupt handler.
72
* \retval 0 success,
73
* \retval !0 error
74
* \sa sb_button_unregisterListener
75
* \sa buttoncallback_t
76
*/
77
int8_t
sb_button_registerListener
(
BUTTON
btn,
BUTTONEVENT
eve,
buttoncallback_t
callback);
78
79
/**
80
* \brief Unregister a callback function for a button event.
81
*
82
*
83
* \param btn the id of the button
84
* \param eve the type of event that the callback function should be invoked for.
85
* event types can be bitwise or'd to register a callback for both
86
* pressed and released events.
87
* \param callback pointer to the callback function
88
* \return 0 on success, negative value on error
89
* \retval 0 success
90
* \retval -1 the callback function was not registered with the given button/event combination
91
* \sa sb_button_registerListener
92
*
93
*/
94
int8_t
sb_button_unregisterListener
(
BUTTON
btn,
BUTTONEVENT
eve,
buttoncallback_t
callback);
95
96
/**
97
* \brief Query the current state of a button.
98
*
99
* \param btn id of the button
100
* \return The buttons current state (pressed or released) as a \ref BUTTONEVENT
101
*/
102
BUTTONEVENT
sb_button_getState
(
BUTTON
btn);
103
104
/** @}*/
105
106
#endif
107
sb_button_registerListener
int8_t sb_button_registerListener(BUTTON btn, BUTTONEVENT eve, buttoncallback_t callback)
Register a callback function for a button event.
BUTTONEVENT
BUTTONEVENT
Events for buttons.
Definition:
button.h:47
BUTTON1
Definition:
button.h:39
sb_button_getState
BUTTONEVENT sb_button_getState(BUTTON btn)
Query the current state of a button.
BUTTON
BUTTON
Identifiers for all available buttons.
Definition:
button.h:37
BTNRELEASED
Definition:
button.h:49
BTNPRESSED
Definition:
button.h:48
sb_button_unregisterListener
int8_t sb_button_unregisterListener(BUTTON btn, BUTTONEVENT eve, buttoncallback_t callback)
Unregister a callback function for a button event.
buttoncallback_t
void(* buttoncallback_t)(BUTTON, BUTTONEVENT)
Type for button event callback functions.
Definition:
button.h:61
BUTTON0
Definition:
button.h:38
Impressum
Datenschutz
Stand: 2016-04-26 17:58
MS