Commit 9b12bc78 authored by Paul Sokolovsky's avatar Paul Sokolovsky
Browse files

cc3200: Switch from HAL_GetTick() to mp_hal_ticks_ms().

parent 19b671c5
......@@ -104,7 +104,7 @@ void HAL_IncrementTick(void) {
HAL_tickCount++;
}
uint32_t HAL_GetTick(void) {
uint32_t mp_hal_ticks_ms(void) {
return HAL_tickCount;
}
......
......@@ -62,7 +62,7 @@
extern void HAL_SystemInit (void);
extern void HAL_SystemDeInit (void);
extern void HAL_IncrementTick(void);
extern uint32_t HAL_GetTick(void);
extern uint32_t mp_hal_ticks_ms(void);
extern void mp_hal_delay_ms(uint32_t delay);
extern NORETURN void mp_hal_raise(int errno);
extern void mp_hal_set_interrupt_char (int c);
......
......@@ -151,12 +151,12 @@ void mperror_heartbeat_signal (void) {
mperror_heart_beat.do_disable = false;
} else if (mperror_heart_beat.enabled) {
if (!mperror_heart_beat.beating) {
if ((mperror_heart_beat.on_time = HAL_GetTick()) - mperror_heart_beat.off_time > MPERROR_HEARTBEAT_OFF_MS) {
if ((mperror_heart_beat.on_time = mp_hal_ticks_ms()) - mperror_heart_beat.off_time > MPERROR_HEARTBEAT_OFF_MS) {
MAP_GPIOPinWrite(MICROPY_SYS_LED_PORT, MICROPY_SYS_LED_PORT_PIN, MICROPY_SYS_LED_PORT_PIN);
mperror_heart_beat.beating = true;
}
} else {
if ((mperror_heart_beat.off_time = HAL_GetTick()) - mperror_heart_beat.on_time > MPERROR_HEARTBEAT_ON_MS) {
if ((mperror_heart_beat.off_time = mp_hal_ticks_ms()) - mperror_heart_beat.on_time > MPERROR_HEARTBEAT_ON_MS) {
MAP_GPIOPinWrite(MICROPY_SYS_LED_PORT, MICROPY_SYS_LED_PORT_PIN, 0);
mperror_heart_beat.beating = false;
}
......
......@@ -40,12 +40,12 @@
bool sys_tick_has_passed(uint32_t start_tick, uint32_t delay_ms) {
return HAL_GetTick() - start_tick >= delay_ms;
return mp_hal_ticks_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.
// mp_hal_ticks_ms() some time before calling this function.
void sys_tick_wait_at_least(uint32_t start_tick, uint32_t delay_ms) {
#ifdef USE_FREERTOS
vTaskDelay (delay_ms / portTICK_PERIOD_MS);
......@@ -58,11 +58,11 @@ void sys_tick_wait_at_least(uint32_t start_tick, uint32_t delay_ms) {
// The SysTick timer counts down at HAL_FCPU_HZ, so we can use that knowledge
// to grab a microsecond counter.
// We assume that HAL_GetTick returns milliseconds.
// We assume that mp_hal_ticks_ms returns milliseconds.
uint32_t sys_tick_get_microseconds(void) {
mp_uint_t irq_state = disable_irq();
uint32_t counter = SysTickValueGet();
uint32_t milliseconds = HAL_GetTick();
uint32_t milliseconds = mp_hal_ticks_ms();
enable_irq(irq_state);
uint32_t load = SysTickPeriodGet();
......
......@@ -151,7 +151,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(time_sleep_us_obj, time_sleep_us);
STATIC mp_obj_t time_ticks_ms(void) {
// We want to "cast" the 32 bit unsigned into a 30-bit small-int
return MP_OBJ_NEW_SMALL_INT(HAL_GetTick() & MP_SMALL_INT_POSITIVE_MASK);
return MP_OBJ_NEW_SMALL_INT(mp_hal_ticks_ms() & MP_SMALL_INT_POSITIVE_MASK);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_0(time_ticks_ms_obj, time_ticks_ms);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment