Skip to content

Commit 3452e55

Browse files
authored
to start with esp32P4
Signed-off-by: Thomas Favennec <48832470+favnec5@users.noreply.github.com>
1 parent 49f81d5 commit 3452e55

16 files changed

+141
-9
lines changed

ports/esp32/adc.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
* THE SOFTWARE.
2626
*/
2727

28+
#if MICROPY_PY_MACHINE_ADC
29+
30+
2831
#include "py/mphal.h"
2932
#include "adc.h"
3033
#include "driver/adc.h"
@@ -106,3 +109,5 @@ mp_int_t madcblock_read_uv_helper(machine_adc_block_obj_t *self, adc_channel_t c
106109

107110
return (mp_int_t)uv * 1000;
108111
}
112+
113+
#endif // MICROPY_PY_MACHINE_ADC

ports/esp32/machine_adc.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
// This file is never compiled standalone, it's included directly from
2929
// extmod/machine_adc.c via MICROPY_PY_MACHINE_ADC_INCLUDEFILE.
3030

31+
3132
#include "py/mphal.h"
3233
#include "adc.h"
3334
#include "driver/adc.h"
@@ -123,6 +124,21 @@ static const machine_adc_obj_t madc_obj[] = {
123124
{{&machine_adc_type}, ADCBLOCK2, ADC_CHANNEL_7, GPIO_NUM_18},
124125
{{&machine_adc_type}, ADCBLOCK2, ADC_CHANNEL_8, GPIO_NUM_19},
125126
{{&machine_adc_type}, ADCBLOCK2, ADC_CHANNEL_9, GPIO_NUM_20},
127+
#elif CONFIG_IDF_TARGET_ESP32P4
128+
{{&machine_adc_type}, ADCBLOCK1, ADC_CHANNEL_0, GPIO_NUM_16},
129+
{{&machine_adc_type}, ADCBLOCK1, ADC_CHANNEL_1, GPIO_NUM_17},
130+
{{&machine_adc_type}, ADCBLOCK1, ADC_CHANNEL_2, GPIO_NUM_18},
131+
{{&machine_adc_type}, ADCBLOCK1, ADC_CHANNEL_3, GPIO_NUM_19},
132+
{{&machine_adc_type}, ADCBLOCK1, ADC_CHANNEL_4, GPIO_NUM_20},
133+
{{&machine_adc_type}, ADCBLOCK1, ADC_CHANNEL_5, GPIO_NUM_21},
134+
{{&machine_adc_type}, ADCBLOCK1, ADC_CHANNEL_6, GPIO_NUM_22},
135+
{{&machine_adc_type}, ADCBLOCK1, ADC_CHANNEL_7, GPIO_NUM_23},
136+
{{&machine_adc_type}, ADCBLOCK1, ADC_CHANNEL_8, GPIO_NUM_49},
137+
{{&machine_adc_type}, ADCBLOCK1, ADC_CHANNEL_9, GPIO_NUM_50},
138+
{{&machine_adc_type}, ADCBLOCK1, ADC_CHANNEL_10, GPIO_NUM_51},
139+
{{&machine_adc_type}, ADCBLOCK1, ADC_CHANNEL_11, GPIO_NUM_52},
140+
{{&machine_adc_type}, ADCBLOCK1, ADC_CHANNEL_12, GPIO_NUM_53},
141+
{{&machine_adc_type}, ADCBLOCK1, ADC_CHANNEL_13, GPIO_NUM_54},
126142
#endif
127143
};
128144

ports/esp32/machine_adc_block.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
// This file is never compiled standalone, it's included directly from
2828
// extmod/machine_adc_block.c via MICROPY_PY_MACHINE_ADC_BLOCK_INCLUDEFILE.
2929

30+
31+
3032
#include "py/mphal.h"
3133
#include "adc.h"
3234
#include "driver/adc.h"

ports/esp32/machine_hw_spi.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@
7373
#define MICROPY_HW_SPI2_SCK (36)
7474
#define MICROPY_HW_SPI2_MOSI (35)
7575
#define MICROPY_HW_SPI2_MISO (37)
76+
#elif CONFIG_IDF_TARGET_ESP32P4
77+
#define MICROPY_HW_SPI2_SCK (43)
78+
#define MICROPY_HW_SPI2_MOSI (44)
79+
#define MICROPY_HW_SPI2_MISO (39)
7680
#endif
7781
#endif
7882

ports/esp32/machine_pin.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@
5555
#define GPIO_FIRST_NON_OUTPUT (34)
5656
#elif CONFIG_IDF_TARGET_ESP32S2
5757
#define GPIO_FIRST_NON_OUTPUT (46)
58+
#elif CONFIG_IDF_TARGET_ESP32P4
59+
#define GPIO_FIRST_NON_OUTPUT (49)
5860
#endif
5961

6062
// Return the gpio_num_t index for a given machine_pin_obj_t pointer.

ports/esp32/machine_pin.h

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,58 @@
174174
#define MICROPY_HW_ENABLE_GPIO48 (1)
175175
#endif
176176

177+
#elif CONFIG_IDF_TARGET_ESP32P4
178+
179+
#define MICROPY_HW_ENABLE_GPIO0 (1)
180+
#define MICROPY_HW_ENABLE_GPIO1 (1)
181+
#define MICROPY_HW_ENABLE_GPIO2 (1)
182+
#define MICROPY_HW_ENABLE_GPIO3 (1)
183+
#define MICROPY_HW_ENABLE_GPIO4 (1)
184+
#define MICROPY_HW_ENABLE_GPIO5 (1)
185+
#define MICROPY_HW_ENABLE_GPIO6 (1)
186+
#define MICROPY_HW_ENABLE_GPIO7 (1)
187+
#define MICROPY_HW_ENABLE_GPIO8 (1)
188+
#define MICROPY_HW_ENABLE_GPIO9 (1)
189+
#define MICROPY_HW_ENABLE_GPIO10 (1)
190+
#define MICROPY_HW_ENABLE_GPIO11 (1)
191+
#define MICROPY_HW_ENABLE_GPIO12 (1)
192+
#define MICROPY_HW_ENABLE_GPIO13 (1)
193+
#define MICROPY_HW_ENABLE_GPIO14 (1)
194+
#define MICROPY_HW_ENABLE_GPIO15 (1)
195+
#define MICROPY_HW_ENABLE_GPIO16 (1)
196+
#define MICROPY_HW_ENABLE_GPIO17 (1)
197+
#define MICROPY_HW_ENABLE_GPIO18 (1)
198+
#define MICROPY_HW_ENABLE_GPIO19 (1)
199+
#define MICROPY_HW_ENABLE_GPIO20 (1)
200+
#define MICROPY_HW_ENABLE_GPIO21 (1)
201+
#define MICROPY_HW_ENABLE_GPIO22 (1)
202+
#define MICROPY_HW_ENABLE_GPIO23 (1)
203+
#define MICROPY_HW_ENABLE_GPIO24 (1)
204+
#define MICROPY_HW_ENABLE_GPIO25 (1)
205+
#define MICROPY_HW_ENABLE_GPIO26 (1)
206+
#define MICROPY_HW_ENABLE_GPIO27 (1)
207+
#define MICROPY_HW_ENABLE_GPIO28 (1)
208+
#define MICROPY_HW_ENABLE_GPIO29 (1)
209+
#define MICROPY_HW_ENABLE_GPIO30 (1)
210+
#define MICROPY_HW_ENABLE_GPIO31 (1)
211+
#define MICROPY_HW_ENABLE_GPIO32 (1)
212+
#define MICROPY_HW_ENABLE_GPIO33 (1)
213+
#define MICROPY_HW_ENABLE_GPIO34 (1)
214+
#define MICROPY_HW_ENABLE_GPIO35 (1)
215+
#define MICROPY_HW_ENABLE_GPIO36 (1)
216+
#define MICROPY_HW_ENABLE_GPIO37 (1)
217+
#define MICROPY_HW_ENABLE_GPIO38 (1)
218+
#define MICROPY_HW_ENABLE_GPIO39 (1)
219+
#define MICROPY_HW_ENABLE_GPIO40 (1)
220+
#define MICROPY_HW_ENABLE_GPIO41 (1)
221+
#define MICROPY_HW_ENABLE_GPIO42 (1)
222+
#define MICROPY_HW_ENABLE_GPIO43 (1)
223+
#define MICROPY_HW_ENABLE_GPIO44 (1)
224+
#define MICROPY_HW_ENABLE_GPIO45 (1)
225+
#define MICROPY_HW_ENABLE_GPIO46 (1)
226+
#define MICROPY_HW_ENABLE_GPIO47 (1)
227+
#define MICROPY_HW_ENABLE_GPIO48 (1)
228+
177229
#endif
178230

179231
typedef struct _machine_pin_irq_obj_t {

ports/esp32/machine_pwm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,4 +785,4 @@ static mp_obj_t mp_machine_pwm_duty_get_ns(machine_pwm_obj_t *self) {
785785

786786
static void mp_machine_pwm_duty_set_ns(machine_pwm_obj_t *self, mp_int_t duty_ns) {
787787
set_duty_ns(self, duty_ns);
788-
}
788+
}

ports/esp32/machine_timer.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@
4747

4848
#define TIMER_FLAGS 0
4949

50+
51+
#if CONFIG_IDF_TARGET_ESP32P4
52+
static uint8_t __DECLARE_RCC_ATOMIC_ENV __attribute__ ((unused));;
53+
#endif
54+
55+
5056
const mp_obj_type_t machine_timer_type;
5157

5258
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);

ports/esp32/machine_touchpad.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include "modmachine.h"
3030
#include "driver/gpio.h"
3131

32-
#if SOC_TOUCH_SENSOR_SUPPORTED
32+
#if SOC_TOUCH_SENSOR_SUPPORTED && !CONFIG_IDF_TARGET_ESP32P4
3333

3434
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 3, 0)
3535
#if SOC_TOUCH_VERSION_1
@@ -80,6 +80,21 @@ static const mtp_obj_t touchpad_obj[] = {
8080
{{&machine_touchpad_type}, GPIO_NUM_12, TOUCH_PAD_NUM12},
8181
{{&machine_touchpad_type}, GPIO_NUM_13, TOUCH_PAD_NUM13},
8282
{{&machine_touchpad_type}, GPIO_NUM_14, TOUCH_PAD_NUM14},
83+
#elif CONFIG_IDF_TARGET_ESP32P4
84+
{{&machine_touchpad_type}, GPIO_NUM_2, TOUCH_PAD_NUM0},
85+
{{&machine_touchpad_type}, GPIO_NUM_3, TOUCH_PAD_NUM1},
86+
{{&machine_touchpad_type}, GPIO_NUM_4, TOUCH_PAD_NUM2},
87+
{{&machine_touchpad_type}, GPIO_NUM_5, TOUCH_PAD_NUM3},
88+
{{&machine_touchpad_type}, GPIO_NUM_6, TOUCH_PAD_NUM4},
89+
{{&machine_touchpad_type}, GPIO_NUM_7, TOUCH_PAD_NUM5},
90+
{{&machine_touchpad_type}, GPIO_NUM_8, TOUCH_PAD_NUM6},
91+
{{&machine_touchpad_type}, GPIO_NUM_9, TOUCH_PAD_NUM7},
92+
{{&machine_touchpad_type}, GPIO_NUM_10, TOUCH_PAD_NUM8},
93+
{{&machine_touchpad_type}, GPIO_NUM_11, TOUCH_PAD_NUM9},
94+
{{&machine_touchpad_type}, GPIO_NUM_12, TOUCH_PAD_NUM10},
95+
{{&machine_touchpad_type}, GPIO_NUM_13, TOUCH_PAD_NUM11},
96+
{{&machine_touchpad_type}, GPIO_NUM_14, TOUCH_PAD_NUM12},
97+
{{&machine_touchpad_type}, GPIO_NUM_15, TOUCH_PAD_NUM13},
8398
#else
8499
#error "Please add GPIO mapping for this SoC"
85100
#endif
@@ -168,4 +183,4 @@ MP_DEFINE_CONST_OBJ_TYPE(
168183
locals_dict, &mtp_locals_dict
169184
);
170185

171-
#endif // SOC_TOUCH_SENSOR_SUPPORTED
186+
#endif // SOC_TOUCH_SENSOR_SUPPORTED

ports/esp32/modesp32.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ static mp_obj_t esp32_wake_on_ulp(const mp_obj_t wake) {
136136
}
137137
static MP_DEFINE_CONST_FUN_OBJ_1(esp32_wake_on_ulp_obj, esp32_wake_on_ulp);
138138

139-
#if !SOC_GPIO_SUPPORT_HOLD_SINGLE_IO_IN_DSLP
139+
#if !SOC_GPIO_SUPPORT_HOLD_SINGLE_IO_IN_DSLP && !CONFIG_IDF_TARGET_ESP32P4
140140
static mp_obj_t esp32_gpio_deep_sleep_hold(const mp_obj_t enable) {
141141
if (mp_obj_is_true(enable)) {
142142
gpio_deep_sleep_hold_en();
@@ -262,7 +262,7 @@ static const mp_rom_map_elem_t esp32_module_globals_table[] = {
262262
{ MP_ROM_QSTR(MP_QSTR_wake_on_ext0), MP_ROM_PTR(&esp32_wake_on_ext0_obj) },
263263
{ MP_ROM_QSTR(MP_QSTR_wake_on_ext1), MP_ROM_PTR(&esp32_wake_on_ext1_obj) },
264264
{ MP_ROM_QSTR(MP_QSTR_wake_on_ulp), MP_ROM_PTR(&esp32_wake_on_ulp_obj) },
265-
#if !SOC_GPIO_SUPPORT_HOLD_SINGLE_IO_IN_DSLP
265+
#if !SOC_GPIO_SUPPORT_HOLD_SINGLE_IO_IN_DSLP && !CONFIG_IDF_TARGET_ESP32P4
266266
{ MP_ROM_QSTR(MP_QSTR_gpio_deep_sleep_hold), MP_ROM_PTR(&esp32_gpio_deep_sleep_hold_obj) },
267267
#endif
268268
#if CONFIG_IDF_TARGET_ESP32
@@ -296,4 +296,4 @@ const mp_obj_module_t esp32_module = {
296296
.globals = (mp_obj_dict_t *)&esp32_module_globals,
297297
};
298298

299-
MP_REGISTER_MODULE(MP_QSTR_esp32, esp32_module);
299+
MP_REGISTER_MODULE(MP_QSTR_esp32, esp32_module);

0 commit comments

Comments
 (0)