Skip to content

Commit 14b3b51

Browse files
committed
Rework build flags, prevent idf errors
1 parent 4900668 commit 14b3b51

File tree

5 files changed

+29
-19
lines changed

5 files changed

+29
-19
lines changed

ports/esp32s2/common-hal/microcontroller/Pin.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ void claim_pin(const mcu_pin_obj_t* pin) {
9898
#endif
9999
}
100100

101+
void common_hal_mcu_pin_claim(const mcu_pin_obj_t* pin) {
102+
claim_pin(pin);
103+
}
104+
101105
bool pin_number_is_free(gpio_num_t pin_number) {
102106
#ifdef MICROPY_HW_NEOPIXEL
103107
if (pin_number == MICROPY_HW_NEOPIXEL->number) {

ports/esp32s2/common-hal/pulseio/PWMOut.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,17 @@ STATIC bool never_reset_chan[LEDC_CHANNEL_MAX];
3939

4040
void pwmout_reset(void) {
4141
for (size_t i = 0; i < LEDC_CHANNEL_MAX; i++ ) {
42-
ledc_stop(LEDC_LOW_SPEED_MODE, i, 0);
42+
if (reserved_channels[i] != INDEX_EMPTY) {
43+
ledc_stop(LEDC_LOW_SPEED_MODE, i, 0);
44+
}
4345
if (!never_reset_chan[i]) {
4446
reserved_channels[i] = INDEX_EMPTY;
4547
}
4648
}
4749
for (size_t i = 0; i < LEDC_TIMER_MAX; i++ ) {
48-
ledc_timer_rst(LEDC_LOW_SPEED_MODE, i);
50+
if (reserved_timer_freq[i]) {
51+
ledc_timer_rst(LEDC_LOW_SPEED_MODE, i);
52+
}
4953
if (!never_reset_tim[i]) {
5054
reserved_timer_freq[i] = 0;
5155
}
@@ -157,7 +161,10 @@ void common_hal_pulseio_pwmout_deinit(pulseio_pwmout_obj_t* self) {
157161
if (common_hal_pulseio_pwmout_deinited(self)) {
158162
return;
159163
}
160-
ledc_stop(LEDC_LOW_SPEED_MODE, self->chan_handle.channel, 0);
164+
165+
if (reserved_channels[self->chan_handle.channel] != INDEX_EMPTY) {
166+
ledc_stop(LEDC_LOW_SPEED_MODE, self->chan_handle.channel, 0);
167+
}
161168
// Search if any other channel is using the timer
162169
bool taken = false;
163170
for (size_t i =0; i < LEDC_CHANNEL_MAX; i++) {
@@ -167,7 +174,9 @@ void common_hal_pulseio_pwmout_deinit(pulseio_pwmout_obj_t* self) {
167174
}
168175
// Variable frequency means there's only one channel on the timer
169176
if (!taken || self->variable_frequency) {
170-
ledc_timer_rst(LEDC_LOW_SPEED_MODE, self->tim_handle.timer_num);
177+
if (reserved_timer_freq[self->tim_handle.timer_num] != 0) {
178+
ledc_timer_rst(LEDC_LOW_SPEED_MODE, self->tim_handle.timer_num);
179+
}
171180
reserved_timer_freq[self->tim_handle.timer_num] = 0;
172181
}
173182
reset_pin_number(self->pin_number);

ports/esp32s2/mpconfigport.mk

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,21 @@ LONGINT_IMPL = MPZ
1414

1515
CIRCUITPY_NEOPIXEL_WRITE = 1
1616

17-
CIRCUITPY_FULL_BUILD = 0
17+
# These modules are implemented in ports/<port>/common-hal:
1818
CIRCUITPY_ANALOGIO = 0
19+
CIRCUITPY_NVM = 0
1920
CIRCUITPY_AUDIOBUSIO = 0
2021
CIRCUITPY_AUDIOIO = 0
21-
CIRCUITPY_BITBANGIO = 1
22-
CIRCUITPY_BOARD = 1
23-
CIRCUITPY_DIGITALIO = 1
24-
CIRCUITPY_BUSIO = 1
25-
CIRCUITPY_DISPLAYIO = 1
26-
CIRCUITPY_FREQUENCYIO = 0
27-
CIRCUITPY_I2CPERIPHERAL = 0
28-
CIRCUITPY_MICROCONTROLLER = 1
29-
CIRCUITPY_NVM = 0
30-
CIRCUITPY_PULSEIO = 1
3122
CIRCUITPY_ROTARYIO = 0
3223
CIRCUITPY_RTC = 0
33-
CIRCUITPY_TOUCHIO = 0
24+
CIRCUITPY_FREQUENCYIO = 0
25+
CIRCUITPY_I2CPERIPHERAL = 0
26+
CIRCUITPY_COUNTIO = 0
3427

35-
# Enable USB HID support
36-
CIRCUITPY_USB_HID = 1
37-
CIRCUITPY_USB_MIDI = 0
28+
# These modules are implemented in shared-module/ - they can be included in
29+
# any port once their prerequisites in common-hal are complete.
30+
CIRCUITPY_RANDOM = 0 # Requires OS
31+
CIRCUITPY_USB_MIDI = 0 # Requires USB
32+
CIRCUITPY_ULAB = 0 # No requirements, but takes extra flash
3833

3934
CIRCUITPY_MODULE ?= none

ports/esp32s2/peripherals/rmt.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,5 @@ rmt_channel_t esp32s2_peripherals_find_and_reserve_rmt(void) {
4242

4343
void esp32s2_peripherals_free_rmt(rmt_channel_t chan) {
4444
rmt_reserved_channels[chan] = false;
45+
rmt_driver_uninstall(chan);
4546
}

supervisor/shared/rgb_led_status.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "shared-bindings/microcontroller/Pin.h"
2929
#include "rgb_led_status.h"
3030
#include "supervisor/shared/tick.h"
31+
#include "py/obj.h"
3132

3233
#ifdef MICROPY_HW_NEOPIXEL
3334
uint8_t rgb_status_brightness = 63;

0 commit comments

Comments
 (0)