teensy: Switch from HAL_* to mp_hal_* functions.
This commit is contained in:
parent
4a9eac20b9
commit
eb099b9893
|
@ -32,7 +32,7 @@
|
||||||
#include "py/obj.h"
|
#include "py/obj.h"
|
||||||
#include "py/gc.h"
|
#include "py/gc.h"
|
||||||
|
|
||||||
#include "teensy_hal.h"
|
#include MICROPY_HAL_H
|
||||||
|
|
||||||
#include "gccollect.h"
|
#include "gccollect.h"
|
||||||
#include "irq.h"
|
#include "irq.h"
|
||||||
|
@ -161,7 +161,7 @@ STATIC mp_obj_t pyb_millis(void) {
|
||||||
// We want to "cast" the 32 bit unsigned into a small-int. This means
|
// We want to "cast" the 32 bit unsigned into a small-int. This means
|
||||||
// copying the MSB down 1 bit (extending the sign down), which is
|
// copying the MSB down 1 bit (extending the sign down), which is
|
||||||
// equivalent to just using the MP_OBJ_NEW_SMALL_INT macro.
|
// equivalent to just using the MP_OBJ_NEW_SMALL_INT macro.
|
||||||
return MP_OBJ_NEW_SMALL_INT(HAL_GetTick());
|
return MP_OBJ_NEW_SMALL_INT(mp_hal_ticks_ms());
|
||||||
}
|
}
|
||||||
STATIC MP_DEFINE_CONST_FUN_OBJ_0(pyb_millis_obj, pyb_millis);
|
STATIC MP_DEFINE_CONST_FUN_OBJ_0(pyb_millis_obj, pyb_millis);
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_0(pyb_millis_obj, pyb_millis);
|
||||||
/// # Perform some operation
|
/// # Perform some operation
|
||||||
STATIC mp_obj_t pyb_elapsed_millis(mp_obj_t start) {
|
STATIC mp_obj_t pyb_elapsed_millis(mp_obj_t start) {
|
||||||
uint32_t startMillis = mp_obj_get_int(start);
|
uint32_t startMillis = mp_obj_get_int(start);
|
||||||
uint32_t currMillis = HAL_GetTick();
|
uint32_t currMillis = mp_hal_ticks_ms();
|
||||||
return MP_OBJ_NEW_SMALL_INT((currMillis - startMillis) & 0x3fffffff);
|
return MP_OBJ_NEW_SMALL_INT((currMillis - startMillis) & 0x3fffffff);
|
||||||
}
|
}
|
||||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(pyb_elapsed_millis_obj, pyb_elapsed_millis);
|
STATIC MP_DEFINE_CONST_FUN_OBJ_1(pyb_elapsed_millis_obj, pyb_elapsed_millis);
|
||||||
|
@ -218,7 +218,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(pyb_elapsed_micros_obj, pyb_elapsed_micros);
|
||||||
STATIC mp_obj_t pyb_delay(mp_obj_t ms_in) {
|
STATIC mp_obj_t pyb_delay(mp_obj_t ms_in) {
|
||||||
mp_int_t ms = mp_obj_get_int(ms_in);
|
mp_int_t ms = mp_obj_get_int(ms_in);
|
||||||
if (ms >= 0) {
|
if (ms >= 0) {
|
||||||
HAL_Delay(ms);
|
mp_hal_delay_ms(ms);
|
||||||
}
|
}
|
||||||
return mp_const_none;
|
return mp_const_none;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,12 +7,12 @@
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#include MICROPY_HAL_H
|
#include MICROPY_HAL_H
|
||||||
|
|
||||||
uint32_t HAL_GetTick(void) {
|
uint32_t mp_hal_ticks_ms(void) {
|
||||||
return millis();
|
return millis();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HAL_Delay(uint32_t Delay) {
|
void mp_hal_delay_ms(uint32_t ms) {
|
||||||
delay(Delay);
|
delay(ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mp_hal_set_interrupt_char(int c) {
|
void mp_hal_set_interrupt_char(int c) {
|
||||||
|
|
|
@ -112,8 +112,8 @@ __attribute__(( always_inline )) static inline void __WFI(void) {
|
||||||
__asm volatile ("wfi");
|
__asm volatile ("wfi");
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t HAL_GetTick(void);
|
uint32_t mp_hal_ticks_ms(void);
|
||||||
void HAL_Delay(uint32_t Delay);
|
void mp_hal_delay_ms(uint32_t delay);
|
||||||
void mp_hal_set_interrupt_char(int c);
|
void mp_hal_set_interrupt_char(int c);
|
||||||
|
|
||||||
void mp_hal_gpio_clock_enable(GPIO_TypeDef *gpio);
|
void mp_hal_gpio_clock_enable(GPIO_TypeDef *gpio);
|
||||||
|
|
Loading…
Reference in New Issue