mimxrt: clean up unused systick code, and fix `mp_hal_delay_ms(0)` by dpgeorge · Pull Request #19115 · micropython/micropython · GitHub
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions ports/mimxrt/mphalport.h
2 changes: 2 additions & 0 deletions ports/mimxrt/pendsv.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#ifndef MICROPY_INCLUDED_MIMXRT_PENDSV_H
#define MICROPY_INCLUDED_MIMXRT_PENDSV_H

#include "py/mpconfig.h"

enum {
PENDSV_DISPATCH_SOFT_TIMER, // For later & for having at least one entry
#if MICROPY_PY_NETWORK && MICROPY_PY_LWIP
Expand Down
20 changes: 1 addition & 19 deletions ports/mimxrt/systick.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@
* THE SOFTWARE.
*/

#include "py/runtime.h"
#include "py/mphal.h"
#include "systick.h"

#include "pendsv.h"
#include "shared/runtime/softtimer.h"

Expand All @@ -36,9 +33,7 @@ volatile uint32_t systick_ms = 0;
systick_dispatch_t systick_dispatch_table[SYSTICK_DISPATCH_NUM_SLOTS];

void SysTick_Handler(void) {
// Instead of calling HAL_IncTick we do the increment here of the counter.
// This is purely for efficiency, since SysTick is called 1000 times per
// second at the highest interrupt priority.
// Increment the systick millisecond counter.
uint32_t uw_tick = systick_ms + 1;
systick_ms = uw_tick;

Expand All @@ -52,16 +47,3 @@ void SysTick_Handler(void) {
pendsv_schedule_dispatch(PENDSV_DISPATCH_SOFT_TIMER, soft_timer_handler);
}
}

bool systick_has_passed(uint32_t start_tick, uint32_t delay_ms) {
return systick_ms - start_tick >= delay_ms;
}

// waits until at least delay_ms milliseconds have passed from the sampling of
// startTick. Handles overflow properly. Assumes stc was taken from
// HAL_GetTick() some time before calling this function.
void systick_wait_at_least(uint32_t start_tick, uint32_t delay_ms) {
while (!systick_has_passed(start_tick, delay_ms)) {
__WFI(); // enter sleep mode, waiting for interrupt
}
}
5 changes: 2 additions & 3 deletions ports/mimxrt/systick.h
Loading