-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathutility.h
57 lines (45 loc) · 1.03 KB
/
utility.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
/*
* @file utility.h
*
* @date Jul 24, 2017
* @author hamster
*
* Utility functions
*
*/
#ifndef UTILITY_H_
#define UTILITY_H_
#define BUTTON_PRESSED 0
#define BUTTON_RELEASED 1
#define BUTTON_DEBOUNCE_MS 15
#define BUTTON_LONG_PRESS_MS 200
typedef enum{
LEVEL0,
LEVEL1,
LEVEL2,
LEVEL3,
LEVEL4
} LEVEL;
typedef enum{
POWERUP_0,
POWERUP_1,
POWERUP_2,
POWERUP_3,
POWERUP_4
} POWERUP;
#define POLYNOM 0x0801
uint16_t calcCRC(uint8_t *data, uint8_t len);
uint16_t crc16(uint16_t crcValue, uint8_t newByte);
uint8_t getButton(bool waitForLongPress);
bool isButtonDown(int button);
void pauseUntilPress(int button);
void beep(int duration, int frequency);
void getString(char *string, uint8_t chars, bool showScroll);
void setLevelLEDs(LEVEL level);
void setPowerUpLEDs(POWERUP powerUp);
APP_TIMER_DEF(sysTickID);
void sysTickStart(void);
void sysTickHandler(void * p_context);
uint32_t getSystick(void);
uint8_t getFiles(char files[][9], char *path, uint8_t fileMax);
#endif /* UTILITY_H_ */