summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormicroDev <70126934+microDev1@users.noreply.github.com>2020-11-22 19:20:21 +0530
committermicroDev <70126934+microDev1@users.noreply.github.com>2020-11-22 19:20:21 +0530
commitf3b5ca5f01058cb1d50be09838bc55b22d3aae69 (patch)
treece37d9cdf9dddecddca24ff049cd5f2db0f29811
parentc457d373e18a5bcadec44e0815bea8b9beb30a97 (diff)
replace goto with conditional break
-rw-r--r--ports/esp32s2/peripherals/timer.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/ports/esp32s2/peripherals/timer.c b/ports/esp32s2/peripherals/timer.c
index 3aee33dc5..0ae140387 100644
--- a/ports/esp32s2/peripherals/timer.c
+++ b/ports/esp32s2/peripherals/timer.c
@@ -46,6 +46,8 @@ void peripherals_timer_reset(void) {
}
void peripherals_timer_init(const timer_config_t * config, timer_index_t * timer) {
+ bool break_loop = false;
+
// get free timer
for (uint8_t i = 0; i < 2; i++) {
for (uint8_t j = 0; j < 2; j++) {
@@ -53,16 +55,17 @@ void peripherals_timer_init(const timer_config_t * config, timer_index_t * timer
timer->idx = (timer_idx_t)j;
timer->group = (timer_group_t)i;
timer_state[i][j] = TIMER_BUSY;
- goto init_timer;
+ break_loop = true;
+ break;
} else if (i == 1 && j == 1) {
timer->idx = TIMER_MAX;
timer->group = TIMER_GROUP_MAX;
return;
}
}
+ if (break_loop) {break;}
}
-init_timer:
// initialize timer module
timer_init(timer->group, timer->idx, config);
timer_set_counter_value(timer->group, timer->idx, 0);