Skip to content

Commit

Permalink
fixes, code format
Browse files Browse the repository at this point in the history
  • Loading branch information
htotoo committed Aug 28, 2024
1 parent 8f24676 commit 7128d4a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
9 changes: 6 additions & 3 deletions firmware/application/portapack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,8 @@ static void shutdown_base() {
});

cgu::pll1::enable();
while (!cgu::pll1::is_locked());
while (!cgu::pll1::is_locked())
;

set_clock_config(clock_config_pll1_boot);

Expand Down Expand Up @@ -357,13 +358,15 @@ static void set_cpu_clock_speed() {
});

cgu::pll1::enable();
while (!cgu::pll1::is_locked());
while (!cgu::pll1::is_locked())
;

set_clock_config(clock_config_pll1_step);

/* Delay >50us at 90-110MHz clock speed */
volatile uint32_t delay = 1400;
while (delay--);
while (delay--)
;

set_clock_config(clock_config_pll1);

Expand Down
1 change: 0 additions & 1 deletion firmware/common/battery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ uint8_t BatteryManagement::calc_percent_voltage(uint16_t voltage) {
uint8_t batteryPercentage = (float)(voltage - BATTERY_MIN_VOLTAGE) / (float)(BATTERY_MAX_VOLTAGE - BATTERY_MIN_VOLTAGE) * 100.0;
// Limit the values to the valid range
batteryPercentage = (batteryPercentage > 100) ? 100 : batteryPercentage;
if (batteryPercentage <= 2) batteryPercentage = 0;
return batteryPercentage;
}

Expand Down
1 change: 1 addition & 0 deletions firmware/common/battery.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ namespace battery {

#define BATTERY_MIN_VOLTAGE 3000.0
#define BATTERY_MAX_VOLTAGE 4170.0
#define BATTERY_DESIGN_CAP 2500

class BatteryManagement {
public:
Expand Down
9 changes: 5 additions & 4 deletions firmware/common/max17055.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <array>
#include <string>

#include "battery.hpp"
#include "i2c_pp.hpp"

#define MAX17055_POR 0
Expand All @@ -47,7 +48,7 @@

// Define Battery Capacity
#ifndef __MAX17055_Design_Capacity__
#define __MAX17055_Design_Capacity__ 2500 // Battery Capacity
#define __MAX17055_Design_Capacity__ BATTERY_DESIGN_CAP // Battery Capacity
#endif

// Define Gauge Resistor
Expand All @@ -57,17 +58,17 @@

// Define Minimum Voltage
#ifndef __MAX17055_Min_Voltage__
#define __MAX17055_Min_Voltage__ 3.0 // Minimum Voltage
#define __MAX17055_Min_Voltage__ BATTERY_MIN_VOLTAGE / 1000.0 // Minimum Voltage
#endif

// Define Maximum Voltage
#ifndef __MAX17055_Max_Voltage__
#define __MAX17055_Max_Voltage__ 4.17 // Maximum Voltage
#define __MAX17055_Max_Voltage__ BATTERY_MAX_VOLTAGE / 1000.0 // Maximum Voltage
#endif

// Define Empty Voltage
#ifndef __MAX17055_Empty_Voltage__
#define __MAX17055_Empty_Voltage__ 3.0 // Empty Voltage
#define __MAX17055_Empty_Voltage__ BATTERY_MIN_VOLTAGE / 1000.0 // Empty Voltage
#endif

// Define Recovery Voltage
Expand Down

0 comments on commit 7128d4a

Please sign in to comment.