Skip to content

Commit de6ce27

Browse files
mmahadevan108adbridge
authored andcommitted
MCUXpresso: Change the Kinetis deep sleep implementation
The code checks if any of the UART's is still transmitting. If so then prevent from entering deepsleep Signed-off-by: Mahesh Mahadevan <[email protected]>
1 parent 575109b commit de6ce27

File tree

1 file changed

+6
-18
lines changed
  • targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/api

1 file changed

+6
-18
lines changed

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/api/sleep.c

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,8 @@
1717
#include "cmsis.h"
1818
#include "fsl_smc.h"
1919
#include "fsl_clock_config.h"
20-
#include "pinmap.h"
21-
#include "fsl_port.h"
22-
#include "PeripheralPins.h"
2320

24-
extern void serial_wait_tx_complete(uint32_t uart_index);
21+
extern bool serial_check_tx_ongoing();
2522

2623
void hal_sleep(void)
2724
{
@@ -32,7 +29,6 @@ void hal_sleep(void)
3229

3330
void hal_deepsleep(void)
3431
{
35-
uint32_t pin_func;
3632
#if (defined(FSL_FEATURE_SOC_MCG_COUNT) && FSL_FEATURE_SOC_MCG_COUNT)
3733
#if (defined(FSL_FEATURE_MCG_HAS_PLL) && FSL_FEATURE_MCG_HAS_PLL)
3834
smc_power_state_t original_power_state;
@@ -41,25 +37,17 @@ void hal_deepsleep(void)
4137
#endif // FSL_FEATURE_MCG_HAS_PLL
4238
#endif // FSL_FEATURE_SOC_MCG_COUNT
4339

44-
SMC_SetPowerModeProtection(SMC, kSMC_AllowPowerModeAll);
45-
46-
/* Wait till debug UART is done transmitting */
47-
serial_wait_tx_complete(STDIO_UART);
40+
/* Check if any of the UART's is transmitting data */
41+
if (serial_check_tx_ongoing()) {
42+
return;
43+
}
4844

49-
/*
50-
* Set pin for current leakage.
51-
* Debug console RX pin: Set to pinmux to disable.
52-
* Debug console TX pin: Don't need to change.
53-
*/
54-
pin_function(STDIO_UART_RX, (int)kPORT_PinDisabledOrAnalog);
45+
SMC_SetPowerModeProtection(SMC, kSMC_AllowPowerModeAll);
5546

5647
SMC_PreEnterStopModes();
5748
SMC_SetPowerModeVlps(SMC);
5849
SMC_PostExitStopModes();
5950

60-
pin_func = pinmap_find_function(STDIO_UART_RX, PinMap_UART_RX);
61-
pin_function(STDIO_UART_RX, pin_func);
62-
6351
#if (defined(FSL_FEATURE_SOC_MCG_COUNT) && FSL_FEATURE_SOC_MCG_COUNT)
6452
#if (defined(FSL_FEATURE_MCG_HAS_PLL) && FSL_FEATURE_MCG_HAS_PLL)
6553
/*

0 commit comments

Comments
 (0)