auto-sync

This commit is contained in:
rusEfi 2015-07-10 18:02:29 -04:00
parent 969ebbf142
commit 51268c966a
2 changed files with 21 additions and 4 deletions

View File

@ -64,6 +64,7 @@ static int spiCount = 0;
static unsigned char tx_buff[1];
static unsigned char rx_buff[1];
static int correctResponse = 0;
static int invalidResponse = 0;
static char pinNameBuffer[16];
static float currentAngleWindowWidth;
@ -95,12 +96,21 @@ SPI_CR1_MSTR |
//SPI_CR1_BR_1 // 5MHz
SPI_CR1_CPHA | SPI_CR1_BR_0 | SPI_CR1_BR_1 | SPI_CR1_BR_2 };
static void checkResponse(void) {
if (tx_buff[0] == rx_buff[0]) {
correctResponse++;
} else {
invalidResponse++;
}
}
// this macro is only used on startup
#define SPI_SYNCHRONOUS(value) \
spiSelect(driver); \
tx_buff[0] = value; \
spiExchange(driver, 1, tx_buff, rx_buff); \
spiUnselect(driver); \
if (rx_buff[0] == value) correctResponse++;
checkResponse();
// todo: make this configurable
static SPIDriver *driver = &SPID2;
@ -131,8 +141,8 @@ static void showHipInfo(void) {
currentIntergratorIndex, engineConfiguration->knockVThreshold,
engine->knockCount, engineConfiguration->maxKnockSubDeg);
scheduleMsg(logger, "spi= IntHold@%s response count=%d", hwPortname(boardConfiguration->hip9011IntHoldPin),
correctResponse);
scheduleMsg(logger, "spi= IntHold@%s response count=%d incorrect response=%d", hwPortname(boardConfiguration->hip9011IntHoldPin),
correctResponse, invalidResponse);
scheduleMsg(logger, "CS@%s updateCount=%d", hwPortname(boardConfiguration->hip9011CsPin), settingUpdateCount);
scheduleMsg(logger, "hip %fv/last=%f@%s/max=%f spiCount=%d adv=%d",
@ -239,9 +249,13 @@ static void setGain(float value) {
showHipInfo();
}
/**
* this is the end of the non-synchronous exchange
*/
static void endOfSpiExchange(SPIDriver *spip) {
spiUnselectI(driver);
state = READY_TO_INTEGRATE;
checkResponse();
}
static int getBandIndex(void) {

View File

@ -11,7 +11,7 @@ import java.awt.*;
import java.util.concurrent.atomic.AtomicBoolean;
public class SettingsTab {
private final JPanel panel = new JPanel(new GridLayout(6, 3));
private final JPanel panel = new JPanel(new GridLayout(8, 3));
private final JPanel content = new JPanel(new BorderLayout());
public SettingsTab() {
@ -28,6 +28,7 @@ public class SettingsTab {
panel.add(UiUtils.wrap(new EnumConfigField(Fields.ALGORITHM, "algorithm").getContent()));
panel.add(UiUtils.wrap(new EnumConfigField(Fields.TRIGGER_TYPE, "trigger type").getContent()));
panel.add(new BitConfigField(Fields.USEONLYFRONTFORTRIGGER, "Only Front").getContent());
panel.add(new BitConfigField(Fields.ISPRINTTRIGGERSYNCHDETAILS, "gap info").getContent());
panel.add(UiUtils.wrap(new EnumConfigField(Fields.TRIGGERINPUTPINS1, "trigger #1 input").getContent()));
panel.add(UiUtils.wrap(new EnumConfigField(Fields.TRIGGERINPUTPINS2, "trigger #2 input").getContent()));
// panel.add(UiUtils.wrap(new EnumConfigField(Fields.TRIGGERINPUTPINS3, "trigger #3 input").getContent()));
@ -38,6 +39,8 @@ public class SettingsTab {
panel.add(UiUtils.wrap(new EnumConfigField(Fields.HIP9011INTHOLDPIN, "int/hold pin").getContent()));
panel.add(UiUtils.wrap(new EnumConfigField(Fields.HIP9011INTHOLDPINMODE, "int/hold pin mode").getContent()));
panel.add(UiUtils.wrap(new EnumConfigField(Fields.IGNITIONPINS1, "ign #1").getContent()));
panel.add(UiUtils.wrap(new EnumConfigField(Fields.IGNITIONPINS3, "ign #3").getContent()));
panel.add(UiUtils.wrap(new EnumConfigField(Fields.AFR_HWCHANNEL, "AFR channel").getContent()));
panel.add(UiUtils.wrap(new EnumConfigField(Fields.MAFADCCHANNEL, "MAF channel").getContent()));