Skip to content

Commit e70b5db

Browse files
committed
stmhal: Some reordering of code/functions.
1 parent 92a47b4 commit e70b5db

2 files changed

Lines changed: 14 additions & 14 deletions

File tree

stmhal/main.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -548,9 +548,8 @@ int main(void) {
548548
printf("PYB: sync filesystems\n");
549549
storage_flush();
550550

551-
timer_deinit();
552-
553551
printf("PYB: soft reboot\n");
552+
timer_deinit();
554553

555554
first_soft_reset = false;
556555
goto soft_reset;

stmhal/timer.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,26 @@ static uint32_t tim3_counter = 0;
107107
STATIC pyb_timer_obj_t *pyb_timer_obj_all[14];
108108
#define PYB_TIMER_OBJ_ALL_NUM MP_ARRAY_SIZE(pyb_timer_obj_all)
109109

110+
STATIC mp_obj_t pyb_timer_deinit(mp_obj_t self_in);
111+
STATIC mp_obj_t pyb_timer_callback(mp_obj_t self_in, mp_obj_t callback);
112+
110113
void timer_init0(void) {
111114
tim3_counter = 0;
112115
for (uint i = 0; i < PYB_TIMER_OBJ_ALL_NUM; i++) {
113116
pyb_timer_obj_all[i] = NULL;
114117
}
115118
}
116119

120+
// unregister all interrupt sources
121+
void timer_deinit(void) {
122+
for (uint i = 0; i < PYB_TIMER_OBJ_ALL_NUM; i++) {
123+
pyb_timer_obj_t *tim = pyb_timer_obj_all[i];
124+
if (tim != NULL) {
125+
pyb_timer_deinit(tim);
126+
}
127+
}
128+
}
129+
117130
// TIM3 is set-up for the USB CDC interface
118131
void timer_tim3_init(void) {
119132
// set up the timer for USBD CDC
@@ -366,8 +379,6 @@ STATIC mp_obj_t pyb_timer_init(uint n_args, const mp_obj_t *args, mp_map_t *kw_a
366379
}
367380
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pyb_timer_init_obj, 1, pyb_timer_init);
368381

369-
STATIC mp_obj_t pyb_timer_callback(mp_obj_t self_in, mp_obj_t callback);
370-
371382
/// \method deinit()
372383
/// Deinitialises the timer.
373384
///
@@ -471,16 +482,6 @@ const mp_obj_type_t pyb_timer_type = {
471482
.locals_dict = (mp_obj_t)&pyb_timer_locals_dict,
472483
};
473484

474-
// Unregister all interrupt sources
475-
void timer_deinit(void) {
476-
for (uint i = 0; i < PYB_TIMER_OBJ_ALL_NUM; i++) {
477-
pyb_timer_obj_t *tim = pyb_timer_obj_all[i];
478-
if (tim != NULL) {
479-
pyb_timer_deinit(tim);
480-
}
481-
}
482-
}
483-
484485
void timer_irq_handler(uint tim_id) {
485486
if (tim_id - 1 < PYB_TIMER_OBJ_ALL_NUM) {
486487
// get the timer object

0 commit comments

Comments
 (0)