From 2ab5c83e5241d3f2defed65f1d29caf6f44703ed Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Tue, 19 Apr 2022 18:10:16 +1000 Subject: [PATCH] Cleanup --- source/Core/BSP/Magic/I2C_Wrapper.cpp | 4 +--- source/Core/BSP/Magic/IRQ.cpp | 14 +++++++++----- source/Core/Threads/POWThread.cpp | 1 - 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/source/Core/BSP/Magic/I2C_Wrapper.cpp b/source/Core/BSP/Magic/I2C_Wrapper.cpp index 5c8af475..e254a5eb 100644 --- a/source/Core/BSP/Magic/I2C_Wrapper.cpp +++ b/source/Core/BSP/Magic/I2C_Wrapper.cpp @@ -17,9 +17,7 @@ extern "C" { SemaphoreHandle_t FRToSI2C::I2CSemaphore = nullptr; StaticSemaphore_t FRToSI2C::xSemaphoreBuffer; #define I2C_TIME_OUT (uint16_t)(12000) -void FRToSI2C::CpltCallback() { - // TODO -} +void FRToSI2C::CpltCallback() {} // Not used bool FRToSI2C::I2C_RegisterWrite(uint8_t address, uint8_t reg, uint8_t data) { return Mem_Write(address, reg, &data, 1); } diff --git a/source/Core/BSP/Magic/IRQ.cpp b/source/Core/BSP/Magic/IRQ.cpp index 8a957087..2058599a 100644 --- a/source/Core/BSP/Magic/IRQ.cpp +++ b/source/Core/BSP/Magic/IRQ.cpp @@ -173,7 +173,7 @@ void setTipPWM(const uint8_t pulse, const bool shouldUseFastModePWM) { // disabled if the PID task is not scheduled often enough. pendingPWM = pulse; fastPWM = shouldUseFastModePWM; - MSG((char *)"PWM Output %d, %d\r\n", pulse, (int)shouldUseFastModePWM); + // MSG((char *)"PWM Output %d, %d\r\n", pulse, (int)shouldUseFastModePWM); } extern osThreadId POWTaskHandle; @@ -213,10 +213,14 @@ bool getFUS302IRQLow() { return false; // return (RESET == gpio_input_bit_get(FUSB302_IRQ_GPIO_Port, FUSB302_IRQ_Pin)); } +uint16_t rescaleADC(const uint16_t value) { + uint32_t temp = value * 33; + uint16_t res = temp / 32; + return res; +} +uint16_t getADCHandleTemp(uint8_t sample) { return rescaleADC(ADC_Temp.average() >> 1); } -uint16_t getADCHandleTemp(uint8_t sample) { return ADC_Temp.average() >> 1; } - -uint16_t getADCVin(uint8_t sample) { return ADC_Vin.average() >> 1; } +uint16_t getADCVin(uint8_t sample) { return rescaleADC(ADC_Vin.average() >> 1); } // Returns either average or instant value. When sample is set the samples from the injected ADC are copied to the filter and then the raw reading is returned -uint16_t getTipRawTemp(uint8_t sample) { return ADC_Tip.average() >> 2; } +uint16_t getTipRawTemp(uint8_t sample) { return rescaleADC(ADC_Tip.average() >> 2); } diff --git a/source/Core/Threads/POWThread.cpp b/source/Core/Threads/POWThread.cpp index 1b10998c..d8638816 100644 --- a/source/Core/Threads/POWThread.cpp +++ b/source/Core/Threads/POWThread.cpp @@ -34,7 +34,6 @@ void startPOWTask(void const *argument __unused) { #endif BaseType_t res; for (;;) { - MSG((char *)"POW Spin\r\n"); res = pdFALSE; // While the interrupt is low, dont delay /*This is due to a possible race condition, where: