Skip to content

File Power.cpp

FileList > demo-projets > stm32 > src > Power.cpp

Go to the source code of this file.

  • #include "stm32f1xx_ll_adc.h"
  • #include "stm32f1xx_ll_rcc.h"
  • #include "Bsp.hpp"
  • #include "BuzzerController.hpp"
  • #include "Dispatcher.hpp"
  • #include "Power.hpp"
  • #include "utils/Debug.hpp"
  • #include "utils/Flash.hpp"
  • #include "utils/TaskWrapper.hpp"
  • #include "utils/TickTimer.hpp"
  • #include "rbcx.pb.h"

Classes

Type Name
struct CalibrationData

Public Static Attributes

Type Name
constexpr uint16_t ThresholdNoBatteryMv = = 5000
constexpr uint16_t ThresholdPowerOffMv = = 6600
CalibrationData calib = = calibrationDefaults
constexpr uint32_t calibrationDataMagic = = 0x4BCA001
constexpr CalibrationData calibrationDefaults = = {
.magic = calibrationDataMagic,
.batteryCoef = 3.4f,
.batteryMidCoef = 1.56f,
.internalVrefMv = 1200,
.tempTypicalMv = 1430,
.tempTypicalAtC = 25,
}
constexpr uint32_t dispatchStatPeriodMs = = 250
TickTimer dispatchStatTimer
uint16_t rawBattery = = 0
uint16_t rawInternalRef = = 0
uint16_t rawMidBattery = = 0
uint16_t rawTemperature = = 0
constexpr uint16_t tempAvgSlope = = 4300
int undervoltageCounter = = 0
constexpr int undervoltageShutdownThreshold = = 5000 / dispatchStatPeriodMs
bool undervoltageWarningOn = = false
uint16_t vrefMv = = 0

Public Functions

Type Name
void AUXILIARY_AND_MOTOR_ADC_IRQ_HANDLER ()
uint16_t powerBatteryMidMv ()
uint16_t powerBatteryMv ()
void powerCalibrate (uint16_t vccMv, uint16_t bMidMv, uint16_t vref33Mv, uint16_t currentTemperatureC)
void powerInit ()
void powerPoll ()
void powerShutDown ()
uint16_t powerTemperatureC ()
uint16_t powerVrefMv ()

Public Static Functions

Type Name
void adcWait (uint32_t clockCycles)
void checkBatteryVoltage (uint16_t vccMv)
void loadCalibration ()

Public Static Attributes Documentation

variable ThresholdNoBatteryMv

constexpr uint16_t ThresholdNoBatteryMv;

variable ThresholdPowerOffMv

constexpr uint16_t ThresholdPowerOffMv;

variable calib

CalibrationData calib;

variable calibrationDataMagic

constexpr uint32_t calibrationDataMagic;

variable calibrationDefaults

constexpr CalibrationData calibrationDefaults;

variable dispatchStatPeriodMs

constexpr uint32_t dispatchStatPeriodMs;

variable dispatchStatTimer

TickTimer dispatchStatTimer;

variable rawBattery

uint16_t rawBattery;

variable rawInternalRef

uint16_t rawInternalRef;

variable rawMidBattery

uint16_t rawMidBattery;

variable rawTemperature

uint16_t rawTemperature;

variable tempAvgSlope

constexpr uint16_t tempAvgSlope;

variable undervoltageCounter

int undervoltageCounter;

variable undervoltageShutdownThreshold

constexpr int undervoltageShutdownThreshold;

variable undervoltageWarningOn

bool undervoltageWarningOn;

variable vrefMv

uint16_t vrefMv;

Public Functions Documentation

function AUXILIARY_AND_MOTOR_ADC_IRQ_HANDLER

void AUXILIARY_AND_MOTOR_ADC_IRQ_HANDLER () 

function powerBatteryMidMv

uint16_t powerBatteryMidMv () 

function powerBatteryMv

uint16_t powerBatteryMv () 

function powerCalibrate

void powerCalibrate (
    uint16_t vccMv,
    uint16_t bMidMv,
    uint16_t vref33Mv,
    uint16_t currentTemperatureC
) 

function powerInit

void powerInit () 

function powerPoll

void powerPoll () 

function powerShutDown

void powerShutDown () 

function powerTemperatureC

uint16_t powerTemperatureC () 

function powerVrefMv

uint16_t powerVrefMv () 

Public Static Functions Documentation

function adcWait

static void adcWait (
    uint32_t clockCycles
) 

function checkBatteryVoltage

static void checkBatteryVoltage (
    uint16_t vccMv
) 

function loadCalibration

static void loadCalibration () 

The documentation for this class was generated from the following file demo-projets/stm32/src/Power.cpp