Skip to content

Commit

Permalink
PAL-out the sleep
Browse files Browse the repository at this point in the history
  • Loading branch information
mck1117 committed Aug 15, 2022
1 parent 2f0dfd7 commit 17ba85c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
3 changes: 3 additions & 0 deletions pt2001/include/rusefi/pt2001.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,7 @@ class Pt2001Base {

// Print out an error message
virtual void onError(const char* why) = 0;

// Sleep for some number of milliseconds
virtual void sleepMs(size_t ms) = 0;
};
10 changes: 4 additions & 6 deletions pt2001/src/pt2001.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

#include <PT2001_LoadData.h>

#include <ch.h>

const int MC_CK = 6; // PLL x24 / CLK_DIV 4 = 6Mhz

const int MAX_SPI_MODE_A_TRANSFER_SIZE = 31; //max size for register config transfer
Expand Down Expand Up @@ -426,9 +424,9 @@ bool Pt2001Base::restart() {
}

// Wait for chip to reset, then release reset and wait again
chThdSleepMilliseconds(1);
sleepMs(1);
setResetB(true);
chThdSleepMilliseconds(1);
sleepMs(1);

// Flag0 should be floating - pulldown means it should read low
flag0before = readFlag0();
Expand Down Expand Up @@ -474,7 +472,7 @@ bool Pt2001Base::restart() {
enableFlash();

// give it a moment to take effect
chThdSleepMilliseconds(10);
sleepMs(10);

if (!checkFlash()) {
onError("MC33 no flash");
Expand All @@ -491,7 +489,7 @@ bool Pt2001Base::restart() {

// Drive High Voltage
setDriveEN(true); // driven = HV
chThdSleepMilliseconds(10); // Give it a moment
sleepMs(10); // Give it a moment
status = readDriverStatus();
if (!checkDrivenEnabled(status)) {
onError("MC33 Driven did not stick!");
Expand Down

0 comments on commit 17ba85c

Please sign in to comment.