Skip to content

Commit 8a96b39

Browse files
renamed efuses and implemented ok function
1 parent c499b1f commit 8a96b39

File tree

7 files changed

+52
-95
lines changed

7 files changed

+52
-95
lines changed

firmware/shared/srcpp/io/efuse/io_efuse.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include "hw_gpio.hpp"
55
#include "hw_adc.hpp"
66

7-
namespace io::efuse
7+
namespace io
88
{
99
class Efuse
1010
{

firmware/shared/srcpp/io/efuse/io_efuseST.cpp

Lines changed: 0 additions & 40 deletions
This file was deleted.

firmware/shared/srcpp/io/efuse/io_efuseST.hpp

Lines changed: 0 additions & 37 deletions
This file was deleted.

firmware/shared/srcpp/io/efuse/io_efuse_ST_VND5.cpp

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,26 @@
1+
extern "C"
2+
{
3+
#include "app_utils.h"
4+
}
5+
16
#include "io_efuse_ST_VND5.hpp"
27
#include "hw_gpio.hpp"
38

4-
namespace io::efuse
9+
namespace io
510
{
6-
ST_VND5_Efuse::ST_VND5_Efuse(const hw::Gpio &enable_gpio, const hw::Adc &sns_adc_channel, const hw::Gpio &stby_reset_gpio)
7-
: Efuse(enable_gpio, sns_adc_channel), stby_reset_gpio(stby_reset_gpio) {}
11+
static constexpr float NOMINAL_V = 3.0f;
12+
// Vsenseh upper threshold
13+
static constexpr float V_SENSE_H_H = 9.5f;
14+
// Vsenseh lower threshold
15+
static constexpr float V_SENSE_H_L = 7.5f;
16+
17+
ST_VND5_Efuse::ST_VND5_Efuse(
18+
const hw::Gpio &enable_gpio,
19+
const hw::Adc &sns_adc_channel,
20+
const hw::Gpio &stby_reset_gpio)
21+
: Efuse(enable_gpio, sns_adc_channel), stby_reset_gpio(stby_reset_gpio)
22+
{
23+
}
824

925
void ST_VND5_Efuse::reset()
1026
{
@@ -20,9 +36,27 @@ namespace io::efuse
2036

2137
const bool ST_VND5_Efuse::ok()
2238
{
23-
// TODO: implement this function
39+
// TODO: WTF is output???
40+
const bool input = this->enable_gpio.readPin();
41+
const bool fault_reset_stby = this->stby_reset_gpio.readPin();
42+
const float voltage = this->sns_adc_channel.getVoltage() / ADC_VOLTAGE_TO_CURRENT_A;
43+
44+
this->faults.flags.overload = (input && (voltage > NOMINAL_V));
45+
this->faults.flags.ovt_stg = (input && (IS_IN_RANGE(V_SENSE_H_L, V_SENSE_H_H, voltage)));
46+
this->faults.flags.under_voltage = (voltage <= 0.0f);
2447

48+
if (fault_reset_stby)
49+
this->faults.flags.short_to_vbat = (!input && IS_IN_RANGE(V_SENSE_H_L, V_SENSE_H_H, voltage));
50+
else
51+
this->faults.flags.short_to_vbat = (input && (voltage < NOMINAL_V));
52+
53+
if (fault_reset_stby)
54+
this->faults.flags.open_load_off_stat = (!input && IS_IN_RANGE(V_SENSE_H_L, V_SENSE_H_H, voltage));
55+
else
56+
this->faults.flags.open_load_off_stat = (input && voltage <= 0.0f);
57+
58+
this->faults.flags.negative_output_voltage_clamp = (!input && voltage <= 0.0f);
59+
2560
return true;
2661
}
27-
2862
}

firmware/shared/srcpp/io/efuse/io_efuse_ST_VND5.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include <stdint.h>
44
#include "io_efuse.hpp"
55

6-
namespace io::efuse
6+
namespace io
77
{
88
class ST_VND5_Efuse : public Efuse
99
{
@@ -14,7 +14,7 @@ namespace io::efuse
1414
struct
1515
{
1616
uint8_t overload : 1;
17-
uint8_t ovt_stp : 1;
17+
uint8_t ovt_stg : 1;
1818
uint8_t under_voltage : 1;
1919
uint8_t short_to_vbat : 1;
2020
uint8_t open_load_off_stat : 1;
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
#include <assert.h>
2-
#include "io_efuseTI.hpp"
2+
#include "io_efuse_TI_TPS2.hpp"
33
#include "hw_gpio.hpp"
44

5-
namespace io::efuse
5+
namespace io
66
{
7-
TI_Efuse::TI_Efuse(const hw::Gpio &enable_gpio, const hw::Adc &sns_adc_channel, const hw::Gpio& pgood)
7+
ST_TPS2_Efuse::ST_TPS2_Efuse(const hw::Gpio &enable_gpio, const hw::Adc &sns_adc_channel, const hw::Gpio& pgood)
88
: Efuse(enable_gpio, sns_adc_channel) , pgood_gpio(pgood) {}
99

10-
void TI_Efuse::reset() {
10+
void ST_TPS2_Efuse::reset() {
1111
this->enable_gpio.writePin(false);
1212
this->enable_gpio.writePin(true);
1313
this->enable_gpio.writePin(false);
1414
}
1515

16-
const bool TI_Efuse::pgood() {
16+
const bool ST_TPS2_Efuse::pgood() {
1717
return this->pgood_gpio.readPin();
1818
}
1919

20-
const bool TI_Efuse::ok() {
20+
const bool ST_TPS2_Efuse::ok() {
2121
return this->pgood();
2222
}
2323
}

firmware/shared/srcpp/io/efuse/io_efuseTI.hpp renamed to firmware/shared/srcpp/io/efuse/io_efuse_TI_TPS2.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33
#include <stdint.h>
44
#include "io_efuse.hpp"
55

6-
namespace io::efuse
6+
namespace io
77
{
8-
class TI_Efuse : public Efuse
8+
class ST_TPS2_Efuse : public Efuse
99
{
1010
private:
1111
const hw::Gpio& pgood_gpio;
1212

1313
public:
14-
explicit TI_Efuse(const hw::Gpio &enable_gpio, const hw::Adc &sns_adc_channel, const hw::Gpio& pgood);
14+
explicit ST_TPS2_Efuse(const hw::Gpio &enable_gpio, const hw::Adc &sns_adc_channel, const hw::Gpio& pgood);
1515
void reset() override;
16-
const bool pgood() override;
16+
const bool pgood();
1717
const bool ok() override;
1818
};
1919
}

0 commit comments

Comments
 (0)