Rework build flags, prevent idf errors

This commit is contained in:
Lucian Copeland 2020-08-04 18:40:24 -04:00
parent 4900668778
commit 14b3b51c58
5 changed files with 29 additions and 19 deletions

View File

@ -98,6 +98,10 @@ void claim_pin(const mcu_pin_obj_t* pin) {
#endif #endif
} }
void common_hal_mcu_pin_claim(const mcu_pin_obj_t* pin) {
claim_pin(pin);
}
bool pin_number_is_free(gpio_num_t pin_number) { bool pin_number_is_free(gpio_num_t pin_number) {
#ifdef MICROPY_HW_NEOPIXEL #ifdef MICROPY_HW_NEOPIXEL
if (pin_number == MICROPY_HW_NEOPIXEL->number) { if (pin_number == MICROPY_HW_NEOPIXEL->number) {

View File

@ -39,13 +39,17 @@ STATIC bool never_reset_chan[LEDC_CHANNEL_MAX];
void pwmout_reset(void) { void pwmout_reset(void) {
for (size_t i = 0; i < LEDC_CHANNEL_MAX; i++ ) { for (size_t i = 0; i < LEDC_CHANNEL_MAX; i++ ) {
ledc_stop(LEDC_LOW_SPEED_MODE, i, 0); if (reserved_channels[i] != INDEX_EMPTY) {
ledc_stop(LEDC_LOW_SPEED_MODE, i, 0);
}
if (!never_reset_chan[i]) { if (!never_reset_chan[i]) {
reserved_channels[i] = INDEX_EMPTY; reserved_channels[i] = INDEX_EMPTY;
} }
} }
for (size_t i = 0; i < LEDC_TIMER_MAX; i++ ) { for (size_t i = 0; i < LEDC_TIMER_MAX; i++ ) {
ledc_timer_rst(LEDC_LOW_SPEED_MODE, i); if (reserved_timer_freq[i]) {
ledc_timer_rst(LEDC_LOW_SPEED_MODE, i);
}
if (!never_reset_tim[i]) { if (!never_reset_tim[i]) {
reserved_timer_freq[i] = 0; reserved_timer_freq[i] = 0;
} }
@ -157,7 +161,10 @@ void common_hal_pulseio_pwmout_deinit(pulseio_pwmout_obj_t* self) {
if (common_hal_pulseio_pwmout_deinited(self)) { if (common_hal_pulseio_pwmout_deinited(self)) {
return; return;
} }
ledc_stop(LEDC_LOW_SPEED_MODE, self->chan_handle.channel, 0);
if (reserved_channels[self->chan_handle.channel] != INDEX_EMPTY) {
ledc_stop(LEDC_LOW_SPEED_MODE, self->chan_handle.channel, 0);
}
// Search if any other channel is using the timer // Search if any other channel is using the timer
bool taken = false; bool taken = false;
for (size_t i =0; i < LEDC_CHANNEL_MAX; i++) { 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) {
} }
// Variable frequency means there's only one channel on the timer // Variable frequency means there's only one channel on the timer
if (!taken || self->variable_frequency) { if (!taken || self->variable_frequency) {
ledc_timer_rst(LEDC_LOW_SPEED_MODE, self->tim_handle.timer_num); if (reserved_timer_freq[self->tim_handle.timer_num] != 0) {
ledc_timer_rst(LEDC_LOW_SPEED_MODE, self->tim_handle.timer_num);
}
reserved_timer_freq[self->tim_handle.timer_num] = 0; reserved_timer_freq[self->tim_handle.timer_num] = 0;
} }
reset_pin_number(self->pin_number); reset_pin_number(self->pin_number);

View File

@ -14,26 +14,21 @@ LONGINT_IMPL = MPZ
CIRCUITPY_NEOPIXEL_WRITE = 1 CIRCUITPY_NEOPIXEL_WRITE = 1
CIRCUITPY_FULL_BUILD = 0 # These modules are implemented in ports/<port>/common-hal:
CIRCUITPY_ANALOGIO = 0 CIRCUITPY_ANALOGIO = 0
CIRCUITPY_NVM = 0
CIRCUITPY_AUDIOBUSIO = 0 CIRCUITPY_AUDIOBUSIO = 0
CIRCUITPY_AUDIOIO = 0 CIRCUITPY_AUDIOIO = 0
CIRCUITPY_BITBANGIO = 1
CIRCUITPY_BOARD = 1
CIRCUITPY_DIGITALIO = 1
CIRCUITPY_BUSIO = 1
CIRCUITPY_DISPLAYIO = 1
CIRCUITPY_FREQUENCYIO = 0
CIRCUITPY_I2CPERIPHERAL = 0
CIRCUITPY_MICROCONTROLLER = 1
CIRCUITPY_NVM = 0
CIRCUITPY_PULSEIO = 1
CIRCUITPY_ROTARYIO = 0 CIRCUITPY_ROTARYIO = 0
CIRCUITPY_RTC = 0 CIRCUITPY_RTC = 0
CIRCUITPY_TOUCHIO = 0 CIRCUITPY_FREQUENCYIO = 0
CIRCUITPY_I2CPERIPHERAL = 0
CIRCUITPY_COUNTIO = 0
# Enable USB HID support # These modules are implemented in shared-module/ - they can be included in
CIRCUITPY_USB_HID = 1 # any port once their prerequisites in common-hal are complete.
CIRCUITPY_USB_MIDI = 0 CIRCUITPY_RANDOM = 0 # Requires OS
CIRCUITPY_USB_MIDI = 0 # Requires USB
CIRCUITPY_ULAB = 0 # No requirements, but takes extra flash
CIRCUITPY_MODULE ?= none CIRCUITPY_MODULE ?= none

View File

@ -42,4 +42,5 @@ rmt_channel_t esp32s2_peripherals_find_and_reserve_rmt(void) {
void esp32s2_peripherals_free_rmt(rmt_channel_t chan) { void esp32s2_peripherals_free_rmt(rmt_channel_t chan) {
rmt_reserved_channels[chan] = false; rmt_reserved_channels[chan] = false;
rmt_driver_uninstall(chan);
} }

View File

@ -28,6 +28,7 @@
#include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/microcontroller/Pin.h"
#include "rgb_led_status.h" #include "rgb_led_status.h"
#include "supervisor/shared/tick.h" #include "supervisor/shared/tick.h"
#include "py/obj.h"
#ifdef MICROPY_HW_NEOPIXEL #ifdef MICROPY_HW_NEOPIXEL
uint8_t rgb_status_brightness = 63; uint8_t rgb_status_brightness = 63;