nRF: Handle SPEAKER_ENABLE_PIN
.. the existing code, which was never activated by the preprocessor, wasn't quite right.
This commit is contained in:
parent
78318ae441
commit
fe47eba97f
@ -25,6 +25,7 @@
|
||||
*/
|
||||
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
#include "shared-bindings/digitalio/DigitalInOut.h"
|
||||
|
||||
#include "nrf_gpio.h"
|
||||
#include "py/mphal.h"
|
||||
@ -47,6 +48,19 @@ bool speaker_enable_in_use;
|
||||
STATIC uint32_t claimed_pins[GPIO_COUNT];
|
||||
STATIC uint32_t never_reset_pins[GPIO_COUNT];
|
||||
|
||||
STATIC void reset_speaker_enable_pin(void) {
|
||||
#ifdef SPEAKER_ENABLE_PIN
|
||||
speaker_enable_in_use = false;
|
||||
nrf_gpio_cfg(SPEAKER_ENABLE_PIN->number,
|
||||
NRF_GPIO_PIN_DIR_OUTPUT,
|
||||
NRF_GPIO_PIN_INPUT_DISCONNECT,
|
||||
NRF_GPIO_PIN_NOPULL,
|
||||
NRF_GPIO_PIN_H0H1,
|
||||
NRF_GPIO_PIN_NOSENSE);
|
||||
nrf_gpio_pin_write(SPEAKER_ENABLE_PIN->number, false);
|
||||
#endif
|
||||
}
|
||||
|
||||
void reset_all_pins(void) {
|
||||
for (size_t i = 0; i < GPIO_COUNT; i++) {
|
||||
claimed_pins[i] = never_reset_pins[i];
|
||||
@ -68,10 +82,7 @@ void reset_all_pins(void) {
|
||||
#endif
|
||||
|
||||
// After configuring SWD because it may be shared.
|
||||
#ifdef SPEAKER_ENABLE_PIN
|
||||
speaker_enable_in_use = false;
|
||||
// TODO set pin to out and turn off.
|
||||
#endif
|
||||
reset_speaker_enable_pin();
|
||||
}
|
||||
|
||||
// Mark pin as free and return it to a quiescent state.
|
||||
@ -104,10 +115,7 @@ void reset_pin_number(uint8_t pin_number) {
|
||||
|
||||
#ifdef SPEAKER_ENABLE_PIN
|
||||
if (pin_number == SPEAKER_ENABLE_PIN->number) {
|
||||
speaker_enable_in_use = false;
|
||||
common_hal_digitalio_digitalinout_switch_to_output(SPEAKER_ENABLE_PIN, true, DRIVE_MODE_PUSH_PULL);
|
||||
nrf_gpio_pin_dir_set(pin_number, NRF_GPIO_PIN_DIR_OUTPUT);
|
||||
nrf_gpio_pin_write(pin_number, false);
|
||||
reset_speaker_enable_pin();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user