From 1c78da782702c6b713eed2af81056271b568c2fd Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Wed, 15 Nov 2023 09:54:22 +0000 Subject: [PATCH] format --- source/Core/BSP/MHP30/IRQ.cpp | 18 +++--- source/Core/BSP/MHP30/Setup.c | 26 ++++----- source/Core/BSP/MHP30/system_stm32f1xx.c | 6 +- source/Core/BSP/Miniware/Setup.cpp | 2 +- source/Core/BSP/Miniware/system_stm32f1xx.c | 6 +- source/Core/BSP/Pinecil/Debug.cpp | 4 +- source/Core/BSP/Pinecil/IRQ.cpp | 34 +++++------ source/Core/BSP/Pinecilv2/BSP.cpp | 2 +- source/Core/BSP/Pinecilv2/Debug.cpp | 4 +- source/Core/BSP/Sequre_S60/Setup.cpp | 56 +++++++++---------- source/Core/BSP/Sequre_S60/system_stm32f1xx.c | 6 +- source/Core/Drivers/BMA223.cpp | 1 - source/Core/Drivers/I2CBB1.cpp | 22 ++++---- source/Core/Drivers/I2CBB2.cpp | 22 ++++---- source/Core/Drivers/MMA8652FC.cpp | 1 - source/Core/Drivers/OLED.cpp | 2 +- source/Core/Drivers/TipThermoModel.cpp | 8 +-- source/Core/Drivers/USBPD.cpp | 2 +- source/Core/Src/QC3.cpp | 44 +++++++-------- 19 files changed, 132 insertions(+), 134 deletions(-) diff --git a/source/Core/BSP/MHP30/IRQ.cpp b/source/Core/BSP/MHP30/IRQ.cpp index d5331ed616..f52e178412 100644 --- a/source/Core/BSP/MHP30/IRQ.cpp +++ b/source/Core/BSP/MHP30/IRQ.cpp @@ -30,15 +30,15 @@ void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *hadc) { extern osThreadId POWTaskHandle; void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) { - (void)GPIO_Pin; - // Notify POW thread that an irq occured - if (POWTaskHandle != nullptr) { - BaseType_t xHigherPriorityTaskWoken = pdFALSE; - xTaskNotifyFromISR(POWTaskHandle, 1, eSetBits, &xHigherPriorityTaskWoken); - /* Force a context switch if xHigherPriorityTaskWoken is now set to pdTRUE. - The macro used to do this is dependent on the port and may be called - portEND_SWITCHING_ISR. */ - portYIELD_FROM_ISR(xHigherPriorityTaskWoken); + (void)GPIO_Pin; + // Notify POW thread that an irq occured + if (POWTaskHandle != nullptr) { + BaseType_t xHigherPriorityTaskWoken = pdFALSE; + xTaskNotifyFromISR(POWTaskHandle, 1, eSetBits, &xHigherPriorityTaskWoken); + /* Force a context switch if xHigherPriorityTaskWoken is now set to pdTRUE. + The macro used to do this is dependent on the port and may be called + portEND_SWITCHING_ISR. */ + portYIELD_FROM_ISR(xHigherPriorityTaskWoken); } } diff --git a/source/Core/BSP/MHP30/Setup.c b/source/Core/BSP/MHP30/Setup.c index 8eaaaf3545..9c6e73636c 100644 --- a/source/Core/BSP/MHP30/Setup.c +++ b/source/Core/BSP/MHP30/Setup.c @@ -29,23 +29,23 @@ static void MX_DMA_Init(void); static void MX_GPIO_Init(void); static void MX_ADC2_Init(void); void Setup_HAL() { - SystemClock_Config(); + SystemClock_Config(); - __HAL_AFIO_REMAP_SWJ_NOJTAG(); + __HAL_AFIO_REMAP_SWJ_NOJTAG(); - MX_GPIO_Init(); - MX_DMA_Init(); + MX_GPIO_Init(); + MX_DMA_Init(); - MX_ADC1_Init(); - MX_ADC2_Init(); - MX_TIM3_Init(); - MX_TIM2_Init(); - MX_IWDG_Init(); - HAL_ADC_Start(&hadc2); - HAL_ADCEx_MultiModeStart_DMA(&hadc1, ADCReadings, + MX_ADC1_Init(); + MX_ADC2_Init(); + MX_TIM3_Init(); + MX_TIM2_Init(); + MX_IWDG_Init(); + HAL_ADC_Start(&hadc2); + HAL_ADCEx_MultiModeStart_DMA(&hadc1, ADCReadings, (ADC_SAMPLES * ADC_CHANNELS)); // start DMA of normal readings - // HAL_ADCEx_InjectedStart(&hadc1); // enable injected readings - // HAL_ADCEx_InjectedStart(&hadc2); // enable injected readings + // HAL_ADCEx_InjectedStart(&hadc1); // enable injected readings + // HAL_ADCEx_InjectedStart(&hadc2); // enable injected readings } // channel 0 -> temperature sensor, 1-> VIN, 2-> tip diff --git a/source/Core/BSP/MHP30/system_stm32f1xx.c b/source/Core/BSP/MHP30/system_stm32f1xx.c index e950ea24e7..643014d703 100644 --- a/source/Core/BSP/MHP30/system_stm32f1xx.c +++ b/source/Core/BSP/MHP30/system_stm32f1xx.c @@ -173,13 +173,13 @@ void SystemCoreClockUpdate(void) { pllmull = pllmull >> 18U; if (pllmull != 0x0DU) { - pllmull += 2U; + pllmull += 2U; } else { /* PLL multiplication factor = PLL input clock * 6.5 */ pllmull = 13U / 2U; } if (pllsource == 0x00U) { - /* HSI oscillator clock divided by 2 selected as PLL clock entry */ + /* HSI oscillator clock divided by 2 selected as PLL clock entry */ SystemCoreClock = (HSI_VALUE >> 1U) * pllmull; } else { /* PREDIV1 selected as PLL clock entry */ @@ -188,7 +188,7 @@ void SystemCoreClockUpdate(void) { prediv1factor = (RCC->CFGR2 & RCC_CFGR2_PREDIV1) + 1U; if (prediv1source == 0U) { - /* HSE oscillator clock selected as PREDIV1 clock entry */ + /* HSE oscillator clock selected as PREDIV1 clock entry */ SystemCoreClock = (HSE_VALUE / prediv1factor) * pllmull; } else { /* PLL2 clock selected as PREDIV1 clock entry */ diff --git a/source/Core/BSP/Miniware/Setup.cpp b/source/Core/BSP/Miniware/Setup.cpp index f4895170b4..22653853b4 100644 --- a/source/Core/BSP/Miniware/Setup.cpp +++ b/source/Core/BSP/Miniware/Setup.cpp @@ -31,7 +31,7 @@ static void MX_DMA_Init(void); static void MX_GPIO_Init(void); static void MX_ADC2_Init(void); void Setup_HAL() { - SystemClock_Config(); + SystemClock_Config(); #ifndef SWD_ENABLE __HAL_AFIO_REMAP_SWJ_DISABLE(); diff --git a/source/Core/BSP/Miniware/system_stm32f1xx.c b/source/Core/BSP/Miniware/system_stm32f1xx.c index 2fd8e60e5f..7a7ce13b25 100644 --- a/source/Core/BSP/Miniware/system_stm32f1xx.c +++ b/source/Core/BSP/Miniware/system_stm32f1xx.c @@ -176,13 +176,13 @@ void SystemCoreClockUpdate(void) { pllmull = pllmull >> 18U; if (pllmull != 0x0DU) { - pllmull += 2U; + pllmull += 2U; } else { /* PLL multiplication factor = PLL input clock * 6.5 */ pllmull = 13U / 2U; } if (pllsource == 0x00U) { - /* HSI oscillator clock divided by 2 selected as PLL clock entry */ + /* HSI oscillator clock divided by 2 selected as PLL clock entry */ SystemCoreClock = (HSI_VALUE >> 1U) * pllmull; } else { /* PREDIV1 selected as PLL clock entry */ @@ -191,7 +191,7 @@ void SystemCoreClockUpdate(void) { prediv1factor = (RCC->CFGR2 & RCC_CFGR2_PREDIV1) + 1U; if (prediv1source == 0U) { - /* HSE oscillator clock selected as PREDIV1 clock entry */ + /* HSE oscillator clock selected as PREDIV1 clock entry */ SystemCoreClock = (HSE_VALUE / prediv1factor) * pllmull; } else { /* PLL2 clock selected as PREDIV1 clock entry */ diff --git a/source/Core/BSP/Pinecil/Debug.cpp b/source/Core/BSP/Pinecil/Debug.cpp index ad44c1aa75..d77c5cb1df 100644 --- a/source/Core/BSP/Pinecil/Debug.cpp +++ b/source/Core/BSP/Pinecil/Debug.cpp @@ -17,9 +17,9 @@ volatile uint32_t currentOutputPos = 0xFF; volatile uint32_t outputLength = 0; extern volatile uint8_t pendingPWM; void log_system_state(int32_t PWMWattsx10) { - if (currentOutputPos == 0xFF) { + if (currentOutputPos == 0xFF) { - // Want to print a CSV log out the uart + // Want to print a CSV log out the uart // Tip_Temp_C,Handle_Temp_C,Output_Power_Wattx10,PWM,Tip_Raw\r\n // 3+1+3+1+3+1+3+1+5+2 = 23, so sizing at 32 for now diff --git a/source/Core/BSP/Pinecil/IRQ.cpp b/source/Core/BSP/Pinecil/IRQ.cpp index e8f93df22e..5756689707 100644 --- a/source/Core/BSP/Pinecil/IRQ.cpp +++ b/source/Core/BSP/Pinecil/IRQ.cpp @@ -37,31 +37,31 @@ void ADC0_1_IRQHandler(void) { volatile uint16_t PWMSafetyTimer = 0; volatile uint8_t pendingPWM = 0; void TIMER1_IRQHandler(void) { - static bool lastPeriodWasFast = false; + static bool lastPeriodWasFast = false; - if (timer_interrupt_flag_get(TIMER1, TIMER_INT_UP) == SET) { - timer_interrupt_flag_clear(TIMER1, TIMER_INT_UP); - // rollover turn on output if required - if (PWMSafetyTimer) { - PWMSafetyTimer--; - if (lastPeriodWasFast != fastPWM) { - if (fastPWM) { - switchToFastPWM(); + if (timer_interrupt_flag_get(TIMER1, TIMER_INT_UP) == SET) { + timer_interrupt_flag_clear(TIMER1, TIMER_INT_UP); + // rollover turn on output if required + if (PWMSafetyTimer) { + PWMSafetyTimer--; + if (lastPeriodWasFast != fastPWM) { + if (fastPWM) { + switchToFastPWM(); } else { - switchToSlowPWM(); + switchToSlowPWM(); } } - if (pendingPWM) { - timer_channel_output_pulse_value_config(TIMER1, TIMER_CH_1, pendingPWM); - timer_channel_output_pulse_value_config(TIMER2, TIMER_CH_0, 50); + if (pendingPWM) { + timer_channel_output_pulse_value_config(TIMER1, TIMER_CH_1, pendingPWM); + timer_channel_output_pulse_value_config(TIMER2, TIMER_CH_0, 50); } else { - timer_channel_output_pulse_value_config(TIMER2, TIMER_CH_0, 0); + timer_channel_output_pulse_value_config(TIMER2, TIMER_CH_0, 0); } } } - if (timer_interrupt_flag_get(TIMER1, TIMER_INT_CH1) == SET) { - timer_interrupt_flag_clear(TIMER1, TIMER_INT_CH1); - timer_channel_output_pulse_value_config(TIMER2, TIMER_CH_0, 0); + if (timer_interrupt_flag_get(TIMER1, TIMER_INT_CH1) == SET) { + timer_interrupt_flag_clear(TIMER1, TIMER_INT_CH1); + timer_channel_output_pulse_value_config(TIMER2, TIMER_CH_0, 0); } } diff --git a/source/Core/BSP/Pinecilv2/BSP.cpp b/source/Core/BSP/Pinecilv2/BSP.cpp index c511be2eb9..b1d9131504 100644 --- a/source/Core/BSP/Pinecilv2/BSP.cpp +++ b/source/Core/BSP/Pinecilv2/BSP.cpp @@ -155,7 +155,7 @@ const uint8_t numTipResistanceReadings = 3; uint32_t tipResistanceReadings[3] = {0, 0, 0}; uint8_t tipResistanceReadingSlot = 0; uint8_t getTipResistanceX10() { - // Return tip resistance in x10 ohms + // Return tip resistance in x10 ohms // We can measure this using the op-amp return lastTipResistance; } diff --git a/source/Core/BSP/Pinecilv2/Debug.cpp b/source/Core/BSP/Pinecilv2/Debug.cpp index 79b0a6a038..791867ade6 100644 --- a/source/Core/BSP/Pinecilv2/Debug.cpp +++ b/source/Core/BSP/Pinecilv2/Debug.cpp @@ -13,9 +13,9 @@ volatile uint32_t currentOutputPos = 0xFF; volatile uint32_t outputLength = 0; extern volatile uint8_t pendingPWM; void log_system_state(int32_t PWMWattsx10) { - if (currentOutputPos == 0xFF) { + if (currentOutputPos == 0xFF) { - // Want to print a CSV log out the uart + // Want to print a CSV log out the uart // Tip_Temp_C,Handle_Temp_C,Output_Power_Wattx10,PWM,Tip_Raw\r\n // 3+1+3+1+3+1+3+1+5+2 = 23, so sizing at 32 for now diff --git a/source/Core/BSP/Sequre_S60/Setup.cpp b/source/Core/BSP/Sequre_S60/Setup.cpp index 51cd346876..d7cfc368eb 100644 --- a/source/Core/BSP/Sequre_S60/Setup.cpp +++ b/source/Core/BSP/Sequre_S60/Setup.cpp @@ -31,34 +31,34 @@ static void MX_DMA_Init(void); static void MX_GPIO_Init(void); static void MX_ADC2_Init(void); void Setup_HAL() { - __HAL_RCC_I2C1_CLK_DISABLE(); - __HAL_RCC_GPIOD_CLK_DISABLE(); - __HAL_RCC_GPIOA_CLK_DISABLE(); - __HAL_RCC_GPIOB_CLK_DISABLE(); - SystemClock_Config(); - - // These are not shared so no harm enabling - __HAL_AFIO_REMAP_SWJ_NOJTAG(); - MX_GPIO_Init(); - MX_DMA_Init(); - MX_ADC1_Init(); - MX_ADC2_Init(); - - MX_TIM4_Init(); - MX_TIM2_Init(); - MX_IWDG_Init(); - HAL_ADC_Start_DMA(&hadc1, (uint32_t *)ADCReadings, (ADC_SAMPLES)); // start DMA of normal readings - HAL_ADCEx_InjectedStart(&hadc1); // enable injected readings - HAL_ADCEx_InjectedStart(&hadc2); // enable injected readings - - // Setup movement pin - { - GPIO_InitTypeDef GPIO_InitStruct; - GPIO_InitStruct.Pin = MOVEMENT_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_INPUT; - GPIO_InitStruct.Pull = GPIO_PULLDOWN; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; // We would like sharp rising edges - HAL_GPIO_Init(MOVEMENT_GPIO_Port, &GPIO_InitStruct); + __HAL_RCC_I2C1_CLK_DISABLE(); + __HAL_RCC_GPIOD_CLK_DISABLE(); + __HAL_RCC_GPIOA_CLK_DISABLE(); + __HAL_RCC_GPIOB_CLK_DISABLE(); + SystemClock_Config(); + + // These are not shared so no harm enabling + __HAL_AFIO_REMAP_SWJ_NOJTAG(); + MX_GPIO_Init(); + MX_DMA_Init(); + MX_ADC1_Init(); + MX_ADC2_Init(); + + MX_TIM4_Init(); + MX_TIM2_Init(); + MX_IWDG_Init(); + HAL_ADC_Start_DMA(&hadc1, (uint32_t *)ADCReadings, (ADC_SAMPLES)); // start DMA of normal readings + HAL_ADCEx_InjectedStart(&hadc1); // enable injected readings + HAL_ADCEx_InjectedStart(&hadc2); // enable injected readings + + // Setup movement pin + { + GPIO_InitTypeDef GPIO_InitStruct; + GPIO_InitStruct.Pin = MOVEMENT_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = GPIO_PULLDOWN; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; // We would like sharp rising edges + HAL_GPIO_Init(MOVEMENT_GPIO_Port, &GPIO_InitStruct); } } diff --git a/source/Core/BSP/Sequre_S60/system_stm32f1xx.c b/source/Core/BSP/Sequre_S60/system_stm32f1xx.c index 5be70b6f3a..c202cd65ca 100644 --- a/source/Core/BSP/Sequre_S60/system_stm32f1xx.c +++ b/source/Core/BSP/Sequre_S60/system_stm32f1xx.c @@ -175,13 +175,13 @@ void SystemCoreClockUpdate(void) { pllmull = pllmull >> 18U; if (pllmull != 0x0DU) { - pllmull += 2U; + pllmull += 2U; } else { /* PLL multiplication factor = PLL input clock * 6.5 */ pllmull = 13U / 2U; } if (pllsource == 0x00U) { - /* HSI oscillator clock divided by 2 selected as PLL clock entry */ + /* HSI oscillator clock divided by 2 selected as PLL clock entry */ SystemCoreClock = (HSI_VALUE >> 1U) * pllmull; } else { /* PREDIV1 selected as PLL clock entry */ @@ -190,7 +190,7 @@ void SystemCoreClockUpdate(void) { prediv1factor = (RCC->CFGR2 & RCC_CFGR2_PREDIV1) + 1U; if (prediv1source == 0U) { - /* HSE oscillator clock selected as PREDIV1 clock entry */ + /* HSE oscillator clock selected as PREDIV1 clock entry */ SystemCoreClock = (HSE_VALUE / prediv1factor) * pllmull; } else { /* PLL2 clock selected as PREDIV1 clock entry */ diff --git a/source/Core/Drivers/BMA223.cpp b/source/Core/Drivers/BMA223.cpp index 416e6aa264..6d0aa5077d 100644 --- a/source/Core/Drivers/BMA223.cpp +++ b/source/Core/Drivers/BMA223.cpp @@ -9,7 +9,6 @@ #include #include - bool BMA223::detect() { if (ACCEL_I2C_CLASS::probe(BMA223_ADDRESS)) { // Read chip id to ensure its not an address collision diff --git a/source/Core/Drivers/I2CBB1.cpp b/source/Core/Drivers/I2CBB1.cpp index 80909b2208..de65e6c43e 100644 --- a/source/Core/Drivers/I2CBB1.cpp +++ b/source/Core/Drivers/I2CBB1.cpp @@ -11,7 +11,7 @@ SemaphoreHandle_t I2CBB1::I2CSemaphore = NULL; StaticSemaphore_t I2CBB1::xSemaphoreBuffer; void I2CBB1::init() { - // Set GPIO's to output open drain + // Set GPIO's to output open drain GPIO_InitTypeDef GPIO_InitStruct; __HAL_RCC_GPIOA_CLK_ENABLE(); __HAL_RCC_GPIOB_CLK_ENABLE(); @@ -29,16 +29,16 @@ void I2CBB1::init() { SOFT_SCL1_HIGH(); // To ensure bus is unlocked; we toggle the Clock a bunch of times to make things error out for (int i = 0; i < 128; i++) { - SOFT_SCL1_LOW(); - asm("nop"); - asm("nop"); - asm("nop"); - asm("nop"); - SOFT_SCL1_HIGH(); - asm("nop"); - asm("nop"); - asm("nop"); - asm("nop"); + SOFT_SCL1_LOW(); + asm("nop"); + asm("nop"); + asm("nop"); + asm("nop"); + SOFT_SCL1_HIGH(); + asm("nop"); + asm("nop"); + asm("nop"); + asm("nop"); } I2CSemaphore = xSemaphoreCreateMutexStatic(&xSemaphoreBuffer); unlock(); diff --git a/source/Core/Drivers/I2CBB2.cpp b/source/Core/Drivers/I2CBB2.cpp index d0764d155e..49ec07d555 100644 --- a/source/Core/Drivers/I2CBB2.cpp +++ b/source/Core/Drivers/I2CBB2.cpp @@ -11,7 +11,7 @@ SemaphoreHandle_t I2CBB2::I2CSemaphore = NULL; StaticSemaphore_t I2CBB2::xSemaphoreBuffer; void I2CBB2::init() { - // Set GPIO's to output open drain + // Set GPIO's to output open drain GPIO_InitTypeDef GPIO_InitStruct; __HAL_RCC_GPIOA_CLK_ENABLE(); GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; @@ -28,16 +28,16 @@ void I2CBB2::init() { SOFT_SCL2_HIGH(); // To ensure bus is unlocked; we toggle the Clock a bunch of times to make things error out for (int i = 0; i < 128; i++) { - SOFT_SCL2_LOW(); - asm("nop"); - asm("nop"); - asm("nop"); - asm("nop"); - SOFT_SCL2_HIGH(); - asm("nop"); - asm("nop"); - asm("nop"); - asm("nop"); + SOFT_SCL2_LOW(); + asm("nop"); + asm("nop"); + asm("nop"); + asm("nop"); + SOFT_SCL2_HIGH(); + asm("nop"); + asm("nop"); + asm("nop"); + asm("nop"); } I2CSemaphore = xSemaphoreCreateMutexStatic(&xSemaphoreBuffer); unlock(); diff --git a/source/Core/Drivers/MMA8652FC.cpp b/source/Core/Drivers/MMA8652FC.cpp index fa38bb3b5c..05a92e9e10 100644 --- a/source/Core/Drivers/MMA8652FC.cpp +++ b/source/Core/Drivers/MMA8652FC.cpp @@ -10,7 +10,6 @@ #include "cmsis_os.h" #include - static const ACCEL_I2C_CLASS::I2C_REG i2c_registers[] = { {CTRL_REG2, 0, 0}, // Normal mode {CTRL_REG2, 0x40, 2}, // Reset all registers to POR values diff --git a/source/Core/Drivers/OLED.cpp b/source/Core/Drivers/OLED.cpp index 27f103fc5c..617873008e 100644 --- a/source/Core/Drivers/OLED.cpp +++ b/source/Core/Drivers/OLED.cpp @@ -232,7 +232,7 @@ void OLED::maskScrollIndicatorOnOLED() { // it from the screen buffer which is updated by `OLED::setRotation`. uint8_t rightmostColumn = screenBuffer[7]; uint8_t maskCommands[] = { - // Set column address: + // Set column address: // A[6:0] - Column start address = rightmost column // B[6:0] - Column end address = rightmost column 0x80, diff --git a/source/Core/Drivers/TipThermoModel.cpp b/source/Core/Drivers/TipThermoModel.cpp index 29edc08df8..f02601a120 100644 --- a/source/Core/Drivers/TipThermoModel.cpp +++ b/source/Core/Drivers/TipThermoModel.cpp @@ -31,7 +31,7 @@ */ volatile uint32_t lastuv = 0; uint32_t TipThermoModel::convertTipRawADCTouV(uint16_t rawADC, bool skipCalOffset) { - // This takes the raw ADC samples, converts these to uV + // This takes the raw ADC samples, converts these to uV // Then divides this down by the gain to convert to the uV on the input to the op-amp (A+B terminals) // Then remove the calibration value that is stored as a tip offset uint32_t vddRailmVX10 = ADC_VDD_MV * 10; // The vreg is +-2%, but we have no higher accuracy available @@ -44,11 +44,11 @@ uint32_t TipThermoModel::convertTipRawADCTouV(uint16_t rawADC, bool ski valueuV /= OP_AMP_GAIN_STAGE; if (getSettingValue(SettingsOptions::CalibrationOffset) && skipCalOffset == false) { - // Remove uV tipOffset + // Remove uV tipOffset if (valueuV > getSettingValue(SettingsOptions::CalibrationOffset)) { - valueuV -= getSettingValue(SettingsOptions::CalibrationOffset); + valueuV -= getSettingValue(SettingsOptions::CalibrationOffset); } else { - valueuV = 0; + valueuV = 0; } } lastuv = valueuV; diff --git a/source/Core/Drivers/USBPD.cpp b/source/Core/Drivers/USBPD.cpp index 7bdd4113dc..8cd5650163 100644 --- a/source/Core/Drivers/USBPD.cpp +++ b/source/Core/Drivers/USBPD.cpp @@ -46,7 +46,7 @@ void USBPowerDelivery::IRQOccured() { pe.IRQOccured(); } bool USBPowerDelivery::negotiationHasWorked() { return pe.pdHasNegotiated(); } uint8_t USBPowerDelivery::getStateNumber() { return pe.currentStateCode(true); } void USBPowerDelivery::step() { - while (pe.thread()) {} + while (pe.thread()) {} } void USBPowerDelivery::PPSTimerCallback() { pe.TimersCallback(); } diff --git a/source/Core/Src/QC3.cpp b/source/Core/Src/QC3.cpp index f5e2977f0f..73e1ee5a83 100644 --- a/source/Core/Src/QC3.cpp +++ b/source/Core/Src/QC3.cpp @@ -58,40 +58,40 @@ void QC_SeekContNeg() { QCState QCMode = QCState::NOT_STARTED; uint8_t QCTries = 0; void seekQC(int16_t Vx10, uint16_t divisor) { - if (QCMode == QCState::NOT_STARTED) { - startQC(divisor); + if (QCMode == QCState::NOT_STARTED) { + startQC(divisor); } - if (Vx10 < 40) { // Bail out if less than 4V + if (Vx10 < 40) { // Bail out if less than 4V return; } - if (xTaskGetTickCount() < TICKS_SECOND) { - return; + if (xTaskGetTickCount() < TICKS_SECOND) { + return; } - // Seek the QC to the Voltage given if this adapter supports continuous mode - // try and step towards the wanted value + // Seek the QC to the Voltage given if this adapter supports continuous mode + // try and step towards the wanted value - // 1. Measure current voltage - int16_t vStart = getInputVoltageX10(divisor, 0); - int difference = Vx10 - vStart; + // 1. Measure current voltage + int16_t vStart = getInputVoltageX10(divisor, 0); + int difference = Vx10 - vStart; - // 2. calculate ideal steps (0.2V changes) + // 2. calculate ideal steps (0.2V changes) - int steps = difference / 2; - if (QCMode == QCState::QC_3) { - while (steps < 0) { - QC_SeekContNeg(); - vTaskDelay(3 * TICKS_10MS); - steps++; + int steps = difference / 2; + if (QCMode == QCState::QC_3) { + while (steps < 0) { + QC_SeekContNeg(); + vTaskDelay(3 * TICKS_10MS); + steps++; } - while (steps > 0) { - QC_SeekContPlus(); - vTaskDelay(3 * TICKS_10MS); - steps--; + while (steps > 0) { + QC_SeekContPlus(); + vTaskDelay(3 * TICKS_10MS); + steps--; } - osDelay(100); + osDelay(100); } #ifdef ENABLE_QC2 // Re-measure