Skip to content

Commit 6d79937

Browse files
pi-anldpgeorge
authored andcommitted
esp32: Add support for esp32c6.
This commit adds general support for ESP32-C6 SoCs. Signed-off-by: Andrew Leech <andrew@alelec.net>
1 parent e5eeaa7 commit 6d79937

21 files changed

+112
-39
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ track of the code size of the core runtime and VM.
108108

109109
In addition, the following ports are provided in this repository:
110110
- [cc3200](ports/cc3200) -- Texas Instruments CC3200 (including PyCom WiPy).
111-
- [esp32](ports/esp32) -- Espressif ESP32 SoC (including ESP32S2, ESP32S3, ESP32C3).
111+
- [esp32](ports/esp32) -- Espressif ESP32 SoC (including ESP32S2, ESP32S3, ESP32C3, ESP32C6).
112112
- [esp8266](ports/esp8266) -- Espressif ESP8266 SoC.
113113
- [mimxrt](ports/mimxrt) -- NXP m.iMX RT (including Teensy 4.x).
114114
- [nrf](ports/nrf) -- Nordic Semiconductor nRF51 and nRF52.

docs/esp32/quickref.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ working with this board it may be useful to get an overview of the microcontroll
1818
general.rst
1919
tutorial/index.rst
2020

21-
Note that there are several varieties of ESP32 -- ESP32, ESP32C3, ESP32S2, ESP32S3 --
21+
Note that there are several varieties of ESP32 -- ESP32, ESP32C3, ESP32C6, ESP32S2, ESP32S3 --
2222
supported by MicroPython, with some differences in functionality between them.
2323

2424
Installing MicroPython
@@ -61,13 +61,13 @@ The :mod:`esp32` module::
6161
import esp32
6262

6363
esp32.raw_temperature() # read the internal temperature of the MCU, in Fahrenheit
64-
esp32.ULP() # access to the Ultra-Low-Power Co-processor, not on ESP32C3
64+
esp32.ULP() # access to the Ultra-Low-Power Co-processor, not on ESP32C3/C6
6565

6666
Note that the temperature sensor in the ESP32 will typically read higher than
6767
ambient due to the IC getting warm while it runs. This effect can be minimised
6868
by reading the temperature sensor immediately after waking up from sleep.
6969

70-
ESP32C3, ESP32S2, and ESP32S3 also have an internal temperature sensor available.
70+
ESP32C3, ESP32C6, ESP32S2, and ESP32S3 also have an internal temperature sensor available.
7171
It is implemented a bit differently to the ESP32 and returns the temperature in
7272
Celsius::
7373

ports/esp32/boards/deploy_c6.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Program your board using the esptool.py program, found [here](https://github.com/espressif/esptool).
2+
3+
If you are putting MicroPython on your board for the first time then you should
4+
first erase the entire flash using:
5+
6+
```bash
7+
esptool.py --chip esp32c6 --port /dev/ttyUSB0 erase_flash
8+
```
9+
10+
From then on program the firmware starting at address 0x0:
11+
12+
```bash
13+
esptool.py --chip esp32c6 --port /dev/ttyUSB0 --baud 460800 write_flash -z 0x0 ESP32_GENERIC_C6-20240602-v1.24.0.bin
14+
```

ports/esp32/esp32_common.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ idf_component_register(
198198
set(MICROPY_TARGET ${COMPONENT_TARGET})
199199

200200
# Define mpy-cross flags, for use with frozen code.
201-
if(NOT IDF_TARGET STREQUAL "esp32c3")
201+
if(CONFIG_IDF_TARGET_ARCH STREQUAL "xtensa")
202202
set(MICROPY_CROSS_FLAGS -march=xtensawin)
203203
endif()
204204

ports/esp32/gccollect.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#include "py/mpthread.h"
3636
#include "gccollect.h"
3737

38-
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
38+
#if CONFIG_IDF_TARGET_ARCH_XTENSA
3939

4040
#include "xtensa/hal.h"
4141

@@ -61,8 +61,7 @@ void gc_collect(void) {
6161
gc_collect_end();
6262
}
6363

64-
#elif CONFIG_IDF_TARGET_ESP32C3
65-
64+
#elif CONFIG_IDF_TARGET_ARCH_RISCV
6665
#include "shared/runtime/gchelper.h"
6766

6867
void gc_collect(void) {
@@ -74,6 +73,8 @@ void gc_collect(void) {
7473
gc_collect_end();
7574
}
7675

76+
#else
77+
#error unknown CONFIG_IDF_TARGET_ARCH
7778
#endif
7879

7980
#if MICROPY_GC_SPLIT_HEAP_AUTO

ports/esp32/machine_adc.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
#define MICROPY_PY_MACHINE_ADC_CLASS_CONSTANTS_WIDTH_9_10_11
4545
#endif
4646

47-
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S3
47+
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32S3
4848
#define MICROPY_PY_MACHINE_ADC_CLASS_CONSTANTS_WIDTH_12 \
4949
{ MP_ROM_QSTR(MP_QSTR_WIDTH_12BIT), MP_ROM_INT(12) },
5050
#else
@@ -87,7 +87,7 @@ static const machine_adc_obj_t madc_obj[] = {
8787
{{&machine_adc_type}, ADCBLOCK2, ADC_CHANNEL_7, GPIO_NUM_27},
8888
{{&machine_adc_type}, ADCBLOCK2, ADC_CHANNEL_8, GPIO_NUM_25},
8989
{{&machine_adc_type}, ADCBLOCK2, ADC_CHANNEL_9, GPIO_NUM_26},
90-
#elif CONFIG_IDF_TARGET_ESP32C3
90+
#elif CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6
9191
{{&machine_adc_type}, ADCBLOCK1, ADC_CHANNEL_0, GPIO_NUM_0},
9292
{{&machine_adc_type}, ADCBLOCK1, ADC_CHANNEL_1, GPIO_NUM_1},
9393
{{&machine_adc_type}, ADCBLOCK1, ADC_CHANNEL_2, GPIO_NUM_2},

ports/esp32/machine_adc_block.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ machine_adc_block_obj_t madcblock_obj[] = {
3535
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S3
3636
{{&machine_adc_block_type}, ADC_UNIT_1, 12, -1, {0}},
3737
{{&machine_adc_block_type}, ADC_UNIT_2, 12, -1, {0}},
38-
#elif CONFIG_IDF_TARGET_ESP32S2
38+
#elif CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32C6
3939
{{&machine_adc_block_type}, ADC_UNIT_1, 13, -1, {0}},
4040
{{&machine_adc_block_type}, ADC_UNIT_2, 13, -1, {0}},
4141
#endif

ports/esp32/machine_bitstream.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
// This is a translation of the cycle counter implementation in ports/stm32/machine_bitstream.c.
4343
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) {
4444
uint32_t pin_mask, gpio_reg_set, gpio_reg_clear;
45-
#if !CONFIG_IDF_TARGET_ESP32C3
45+
#if !CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6
4646
if (pin >= 32) {
4747
pin_mask = 1 << (pin - 32);
4848
gpio_reg_set = GPIO_OUT1_W1TS_REG;

ports/esp32/machine_hw_spi.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@
3838
#include "soc/spi_pins.h"
3939

4040
// SPI mappings by device, naming used by IDF old/new
41-
// upython | ESP32 | ESP32S2 | ESP32S3 | ESP32C3
42-
// ----------+-----------+-----------+---------+---------
43-
// SPI(id=1) | HSPI/SPI2 | FSPI/SPI2 | SPI2 | SPI2
44-
// SPI(id=2) | VSPI/SPI3 | HSPI/SPI3 | SPI3 | err
41+
// upython | ESP32 | ESP32S2 | ESP32S3 | ESP32C3 | ESP32C6
42+
// ----------+-----------+-----------+---------+---------+---------
43+
// SPI(id=1) | HSPI/SPI2 | FSPI/SPI2 | SPI2 | SPI2 | SPI2
44+
// SPI(id=2) | VSPI/SPI3 | HSPI/SPI3 | SPI3 | err | err
4545

4646
// Number of available hardware SPI peripherals.
4747
#if SOC_SPI_PERIPH_NUM > 2
@@ -251,14 +251,14 @@ static void machine_hw_spi_init_internal(machine_hw_spi_obj_t *self, mp_arg_val_
251251

252252
// Select DMA channel based on the hardware SPI host
253253
int dma_chan = 0;
254-
#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32C3
255-
dma_chan = SPI_DMA_CH_AUTO;
256-
#else
254+
#if CONFIG_IDF_TARGET_ESP32
257255
if (self->host == SPI2_HOST) {
258256
dma_chan = 1;
259257
} else {
260258
dma_chan = 2;
261259
}
260+
#else
261+
dma_chan = SPI_DMA_CH_AUTO;
262262
#endif
263263

264264
ret = spi_bus_initialize(self->host, &buscfg, dma_chan);

ports/esp32/machine_i2c.c

100755100644
+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
#endif
5050
#endif
5151

52-
#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S3
52+
#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32S3
5353
#define I2C_SCLK_FREQ XTAL_CLK_FREQ
5454
#elif CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2
5555
#define I2C_SCLK_FREQ APB_CLK_FREQ

ports/esp32/machine_pin.c

+7-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
#include "modesp32.h"
4444
#include "genhdr/pins.h"
4545

46-
#if CONFIG_IDF_TARGET_ESP32C3
46+
#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6
4747
#include "soc/usb_serial_jtag_reg.h"
4848
#endif
4949

@@ -152,7 +152,7 @@ static mp_obj_t machine_pin_obj_init_helper(const machine_pin_obj_t *self, size_
152152
// reset the pin to digital if this is a mode-setting init (grab it back from ADC)
153153
if (args[ARG_mode].u_obj != mp_const_none) {
154154
if (rtc_gpio_is_valid_gpio(index)) {
155-
#if !CONFIG_IDF_TARGET_ESP32C3
155+
#if !(CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6)
156156
rtc_gpio_deinit(index);
157157
#endif
158158
}
@@ -163,6 +163,11 @@ static mp_obj_t machine_pin_obj_init_helper(const machine_pin_obj_t *self, size_
163163
CLEAR_PERI_REG_MASK(USB_SERIAL_JTAG_CONF0_REG, USB_SERIAL_JTAG_USB_PAD_ENABLE);
164164
}
165165
#endif
166+
#if CONFIG_IDF_TARGET_ESP32C6 && CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG_ENABLED
167+
if (index == 12 || index == 13) {
168+
CLEAR_PERI_REG_MASK(USB_SERIAL_JTAG_CONF0_REG, USB_SERIAL_JTAG_USB_PAD_ENABLE);
169+
}
170+
#endif
166171

167172
// configure the pin for gpio
168173
esp_rom_gpio_pad_select_gpio(index);

ports/esp32/machine_pin.h

+30
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,36 @@
9494
#define MICROPY_HW_ENABLE_GPIO20 (1)
9595
#define MICROPY_HW_ENABLE_GPIO21 (1)
9696

97+
#elif CONFIG_IDF_TARGET_ESP32C6
98+
99+
#define MICROPY_HW_ENABLE_GPIO0 (1)
100+
#define MICROPY_HW_ENABLE_GPIO1 (1)
101+
#define MICROPY_HW_ENABLE_GPIO2 (1)
102+
#define MICROPY_HW_ENABLE_GPIO3 (1)
103+
#define MICROPY_HW_ENABLE_GPIO4 (1)
104+
#define MICROPY_HW_ENABLE_GPIO5 (1)
105+
#define MICROPY_HW_ENABLE_GPIO6 (1)
106+
#define MICROPY_HW_ENABLE_GPIO7 (1)
107+
#define MICROPY_HW_ENABLE_GPIO8 (1)
108+
#define MICROPY_HW_ENABLE_GPIO9 (1)
109+
#define MICROPY_HW_ENABLE_GPIO10 (1)
110+
#define MICROPY_HW_ENABLE_GPIO11 (1)
111+
#if !CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG
112+
#define MICROPY_HW_ENABLE_GPIO12 (1)
113+
#define MICROPY_HW_ENABLE_GPIO13 (1)
114+
#endif
115+
#define MICROPY_HW_ENABLE_GPIO14 (1)
116+
#define MICROPY_HW_ENABLE_GPIO15 (1)
117+
#define MICROPY_HW_ENABLE_GPIO16 (1)
118+
#define MICROPY_HW_ENABLE_GPIO17 (1)
119+
#define MICROPY_HW_ENABLE_GPIO18 (1)
120+
#define MICROPY_HW_ENABLE_GPIO19 (1)
121+
#define MICROPY_HW_ENABLE_GPIO20 (1)
122+
#define MICROPY_HW_ENABLE_GPIO21 (1)
123+
#define MICROPY_HW_ENABLE_GPIO22 (1)
124+
#define MICROPY_HW_ENABLE_GPIO23 (1)
125+
// GPIO 24-30 are used for spi/sip flash.
126+
97127
#elif CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
98128

99129
#define MICROPY_HW_ENABLE_GPIO0 (1)

ports/esp32/machine_pwm.c

+4
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,11 @@ static void set_freq(machine_pwm_obj_t *self, unsigned int freq, ledc_timer_conf
241241
// Configure the new resolution and frequency
242242
timer->duty_resolution = res;
243243
timer->freq_hz = freq;
244+
#if SOC_LEDC_SUPPORT_XTAL_CLOCK
245+
timer->clk_cfg = LEDC_USE_XTAL_CLK;
246+
#else
244247
timer->clk_cfg = LEDC_USE_APB_CLK;
248+
#endif
245249
#if SOC_LEDC_SUPPORT_REF_TICK
246250
if (freq < EMPIRIC_FREQ) {
247251
timer->clk_cfg = LEDC_USE_REF_TICK;

ports/esp32/main_esp32c3/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ if(NOT MICROPY_PORT_DIR)
99
endif()
1010

1111
list(APPEND MICROPY_SOURCE_LIB ${MICROPY_DIR}/shared/runtime/gchelper_generic.c)
12+
list(APPEND IDF_COMPONENTS riscv)
1213

1314
include(${MICROPY_PORT_DIR}/esp32_common.cmake)
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Set location of base MicroPython directory.
2+
if(NOT MICROPY_DIR)
3+
get_filename_component(MICROPY_DIR ${CMAKE_CURRENT_LIST_DIR}/../../.. ABSOLUTE)
4+
endif()
5+
6+
# Set location of the ESP32 port directory.
7+
if(NOT MICROPY_PORT_DIR)
8+
get_filename_component(MICROPY_PORT_DIR ${MICROPY_DIR}/ports/esp32 ABSOLUTE)
9+
endif()
10+
11+
list(APPEND MICROPY_SOURCE_LIB ${MICROPY_DIR}/shared/runtime/gchelper_generic.c)
12+
list(APPEND IDF_COMPONENTS riscv)
13+
14+
include(${MICROPY_PORT_DIR}/esp32_common.cmake)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## IDF Component Manager Manifest File
2+
dependencies:
3+
espressif/mdns: "~1.1.0"
4+
idf:
5+
version: ">=5.1.0"

ports/esp32/main_esp32c6/linker.lf

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Empty linker fragment (no workaround required for C6, see main_esp32/linker.lf).

ports/esp32/modesp32.c

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929

3030
#include <time.h>
3131
#include <sys/time.h>
32-
#include "soc/rtc_cntl_reg.h"
3332
#include "driver/gpio.h"
3433
#include "driver/adc.h"
3534
#include "esp_heap_caps.h"

ports/esp32/modmachine.c

+7-6
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,8 @@ typedef enum {
9090

9191
static bool is_soft_reset = 0;
9292

93-
#if CONFIG_IDF_TARGET_ESP32C3
94-
int esp_clk_cpu_freq(void);
95-
#endif
93+
// Note: this is from a private IDF header
94+
extern int esp_clk_cpu_freq(void);
9695

9796
static mp_obj_t mp_machine_get_freq(void) {
9897
return mp_obj_new_int(esp_rom_get_cpu_ticks_per_us() * 1000000);
@@ -101,11 +100,11 @@ static mp_obj_t mp_machine_get_freq(void) {
101100
static void mp_machine_set_freq(size_t n_args, const mp_obj_t *args) {
102101
mp_int_t freq = mp_obj_get_int(args[0]) / 1000000;
103102
if (freq != 20 && freq != 40 && freq != 80 && freq != 160
104-
#if !CONFIG_IDF_TARGET_ESP32C3
103+
#if !(CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6)
105104
&& freq != 240
106105
#endif
107106
) {
108-
#if CONFIG_IDF_TARGET_ESP32C3
107+
#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6
109108
mp_raise_ValueError(MP_ERROR_TEXT("frequency must be 20MHz, 40MHz, 80Mhz or 160MHz"));
110109
#else
111110
mp_raise_ValueError(MP_ERROR_TEXT("frequency must be 20MHz, 40MHz, 80Mhz, 160MHz or 240MHz"));
@@ -118,6 +117,8 @@ static void mp_machine_set_freq(size_t n_args, const mp_obj_t *args) {
118117
esp_pm_config_esp32_t pm;
119118
#elif CONFIG_IDF_TARGET_ESP32C3
120119
esp_pm_config_esp32c3_t pm;
120+
#elif CONFIG_IDF_TARGET_ESP32C6
121+
esp_pm_config_esp32c6_t pm;
121122
#elif CONFIG_IDF_TARGET_ESP32S2
122123
esp_pm_config_esp32s2_t pm;
123124
#elif CONFIG_IDF_TARGET_ESP32S3
@@ -146,7 +147,7 @@ static void machine_sleep_helper(wake_type_t wake_type, size_t n_args, const mp_
146147
esp_sleep_enable_timer_wakeup(((uint64_t)expiry) * 1000);
147148
}
148149

149-
#if !CONFIG_IDF_TARGET_ESP32C3
150+
#if !(CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6)
150151

151152
if (machine_rtc_config.ext0_pin != -1 && (machine_rtc_config.ext0_wake_types & wake_type)) {
152153
esp_sleep_enable_ext0_wakeup(machine_rtc_config.ext0_pin, machine_rtc_config.ext0_level ? 1 : 0);

ports/esp32/mpconfigport.h

+7-9
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
// object representation and NLR handling
2020
#define MICROPY_OBJ_REPR (MICROPY_OBJ_REPR_A)
21-
#if !CONFIG_IDF_TARGET_ESP32C3
21+
#if CONFIG_IDF_TARGET_ARCH_XTENSA
2222
#define MICROPY_NLR_SETJMP (1)
2323
#endif
2424

@@ -41,10 +41,10 @@
4141

4242
// emitters
4343
#define MICROPY_PERSISTENT_CODE_LOAD (1)
44-
#if !CONFIG_IDF_TARGET_ESP32C3
45-
#define MICROPY_EMIT_XTENSAWIN (1)
46-
#else
44+
#if CONFIG_IDF_TARGET_ARCH_RISCV
4745
#define MICROPY_EMIT_RV32 (1)
46+
#else
47+
#define MICROPY_EMIT_XTENSAWIN (1)
4848
#endif
4949

5050
// optimisations
@@ -161,6 +161,8 @@
161161
#define MICROPY_PY_NETWORK_HOSTNAME_DEFAULT "mpy-esp32s3"
162162
#elif CONFIG_IDF_TARGET_ESP32C3
163163
#define MICROPY_PY_NETWORK_HOSTNAME_DEFAULT "mpy-esp32c3"
164+
#elif CONFIG_IDF_TARGET_ESP32C6
165+
#define MICROPY_PY_NETWORK_HOSTNAME_DEFAULT "mpy-esp32c6"
164166
#endif
165167
#endif
166168
#define MICROPY_PY_NETWORK_INCLUDEFILE "ports/esp32/modnetwork.h"
@@ -364,11 +366,7 @@ void boardctrl_startup(void);
364366

365367
#if MICROPY_PY_NETWORK_LAN && CONFIG_ETH_USE_SPI_ETHERNET
366368
#ifndef MICROPY_PY_NETWORK_LAN_SPI_CLOCK_SPEED_MZ
367-
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C2
368-
#define MICROPY_PY_NETWORK_LAN_SPI_CLOCK_SPEED_MZ (12)
369-
#else
370-
#define MICROPY_PY_NETWORK_LAN_SPI_CLOCK_SPEED_MZ (36)
371-
#endif
369+
#define MICROPY_PY_NETWORK_LAN_SPI_CLOCK_SPEED_MZ (20)
372370
#endif
373371
#endif
374372

ports/esp32/mphalport.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ void check_esp_err_(esp_err_t code, const char *func, const int line, const char
7373
uint32_t mp_hal_ticks_us(void);
7474
__attribute__((always_inline)) static inline uint32_t mp_hal_ticks_cpu(void) {
7575
uint32_t ccount;
76-
#if CONFIG_IDF_TARGET_ESP32C3
76+
#if CONFIG_IDF_TARGET_ARCH_RISCV
7777
__asm__ __volatile__ ("csrr %0, 0x7E2" : "=r" (ccount)); // Machine Performance Counter Value
7878
#else
7979
__asm__ __volatile__ ("rsr %0,ccount" : "=a" (ccount));

0 commit comments

Comments
 (0)