Merge pull request #3375 from DavePutz/issue3296

Correction for Issue #3296 - ble hanging on nrf52840
This commit is contained in:
Scott Shawcroft 2020-09-10 12:36:17 -07:00 committed by GitHub
commit 9e722c8c99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 1 deletions

View File

@ -106,6 +106,10 @@ void reset_all_pins(void) {
} }
void never_reset_pin_number(uint8_t pin_number) { void never_reset_pin_number(uint8_t pin_number) {
if (pin_number >= PORT_BITS) {
return;
}
never_reset_pins[GPIO_PORT(pin_number)] |= 1 << GPIO_PIN(pin_number); never_reset_pins[GPIO_PORT(pin_number)] |= 1 << GPIO_PIN(pin_number);
} }

View File

@ -45,6 +45,9 @@ bool apa102_mosi_in_use;
bool apa102_sck_in_use; bool apa102_sck_in_use;
void never_reset_pin_number(gpio_num_t pin_number) { void never_reset_pin_number(gpio_num_t pin_number) {
if (pin_number == -1 ) {
return;
}
never_reset_pins[pin_number / 32] |= 1 << pin_number % 32; never_reset_pins[pin_number / 32] |= 1 << pin_number % 32;
} }
@ -54,6 +57,9 @@ void common_hal_never_reset_pin(const mcu_pin_obj_t* pin) {
// Mark pin as free and return it to a quiescent state. // Mark pin as free and return it to a quiescent state.
void reset_pin_number(gpio_num_t pin_number) { void reset_pin_number(gpio_num_t pin_number) {
if (pin_number == -1 ) {
return;
}
never_reset_pins[pin_number / 32] &= ~(1 << pin_number % 32); never_reset_pins[pin_number / 32] &= ~(1 << pin_number % 32);
in_use[pin_number / 32] &= ~(1 << pin_number % 32); in_use[pin_number / 32] &= ~(1 << pin_number % 32);

View File

@ -180,7 +180,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self, const mcu_pin_obj_t *
if (miso != NULL) { if (miso != NULL) {
config.miso_pin = miso->number; config.miso_pin = miso->number;
self->MISO_pin_number = mosi->number; self->MISO_pin_number = miso->number;
claim_pin(miso); claim_pin(miso);
} else { } else {
self->MISO_pin_number = NO_PIN; self->MISO_pin_number = NO_PIN;

View File

@ -123,6 +123,9 @@ void reset_pin_number(uint8_t pin_number) {
void never_reset_pin_number(uint8_t pin_number) { void never_reset_pin_number(uint8_t pin_number) {
if (pin_number == NO_PIN) {
return;
}
never_reset_pins[nrf_pin_port(pin_number)] |= 1 << nrf_relative_pin_number(pin_number); never_reset_pins[nrf_pin_port(pin_number)] |= 1 << nrf_relative_pin_number(pin_number);
} }

View File

@ -70,6 +70,10 @@ void reset_all_pins(void) {
// Mark pin as free and return it to a quiescent state. // Mark pin as free and return it to a quiescent state.
void reset_pin_number(uint8_t pin_port, uint8_t pin_number) { void reset_pin_number(uint8_t pin_port, uint8_t pin_number) {
if ( pin_number == NO_PIN ) {
return;
}
if (pin_port == 0x0F) { if (pin_port == 0x0F) {
return; return;
} }
@ -88,6 +92,9 @@ void reset_pin_number(uint8_t pin_port, uint8_t pin_number) {
} }
void never_reset_pin_number(uint8_t pin_port, uint8_t pin_number) { void never_reset_pin_number(uint8_t pin_port, uint8_t pin_number) {
if ( pin_number == NO_PIN ) {
return;
}
never_reset_pins[pin_port] |= 1<<pin_number; never_reset_pins[pin_port] |= 1<<pin_number;
// Make sure never reset pins are also always claimed // Make sure never reset pins are also always claimed
claimed_pins[pin_port] |= 1<<pin_number; claimed_pins[pin_port] |= 1<<pin_number;