Could be functioning

This commit is contained in:
2024-07-26 21:27:39 +03:00
parent 1c560a9b0f
commit 196d440b2b
12 changed files with 516 additions and 115 deletions

View File

@@ -2,7 +2,7 @@
#include "../utils/utils.h"
#include "dccd_hw.h"
using namespace hw;
using namespace dccd;
/**** Private definitions ****/
/**** Private constants ****/
@@ -22,10 +22,8 @@ dccd::DccdHw::~DccdHw(void)
void dccd::DccdHw::init(dccdHwCfg_t* cfg)
{
bsp::Board::boardCfg_t board_cfg;
board_cfg.pwm_f_khz = cfg->pwm_f_khz;
board_cfg.od_common_is_pwm = 1;
this->board_hw.init(&board_cfg);
this->counter.init(0xFFFF, 900);
@@ -84,7 +82,13 @@ void dccd::DccdHw::init(dccdHwCfg_t* cfg)
this->pot.init(&(this->board_hw.ain2), 500, 4500);
this->pot.update_ain = 0;
this->outdriver.init(&(this->board_hw.out_pwm), &(this->board_hw.out_low));
hw::OutReg::outRegCfg_t outreg_cfg;
outreg_cfg.pwm_high = &this->board_hw.out_pwm;
outreg_cfg.dout_low = &this->board_hw.out_low;
outreg_cfg.ubat = &this->board_hw.battery_voltage;
outreg_cfg.uout = &this->board_hw.out_voltage;
outreg_cfg.iout = &this->board_hw.out_current;
this->outreg.init(&outreg_cfg);
hw::LedDisplay::doutCfg_t dsp_cfg;
dsp_cfg.led0_dout_ch = &(this->board_hw.od1);
@@ -110,8 +114,13 @@ void dccd::DccdHw::init(dccdHwCfg_t* cfg)
else this->board_hw.freq_pull.write(0);
// Set initial output states
this->outdriver.write((uint16_t)0);
this->outdriver.enable();
this->outreg.voltage = 0;
this->outreg.current = 0;
this->outreg.out_on = 0;
this->outreg.lock = 0;
this->outreg.cc_mode_en = 0;
this->outreg.update_ain = 0;
this->outreg.process();
this->display.write_backlight(100);
this->display.write(0x00);
@@ -139,4 +148,10 @@ void dccd::DccdHw::read(void)
this->pot.read();
}
void dccd::DccdHw::write(void)
{
this->display.process();
this->outreg.process();
}
/**** Private function definitions ***/