-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy patherror.h
More file actions
52 lines (41 loc) · 1.17 KB
/
error.h
File metadata and controls
52 lines (41 loc) · 1.17 KB
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
/*
* error.h
*
* Description: Provides declarations for variables and function prototypes related to error handling.
*
* Created on: Mar 30, 2024
* Author: Moiz
*/
#include <cstdint>
#ifndef INC_ERROR_H_
#define INC_ERROR_H_
#define ERROR_LOG_SIZE 10
typedef enum
{
ERR_LOW,
ERR_MID,
ERR_HIGH
}errlevel;
typedef enum
{
SLOW_BLINK,
FAST_BLINK,
}ledpattern;
typedef enum
{
OK,
ERROR
} errcode;
// TODO: Move both of these definitions to source code later otherwise the compiler will complain (multiple definitions)
errcode errlog[ERROR_LOG_SIZE];
uint8_t index;
//-- Internal functions
static void reportError(errcode err_code, errlevel err_level); // Sending all accumulated error codes through UART and/or through CAN
static void logError(errcode err_code); // Add error to error logs. Can be stored in memory
static void ledIndicationError(ledpattern pattern);
static void I2C_ErrorResetCycle(I2C_HandleTypeDef handle, uint16_t device_address, uint8_t register_address, int read_regs);
//-- Public Functions
#define REPORT_ERR(err_code, err_level) (reportError(err_code, err_level))
errcode getLatestError(void);
void clearAllErrors(void);
#endif /* INC_ERROR_H_ */