ports/esp32: Add support for risk-v and esp32c6.

Signed-off-by: Andrew Leech <andrew@alelec.net>
Andrew Leech 2023-06-26 11:53:28 +10:00
rodzic 5114f2c1ea
commit 3641c0d103
22 zmienionych plików z 83 dodań i 28 usunięć

Wyświetl plik

@ -108,7 +108,7 @@ track of the code size of the core runtime and VM.
In addition, the following ports are provided in this repository: In addition, the following ports are provided in this repository:
- [cc3200](ports/cc3200) -- Texas Instruments CC3200 (including PyCom WiPy). - [cc3200](ports/cc3200) -- Texas Instruments CC3200 (including PyCom WiPy).
- [esp32](ports/esp32) -- Espressif ESP32 SoC (including ESP32S2, ESP32S3, ESP32C3). - [esp32](ports/esp32) -- Espressif ESP32 SoC (including ESP32S2, ESP32S3, ESP32C3, ESP32C6).
- [esp8266](ports/esp8266) -- Espressif ESP8266 SoC. - [esp8266](ports/esp8266) -- Espressif ESP8266 SoC.
- [mimxrt](ports/mimxrt) -- NXP m.iMX RT (including Teensy 4.x). - [mimxrt](ports/mimxrt) -- NXP m.iMX RT (including Teensy 4.x).
- [nrf](ports/nrf) -- Nordic Semiconductor nRF51 and nRF52. - [nrf](ports/nrf) -- Nordic Semiconductor nRF51 and nRF52.

Wyświetl plik

@ -0,0 +1,14 @@
Program your board using the esptool.py program, found [here](https://github.com/espressif/esptool).
If you are putting MicroPython on your board for the first time then you should
first erase the entire flash using:
```bash
esptool.py --chip esp32c6 --port /dev/ttyUSB0 erase_flash
```
From then on program the firmware starting at address 0x0:
```bash
esptool.py --chip esp32c6 --port /dev/ttyUSB0 --baud 460800 write_flash -z 0x0 esp32c6-20220117-v1.18.bin
```

Wyświetl plik

@ -7,6 +7,9 @@ CONFIG_BT_NIMBLE_SVC_GAP_DEVICE_NAME="MPY ESP32"
CONFIG_BT_NIMBLE_MAX_CONNECTIONS=4 CONFIG_BT_NIMBLE_MAX_CONNECTIONS=4
# Needed to enable esp_nimble_hci on ESP32C6
#CONFIG_BT_NIMBLE_LEGACY_VHCI_ENABLE=y
# Put NimBLE on core 1, and for synchronisation # Put NimBLE on core 1, and for synchronisation
# with the ringbuffer and scheduler MP needs to be on the same core. # with the ringbuffer and scheduler MP needs to be on the same core.
# MP on core 1 prevents interference with WiFi for time sensitive operations. # MP on core 1 prevents interference with WiFi for time sensitive operations.

Wyświetl plik

@ -161,7 +161,7 @@ idf_component_register(
set(MICROPY_TARGET ${COMPONENT_TARGET}) set(MICROPY_TARGET ${COMPONENT_TARGET})
# Define mpy-cross flags, for use with frozen code. # Define mpy-cross flags, for use with frozen code.
if(NOT IDF_TARGET STREQUAL "esp32c3") if(NOT IDF_TARGET MATCHES "^esp32c[36]$")
set(MICROPY_CROSS_FLAGS -march=xtensawin) set(MICROPY_CROSS_FLAGS -march=xtensawin)
endif() endif()
@ -200,6 +200,10 @@ foreach(comp ${__COMPONENT_NAMES_RESOLVED})
micropy_gather_target_properties(${comp}) micropy_gather_target_properties(${comp})
endforeach() endforeach()
list(APPEND MICROPY_CPP_INC_EXTRA ${IDF_PATH}/components/riscv/include)
list(APPEND MICROPY_CPP_INC_EXTRA ${IDF_PATH}/components/soc/soc/include)
# Include the main MicroPython cmake rules. # Include the main MicroPython cmake rules.
include(${MICROPY_DIR}/py/mkrules.cmake) include(${MICROPY_DIR}/py/mkrules.cmake)

Wyświetl plik

@ -61,7 +61,7 @@ void gc_collect(void) {
gc_collect_end(); gc_collect_end();
} }
#elif CONFIG_IDF_TARGET_ESP32C3 #elif CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6
#include "shared/runtime/gchelper.h" #include "shared/runtime/gchelper.h"

Wyświetl plik

@ -44,7 +44,7 @@
#define MICROPY_PY_MACHINE_ADC_CLASS_CONSTANTS_WIDTH_9_10_11 #define MICROPY_PY_MACHINE_ADC_CLASS_CONSTANTS_WIDTH_9_10_11
#endif #endif
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S3 #if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32S3
#define MICROPY_PY_MACHINE_ADC_CLASS_CONSTANTS_WIDTH_12 \ #define MICROPY_PY_MACHINE_ADC_CLASS_CONSTANTS_WIDTH_12 \
{ MP_ROM_QSTR(MP_QSTR_WIDTH_12BIT), MP_ROM_INT(12) }, { MP_ROM_QSTR(MP_QSTR_WIDTH_12BIT), MP_ROM_INT(12) },
#else #else
@ -87,7 +87,7 @@ static const machine_adc_obj_t madc_obj[] = {
{{&machine_adc_type}, ADCBLOCK2, ADC_CHANNEL_7, GPIO_NUM_27}, {{&machine_adc_type}, ADCBLOCK2, ADC_CHANNEL_7, GPIO_NUM_27},
{{&machine_adc_type}, ADCBLOCK2, ADC_CHANNEL_8, GPIO_NUM_25}, {{&machine_adc_type}, ADCBLOCK2, ADC_CHANNEL_8, GPIO_NUM_25},
{{&machine_adc_type}, ADCBLOCK2, ADC_CHANNEL_9, GPIO_NUM_26}, {{&machine_adc_type}, ADCBLOCK2, ADC_CHANNEL_9, GPIO_NUM_26},
#elif CONFIG_IDF_TARGET_ESP32C3 #elif CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6
{{&machine_adc_type}, ADCBLOCK1, ADC_CHANNEL_0, GPIO_NUM_0}, {{&machine_adc_type}, ADCBLOCK1, ADC_CHANNEL_0, GPIO_NUM_0},
{{&machine_adc_type}, ADCBLOCK1, ADC_CHANNEL_1, GPIO_NUM_1}, {{&machine_adc_type}, ADCBLOCK1, ADC_CHANNEL_1, GPIO_NUM_1},
{{&machine_adc_type}, ADCBLOCK1, ADC_CHANNEL_2, GPIO_NUM_2}, {{&machine_adc_type}, ADCBLOCK1, ADC_CHANNEL_2, GPIO_NUM_2},

Wyświetl plik

@ -35,7 +35,7 @@ machine_adc_block_obj_t madcblock_obj[] = {
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S3 #if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S3
{{&machine_adc_block_type}, ADC_UNIT_1, 12, -1, {0}}, {{&machine_adc_block_type}, ADC_UNIT_1, 12, -1, {0}},
{{&machine_adc_block_type}, ADC_UNIT_2, 12, -1, {0}}, {{&machine_adc_block_type}, ADC_UNIT_2, 12, -1, {0}},
#elif CONFIG_IDF_TARGET_ESP32S2 #elif CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32C6
{{&machine_adc_block_type}, ADC_UNIT_1, 13, -1, {0}}, {{&machine_adc_block_type}, ADC_UNIT_1, 13, -1, {0}},
{{&machine_adc_block_type}, ADC_UNIT_2, 13, -1, {0}}, {{&machine_adc_block_type}, ADC_UNIT_2, 13, -1, {0}},
#endif #endif

Wyświetl plik

@ -42,7 +42,7 @@
// This is a translation of the cycle counter implementation in ports/stm32/machine_bitstream.c. // This is a translation of the cycle counter implementation in ports/stm32/machine_bitstream.c.
static void IRAM_ATTR machine_bitstream_high_low_bitbang(mp_hal_pin_obj_t pin, uint32_t *timing_ns, const uint8_t *buf, size_t len) { static void IRAM_ATTR machine_bitstream_high_low_bitbang(mp_hal_pin_obj_t pin, uint32_t *timing_ns, const uint8_t *buf, size_t len) {
uint32_t pin_mask, gpio_reg_set, gpio_reg_clear; uint32_t pin_mask, gpio_reg_set, gpio_reg_clear;
#if !CONFIG_IDF_TARGET_ESP32C3 #if !CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6
if (pin >= 32) { if (pin >= 32) {
pin_mask = 1 << (pin - 32); pin_mask = 1 << (pin - 32);
gpio_reg_set = GPIO_OUT1_W1TS_REG; gpio_reg_set = GPIO_OUT1_W1TS_REG;

Wyświetl plik

@ -38,10 +38,10 @@
#include "soc/spi_pins.h" #include "soc/spi_pins.h"
// SPI mappings by device, naming used by IDF old/new // SPI mappings by device, naming used by IDF old/new
// upython | ESP32 | ESP32S2 | ESP32S3 | ESP32C3 // upython | ESP32 | ESP32S2 | ESP32S3 | ESP32C3 | ESP32C6
// ----------+-----------+-----------+---------+--------- // ----------+-----------+-----------+---------+---------+---------
// SPI(id=1) | HSPI/SPI2 | FSPI/SPI2 | SPI2 | SPI2 // SPI(id=1) | HSPI/SPI2 | FSPI/SPI2 | SPI2 | SPI2 | SPI2
// SPI(id=2) | VSPI/SPI3 | HSPI/SPI3 | SPI3 | err // SPI(id=2) | VSPI/SPI3 | HSPI/SPI3 | SPI3 | err | err
// Number of available hardware SPI peripherals. // Number of available hardware SPI peripherals.
#if SOC_SPI_PERIPH_NUM > 2 #if SOC_SPI_PERIPH_NUM > 2
@ -251,7 +251,7 @@ static void machine_hw_spi_init_internal(machine_hw_spi_obj_t *self, mp_arg_val_
// Select DMA channel based on the hardware SPI host // Select DMA channel based on the hardware SPI host
int dma_chan = 0; int dma_chan = 0;
#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32C3 #if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6
dma_chan = SPI_DMA_CH_AUTO; dma_chan = SPI_DMA_CH_AUTO;
#else #else
if (self->host == SPI2_HOST) { if (self->host == SPI2_HOST) {

Wyświetl plik

@ -49,7 +49,7 @@
#endif #endif
#endif #endif
#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S3 #if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32C6
#define I2C_SCLK_FREQ XTAL_CLK_FREQ #define I2C_SCLK_FREQ XTAL_CLK_FREQ
#elif CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2 #elif CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2
#define I2C_SCLK_FREQ APB_CLK_FREQ #define I2C_SCLK_FREQ APB_CLK_FREQ

Wyświetl plik

@ -44,7 +44,7 @@
#include "modesp32.h" #include "modesp32.h"
#include "genhdr/pins.h" #include "genhdr/pins.h"
#if CONFIG_IDF_TARGET_ESP32C3 #if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6
#include "soc/usb_serial_jtag_reg.h" #include "soc/usb_serial_jtag_reg.h"
#endif #endif
@ -153,13 +153,13 @@ static mp_obj_t machine_pin_obj_init_helper(const machine_pin_obj_t *self, size_
// reset the pin to digital if this is a mode-setting init (grab it back from ADC) // reset the pin to digital if this is a mode-setting init (grab it back from ADC)
if (args[ARG_mode].u_obj != mp_const_none) { if (args[ARG_mode].u_obj != mp_const_none) {
if (rtc_gpio_is_valid_gpio(index)) { if (rtc_gpio_is_valid_gpio(index)) {
#if !CONFIG_IDF_TARGET_ESP32C3 #if !(CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6)
rtc_gpio_deinit(index); rtc_gpio_deinit(index);
#endif #endif
} }
} }
#if CONFIG_IDF_TARGET_ESP32C3 #if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6
if (index == 18 || index == 19) { if (index == 18 || index == 19) {
CLEAR_PERI_REG_MASK(USB_SERIAL_JTAG_CONF0_REG, USB_SERIAL_JTAG_USB_PAD_ENABLE); CLEAR_PERI_REG_MASK(USB_SERIAL_JTAG_CONF0_REG, USB_SERIAL_JTAG_USB_PAD_ENABLE);
} }

Wyświetl plik

@ -71,7 +71,7 @@
#define MICROPY_HW_ENABLE_GPIO38 (1) #define MICROPY_HW_ENABLE_GPIO38 (1)
#define MICROPY_HW_ENABLE_GPIO39 (1) #define MICROPY_HW_ENABLE_GPIO39 (1)
#elif CONFIG_IDF_TARGET_ESP32C3 #elif CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6
#define MICROPY_HW_ENABLE_GPIO0 (1) #define MICROPY_HW_ENABLE_GPIO0 (1)
#define MICROPY_HW_ENABLE_GPIO1 (1) #define MICROPY_HW_ENABLE_GPIO1 (1)

Wyświetl plik

@ -241,7 +241,12 @@ static void set_freq(machine_pwm_obj_t *self, unsigned int freq, ledc_timer_conf
// Configure the new resolution and frequency // Configure the new resolution and frequency
timer->duty_resolution = res; timer->duty_resolution = res;
timer->freq_hz = freq; timer->freq_hz = freq;
#if CONFIG_IDF_TARGET_ESP32C6
// TODO don't know if this is appropriate, compiler error suggested it
timer->clk_cfg = LEDC_USE_XTAL_CLK;
#else
timer->clk_cfg = LEDC_USE_APB_CLK; timer->clk_cfg = LEDC_USE_APB_CLK;
#endif
#if SOC_LEDC_SUPPORT_REF_TICK #if SOC_LEDC_SUPPORT_REF_TICK
if (freq < EMPIRIC_FREQ) { if (freq < EMPIRIC_FREQ) {
timer->clk_cfg = LEDC_USE_REF_TICK; timer->clk_cfg = LEDC_USE_REF_TICK;

Wyświetl plik

@ -72,7 +72,7 @@
#define MP_TASK_PRIORITY (ESP_TASK_PRIO_MIN + 1) #define MP_TASK_PRIORITY (ESP_TASK_PRIO_MIN + 1)
// Set the margin for detecting stack overflow, depending on the CPU architecture. // Set the margin for detecting stack overflow, depending on the CPU architecture.
#if CONFIG_IDF_TARGET_ESP32C3 #if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6
#define MP_TASK_STACK_LIMIT_MARGIN (2048) #define MP_TASK_STACK_LIMIT_MARGIN (2048)
#else #else
#define MP_TASK_STACK_LIMIT_MARGIN (1024) #define MP_TASK_STACK_LIMIT_MARGIN (1024)

Wyświetl plik

@ -0,0 +1,14 @@
# Set location of base MicroPython directory.
if(NOT MICROPY_DIR)
get_filename_component(MICROPY_DIR ${CMAKE_CURRENT_LIST_DIR}/../../.. ABSOLUTE)
endif()
# Set location of the ESP32 port directory.
if(NOT MICROPY_PORT_DIR)
get_filename_component(MICROPY_PORT_DIR ${MICROPY_DIR}/ports/esp32 ABSOLUTE)
endif()
list(APPEND MICROPY_SOURCE_LIB ${MICROPY_DIR}/shared/runtime/gchelper_generic.c)
list(APPEND IDF_COMPONENTS riscv)
include(${MICROPY_PORT_DIR}/esp32_common.cmake)

Wyświetl plik

@ -0,0 +1,5 @@
## IDF Component Manager Manifest File
dependencies:
espressif/mdns: "~1.1.0"
idf:
version: ">=5.1.0"

Wyświetl plik

@ -0,0 +1 @@
# Empty linker fragment (no workaround required for C3, see main_esp32/linker.lf).

Wyświetl plik

@ -29,7 +29,7 @@
#include <time.h> #include <time.h>
#include <sys/time.h> #include <sys/time.h>
#include "soc/rtc_cntl_reg.h" // #include "soc/rtc_cntl_reg.h"
#include "driver/gpio.h" #include "driver/gpio.h"
#include "driver/adc.h" #include "driver/adc.h"
#include "esp_heap_caps.h" #include "esp_heap_caps.h"

Wyświetl plik

@ -90,7 +90,7 @@ typedef enum {
static bool is_soft_reset = 0; static bool is_soft_reset = 0;
#if CONFIG_IDF_TARGET_ESP32C3 #if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6
int esp_clk_cpu_freq(void); int esp_clk_cpu_freq(void);
#endif #endif
@ -101,11 +101,11 @@ static mp_obj_t mp_machine_get_freq(void) {
static void mp_machine_set_freq(size_t n_args, const mp_obj_t *args) { static void mp_machine_set_freq(size_t n_args, const mp_obj_t *args) {
mp_int_t freq = mp_obj_get_int(args[0]) / 1000000; mp_int_t freq = mp_obj_get_int(args[0]) / 1000000;
if (freq != 20 && freq != 40 && freq != 80 && freq != 160 if (freq != 20 && freq != 40 && freq != 80 && freq != 160
#if !CONFIG_IDF_TARGET_ESP32C3 #if !(CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6)
&& freq != 240 && freq != 240
#endif #endif
) { ) {
#if CONFIG_IDF_TARGET_ESP32C3 #if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6
mp_raise_ValueError(MP_ERROR_TEXT("frequency must be 20MHz, 40MHz, 80Mhz or 160MHz")); mp_raise_ValueError(MP_ERROR_TEXT("frequency must be 20MHz, 40MHz, 80Mhz or 160MHz"));
#else #else
mp_raise_ValueError(MP_ERROR_TEXT("frequency must be 20MHz, 40MHz, 80Mhz, 160MHz or 240MHz")); mp_raise_ValueError(MP_ERROR_TEXT("frequency must be 20MHz, 40MHz, 80Mhz, 160MHz or 240MHz"));
@ -118,6 +118,8 @@ static void mp_machine_set_freq(size_t n_args, const mp_obj_t *args) {
esp_pm_config_esp32_t pm; esp_pm_config_esp32_t pm;
#elif CONFIG_IDF_TARGET_ESP32C3 #elif CONFIG_IDF_TARGET_ESP32C3
esp_pm_config_esp32c3_t pm; esp_pm_config_esp32c3_t pm;
#elif CONFIG_IDF_TARGET_ESP32C6
esp_pm_config_esp32c6_t pm;
#elif CONFIG_IDF_TARGET_ESP32S2 #elif CONFIG_IDF_TARGET_ESP32S2
esp_pm_config_esp32s2_t pm; esp_pm_config_esp32s2_t pm;
#elif CONFIG_IDF_TARGET_ESP32S3 #elif CONFIG_IDF_TARGET_ESP32S3
@ -146,7 +148,7 @@ static void machine_sleep_helper(wake_type_t wake_type, size_t n_args, const mp_
esp_sleep_enable_timer_wakeup(((uint64_t)expiry) * 1000); esp_sleep_enable_timer_wakeup(((uint64_t)expiry) * 1000);
} }
#if !CONFIG_IDF_TARGET_ESP32C3 #if !(CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6)
if (machine_rtc_config.ext0_pin != -1 && (machine_rtc_config.ext0_wake_types & wake_type)) { if (machine_rtc_config.ext0_pin != -1 && (machine_rtc_config.ext0_wake_types & wake_type)) {
esp_sleep_enable_ext0_wakeup(machine_rtc_config.ext0_pin, machine_rtc_config.ext0_level ? 1 : 0); esp_sleep_enable_ext0_wakeup(machine_rtc_config.ext0_pin, machine_rtc_config.ext0_level ? 1 : 0);

Wyświetl plik

@ -19,7 +19,7 @@
// object representation and NLR handling // object representation and NLR handling
#define MICROPY_OBJ_REPR (MICROPY_OBJ_REPR_A) #define MICROPY_OBJ_REPR (MICROPY_OBJ_REPR_A)
#define MICROPY_NLR_SETJMP (1) #define MICROPY_NLR_SETJMP (1)
#if CONFIG_IDF_TARGET_ESP32C3 #if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6
#define MICROPY_GCREGS_SETJMP (1) #define MICROPY_GCREGS_SETJMP (1)
#endif #endif
@ -42,7 +42,7 @@
// emitters // emitters
#define MICROPY_PERSISTENT_CODE_LOAD (1) #define MICROPY_PERSISTENT_CODE_LOAD (1)
#if !CONFIG_IDF_TARGET_ESP32C3 #if !(CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6)
#define MICROPY_EMIT_XTENSAWIN (1) #define MICROPY_EMIT_XTENSAWIN (1)
#endif #endif
@ -164,6 +164,8 @@
#define MICROPY_PY_NETWORK_HOSTNAME_DEFAULT "mpy-esp32s3" #define MICROPY_PY_NETWORK_HOSTNAME_DEFAULT "mpy-esp32s3"
#elif CONFIG_IDF_TARGET_ESP32C3 #elif CONFIG_IDF_TARGET_ESP32C3
#define MICROPY_PY_NETWORK_HOSTNAME_DEFAULT "mpy-esp32c3" #define MICROPY_PY_NETWORK_HOSTNAME_DEFAULT "mpy-esp32c3"
#elif CONFIG_IDF_TARGET_ESP32C6
#define MICROPY_PY_NETWORK_HOSTNAME_DEFAULT "mpy-esp32c6"
#endif #endif
#endif #endif
#define MICROPY_PY_NETWORK_INCLUDEFILE "ports/esp32/modnetwork.h" #define MICROPY_PY_NETWORK_INCLUDEFILE "ports/esp32/modnetwork.h"
@ -299,7 +301,7 @@ void boardctrl_startup(void);
#if MICROPY_PY_NETWORK_LAN && CONFIG_ETH_USE_SPI_ETHERNET #if MICROPY_PY_NETWORK_LAN && CONFIG_ETH_USE_SPI_ETHERNET
#ifndef MICROPY_PY_NETWORK_LAN_SPI_CLOCK_SPEED_MZ #ifndef MICROPY_PY_NETWORK_LAN_SPI_CLOCK_SPEED_MZ
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C2 #if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C6
#define MICROPY_PY_NETWORK_LAN_SPI_CLOCK_SPEED_MZ (12) #define MICROPY_PY_NETWORK_LAN_SPI_CLOCK_SPEED_MZ (12)
#else #else
#define MICROPY_PY_NETWORK_LAN_SPI_CLOCK_SPEED_MZ (36) #define MICROPY_PY_NETWORK_LAN_SPI_CLOCK_SPEED_MZ (36)

Wyświetl plik

@ -73,7 +73,7 @@ void check_esp_err_(esp_err_t code, const char *func, const int line, const char
uint32_t mp_hal_ticks_us(void); uint32_t mp_hal_ticks_us(void);
__attribute__((always_inline)) static inline uint32_t mp_hal_ticks_cpu(void) { __attribute__((always_inline)) static inline uint32_t mp_hal_ticks_cpu(void) {
uint32_t ccount; uint32_t ccount;
#if CONFIG_IDF_TARGET_ESP32C3 #if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6
__asm__ __volatile__ ("csrr %0, 0x7E2" : "=r" (ccount)); // Machine Performance Counter Value __asm__ __volatile__ ("csrr %0, 0x7E2" : "=r" (ccount)); // Machine Performance Counter Value
#else #else
__asm__ __volatile__ ("rsr %0,ccount" : "=a" (ccount)); __asm__ __volatile__ ("rsr %0,ccount" : "=a" (ccount));

Wyświetl plik

@ -32,7 +32,9 @@
#define DEBUG_printf(...) // printf("nimble (esp32): " __VA_ARGS__) #define DEBUG_printf(...) // printf("nimble (esp32): " __VA_ARGS__)
#if !CONFIG_IDF_TARGET_ESP32C6
#include "esp_nimble_hci.h" #include "esp_nimble_hci.h"
#endif
#include "nimble/nimble_port.h" #include "nimble/nimble_port.h"
#include "nimble/nimble_port_freertos.h" #include "nimble/nimble_port_freertos.h"
@ -46,13 +48,16 @@ static void ble_host_task(void *param) {
void mp_bluetooth_nimble_port_hci_init(void) { void mp_bluetooth_nimble_port_hci_init(void) {
DEBUG_printf("mp_bluetooth_nimble_port_hci_init\n"); DEBUG_printf("mp_bluetooth_nimble_port_hci_init\n");
#if !CONFIG_IDF_TARGET_ESP32C6
esp_nimble_hci_init(); esp_nimble_hci_init();
#endif
} }
void mp_bluetooth_nimble_port_hci_deinit(void) { void mp_bluetooth_nimble_port_hci_deinit(void) {
DEBUG_printf("mp_bluetooth_nimble_port_hci_deinit\n"); DEBUG_printf("mp_bluetooth_nimble_port_hci_deinit\n");
#if !CONFIG_IDF_TARGET_ESP32C6
esp_nimble_hci_deinit(); esp_nimble_hci_deinit();
#endif
} }
void mp_bluetooth_nimble_port_start(void) { void mp_bluetooth_nimble_port_start(void) {