Skip to content

Commit

Permalink
microbitv2: Add comments to KL27/nRF52 power.c differences
Browse files Browse the repository at this point in the history
  • Loading branch information
martinwork authored and microbit-carlos committed Jan 21, 2022
1 parent 8e7ddac commit 0a04452
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions source/board/microbitv2/kl27z/power.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,11 @@ static void power_mode_switch(smc_power_state_t curPowerState, app_power_mode_t

static void power_pre_switch_hook(smc_power_state_t originPowerState, app_power_mode_t targetMode)
{
// TODO: Check if this is necessary, when we have time to test. This has always been in the V2 code.
// The comment here is misleading. The code waits for completion of the current byte tranmission,
// which is from interface to target. We could possibly move this into uart_uninitialize(),
// and consider waiting for the write buffer to empty too, but as this is our only call to uart_uninitialize()
// and we never get here with USB connected it may be unnecessary.
/* Wait for debug console output finished. */
while (!(LPUART_STAT_TC_MASK & UART->STAT))
{
Expand Down Expand Up @@ -255,6 +260,9 @@ static void power_post_switch_hook(smc_power_state_t originPowerState, app_power
PORT_SetPinMux(UART_PORT, PIN_UART_TX_BIT, (port_mux_t)PIN_UART_TX_MUX_ALT);

uart_initialize();
// TODO: Check if this is necessary, when we have time to test. This has always been in the V2 code.
// It used to be at the end of board_handle_powerdown. We are not aware that this is causing a problem,
// but it seems odd if we have been woken by an I2C transaction from the target.
i2c_deinitialize();
i2c_initialize();
}

0 comments on commit 0a04452

Please sign in to comment.