diff --git a/boards/cats_rev1/Core/Inc/config/cats_config.h b/boards/cats_rev1/Core/Inc/config/cats_config.h index 36fef565..2560d7c5 100644 --- a/boards/cats_rev1/Core/Inc/config/cats_config.h +++ b/boards/cats_rev1/Core/Inc/config/cats_config.h @@ -29,7 +29,7 @@ typedef struct { uint32_t recorder_mask; //Timers - config_timer_t timers[8]; + config_timer_t timers[4]; // Event action map config_event_actions_t event_actions[9]; } cats_config_t; diff --git a/boards/cats_rev1/Core/Inc/util/types.h b/boards/cats_rev1/Core/Inc/util/types.h index bee1bbb6..43fd6e4d 100644 --- a/boards/cats_rev1/Core/Inc/util/types.h +++ b/boards/cats_rev1/Core/Inc/util/types.h @@ -188,7 +188,7 @@ typedef struct { } control_settings_t; typedef struct { - uint16_t duration; + uint32_t duration; uint8_t start_event; uint8_t end_event; } config_timer_t; diff --git a/boards/cats_rev1/Core/Src/cli/settings.c b/boards/cats_rev1/Core/Src/cli/settings.c index 0d98e31b..1799a2d8 100644 --- a/boards/cats_rev1/Core/Src/cli/settings.c +++ b/boards/cats_rev1/Core/Src/cli/settings.c @@ -37,19 +37,19 @@ const clivalue_t valueTable[] = { // Timers { "timer1_start", VAR_UINT8 | MODE_LOOKUP, .config.lookup = { TABLE_EVENTS }, &global_cats_config.config.timers[0].start_event}, { "timer1_end", VAR_UINT8 | MODE_LOOKUP, .config.lookup = { TABLE_EVENTS }, &global_cats_config.config.timers[0].end_event}, - { "timer1_duration", VAR_UINT16, .config.minmaxUnsigned = { 1000, 60000 }, &global_cats_config.config.timers[0].duration}, + { "timer1_duration", VAR_UINT32, .config.u32Max = 1200000, &global_cats_config.config.timers[0].duration}, { "timer2_start", VAR_UINT8 | MODE_LOOKUP, .config.lookup = { TABLE_EVENTS }, &global_cats_config.config.timers[1].start_event}, { "timer2_end", VAR_UINT8 | MODE_LOOKUP, .config.lookup = { TABLE_EVENTS }, &global_cats_config.config.timers[1].end_event}, - { "timer2_duration", VAR_UINT16, .config.minmaxUnsigned = { 1000, 60000 }, &global_cats_config.config.timers[1].duration}, + { "timer2_duration", VAR_UINT32, .config.u32Max = 1200000, &global_cats_config.config.timers[1].duration}, { "timer3_start", VAR_UINT8 | MODE_LOOKUP, .config.lookup = { TABLE_EVENTS }, &global_cats_config.config.timers[2].start_event}, { "timer3_end", VAR_UINT8 | MODE_LOOKUP, .config.lookup = { TABLE_EVENTS }, &global_cats_config.config.timers[2].end_event}, - { "timer3_duration", VAR_UINT16, .config.minmaxUnsigned = { 1000, 60000 }, &global_cats_config.config.timers[2].duration}, + { "timer3_duration", VAR_UINT32, .config.u32Max = 1200000, &global_cats_config.config.timers[2].duration}, { "timer4_start", VAR_UINT8 | MODE_LOOKUP, .config.lookup = { TABLE_EVENTS }, &global_cats_config.config.timers[3].start_event}, { "timer4_end", VAR_UINT8 | MODE_LOOKUP, .config.lookup = { TABLE_EVENTS }, &global_cats_config.config.timers[3].end_event}, - { "timer4_duration", VAR_UINT16, .config.minmaxUnsigned = { 1000, 60000 }, &global_cats_config.config.timers[3].duration}, + { "timer4_duration", VAR_UINT32, .config.u32Max = 1200000, &global_cats_config.config.timers[3].duration}, }; diff --git a/boards/cats_rev1/Core/Src/config/cats_config.c b/boards/cats_rev1/Core/Src/config/cats_config.c index 1e233582..2362e087 100644 --- a/boards/cats_rev1/Core/Src/config/cats_config.c +++ b/boards/cats_rev1/Core/Src/config/cats_config.c @@ -58,8 +58,7 @@ void cc_init() { EE_CleanUp(); } void cc_defaults() { - // TODO get this working! - //memset(&global_cats_config, &DEFAULT_CONFIG, sizeof(global_cats_config)); + memcpy(&global_cats_config, &DEFAULT_CONFIG, sizeof(global_cats_config)); } /** persistence functions **/ diff --git a/boards/cats_rev1/Core/Src/tasks/task_init.c b/boards/cats_rev1/Core/Src/tasks/task_init.c index fe4cdbae..967187de 100644 --- a/boards/cats_rev1/Core/Src/tasks/task_init.c +++ b/boards/cats_rev1/Core/Src/tasks/task_init.c @@ -372,7 +372,7 @@ static void init_timers() { if (global_cats_config.config.timers[i].start_event && global_cats_config.config.timers[i].end_event) { ev_timers[i].timer_init_event = (cats_event_e)global_cats_config.config.timers[i].start_event; ev_timers[i].execute_event = (cats_event_e)global_cats_config.config.timers[i].end_event; - ev_timers[i].timer_duration_ticks = (uint32_t)global_cats_config.config.timers[i].duration; + ev_timers[i].timer_duration_ticks = global_cats_config.config.timers[i].duration; used_timers++; } } diff --git a/boards/cats_rev1Pro/src/cli/cli.c b/boards/cats_rev1Pro/src/cli/cli.c index e2a8cf5a..06048471 100644 --- a/boards/cats_rev1Pro/src/cli/cli.c +++ b/boards/cats_rev1Pro/src/cli/cli.c @@ -476,7 +476,7 @@ static void print_timer_config() { cliPrintf("\nTIMER %d\n", i + 1); cliPrintf(" Start: %s\n", p_event_table->values[global_cats_config.config.timers[i].start_event]); cliPrintf(" End: %s\n", p_event_table->values[global_cats_config.config.timers[i].end_event]); - cliPrintf(" Duration: %d ms\n", global_cats_config.config.timers[i].duration); + cliPrintf(" Duration: %lu ms\n", global_cats_config.config.timers[i].duration); } } } diff --git a/boards/cats_rev1Pro/src/cli/settings.c b/boards/cats_rev1Pro/src/cli/settings.c index daf6afa5..5387e1ee 100644 --- a/boards/cats_rev1Pro/src/cli/settings.c +++ b/boards/cats_rev1Pro/src/cli/settings.c @@ -53,29 +53,29 @@ const clivalue_t valueTable[] = { {"acc_threshhold", VAR_UINT16, .config.minmaxUnsigned = {1500, 8000}, &global_cats_config.config.control_settings.liftoff_acc_threshold}, {"mach_timer_duration", VAR_UINT16, .config.minmaxUnsigned = {0, 60000}, - &global_cats_config.config.control_settings.mach_timer_duration}, + &global_cats_config.config.control_settings.mach_timer_duration}, // Timers {"timer1_start", VAR_UINT8 | MODE_LOOKUP, .config.lookup = {TABLE_EVENTS}, &global_cats_config.config.timers[0].start_event}, {"timer1_end", VAR_UINT8 | MODE_LOOKUP, .config.lookup = {TABLE_EVENTS}, &global_cats_config.config.timers[0].end_event}, - {"timer1_duration", VAR_UINT16, .config.minmaxUnsigned = {0, 60000}, &global_cats_config.config.timers[0].duration}, + {"timer1_duration", VAR_UINT32, .config.u32Max = 1200000, &global_cats_config.config.timers[0].duration}, {"timer2_start", VAR_UINT8 | MODE_LOOKUP, .config.lookup = {TABLE_EVENTS}, &global_cats_config.config.timers[1].start_event}, {"timer2_end", VAR_UINT8 | MODE_LOOKUP, .config.lookup = {TABLE_EVENTS}, &global_cats_config.config.timers[1].end_event}, - {"timer2_duration", VAR_UINT16, .config.minmaxUnsigned = {0, 60000}, &global_cats_config.config.timers[1].duration}, + {"timer2_duration", VAR_UINT32, .config.u32Max = 1200000, &global_cats_config.config.timers[1].duration}, {"timer3_start", VAR_UINT8 | MODE_LOOKUP, .config.lookup = {TABLE_EVENTS}, &global_cats_config.config.timers[2].start_event}, {"timer3_end", VAR_UINT8 | MODE_LOOKUP, .config.lookup = {TABLE_EVENTS}, &global_cats_config.config.timers[2].end_event}, - {"timer3_duration", VAR_UINT16, .config.minmaxUnsigned = {0, 60000}, &global_cats_config.config.timers[2].duration}, + {"timer3_duration", VAR_UINT32, .config.u32Max = 1200000, &global_cats_config.config.timers[2].duration}, {"timer4_start", VAR_UINT8 | MODE_LOOKUP, .config.lookup = {TABLE_EVENTS}, &global_cats_config.config.timers[3].start_event}, {"timer4_end", VAR_UINT8 | MODE_LOOKUP, .config.lookup = {TABLE_EVENTS}, &global_cats_config.config.timers[3].end_event}, - {"timer4_duration", VAR_UINT16, .config.minmaxUnsigned = {0, 60000}, &global_cats_config.config.timers[3].duration}, + {"timer4_duration", VAR_UINT32, .config.u32Max = 1200000, &global_cats_config.config.timers[3].duration}, // Events {"ev_moving", VAR_INT16 | MODE_ARRAY, .config.array.length = 16, global_cats_config.config.action_array[EV_MOVING]}, diff --git a/boards/cats_rev1Pro/src/tasks/task_imu_read.c b/boards/cats_rev1Pro/src/tasks/task_imu_read.c index 521e1714..549943ca 100644 --- a/boards/cats_rev1Pro/src/tasks/task_imu_read.c +++ b/boards/cats_rev1Pro/src/tasks/task_imu_read.c @@ -85,12 +85,12 @@ void task_imu_read(void *argument) { /* Read and Save High-G IMU Data */ int8_t tmp_data[3]; h3lis100dl_read_raw(&ACCEL, tmp_data); - accel_data.acc_x = tmp_data[1]; - accel_data.acc_y = -tmp_data[0]; + accel_data.acc_x = tmp_data[0]; + accel_data.acc_y = tmp_data[1]; accel_data.acc_z = tmp_data[2]; - memcpy(&(global_accel.acc_x), &(accel_data.acc_x), 3 * sizeof(int8_t)); + //memcpy(&(global_accel.acc_x), &(accel_data.acc_x), 3 * sizeof(int8_t)); global_accel.ts = tick_count; - record(ACCELEROMETER, &(global_accel)); + record(ACCELEROMETER, &(accel_data)); /* TODO: The speed of copying looks to be the same, code size reduced by 16B * with memcpy vs. assignment with -0g */ diff --git a/boards/cats_rev1Pro/src/tasks/task_init.c b/boards/cats_rev1Pro/src/tasks/task_init.c index 15b548bb..a07ecbf3 100644 --- a/boards/cats_rev1Pro/src/tasks/task_init.c +++ b/boards/cats_rev1Pro/src/tasks/task_init.c @@ -371,7 +371,7 @@ static void init_timers() { if (global_cats_config.config.timers[i].duration > 0) { ev_timers[i].timer_init_event = (cats_event_e)global_cats_config.config.timers[i].start_event; ev_timers[i].execute_event = (cats_event_e)global_cats_config.config.timers[i].end_event; - ev_timers[i].timer_duration_ticks = (uint32_t)global_cats_config.config.timers[i].duration; + ev_timers[i].timer_duration_ticks = global_cats_config.config.timers[i].duration; used_timers++; } } diff --git a/boards/cats_rev1Pro/src/util/buzzer_handler.c b/boards/cats_rev1Pro/src/util/buzzer_handler.c index 4d8d9698..542b5c42 100644 --- a/boards/cats_rev1Pro/src/util/buzzer_handler.c +++ b/boards/cats_rev1Pro/src/util/buzzer_handler.c @@ -38,7 +38,7 @@ uint32_t pitch_lookup[8] = { 2793, // F D 2959, // F# E 3135, // G F - 1200, // Error G + 1200, // Error G 2217, // C# H }; @@ -62,10 +62,10 @@ const char cats_error_codes[16][BUZZER_COMMAND_MAX_LENGTH] = { const char cats_status_codes[5][BUZZER_COMMAND_MAX_LENGTH] = { " ", - "caef", // bootup - "aa", // ready - "Eca", // ready -> moving - "ace", // moving -> ready + "caef", // bootup + "aa", // ready + "Eca", // ready -> moving + "ace", // moving -> ready }; static uint32_t status_queue_index = 0; @@ -83,15 +83,15 @@ bool buzzer_queue_status(buzzer_status_e status) { } void buzzer_handler_update() { - static uint8_t error_started = 0; - if (status_queue_elements > 0 && get_error_count() == 0 && error_started == 0) { + if (status_queue_elements > 0) { if (status_buzzer(status_queue[status_queue_index]) == 0) { status_queue_index = (status_queue_index + 1) % BUZZER_MAX_STATUS_QUEUE; status_queue_elements--; } - } else if(get_error_count()>0 || error_started == 1){ - error_started = error_buzzer(log2_32(get_error_by_priority(0))); } + // else if(get_error_count()>0 || error_started == 1){ + // error_started = error_buzzer(log2_32(get_error_by_priority(0))); + // } buzzer_update(&BUZZER); } diff --git a/boards/cats_rev1Pro/src/util/types.h b/boards/cats_rev1Pro/src/util/types.h index 6863a35b..f2b6a703 100644 --- a/boards/cats_rev1Pro/src/util/types.h +++ b/boards/cats_rev1Pro/src/util/types.h @@ -215,7 +215,7 @@ typedef struct { } control_settings_t; typedef struct { - uint16_t duration; + uint32_t duration; uint8_t start_event; uint8_t end_event; } config_timer_t;