@@ -317,9 +317,12 @@ void goToSleep(uint32_t sysTicksToSleep)
317317 am_hal_gpio_pinconfig (PIN_QWIIC_SDA , g_AM_HAL_GPIO_DISABLE);
318318 am_hal_gpio_pinconfig (PIN_QWIIC_SCL , g_AM_HAL_GPIO_DISABLE);
319319
320- // Do disable pins 48 and 49 (UART0) to stop them back-feeding the CH340
321- am_hal_gpio_pinconfig (48 , g_AM_HAL_GPIO_DISABLE); // TX0
322- am_hal_gpio_pinconfig (49 , g_AM_HAL_GPIO_DISABLE); // RX0
320+ // If requested, disable pins 48 and 49 (UART0) to stop them back-feeding the CH340
321+ if (settings.serialTxRxDuringSleep == false )
322+ {
323+ am_hal_gpio_pinconfig (48 , g_AM_HAL_GPIO_DISABLE); // TX0
324+ am_hal_gpio_pinconfig (49 , g_AM_HAL_GPIO_DISABLE); // RX0
325+ }
323326
324327 // Make sure PIN_POWER_LOSS is configured as an input for the WDT
325328 pinMode (PIN_POWER_LOSS, INPUT); // BD49K30G-TL has CMOS output and does not need a pull-up
@@ -405,7 +408,7 @@ void wakeFromSleep()
405408
406409 // If 3.3V rail drops below 3V, system will enter low power mode and maintain RTC
407410 pinMode (PIN_POWER_LOSS, INPUT); // BD49K30G-TL has CMOS output and does not need a pull-up
408- pin_config (PinName (PIN_POWER_LOSS), g_AM_HAL_GPIO_INPUT); // Make sure the pin does actually get re-configured after being disabled
411+ pin_config (PinName (PIN_POWER_LOSS), g_AM_HAL_GPIO_INPUT); // Make sure the pin does actually get re-configured
409412
410413 delay (1 ); // Let PIN_POWER_LOSS stabilize
411414
@@ -418,39 +421,44 @@ void wakeFromSleep()
418421 if (settings.useGPIO32ForStopLogging == true )
419422 {
420423 pinMode (PIN_STOP_LOGGING, INPUT_PULLUP);
421- pin_config (PinName (PIN_STOP_LOGGING), g_AM_HAL_GPIO_INPUT_PULLUP); // Make sure the pin does actually get re-configured after being disabled
424+ pin_config (PinName (PIN_STOP_LOGGING), g_AM_HAL_GPIO_INPUT_PULLUP); // Make sure the pin does actually get re-configured
422425 delay (1 ); // Let the pin stabilize
423426 attachInterrupt (PIN_STOP_LOGGING, stopLoggingISR, FALLING); // Enable the interrupt
427+ pin_config (PinName (PIN_STOP_LOGGING), g_AM_HAL_GPIO_INPUT_PULLUP); // Make sure the pull-up does actually stay enabled
424428 stopLoggingSeen = false ; // Make sure the flag is clear
425429 }
426430
427431 if (settings.useGPIO11ForTrigger == true ) // (This should be redundant. We should not be going to sleep if triggering is enabled?)
428432 {
429433 pinMode (PIN_TRIGGER, INPUT_PULLUP);
430- pin_config (PinName (PIN_TRIGGER), g_AM_HAL_GPIO_INPUT_PULLUP); // Make sure the pin does actually get re-configured after being disabled
434+ pin_config (PinName (PIN_TRIGGER), g_AM_HAL_GPIO_INPUT_PULLUP); // Make sure the pin does actually get re-configured
431435 delay (1 ); // Let the pin stabilize
432436 if (settings.fallingEdgeTrigger == true )
433437 attachInterrupt (PIN_TRIGGER, triggerPinISR, FALLING); // Enable the interrupt
434438 else
435439 attachInterrupt (PIN_TRIGGER, triggerPinISR, RISING); // Enable the interrupt
440+ pin_config (PinName (PIN_TRIGGER), g_AM_HAL_GPIO_INPUT_PULLUP); // Make sure the pull-up does actually stay enabled
436441 triggerEdgeSeen = false ; // Make sure the flag is clear
437442 }
438443
439444 if (settings.useGPIO11ForFastSlowLogging == true )
440445 {
441446 pinMode (PIN_TRIGGER, INPUT_PULLUP);
442- pin_config (PinName (PIN_TRIGGER), g_AM_HAL_GPIO_INPUT_PULLUP); // Make sure the pin does actually get re-configured after being disabled
447+ pin_config (PinName (PIN_TRIGGER), g_AM_HAL_GPIO_INPUT_PULLUP); // Make sure the pin does actually get re-configured
443448 }
444449
445450 pinMode (PIN_STAT_LED, OUTPUT);
446- pin_config (PinName (PIN_STAT_LED), g_AM_HAL_GPIO_OUTPUT); // Make sure the pin does actually get re-configured after being disabled
451+ pin_config (PinName (PIN_STAT_LED), g_AM_HAL_GPIO_OUTPUT); // Make sure the pin does actually get re-configured
447452 digitalWrite (PIN_STAT_LED, LOW);
448453
449454 powerLEDOn ();
450455
451- // Re-enable pins 48 and 49 (UART0)
452- pin_config (PinName (48 ), g_AM_BSP_GPIO_COM_UART_TX);
453- pin_config (PinName (49 ), g_AM_BSP_GPIO_COM_UART_RX);
456+ // Re-enable pins 48 and 49 (UART0) if requested
457+ if (settings.serialTxRxDuringSleep == false )
458+ {
459+ pin_config (PinName (48 ), g_AM_BSP_GPIO_COM_UART_TX);
460+ pin_config (PinName (49 ), g_AM_BSP_GPIO_COM_UART_RX);
461+ }
454462
455463 // Re-enable CIPO, COPI, SCK and the chip selects but may as well leave ICM_INT disabled
456464 pin_config (PinName (PIN_SPI_CIPO), g_AM_BSP_GPIO_IOM0_MISO);
@@ -553,7 +561,7 @@ void waitForQwiicBusPowerDelay() // Wait while the qwiic devices power up
553561void qwiicPowerOn ()
554562{
555563 pinMode (PIN_QWIIC_POWER, OUTPUT);
556- pin_config (PinName (PIN_QWIIC_POWER), g_AM_HAL_GPIO_OUTPUT); // Make sure the pin does actually get re-configured after being disabled
564+ pin_config (PinName (PIN_QWIIC_POWER), g_AM_HAL_GPIO_OUTPUT); // Make sure the pin does actually get re-configured
557565#if (HARDWARE_VERSION_MAJOR == 0)
558566 digitalWrite (PIN_QWIIC_POWER, LOW);
559567#else
@@ -565,7 +573,7 @@ void qwiicPowerOn()
565573void qwiicPowerOff ()
566574{
567575 pinMode (PIN_QWIIC_POWER, OUTPUT);
568- pin_config (PinName (PIN_QWIIC_POWER), g_AM_HAL_GPIO_OUTPUT); // Make sure the pin does actually get re-configured after being disabled
576+ pin_config (PinName (PIN_QWIIC_POWER), g_AM_HAL_GPIO_OUTPUT); // Make sure the pin does actually get re-configured
569577#if (HARDWARE_VERSION_MAJOR == 0)
570578 digitalWrite (PIN_QWIIC_POWER, HIGH);
571579#else
@@ -576,42 +584,42 @@ void qwiicPowerOff()
576584void microSDPowerOn ()
577585{
578586 pinMode (PIN_MICROSD_POWER, OUTPUT);
579- pin_config (PinName (PIN_MICROSD_POWER), g_AM_HAL_GPIO_OUTPUT); // Make sure the pin does actually get re-configured after being disabled
587+ pin_config (PinName (PIN_MICROSD_POWER), g_AM_HAL_GPIO_OUTPUT); // Make sure the pin does actually get re-configured
580588 digitalWrite (PIN_MICROSD_POWER, LOW);
581589}
582590void microSDPowerOff ()
583591{
584592 pinMode (PIN_MICROSD_POWER, OUTPUT);
585- pin_config (PinName (PIN_MICROSD_POWER), g_AM_HAL_GPIO_OUTPUT); // Make sure the pin does actually get re-configured after being disabled
593+ pin_config (PinName (PIN_MICROSD_POWER), g_AM_HAL_GPIO_OUTPUT); // Make sure the pin does actually get re-configured
586594 digitalWrite (PIN_MICROSD_POWER, HIGH);
587595}
588596
589597void imuPowerOn ()
590598{
591599 pinMode (PIN_IMU_POWER, OUTPUT);
592- pin_config (PinName (PIN_IMU_POWER), g_AM_HAL_GPIO_OUTPUT); // Make sure the pin does actually get re-configured after being disabled
600+ pin_config (PinName (PIN_IMU_POWER), g_AM_HAL_GPIO_OUTPUT); // Make sure the pin does actually get re-configured
593601 digitalWrite (PIN_IMU_POWER, HIGH);
594602}
595603void imuPowerOff ()
596604{
597605 pinMode (PIN_IMU_POWER, OUTPUT);
598- pin_config (PinName (PIN_IMU_POWER), g_AM_HAL_GPIO_OUTPUT); // Make sure the pin does actually get re-configured after being disabled
606+ pin_config (PinName (PIN_IMU_POWER), g_AM_HAL_GPIO_OUTPUT); // Make sure the pin does actually get re-configured
599607 digitalWrite (PIN_IMU_POWER, LOW);
600608}
601609
602610void powerLEDOn ()
603611{
604612#if (HARDWARE_VERSION_MAJOR >= 1)
605613 pinMode (PIN_PWR_LED, OUTPUT);
606- pin_config (PinName (PIN_PWR_LED), g_AM_HAL_GPIO_OUTPUT); // Make sure the pin does actually get re-configured after being disabled
614+ pin_config (PinName (PIN_PWR_LED), g_AM_HAL_GPIO_OUTPUT); // Make sure the pin does actually get re-configured
607615 digitalWrite (PIN_PWR_LED, HIGH); // Turn the Power LED on
608616#endif
609617}
610618void powerLEDOff ()
611619{
612620#if (HARDWARE_VERSION_MAJOR >= 1)
613621 pinMode (PIN_PWR_LED, OUTPUT);
614- pin_config (PinName (PIN_PWR_LED), g_AM_HAL_GPIO_OUTPUT); // Make sure the pin does actually get re-configured after being disabled
622+ pin_config (PinName (PIN_PWR_LED), g_AM_HAL_GPIO_OUTPUT); // Make sure the pin does actually get re-configured
615623 digitalWrite (PIN_PWR_LED, LOW); // Turn the Power LED off
616624#endif
617625}
0 commit comments