Compare commits
10 Commits
c0252d73c6
...
281615c157
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
281615c157 | ||
| f05c88b116 | |||
| b40d0673a7 | |||
| 05d92db6f3 | |||
|
|
4ce2dd2cda | ||
|
|
593ae04eeb | ||
|
|
ce109af712 | ||
|
|
d5ecda05eb | ||
|
|
255d74b5a8 | ||
|
|
7c8ae78a03 |
Submodule lib/micropython-lib updated: 5b496e944e...34c4ee1647
Submodule lib/pico-sdk updated: 9a4113fbba...bddd20f928
@@ -132,10 +132,12 @@
|
||||
#define MICROPY_PY_MACHINE_PULSE (1)
|
||||
#define MICROPY_PY_MACHINE_I2C (MICROPY_HW_ENABLE_HW_I2C)
|
||||
#define MICROPY_PY_MACHINE_I2C_TRANSFER_WRITE1 (1)
|
||||
#ifndef MICROPY_PY_MACHINE_I2C_TARGET
|
||||
#define MICROPY_PY_MACHINE_I2C_TARGET (MICROPY_HW_ENABLE_HW_I2C)
|
||||
#define MICROPY_PY_MACHINE_I2C_TARGET_INCLUDEFILE "ports/alif/machine_i2c_target.c"
|
||||
#define MICROPY_PY_MACHINE_I2C_TARGET_MAX (4)
|
||||
#define MICROPY_PY_MACHINE_I2C_TARGET_HARD_IRQ (1)
|
||||
#endif
|
||||
#define MICROPY_PY_MACHINE_SOFTI2C (1)
|
||||
#define MICROPY_PY_MACHINE_SPI (1)
|
||||
#define MICROPY_PY_MACHINE_SOFTSPI (1)
|
||||
|
||||
@@ -38,13 +38,13 @@
|
||||
#include "hal/timer_hal.h"
|
||||
#include "hal/timer_ll.h"
|
||||
#include "soc/timer_periph.h"
|
||||
#include "esp_private/esp_clk_tree_common.h"
|
||||
#include "esp_private/periph_ctrl.h"
|
||||
#include "machine_timer.h"
|
||||
|
||||
#define TIMER_CLK_SRC GPTIMER_CLK_SRC_DEFAULT
|
||||
#define TIMER_DIVIDER 8
|
||||
|
||||
// TIMER_BASE_CLK is normally 80MHz. TIMER_DIVIDER ought to divide this exactly
|
||||
#define TIMER_SCALE (APB_CLK_FREQ / TIMER_DIVIDER)
|
||||
|
||||
#define TIMER_FLAGS 0
|
||||
|
||||
const mp_obj_type_t machine_timer_type;
|
||||
@@ -52,6 +52,14 @@ const mp_obj_type_t machine_timer_type;
|
||||
static mp_obj_t machine_timer_init_helper(machine_timer_obj_t *self, mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args);
|
||||
static mp_obj_t machine_timer_deinit(mp_obj_t self_in);
|
||||
|
||||
uint32_t machine_timer_freq_hz(void) {
|
||||
// The timer source clock is APB or a fixed PLL (depending on chip), both constant frequency.
|
||||
uint32_t freq;
|
||||
check_esp_err(esp_clk_tree_src_get_freq_hz(TIMER_CLK_SRC, ESP_CLK_TREE_SRC_FREQ_PRECISION_CACHED, &freq));
|
||||
assert(freq % TIMER_DIVIDER == 0); // Source clock should divide evenly into TIMER_DIVIDER
|
||||
return freq / TIMER_DIVIDER;
|
||||
}
|
||||
|
||||
void machine_timer_deinit_all(void) {
|
||||
// Disable, deallocate and remove all timers from list
|
||||
machine_timer_obj_t **t = &MP_STATE_PORT(machine_timer_obj_head);
|
||||
@@ -66,7 +74,7 @@ void machine_timer_deinit_all(void) {
|
||||
static void machine_timer_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
|
||||
machine_timer_obj_t *self = self_in;
|
||||
qstr mode = self->repeat ? MP_QSTR_PERIODIC : MP_QSTR_ONE_SHOT;
|
||||
uint64_t period = self->period / (TIMER_SCALE / 1000); // convert to ms
|
||||
uint64_t period = self->period / (machine_timer_freq_hz() / 1000); // convert to ms
|
||||
#if SOC_TIMER_GROUP_TIMERS_PER_GROUP == 1
|
||||
mp_printf(print, "Timer(%u, mode=%q, period=%lu)", self->group, mode, period);
|
||||
#else
|
||||
@@ -163,8 +171,18 @@ static void machine_timer_isr_handler(machine_timer_obj_t *self) {
|
||||
void machine_timer_enable(machine_timer_obj_t *self) {
|
||||
// Initialise the timer.
|
||||
timer_hal_init(&self->hal_context, self->group, self->index);
|
||||
|
||||
PERIPH_RCC_ACQUIRE_ATOMIC(timer_group_periph_signals.groups[self->index].module, ref_count) {
|
||||
if (ref_count == 0) {
|
||||
timer_ll_enable_bus_clock(self->index, true);
|
||||
timer_ll_reset_register(self->index);
|
||||
}
|
||||
}
|
||||
|
||||
timer_ll_enable_counter(self->hal_context.dev, self->index, false);
|
||||
timer_ll_set_clock_source(self->hal_context.dev, self->index, GPTIMER_CLK_SRC_DEFAULT);
|
||||
esp_clk_tree_enable_src(TIMER_CLK_SRC, true);
|
||||
timer_ll_set_clock_source(self->hal_context.dev, self->index, TIMER_CLK_SRC);
|
||||
timer_ll_enable_clock(self->hal_context.dev, self->index, true);
|
||||
timer_ll_set_clock_prescale(self->hal_context.dev, self->index, TIMER_DIVIDER);
|
||||
timer_hal_set_counter_value(&self->hal_context, 0);
|
||||
timer_ll_set_count_direction(self->hal_context.dev, self->index, GPTIMER_COUNT_UP);
|
||||
@@ -224,7 +242,7 @@ static mp_obj_t machine_timer_init_helper(machine_timer_obj_t *self, mp_uint_t n
|
||||
|
||||
#if MICROPY_PY_BUILTINS_FLOAT
|
||||
if (args[ARG_freq].u_obj != mp_const_none) {
|
||||
self->period = (uint64_t)(TIMER_SCALE / mp_obj_get_float(args[ARG_freq].u_obj));
|
||||
self->period = (uint64_t)(machine_timer_freq_hz() / mp_obj_get_float(args[ARG_freq].u_obj));
|
||||
}
|
||||
#else
|
||||
if (args[ARG_freq].u_int != 0xffffffff) {
|
||||
@@ -232,7 +250,7 @@ static mp_obj_t machine_timer_init_helper(machine_timer_obj_t *self, mp_uint_t n
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
self->period = (((uint64_t)args[ARG_period].u_int) * TIMER_SCALE) / args[ARG_tick_hz].u_int;
|
||||
self->period = (((uint64_t)args[ARG_period].u_int) * machine_timer_freq_hz()) / args[ARG_tick_hz].u_int;
|
||||
}
|
||||
|
||||
self->repeat = args[ARG_mode].u_int;
|
||||
@@ -268,7 +286,7 @@ static mp_obj_t machine_timer_value(mp_obj_t self_in) {
|
||||
mp_raise_ValueError(MP_ERROR_TEXT("timer not set"));
|
||||
}
|
||||
uint64_t result = timer_ll_get_counter_value(self->hal_context.dev, self->index);
|
||||
return MP_OBJ_NEW_SMALL_INT((mp_uint_t)(result / (TIMER_SCALE / 1000))); // value in ms
|
||||
return MP_OBJ_NEW_SMALL_INT((mp_uint_t)(result / (machine_timer_freq_hz() / 1000))); // value in ms
|
||||
}
|
||||
static MP_DEFINE_CONST_FUN_OBJ_1(machine_timer_value_obj, machine_timer_value);
|
||||
|
||||
|
||||
@@ -34,13 +34,6 @@
|
||||
#include "hal/timer_ll.h"
|
||||
#include "soc/timer_periph.h"
|
||||
|
||||
#define TIMER_DIVIDER 8
|
||||
|
||||
// TIMER_BASE_CLK is normally 80MHz. TIMER_DIVIDER ought to divide this exactly
|
||||
#define TIMER_SCALE (APB_CLK_FREQ / TIMER_DIVIDER)
|
||||
|
||||
#define TIMER_FLAGS 0
|
||||
|
||||
typedef struct _machine_timer_obj_t {
|
||||
mp_obj_base_t base;
|
||||
|
||||
@@ -64,4 +57,6 @@ machine_timer_obj_t *machine_timer_create(mp_uint_t timer);
|
||||
void machine_timer_enable(machine_timer_obj_t *self);
|
||||
void machine_timer_disable(machine_timer_obj_t *self);
|
||||
|
||||
uint32_t machine_timer_freq_hz(void);
|
||||
|
||||
#endif // MICROPY_INCLUDED_ESP32_MACHINE_TIMER_H
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
#define UART_IRQ_RXIDLE (0x1000)
|
||||
#define UART_IRQ_BREAK (1 << UART_BREAK)
|
||||
#define MP_UART_ALLOWED_FLAGS (UART_IRQ_RX | UART_IRQ_RXIDLE | UART_IRQ_BREAK)
|
||||
#define RXIDLE_TIMER_MIN (5000) // 500 us
|
||||
#define RXIDLE_TIMER_MIN (machine_timer_freq_hz() * 5 / 10000) // 500us minimum rxidle time
|
||||
#define UART_QUEUE_SIZE (3)
|
||||
|
||||
enum {
|
||||
@@ -535,7 +535,7 @@ static void uart_irq_configure_timer(machine_uart_obj_t *self, mp_uint_t trigger
|
||||
self->mp_irq_obj->ishard = false;
|
||||
uint32_t baudrate;
|
||||
uart_get_baudrate(self->uart_num, &baudrate);
|
||||
mp_int_t period = TIMER_SCALE * 20 / baudrate + 1;
|
||||
mp_int_t period = machine_timer_freq_hz() * 20 / baudrate + 1;
|
||||
if (period < RXIDLE_TIMER_MIN) {
|
||||
period = RXIDLE_TIMER_MIN;
|
||||
}
|
||||
|
||||
@@ -139,11 +139,13 @@
|
||||
#define MICROPY_PY_MACHINE_PWM_INCLUDEFILE "ports/esp32/machine_pwm.c"
|
||||
#define MICROPY_PY_MACHINE_I2C (1)
|
||||
#define MICROPY_PY_MACHINE_I2C_TRANSFER_WRITE1 (1)
|
||||
#ifndef MICROPY_PY_MACHINE_I2C_TARGET
|
||||
// I2C target hardware is limited on ESP32 (eg read event comes after the read) so we only support newer SoCs.
|
||||
// ESP32C6 does not have enough flash space so also disable it on that SoC.
|
||||
#define MICROPY_PY_MACHINE_I2C_TARGET (SOC_I2C_SUPPORT_SLAVE && !CONFIG_IDF_TARGET_ESP32 && !CONFIG_IDF_TARGET_ESP32C6)
|
||||
#define MICROPY_PY_MACHINE_I2C_TARGET_INCLUDEFILE "ports/esp32/machine_i2c_target.c"
|
||||
#define MICROPY_PY_MACHINE_I2C_TARGET_MAX (2)
|
||||
#endif
|
||||
#define MICROPY_PY_MACHINE_SOFTI2C (1)
|
||||
#define MICROPY_PY_MACHINE_SPI (1)
|
||||
#define MICROPY_PY_MACHINE_SOFTSPI (1)
|
||||
|
||||
@@ -92,11 +92,13 @@ uint32_t trng_random_u32(void);
|
||||
#define MICROPY_PY_MACHINE_PWM (1)
|
||||
#define MICROPY_PY_MACHINE_PWM_INCLUDEFILE "ports/mimxrt/machine_pwm.c"
|
||||
#define MICROPY_PY_MACHINE_I2C (1)
|
||||
#ifndef MICROPY_PY_MACHINE_I2C_TARGET
|
||||
#define MICROPY_PY_MACHINE_I2C_TARGET (1)
|
||||
#define MICROPY_PY_MACHINE_I2C_TARGET_INCLUDEFILE "ports/mimxrt/machine_i2c_target.c"
|
||||
#define MICROPY_PY_MACHINE_I2C_TARGET_MAX (FSL_FEATURE_SOC_LPI2C_COUNT)
|
||||
#define MICROPY_PY_MACHINE_I2C_TARGET_HARD_IRQ (1)
|
||||
#define MICROPY_PY_MACHINE_I2C_TARGET_FINALISER (1)
|
||||
#endif
|
||||
#ifndef MICROPY_PY_MACHINE_I2S
|
||||
#define MICROPY_PY_MACHINE_I2S (0)
|
||||
#endif
|
||||
|
||||
@@ -99,6 +99,7 @@
|
||||
#ifndef MICROPY_FLOAT_IMPL // can be configured by each board via mpconfigboard.mk
|
||||
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT)
|
||||
#endif
|
||||
#define MICROPY_TIME_SUPPORT_Y1969_AND_BEFORE (1)
|
||||
#define MICROPY_USE_INTERNAL_ERRNO (1)
|
||||
#define MICROPY_SCHEDULER_DEPTH (8)
|
||||
#define MICROPY_SCHEDULER_STATIC_NODES (1)
|
||||
|
||||
@@ -479,6 +479,15 @@ if (MICROPY_PY_NETWORK_WIZNET5K)
|
||||
)
|
||||
endif()
|
||||
|
||||
if (MICROPY_PY_BTREE)
|
||||
target_link_libraries(${MICROPY_TARGET} micropy_extmod_btree)
|
||||
target_compile_definitions(${MICROPY_TARGET} PRIVATE
|
||||
MICROPY_STREAMS_POSIX_API=1
|
||||
MICROPY_BERKELEY_DB_DEFPSIZE=1024
|
||||
MICROPY_BERKELEY_DB_MINCACHE=3
|
||||
)
|
||||
endif()
|
||||
|
||||
# Add qstr sources for extmod and usermod, in case they are modified by components above.
|
||||
list(APPEND MICROPY_SOURCE_QSTR
|
||||
${MICROPY_SOURCE_EXTMOD}
|
||||
@@ -572,13 +581,14 @@ set_source_files_properties(
|
||||
)
|
||||
|
||||
target_compile_definitions(${MICROPY_TARGET} PRIVATE
|
||||
${MICROPY_DEF_CORE}
|
||||
${MICROPY_DEF_BOARD}
|
||||
FFCONF_H=\"${MICROPY_OOFATFS_DIR}/ffconf.h\"
|
||||
LFS1_NO_MALLOC LFS1_NO_DEBUG LFS1_NO_WARN LFS1_NO_ERROR LFS1_NO_ASSERT
|
||||
LFS2_NO_MALLOC LFS2_NO_DEBUG LFS2_NO_WARN LFS2_NO_ERROR LFS2_NO_ASSERT
|
||||
PICO_FLOAT_PROPAGATE_NANS=1
|
||||
PICO_STACK_SIZE=0x2000
|
||||
PICO_CORE1_STACK_SIZE=0
|
||||
PICO_STACK_SIZE=0x1000
|
||||
PICO_CORE1_STACK_SIZE=0x1000
|
||||
PICO_MAX_SHARED_IRQ_HANDLERS=8 # we need more than the default
|
||||
PICO_PROGRAM_NAME="MicroPython"
|
||||
PICO_NO_PROGRAM_VERSION_STRING=1 # do it ourselves in main.c
|
||||
|
||||
@@ -69,7 +69,7 @@ SECTIONS
|
||||
* FLASH ... we will include any thing excluded here in .data below by default */
|
||||
*(.init)
|
||||
/* Change for MicroPython... exclude gc.c, parse.c, vm.c from flash */
|
||||
*(EXCLUDE_FILE(*libgcc.a: *libc.a: *lib_a-mem*.o *libm.a: *gc.c.obj *vm.c.obj *parse.c.obj) .text*)
|
||||
*(EXCLUDE_FILE(*libgcc.a: *libc.a: *lib_a-mem*.o *libm.a: *gc.c.obj *vm.c.obj *parse.c.obj *libhelix_mp3.a:) .text*)
|
||||
*(.fini)
|
||||
/* Pull all c'tors into .text */
|
||||
*crtbegin.o(.ctors)
|
||||
@@ -89,7 +89,7 @@ SECTIONS
|
||||
} > FLASH
|
||||
|
||||
.rodata : {
|
||||
*(EXCLUDE_FILE(*libgcc.a: *libc.a:*lib_a-mem*.o *libm.a:) .rodata*)
|
||||
*(EXCLUDE_FILE(*libgcc.a: *libc.a:*lib_a-mem*.o *libm.a: *libhelix_mp3.a:) .rodata*)
|
||||
. = ALIGN(4);
|
||||
*(SORT_BY_ALIGNMENT(SORT_BY_NAME(.flashdata*)))
|
||||
. = ALIGN(4);
|
||||
|
||||
@@ -171,10 +171,12 @@
|
||||
#define MICROPY_PY_MACHINE_PWM (1)
|
||||
#define MICROPY_PY_MACHINE_PWM_INCLUDEFILE "ports/rp2/machine_pwm.c"
|
||||
#define MICROPY_PY_MACHINE_I2C (1)
|
||||
#ifndef MICROPY_PY_MACHINE_I2C_TARGET
|
||||
#define MICROPY_PY_MACHINE_I2C_TARGET (1)
|
||||
#define MICROPY_PY_MACHINE_I2C_TARGET_INCLUDEFILE "ports/rp2/machine_i2c_target.c"
|
||||
#define MICROPY_PY_MACHINE_I2C_TARGET_MAX (2)
|
||||
#define MICROPY_PY_MACHINE_I2C_TARGET_HARD_IRQ (1)
|
||||
#endif
|
||||
#define MICROPY_PY_MACHINE_SOFTI2C (1)
|
||||
#define MICROPY_PY_MACHINE_I2S (1)
|
||||
#define MICROPY_PY_MACHINE_I2S_INCLUDEFILE "ports/rp2/machine_i2s.c"
|
||||
|
||||
@@ -639,11 +639,13 @@
|
||||
#if defined(MICROPY_HW_I2C1_SCL) || defined(MICROPY_HW_I2C2_SCL) \
|
||||
|| defined(MICROPY_HW_I2C3_SCL) || defined(MICROPY_HW_I2C4_SCL)
|
||||
#define MICROPY_HW_ENABLE_HW_I2C (1)
|
||||
#ifndef MICROPY_HW_ENABLE_HW_I2C_TARGET
|
||||
#if defined(STM32F4) || defined(STM32F7) || defined(STM32H7) || defined(STM32WB)
|
||||
#define MICROPY_HW_ENABLE_HW_I2C_TARGET (1)
|
||||
#else
|
||||
#define MICROPY_HW_ENABLE_HW_I2C_TARGET (0)
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
#define MICROPY_HW_ENABLE_HW_I2C (0)
|
||||
#define MICROPY_HW_ENABLE_HW_I2C_TARGET (0)
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#define MICROPY_VERSION_MAJOR 1
|
||||
#define MICROPY_VERSION_MINOR 26
|
||||
#define MICROPY_VERSION_MICRO 0
|
||||
#define MICROPY_VERSION_PRERELEASE 1
|
||||
#define MICROPY_VERSION_PRERELEASE 0
|
||||
|
||||
// Combined version as a 32-bit number for convenience to allow version
|
||||
// comparison. Doesn't include prerelease state.
|
||||
|
||||
Reference in New Issue
Block a user