Add existing code: Power consumption test cases and Semaphore power scheduler skeleton
This commit is contained in:
35
src/power/Power.h
Normal file
35
src/power/Power.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* @file Power.h
|
||||
* @author Phillip Kühne
|
||||
* @brief This component provides utilities for keeping track of power usage
|
||||
* consumption.
|
||||
* @version 0.1
|
||||
* @date 2024-11-23
|
||||
*/
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#ifndef Power_h
|
||||
#define Power_h
|
||||
|
||||
#define TOTAL_POWER_MILLIWATTS 700
|
||||
|
||||
class Power {
|
||||
protected:
|
||||
static const uint16_t total_power_budget = TOTAL_POWER_MILLIWATTS;
|
||||
uint16_t free_power_budget;
|
||||
|
||||
public:
|
||||
Power();
|
||||
uint16_t getFreePowerBudget(void);
|
||||
/// @brief Request an allowance of a certain number of milliwatts from the power scheduler
|
||||
/// @param neededPower the amount of power we want to be accounted for (in mW)
|
||||
/// @return whether the power could be successfully allocated
|
||||
bool tryAccquirePowerAllowance(uint16_t neededPower);
|
||||
/// @brief "Return" a certain amount of power when it is no longer needed
|
||||
/// @param power the amount of power to return (in mW)
|
||||
/// @return whether the power
|
||||
void releasePower(uint16_t power);
|
||||
};
|
||||
|
||||
#endif //Power
|
||||
Reference in New Issue
Block a user