Callisto4Bootloader: lib/c4_error_codes.c Source File

Callisto4Bootloader

c4_error_codes.c
Go to the documentation of this file.
1
12 #include "c4_error_codes.h"
13 #include "c4_privilege_modes.h"
14 //#include "fsl_debug_console.h"
15 #include <stdio.h>
16 #include <stdint.h>
17
18 static void C4_flashError(const uint32_t err[6]);
19
20 static const uint16_t g_ditLength = 1000U * 60/50/2/5; // milli-seconds
21
22 #define DIT (1)
23 #define DI (DIT)
24 #define DAH (3)
25 #define CODE_SPACE (1)
26 #define CHAR_SPACE (3 - CODE_SPACE)
27 #define WORD_SPACE (7 - CHAR_SPACE - CODE_SPACE)
28
29
30 static const uint32_t FlashCode[C4_ERR_MAX][6] = {
31 #define CALLISTO_ERR(name, text, ...) __VA_ARGS__ ,
32 ERROR_LIST
33 #undef CALLISTO_ERR
34 };
35
36 const char err_strings[C4_ERR_MAX][72] = {
37 #define CALLISTO_ERR(name, text, ...) "C4_ERR_"#name" : "#text,
38 ERROR_LIST
39 #undef CALLISTO_ERR
40 };
41
42 extern void BL_SysTick_DelayTicks(uint32_t n);
43
44 void C4_displayError(const char *text, exit_code_t errVal, bool fatal)
45 {
46 printf("%s: %s\n", err_strings[errVal], text);
47
48 do {
49 C4_flashError(FlashCode[errVal]);
50 BL_SysTick_DelayTicks(3 * DIT * g_ditLength);
51 } while ((true == fatal) && (C4_ERR_OK != errVal));
52 }
53
54 void C4_flashError(const uint32_t code[6])
55 {
56 for (unsigned int i = 1; i < 6; ++i)
57 {
58 FlashLed(code[0], code[i]*g_ditLength, CODE_SPACE*g_ditLength);
59 }
60
61 BL_SysTick_DelayTicks(CHAR_SPACE);
62 }
63
ERROR_LIST
#define ERROR_LIST
Error codes and strings.
Definition: c4_error_codes.h:36
C4_displayError
void C4_displayError(const char *text, exit_code_t errVal, bool fatal)
Print exit code on serial line and flash led.
Definition: c4_error_codes.c:44
g_ditLength
static const uint16_t g_ditLength
Definition: c4_error_codes.c:20
c4_error_codes.h
Enumeration of Error Codes.
i
volatile int i
Definition: excep_test.c:17
FlashCode
static const uint32_t FlashCode[C4_ERR_MAX][6]
Definition: c4_error_codes.c:30
exit_code_t
exit_code_t
Enumeration of error codes.
Definition: c4_error_codes.h:96
CODE_SPACE
#define CODE_SPACE
Definition: c4_error_codes.c:25
BL_SysTick_DelayTicks
void BL_SysTick_DelayTicks(uint32_t n)
Sets a delay.
Definition: bootloader.c:317
FlashLed
void FlashLed(colour_t led, unsigned int on, unsigned int off)
Flash the led in the specified colour.
Definition: c4_colours.c:55
C4_ERR_MAX
Definition: c4_error_codes.h:102
C4_flashError
static void C4_flashError(const uint32_t err[6])
Definition: c4_error_codes.c:54
err_strings
const char err_strings[C4_ERR_MAX][72]
Definition: c4_error_codes.c:36
c4_privilege_modes.h
Provide mechanisms to specify which stack to use and for the processor to operate in Unprivileged mod...
DIT
#define DIT
Definition: c4_error_codes.c:22
CHAR_SPACE
#define CHAR_SPACE
Definition: c4_error_codes.c:26