-
Notifications
You must be signed in to change notification settings - Fork 0
/
BNT.h
59 lines (48 loc) · 1.38 KB
/
BNT.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*! @file BNT.h
*
* @brief Routines for controlling buttons on the PIC16F87XA.
*
* @author A.Pope
* @date 02-08-2016
*/
#ifndef BNT_H
#define BNT_H
#ifdef __cplusplus
extern "C" {
#endif
#include "types.h"
/* Definition of push buttons and corresponding port pins */
#define BNT_PB1 !RB2
#define BNT_PB2 !RB3
#define BNT_PB3 !RB4
#define BNT_PB4 !RB5
#define BNT_DEB_COUNT 10
typedef void (*buttonCBFunc) (void); /* Used within the button struct. It is a function that is invoked upon button press */
typedef struct
{
volatile bool bntPressed; /* Indicates if button is pressed */
volatile bool bntReleased; /* Indicates if button is released */
volatile unsigned int bntDebounceCnt; /* Used to debounce the button */
buttonCBFunc cm; /* Function to invoke on press */
} button_t;
/*! @brief Sets up the button module before first use.
*
* @return TRUE if the module was successfully initialized.
*/
bool BNT_Init(void);
/*! @brief Debounces a specific button.
*
* @param button - The button to debounce
* @note Assumes that DEB_Init has been called.
*/
void BNT_Debounce(button_t *button);
/*! @brief Resets the debouncing process for a button.
*
* @param button - The button to reset
* @note Assumes that DEB_Init has been called.
*/
void BNT_ResetDebounce(button_t *button);
#ifdef __cplusplus
}
#endif
#endif /* BNT_H */