kopia lustrzana https://github.com/mobilinkd/tnc3-firmware
Start work on power saving modes.
rodzic
8778ad3f1e
commit
7523bac4f4
|
@ -0,0 +1,52 @@
|
|||
// Copyright 2018 Rob Riggs <rob@mobilinkd.com>
|
||||
// All rights reserved.
|
||||
|
||||
#include "main.h"
|
||||
#include "PowerMode.h"
|
||||
#include "stm32l4xx_hal.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
volatile PowerMode power_mode{PowerMode::RUN};
|
||||
PowerMode previous_mode{PowerMode::RUN}; // Always start in RUN mode.
|
||||
|
||||
/**
|
||||
* Handle state transitions here. Valid transitions are from RUN to any mode,
|
||||
* LPRUN to any mode, SLEEP to LPRUN or STOP, and STOP to LPRUN or SLEEP.
|
||||
*
|
||||
* If moving from RUN to any SLEEP or STOP, we assume the upper layers have
|
||||
* already disconnected the connection, either bu
|
||||
*
|
||||
* @param ulExpectedIdleTime
|
||||
*/
|
||||
extern "C" void PreSleepProcessing(uint32_t *ulExpectedIdleTime)
|
||||
{
|
||||
switch (power_mode)
|
||||
{
|
||||
case PowerMode::RUN:
|
||||
break;
|
||||
case PowerMode::LPRUN:
|
||||
if (previous_mode != power_mode);
|
||||
break;
|
||||
case PowerMode::SLEEP:
|
||||
break;
|
||||
case PowerMode::STOP:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" void PostSleepProcessing(uint32_t *ulExpectedIdleTime)
|
||||
{
|
||||
switch (power_mode)
|
||||
{
|
||||
case PowerMode::RUN:
|
||||
break;
|
||||
case PowerMode::LPRUN:
|
||||
break;
|
||||
case PowerMode::SLEEP:
|
||||
break;
|
||||
case PowerMode::STOP:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
// Copyright 2018 Rob Riggs <rob@mobilinkd.com>
|
||||
// All rights reserved.
|
||||
|
||||
#ifndef TNC_POWERMODE_H_
|
||||
#define TNC_POWERMODE_H_
|
||||
|
||||
enum class PowerMode {
|
||||
RUN, // Power on, connected.
|
||||
LPRUN, // Power on, not connected.
|
||||
SLEEP, // Power off, USB connected.
|
||||
STOP // Power off, no USB connection.
|
||||
};
|
||||
|
||||
extern volatile PowerMode power_mode;
|
||||
|
||||
#endif // TNC_POWERMODE_H_
|
Ładowanie…
Reference in New Issue