auto-sync
This commit is contained in:
parent
d7979596ef
commit
0ae7cba9ed
|
@ -440,6 +440,57 @@ typedef enum {
|
|||
GPIOE_14 = 78,
|
||||
GPIOE_15 = 79,
|
||||
|
||||
// GPIOF_0 = 80,
|
||||
// GPIOF_1 = 81,
|
||||
// GPIOF_2 = 82,
|
||||
// GPIOF_3 = 83,
|
||||
// GPIOF_4 = 84,
|
||||
// GPIOF_5 = 85,
|
||||
// GPIOF_6 = 86,
|
||||
// GPIOF_7 = 87,
|
||||
// GPIOF_8 = 88,
|
||||
// GPIOF_9 = 89,
|
||||
// GPIOF_10 = 90,
|
||||
// GPIOF_11 = 91,
|
||||
// GPIOF_12 = 92,
|
||||
// GPIOF_13 = 93,
|
||||
// GPIOF_14 = 94,
|
||||
// GPIOF_15 = 95,
|
||||
//
|
||||
// GPIOG_0 = 96,
|
||||
// GPIOG_1 = 97,
|
||||
// GPIOG_2 = 98,
|
||||
// GPIOG_3 = 99,
|
||||
// GPIOG_4 = 100,
|
||||
// GPIOG_5 = 101,
|
||||
// GPIOG_6 = 102,
|
||||
// GPIOG_7 = 103,
|
||||
// GPIOG_8 = 104,
|
||||
// GPIOG_9 = 105,
|
||||
// GPIOG_10 = 106,
|
||||
// GPIOG_11 = 107,
|
||||
// GPIOG_12 = 108,
|
||||
// GPIOG_13 = 109,
|
||||
// GPIOG_14 = 110,
|
||||
// GPIOG_15 = 111,
|
||||
//
|
||||
// GPIOH_0 = 112,
|
||||
// GPIOH_1 = 113,
|
||||
// GPIOH_2 = 114,
|
||||
// GPIOH_3 = 115,
|
||||
// GPIOH_4 = 116,
|
||||
// GPIOH_5 = 117,
|
||||
// GPIOH_6 = 118,
|
||||
// GPIOH_7 = 119,
|
||||
// GPIOH_8 = 120,
|
||||
// GPIOH_9 = 121,
|
||||
// GPIOH_10 = 122,
|
||||
// GPIOH_11 = 123,
|
||||
// GPIOH_12 = 124,
|
||||
// GPIOH_13 = 125,
|
||||
// GPIOH_14 = 126,
|
||||
// GPIOH_15 = 128,
|
||||
|
||||
GPIO_UNASSIGNED = 80,
|
||||
GPIO_INVALID = 81,
|
||||
|
||||
|
|
|
@ -24,11 +24,16 @@
|
|||
#include "engine.h"
|
||||
#include "settings.h"
|
||||
#include "pin_repository.h"
|
||||
#include "hardware.h"
|
||||
#include "rpm_calculator.h"
|
||||
#include "trigger_central.h"
|
||||
|
||||
#if EFI_HIP_9011
|
||||
|
||||
#define HIP9011_CS_PORT GPIOE
|
||||
#define HIP9011_CS_PIN 11
|
||||
static scheduling_s startTimer[2];
|
||||
static scheduling_s endTimer[2];
|
||||
|
||||
extern pin_output_mode_e DEFAULT_OUTPUT;
|
||||
|
||||
// 0b01000000
|
||||
#define SET_PRESCALER_CMD 0x40
|
||||
|
@ -50,16 +55,16 @@ static int callbackc = 0;
|
|||
static void spiCallback(SPIDriver *spip) {
|
||||
spiUnselectI(spip);
|
||||
|
||||
scheduleMsg(&logger, "spiCallback HIP=%d", callbackc++);
|
||||
// scheduleMsg(&logger, "spiCallback HIP=%d", callbackc++);
|
||||
|
||||
}
|
||||
|
||||
// SPI_CR1_BR_1 // 5MHz
|
||||
|
||||
static const SPIConfig spicfg = { spiCallback,
|
||||
static SPIConfig spicfg = { spiCallback,
|
||||
/* HW dependent part.*/
|
||||
HIP9011_CS_PORT,
|
||||
HIP9011_CS_PIN,
|
||||
NULL,
|
||||
0,
|
||||
//SPI_CR1_MSTR |
|
||||
//SPI_CR1_BR_1 // 5MHz
|
||||
SPI_CR1_BR_0 | SPI_CR1_BR_1 | SPI_CR1_BR_2 };
|
||||
|
@ -81,15 +86,19 @@ static msg_t ivThread(int param) {
|
|||
// channel #1
|
||||
tx_buff[4] = SET_CHANNEL_CMD;
|
||||
|
||||
while (TRUE) {
|
||||
while (true) {
|
||||
chThdSleepMilliseconds(10);
|
||||
|
||||
scheduleMsg(&logger, "poking HIP=%d", counter++);
|
||||
// scheduleMsg(&logger, "poking HIP=%d", counter++);
|
||||
|
||||
// todo: make sure spiCallback has been invoked?
|
||||
spiSelect(driver);
|
||||
|
||||
spiStartExchange(driver, 2, tx_buff, rx_buff);
|
||||
spiUnselect(driver);
|
||||
spiStartExchange(driver, 8, tx_buff, rx_buff);
|
||||
/**
|
||||
* spiUnselectI takes place in spiCallback
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
#if defined __GNUC__
|
||||
|
@ -158,11 +167,30 @@ static void showHipInfo(void) {
|
|||
void setHip9011FrankensoPinout(void) {
|
||||
/**
|
||||
* SPI on PB13/14/15
|
||||
* ChipSelect is hard-wired
|
||||
*/
|
||||
boardConfiguration->isHip9011Enabled = true;
|
||||
//boardConfiguration->hip9011CsPin =
|
||||
boardConfiguration->hip9011CsPin = GPIOE_15; // ChipSelect is hard-wired, setting a crazy value to make the driver happy
|
||||
boardConfiguration->hip9011IntHoldPin = GPIOB_11;
|
||||
boardConfiguration->is_enabled_spi_2 = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shaft Position callback used to start or finish HIP integration
|
||||
*/
|
||||
static void intHoldCallback(trigger_event_e ckpEventType, uint32_t index DECLARE_ENGINE_PARAMETER_S) {
|
||||
// this callback is invoked on interrupt thread
|
||||
|
||||
if (index != 0)
|
||||
return;
|
||||
|
||||
int rpm = engine->rpmCalculator.rpmValue;
|
||||
if (!isValidRpm(rpm))
|
||||
return;
|
||||
|
||||
int structIndex = getRevolutionCounter() % 2;
|
||||
// todo: schedule this based on closest trigger event, same as ignition works
|
||||
scheduleByAngle(rpm, &startTimer[structIndex], engineConfiguration->knockDetectionWindowStart, (schfunc_t)&turnPinHigh, (void*)HIP9011_INT_HOLD);
|
||||
scheduleByAngle(rpm, &endTimer[structIndex], engineConfiguration->knockDetectionWindowEnd, (schfunc_t)&turnPinLow,(void*) HIP9011_INT_HOLD);
|
||||
}
|
||||
|
||||
void initHip9011(void) {
|
||||
|
@ -170,13 +198,23 @@ void initHip9011(void) {
|
|||
return;
|
||||
initLogging(&logger, "HIP driver");
|
||||
|
||||
print("Starting HIP9011/TPIC8101 driver\r\n");
|
||||
// driver = getSpiDevice(boardConfiguration->digitalPotentiometerSpiDevice);
|
||||
|
||||
|
||||
spicfg.ssport = getHwPort(boardConfiguration->hip9011CsPin);
|
||||
spicfg.sspad = getHwPin(boardConfiguration->hip9011CsPin);
|
||||
|
||||
scheduleMsg(&logger, "Starting HIP9011/TPIC8101 driver");
|
||||
spiStart(driver, &spicfg);
|
||||
|
||||
// chThdCreateStatic(htThreadStack, sizeof(htThreadStack), NORMALPRIO, (tfunc_t) ivThread, NULL);
|
||||
outputPinRegisterExt2("hip int/hold", HIP9011_INT_HOLD, boardConfiguration->hip9011IntHoldPin, &DEFAULT_OUTPUT);
|
||||
|
||||
chThdCreateStatic(htThreadStack, sizeof(htThreadStack), NORMALPRIO, (tfunc_t) ivThread, NULL);
|
||||
|
||||
bandIndex = findIndex(bandFreqLookup, BAND_LOOKUP_SIZE, BAND(engineConfiguration->cylinderBore));
|
||||
|
||||
addTriggerEventListener(&intHoldCallback, "DD int/hold", engine);
|
||||
|
||||
|
||||
addConsoleAction("hipinfo", showHipInfo);
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ extern OutputPin outputs[IO_PIN_COUNT];
|
|||
|
||||
static GPIO_TypeDef *PORTS[] = { GPIOA, GPIOB, GPIOC, GPIOD, GPIOE, GPIOF, GPIOG, GPIOH };
|
||||
|
||||
static pin_output_mode_e DEFAULT_OUTPUT = OM_DEFAULT;
|
||||
pin_output_mode_e DEFAULT_OUTPUT = OM_DEFAULT;
|
||||
|
||||
inline static void assertOMode(pin_output_mode_e mode) {
|
||||
// mode >= 0 is always true since that's an unsigned
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// This file was generated by Version2Header
|
||||
// Wed Dec 17 14:13:21 EST 2014
|
||||
// Thu Dec 18 08:42:54 EST 2014
|
||||
#ifndef VCS_VERSION
|
||||
#define VCS_VERSION "5819"
|
||||
#define VCS_VERSION "5826"
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue