auto-sync
This commit is contained in:
parent
41e7abdd6f
commit
ff53f35d99
|
@ -64,6 +64,7 @@ static int spiCount = 0;
|
||||||
static unsigned char tx_buff[1];
|
static unsigned char tx_buff[1];
|
||||||
static unsigned char rx_buff[1];
|
static unsigned char rx_buff[1];
|
||||||
static int correctResponse = 0;
|
static int correctResponse = 0;
|
||||||
|
static int invalidResponse = 0;
|
||||||
static char pinNameBuffer[16];
|
static char pinNameBuffer[16];
|
||||||
static float currentAngleWindowWidth;
|
static float currentAngleWindowWidth;
|
||||||
|
|
||||||
|
@ -95,12 +96,21 @@ SPI_CR1_MSTR |
|
||||||
//SPI_CR1_BR_1 // 5MHz
|
//SPI_CR1_BR_1 // 5MHz
|
||||||
SPI_CR1_CPHA | SPI_CR1_BR_0 | SPI_CR1_BR_1 | SPI_CR1_BR_2 };
|
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) \
|
#define SPI_SYNCHRONOUS(value) \
|
||||||
spiSelect(driver); \
|
spiSelect(driver); \
|
||||||
tx_buff[0] = value; \
|
tx_buff[0] = value; \
|
||||||
spiExchange(driver, 1, tx_buff, rx_buff); \
|
spiExchange(driver, 1, tx_buff, rx_buff); \
|
||||||
spiUnselect(driver); \
|
spiUnselect(driver); \
|
||||||
if (rx_buff[0] == value) correctResponse++;
|
checkResponse();
|
||||||
|
|
||||||
// todo: make this configurable
|
// todo: make this configurable
|
||||||
static SPIDriver *driver = &SPID2;
|
static SPIDriver *driver = &SPID2;
|
||||||
|
@ -131,8 +141,8 @@ static void showHipInfo(void) {
|
||||||
currentIntergratorIndex, engineConfiguration->knockVThreshold,
|
currentIntergratorIndex, engineConfiguration->knockVThreshold,
|
||||||
engine->knockCount, engineConfiguration->maxKnockSubDeg);
|
engine->knockCount, engineConfiguration->maxKnockSubDeg);
|
||||||
|
|
||||||
scheduleMsg(logger, "spi= IntHold@%s response count=%d", hwPortname(boardConfiguration->hip9011IntHoldPin),
|
scheduleMsg(logger, "spi= IntHold@%s response count=%d incorrect response=%d", hwPortname(boardConfiguration->hip9011IntHoldPin),
|
||||||
correctResponse);
|
correctResponse, invalidResponse);
|
||||||
scheduleMsg(logger, "CS@%s updateCount=%d", hwPortname(boardConfiguration->hip9011CsPin), settingUpdateCount);
|
scheduleMsg(logger, "CS@%s updateCount=%d", hwPortname(boardConfiguration->hip9011CsPin), settingUpdateCount);
|
||||||
|
|
||||||
scheduleMsg(logger, "hip %fv/last=%f@%s/max=%f spiCount=%d adv=%d",
|
scheduleMsg(logger, "hip %fv/last=%f@%s/max=%f spiCount=%d adv=%d",
|
||||||
|
@ -239,9 +249,13 @@ static void setGain(float value) {
|
||||||
showHipInfo();
|
showHipInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* this is the end of the non-synchronous exchange
|
||||||
|
*/
|
||||||
static void endOfSpiExchange(SPIDriver *spip) {
|
static void endOfSpiExchange(SPIDriver *spip) {
|
||||||
spiUnselectI(driver);
|
spiUnselectI(driver);
|
||||||
state = READY_TO_INTEGRATE;
|
state = READY_TO_INTEGRATE;
|
||||||
|
checkResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
static int getBandIndex(void) {
|
static int getBandIndex(void) {
|
||||||
|
|
|
@ -11,7 +11,7 @@ import java.awt.*;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
public class SettingsTab {
|
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());
|
private final JPanel content = new JPanel(new BorderLayout());
|
||||||
|
|
||||||
public SettingsTab() {
|
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.ALGORITHM, "algorithm").getContent()));
|
||||||
panel.add(UiUtils.wrap(new EnumConfigField(Fields.TRIGGER_TYPE, "trigger type").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.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.TRIGGERINPUTPINS1, "trigger #1 input").getContent()));
|
||||||
panel.add(UiUtils.wrap(new EnumConfigField(Fields.TRIGGERINPUTPINS2, "trigger #2 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()));
|
// 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.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.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.AFR_HWCHANNEL, "AFR channel").getContent()));
|
||||||
panel.add(UiUtils.wrap(new EnumConfigField(Fields.MAFADCCHANNEL, "MAF channel").getContent()));
|
panel.add(UiUtils.wrap(new EnumConfigField(Fields.MAFADCCHANNEL, "MAF channel").getContent()));
|
||||||
|
|
Loading…
Reference in New Issue