mirror of
https://github.com/Polprzewodnikowy/SummerCart64.git
synced 2024-11-21 21:49:15 +01:00
led error codes
This commit is contained in:
parent
27fe9b6d7b
commit
e7bce4df53
@ -9,11 +9,27 @@
|
||||
#define LED_CYCLE_TICKS_ON (3)
|
||||
|
||||
|
||||
typedef enum {
|
||||
ON,
|
||||
OFF
|
||||
} led_state_e;
|
||||
|
||||
typedef struct {
|
||||
uint32_t timer;
|
||||
led_state_e state;
|
||||
} error_cycle_t;
|
||||
|
||||
|
||||
static uint32_t timer = 0;
|
||||
static uint8_t error_cycle = 0;
|
||||
static uint32_t current_act_counter = 0;
|
||||
static volatile uint32_t next_act_counter = 0;
|
||||
static volatile bool cic_error = false;
|
||||
static volatile bool rtc_error = false;
|
||||
static const error_cycle_t error_codes[2][8] = {
|
||||
{ { 50, ON }, { 50, OFF }, { 5, ON }, { 0, OFF }, { 0, OFF }, { 0, OFF }, { 0, OFF }, { 100, OFF } },
|
||||
{ { 50, ON }, { 50, OFF }, { 5, ON }, { 20, OFF }, { 5, ON }, { 0, OFF }, { 0, OFF }, { 100, OFF } },
|
||||
};
|
||||
|
||||
|
||||
static void led_task_resume (void) {
|
||||
@ -44,7 +60,27 @@ static void led_process_act (void) {
|
||||
}
|
||||
|
||||
static void led_process_errors (void) {
|
||||
// TODO: implement error blink codes
|
||||
if (timer > 0) {
|
||||
timer -= 1;
|
||||
} else {
|
||||
uint8_t error_code = 0;
|
||||
if (cic_error) {
|
||||
error_code = 0;
|
||||
} else if (rtc_error) {
|
||||
error_code = 1;
|
||||
}
|
||||
error_cycle_t error = error_codes[error_code][error_cycle];
|
||||
timer = error.timer;
|
||||
if (error.state == ON) {
|
||||
hw_gpio_set(GPIO_ID_LED);
|
||||
} else {
|
||||
hw_gpio_reset(GPIO_ID_LED);
|
||||
}
|
||||
error_cycle += 1;
|
||||
if (error_cycle >= 8) {
|
||||
error_cycle = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -81,6 +117,7 @@ void led_task (void) {
|
||||
if (led_has_errors()) {
|
||||
led_process_errors();
|
||||
} else {
|
||||
error_cycle = 0;
|
||||
led_process_act();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user