Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralim committed Nov 15, 2023
1 parent 726cc42 commit 1c78da7
Show file tree
Hide file tree
Showing 19 changed files with 132 additions and 134 deletions.
18 changes: 9 additions & 9 deletions source/Core/BSP/MHP30/IRQ.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
26 changes: 13 additions & 13 deletions source/Core/BSP/MHP30/Setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions source/Core/BSP/MHP30/system_stm32f1xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand All @@ -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 */

Expand Down
2 changes: 1 addition & 1 deletion source/Core/BSP/Miniware/Setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions source/Core/BSP/Miniware/system_stm32f1xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand All @@ -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 */

Expand Down
4 changes: 2 additions & 2 deletions source/Core/BSP/Pinecil/Debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
34 changes: 17 additions & 17 deletions source/Core/BSP/Pinecil/IRQ.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
2 changes: 1 addition & 1 deletion source/Core/BSP/Pinecilv2/BSP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions source/Core/BSP/Pinecilv2/Debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
56 changes: 28 additions & 28 deletions source/Core/BSP/Sequre_S60/Setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
6 changes: 3 additions & 3 deletions source/Core/BSP/Sequre_S60/system_stm32f1xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand All @@ -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 */

Expand Down
1 change: 0 additions & 1 deletion source/Core/Drivers/BMA223.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <BMA223.hpp>
#include <array>


bool BMA223::detect() {
if (ACCEL_I2C_CLASS::probe(BMA223_ADDRESS)) {
// Read chip id to ensure its not an address collision
Expand Down
22 changes: 11 additions & 11 deletions source/Core/Drivers/I2CBB1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down
22 changes: 11 additions & 11 deletions source/Core/Drivers/I2CBB2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down
1 change: 0 additions & 1 deletion source/Core/Drivers/MMA8652FC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "cmsis_os.h"
#include <array>


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
Expand Down
2 changes: 1 addition & 1 deletion source/Core/Drivers/OLED.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading

0 comments on commit 1c78da7

Please sign in to comment.