Skip to content

Commit

Permalink
0.2.rev.A. Fix vgenerator init and vget() in firmware
Browse files Browse the repository at this point in the history
  • Loading branch information
robsonsmartins committed Jan 8, 2024
1 parent 5f040c6 commit ddf55f5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
8 changes: 4 additions & 4 deletions firmware/usbflashprog/modules/runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ void Runner::init() {
addrBusConfig_.aClrPin = kBusAddrClrPin;
addrBusConfig_.aRckPin = kBusAddrRckPin;

dataBus_.configure(dataBusConfig_);
addrBus_.configure(addrBusConfig_);
ctrlBus_.configure(ctrlBusConfig_);
vgen_.configure(vgenConfig_);

vgen_.vpp.setV(kVppInitial);
vgen_.vdd.setV(kVddInitial);
vgen_.start();

dataBus_.configure(dataBusConfig_);
addrBus_.configure(addrBusConfig_);
ctrlBus_.configure(ctrlBusConfig_);
}

void Runner::loop() {
Expand Down
3 changes: 2 additions & 1 deletion firmware/usbflashprog/modules/vgenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ float GenericGenerator::getVTarget() const {
}

float GenericGenerator::getV() const {
if (!owner_->isRunning() || !isOn() ||
if (!owner_->isRunning() ||
dc2dc_.getV() < 0.0f) { return 0.0f; }
return dc2dc_.getV();
}
Expand Down Expand Up @@ -300,6 +300,7 @@ bool VGenerator::start() {
multicore_.putParam(reinterpret_cast<uintptr_t>(&vpp));
multicore_.putParam(reinterpret_cast<uintptr_t>(&vdd));
while (status_ == MultiCore::csStarting) { MultiCore::usleep(1); }
MultiCore::msleep(200);
return (vppRes && vddRes);
}

Expand Down
12 changes: 7 additions & 5 deletions firmware/usbflashprog/test/modules/vgenerator_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,16 @@ TEST_F(VGeneratorTest, start_stop) {

TEST_F(VGeneratorTest, set_get_v_duty) {
EXPECT_EQ(vGenerator_.isRunning(), false);
EXPECT_EQ(vGenerator_.start(), true);
EXPECT_EQ(vGenerator_.isRunning(), true);

EXPECT_EQ(vGenerator_.vdd.getVTarget(), 0.0f);
EXPECT_EQ(vGenerator_.vdd.getDuty(), 0.0f);
EXPECT_EQ(vGenerator_.vdd.getV(), 0.0f);
EXPECT_EQ(vGenerator_.vpp.getVTarget(), 0.0f);
EXPECT_EQ(vGenerator_.vpp.getDuty(), 0.0f);
EXPECT_EQ(vGenerator_.vpp.getV(), 0.0f);

EXPECT_EQ(vGenerator_.start(), true);
EXPECT_EQ(vGenerator_.isRunning(), true);
vGenerator_.vdd.on();
vGenerator_.vdd.setV(5.0f);
EXPECT_EQ(vGenerator_.vdd.getVTarget(), 5.0f);
Expand All @@ -96,9 +101,6 @@ TEST_F(VGeneratorTest, set_get_v_duty) {
MultiCore::msleep(10);
EXPECT_NEAR(vGenerator_.vdd.getV(), vActual, 0.2f);

EXPECT_EQ(vGenerator_.vpp.getVTarget(), 0.0f);
EXPECT_EQ(vGenerator_.vpp.getDuty(), 0.0f);
EXPECT_EQ(vGenerator_.vpp.getV(), 0.0f);
vGenerator_.vpp.on();
vGenerator_.vpp.setV(12.0f);
EXPECT_EQ(vGenerator_.vpp.getVTarget(), 12.0f);
Expand Down

0 comments on commit ddf55f5

Please sign in to comment.