1
0
forked from me/IronOS

Clean up power calls

This commit is contained in:
Ben V. Brown
2020-05-30 12:43:32 +10:00
parent 5bb85a4a32
commit 05b43dfa1c
5 changed files with 52 additions and 12 deletions

View File

@@ -1,4 +1,5 @@
#include "BSP_Flash.h"
#include "BSP_Power.h"
#include "BSP_QC.h"
#include "Defines.h"
#include "UnitSettings.h"

View File

@@ -0,0 +1,27 @@
#include "stdint.h"
/*
* BSP_Power.h -- Board Support for Power control
*
* These functions are hooks used to allow for power control
*
*/
#ifndef BSP_POWER_H_
#define BSP_POWER_H_
#ifdef __cplusplus
extern "C" {
#endif
// Called once at startup, after RToS
// This can handle negotiations for QC/PD etc
void power_probe();
// Called periodically in the movement handling thread
// Can be used to check any details for the power system
void power_check();
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,20 @@
#include "BSP.h"
#include "BSP_Power.h"
#include "QC3.h"
void power_probe() {
// If TS80 probe for QC
// If TS100 - noop
#ifdef MODEL_TS80
startQC(systemSettings.voltageDiv);
seekQC((systemSettings.cutoutSetting) ? 120 : 90,
systemSettings.voltageDiv); // this will move the QC output to the preferred voltage to start with
#endif
}
void power_check() {
#ifdef MODEL_TS80
QC_resync();
#endif
}

View File

@@ -9,15 +9,5 @@
#include "task.h"
void postRToSInit() {
#ifdef MODEL_TS80
startQC(systemSettings.voltageDiv);
while (pidTaskNotification == 0) osDelay(30); // Wait for PID to start
seekQC((systemSettings.cutoutSetting) ? 120 : 90,
systemSettings.voltageDiv); // this will move the QC output to the preferred voltage to start with
#else
while (pidTaskNotification == 0) osDelay(30); // Wait for PID to start
osDelay(200); // wait for accelerometer to stabilize
#endif
// Any after RTos setup
}

View File

@@ -25,6 +25,8 @@ uint32_t lastMovementTime = 0;
void startMOVTask(void const *argument __unused) {
OLED::setRotation(true);
postRToSInit();
power_probe();
while (pidTaskNotification == 0) osDelay(30); // Wait for PID to start
OLED::setRotation(systemSettings.OrientationMode & 1);
lastMovementTime = 0;
@@ -86,6 +88,6 @@ void startMOVTask(void const *argument __unused) {
}
osDelay(100); // Slow down update rate
QC_resync();
power_check();
}
}