measure bat volt (no periodic event)
This commit is contained in:
+5
-24
@@ -2,7 +2,6 @@
|
||||
#ifndef ELITEVT
|
||||
#define ELITEVT
|
||||
static int32_t VTInputVoltData(uint16_t VoVi_Switch, VTMode *VT);
|
||||
#include <driverlib/aon_batmon.h>
|
||||
|
||||
static void VT_Plot(VTMode *VT) {
|
||||
|
||||
@@ -14,35 +13,17 @@ static void VT_Plot(VTMode *VT) {
|
||||
int32_t VoltData;
|
||||
|
||||
if(ADCSwitch == 0){ /**read V(buffer)**/
|
||||
|
||||
//2
|
||||
|
||||
// uint16_t bat_volt = 0;
|
||||
// ReadBatVolt(spi_ADC_rxbuf);
|
||||
// bat_volt = (uint16_t) (spi_ADC_rxbuf[0] << 8) | (uint16_t) (spi_ADC_rxbuf[1]);
|
||||
// uint32_t internal_batt_sense = (uint32_t)(bat_volt) * 12 / 125; //x * 375 / 10000 / 125 * 320 ;
|
||||
|
||||
//1
|
||||
// AONBatMonEnable();
|
||||
// uint8_t internal_battery_percent;
|
||||
// uint32_t internal_batt_sense = AONBatMonBatteryVoltageGet();
|
||||
|
||||
//3
|
||||
headstage_battery_volt();
|
||||
NotifyVolt[0] = 0;
|
||||
NotifyVolt[1] = 0;
|
||||
NotifyVolt[2] = NotifyVoltBat[2];
|
||||
NotifyVolt[3] = NotifyVoltBat[3];
|
||||
|
||||
// InputNotify(NOTIFY_VOLT, internal_batt_sense);
|
||||
ReadADCVolt(VT->_VoVi_Switch);
|
||||
VoltData = VTInputVoltData(VT->_VoVi_Switch, VT);
|
||||
InputNotify(NOTIFY_VOLT, VoltData);
|
||||
ADCSwitch++;
|
||||
}
|
||||
else if(ADCSwitch == 1){ /**read V**/
|
||||
ReadBatVolt(spi_ADC_rxbuf);
|
||||
ReadADCVolt(VT->_VoVi_Switch);
|
||||
ADCSwitch++;
|
||||
}
|
||||
else if(ADCSwitch == 2){ /**read V**/
|
||||
ReadBatVolt(spi_ADC_rxbuf);
|
||||
ReadADCVolt(VT->_VoVi_Switch);
|
||||
ADCSwitch = 0;
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -91,6 +91,7 @@ static void EliteADCBattery(){
|
||||
NotifyVolt[2] = NotifyVoltBat[2];
|
||||
NotifyVolt[3] = NotifyVoltBat[3];
|
||||
batteryCheckFlag = false;
|
||||
// LED_color(DARKLED, 0xFF, 0x00, 0x00);
|
||||
ADCSwitch = 0;
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -3,10 +3,10 @@
|
||||
#define VERSION_DATE
|
||||
|
||||
#define VERSION_DATE_YEAR 20
|
||||
#define VERSION_DATE_MONTH 6
|
||||
#define VERSION_DATE_DAY 30
|
||||
#define VERSION_DATE_HOUR 18
|
||||
#define VERSION_DATE_MINUTE 31
|
||||
#define VERSION_DATE_MONTH 7
|
||||
#define VERSION_DATE_DAY 1
|
||||
#define VERSION_DATE_HOUR 10
|
||||
#define VERSION_DATE_MINUTE 18
|
||||
|
||||
// this is NOT the version hash !!
|
||||
// it's the last version hash
|
||||
|
||||
+30
-28
@@ -567,7 +567,6 @@ uint16_t bat_counter = 0;
|
||||
GPT.GptimerCounter0 = GPT.GptimerCounter;
|
||||
ADCbattery_flag = false;
|
||||
|
||||
|
||||
for (;;) {
|
||||
// Waits for a signal to the semaphore associated with the calling thread.
|
||||
// Note that the semaphore associated with a thread is signaled when a
|
||||
@@ -618,33 +617,6 @@ uint16_t bat_counter = 0;
|
||||
if(events & SBP_PERIODIC_EVT){
|
||||
events &= ~SBP_PERIODIC_EVT;
|
||||
if (!PeriodicEvent) { // if there is no periodic event
|
||||
GPT.DeltaGptimerCounter = GPT.GptimerCounter - GPT.GptimerCounter0;
|
||||
GPT.GptimerCounter0 = GPT.GptimerCounter;
|
||||
|
||||
|
||||
GPT.BatteryADCCounter = GPT.BatteryADCCounter + GPT.DeltaGptimerCounter;
|
||||
GPT.BatteryCheckCounter = GPT.BatteryCheckCounter + GPT.DeltaGptimerCounter;
|
||||
|
||||
if(GPT.BatteryCheckCounter >= 200000){
|
||||
GPT.BatteryCheckCounter = 0;
|
||||
batteryCheckFlag = true;
|
||||
}
|
||||
if(GPT.BatteryADCCounter >= 15 && batteryCheckFlag){
|
||||
GPT.BatteryADCCounter = 0; //To get the data right, ADC must be delay 1.5ms
|
||||
ADCbattery_flag = true;
|
||||
if(ADCbattery_flag){
|
||||
EliteADCBattery();
|
||||
ADCbattery_flag = false;
|
||||
}
|
||||
}
|
||||
uint16_t bat = ((uint16_t)(NotifyVoltBat[2]) << 8 & 0xFF00 ) |
|
||||
((uint16_t)(NotifyVoltBat[3]) & 0x00FF);
|
||||
if( bat < 768 && bat > 20){
|
||||
PIN_setOutputValue(pin_handle, enable_5v, 0);
|
||||
}else{
|
||||
PIN_setOutputValue(pin_handle, enable_5v, 1);
|
||||
}
|
||||
|
||||
key = PIN_getInputValue(switch_on);
|
||||
if (EliteOn) {
|
||||
if (counter6994 < CLOCK_ONE_SECOND/2) { // counter6994 enable a IC after 35 counts
|
||||
@@ -654,6 +626,36 @@ uint16_t bat_counter = 0;
|
||||
counter6994++;
|
||||
}
|
||||
EliteKeyPress(key);
|
||||
if(key != 0){
|
||||
GPT.DeltaGptimerCounter = GPT.GptimerCounter - GPT.GptimerCounter0;
|
||||
GPT.GptimerCounter0 = GPT.GptimerCounter;
|
||||
|
||||
GPT.BatteryADCCounter = GPT.BatteryADCCounter + GPT.DeltaGptimerCounter;
|
||||
GPT.BatteryCheckCounter = GPT.BatteryCheckCounter + GPT.DeltaGptimerCounter;
|
||||
|
||||
if(GPT.BatteryCheckCounter >= 50000){
|
||||
GPT.BatteryCheckCounter = 0;
|
||||
batteryCheckFlag = true;
|
||||
}
|
||||
|
||||
if(GPT.BatteryADCCounter >= 15 && batteryCheckFlag){
|
||||
GPT.BatteryADCCounter = 0; //To get the data right, ADC must be delay 1.5ms
|
||||
ADCbattery_flag = true;
|
||||
if(ADCbattery_flag){
|
||||
EliteADCBattery();
|
||||
ADCbattery_flag = false;
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t bat = ((uint16_t)(NotifyVoltBat[2]) << 8 & 0xFF00 ) |
|
||||
((uint16_t)(NotifyVoltBat[3]) & 0x00FF);
|
||||
if( bat < 768 && bat > 20){
|
||||
PIN_setOutputValue(pin_handle, enable_5v, 0);
|
||||
}else{
|
||||
PIN_setOutputValue(pin_handle, enable_5v, 1);
|
||||
}
|
||||
|
||||
}
|
||||
if(Free_Work_Mode){
|
||||
FreeWorkMode(WorkModeData);
|
||||
InitEliteInstruction();
|
||||
|
||||
Reference in New Issue
Block a user