// // Created by xemon on 29.08.22. // #ifndef UVEOS_DEMO_ON_NIIET_MCU_POWERMANAGEMENT_H #define UVEOS_DEMO_ON_NIIET_MCU_POWERMANAGEMENT_H #include #include "GpioPin.h" #include "UserInput.h" #include "UserIndication.h" #include "SpiPorts.h" #include "Adc.h" #include "LoggerInterface.h" #ifdef USE_GSM_AND_GNSS_TELIT #include "PwmLe910.h" //#include "Gpios.h" #endif #ifdef USE_GSM_AND_GNSS_SIMCOM #include "PwmSim68m.h" #include "PwmSim7600e.h" #endif #if USE_POLAR_DEPENDENT_BIP typedef struct { tGpioPin ignitionOn; tGpioPin bacLightOn; } tPowerBip; #endif typedef struct { tGpioPin shutdownB; tGpioPin shutdownD; tGpioPin gain; tGpioPin mic; } tAudioPower; typedef struct { tGpioPin ignition; tGpioPin standby; tGpioPin garage; tGpioPin ecall; tGpioPin muteP; tGpioPin muteN; tGpioPin inAnt; } tMainPower; typedef struct { tGpioPin enable; tGpioPin charge; } tBatteryPower; typedef struct { tGpioPin bip; tGpioPin comInt485; tGpioPin usb; tAudioPower audio; tBatteryPower battery; tMainPower main; #ifdef USE_GSM_AND_GNSS_TELIT tTelitPower telit; #endif } tPowerPins; typedef struct { tLoggerInterface *logger; tPowerPins *pins; bool *positiveMute; tAdcIO *batteryMeasure; uint32_t shutdownDelay; uint32_t lastIgnEnabled; int32_t currentBatVoltage; bool currentChargeState; bool currentPwrSaveState; struct { osThreadId_t id; uint32_t stack[256]; StaticTask_t controlBlock; osThreadAttr_t attr; } thread; } tPowerManagement; void Pwm_Init(tPowerManagement *env, tPowerPins *pins, tAdcIO *batteryMeasure, bool *positiveMute); void PowerManagement_StartThread(tPowerManagement *env); void Pwm_OnDeviceInit(tPowerManagement *env); bool Pwm_IsShutdownRequired(tPowerManagement *env); void Pwm_Blackout(tPowerManagement *env); void Pwm_AudioEnable(tPowerManagement *env); void Pwm_AudioDisable(tPowerManagement *env); void Pwm_LedtUp(tPowerManagement *env); void Pwm_LedBoardDown(tPowerManagement *env); void Pwm_ChargeDisable(tPowerManagement *env); void Pwm_ChargeEnable(tPowerManagement *env); void Pwm_PowerSavingEnable(tPowerManagement *env); void Pwm_PowerSavingDisable(tPowerManagement *env); void Pwm_SetMute(tPowerManagement *env, bool value); void Pwm_GsmAndGnssShutdown(tPowerManagement *env); void Pwm_BipShutdown(tPowerManagement *env); void Pwm_GsmAndBipStartUp(tPowerManagement *env); void Pwm_GsmAndGnssStartup(tPowerManagement *env); void Pwm_Rs485Disable(tPowerManagement *env); //void PowerManagementTelitShutdown(tPowerManagement *env); #endif //UVEOS_DEMO_ON_NIIET_MCU_POWERMANAGEMENT_H