-
Notifications
You must be signed in to change notification settings - Fork 1
/
utility.h
75 lines (58 loc) · 1.57 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
* @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 CRC_SEED_DC26 0x0801
#define CRC_SEED_DC27 0x0180
uint16_t calcCRC(uint8_t *data, uint8_t len, const uint16_t POLYNOM);
uint16_t crc16(uint16_t crcValue, uint8_t newByte, const uint16_t POLYNOM);
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);
uint32_t millis_elapsed(uint32_t currentMillis, uint32_t previousMillis);
uint32_t millis();
uint8_t getFiles(char files[][9], char *path, uint8_t fileMax);
void EEpwm_init();
void EEpwm_set(int percent);
void EEget_milliVolts(int percent, int *v1, int *v2, int *v3);
uint32_t hex2dec(uint32_t v);
int RC4(const char *key, unsigned char *data, size_t dataLen);
int decryptFile(const char* key, const char* infile, const char* outfile);
void morseInit(void);
void morseStart(void);
void morseStop(void);
bool morseGetRunning(void);
#endif /* UTILITY_H_ */