SENT protocol capture implementation (#4631)
* boards: MRE: enable SEND protocol capture * SENT protocol capture implementation #4631 * SENT protocol capture implementation #4631 Co-authored-by: rusefillc <sdfsdfqsf2334234234>
This commit is contained in:
parent
f9d226f66a
commit
c36c1b0434
|
@ -35,6 +35,9 @@ DDEFS += -DFIRMWARE_ID=\"microRusEFI\"
|
||||||
DDEFS += -DEFI_SOFTWARE_KNOCK=TRUE -DSTM32_ADC_USE_ADC3=TRUE
|
DDEFS += -DEFI_SOFTWARE_KNOCK=TRUE -DSTM32_ADC_USE_ADC3=TRUE
|
||||||
DDEFS += $(VAR_DEF_ENGINE_TYPE)
|
DDEFS += $(VAR_DEF_ENGINE_TYPE)
|
||||||
|
|
||||||
|
# This board can capture SENT
|
||||||
|
DDEFS += -DEFI_SENT_SUPPORT=TRUE
|
||||||
|
|
||||||
# We are running on microRusEFI hardware!
|
# We are running on microRusEFI hardware!
|
||||||
DDEFS += -DHW_MICRO_RUSEFI=1
|
DDEFS += -DHW_MICRO_RUSEFI=1
|
||||||
|
|
||||||
|
|
|
@ -22,10 +22,7 @@
|
||||||
#if (HAL_USE_ICU == TRUE)
|
#if (HAL_USE_ICU == TRUE)
|
||||||
|
|
||||||
/* TODO: get at runtime */
|
/* TODO: get at runtime */
|
||||||
#define SENT_ICU_FREQ (168000000 / 2) // == CPU freq / 2
|
#define SENT_ICU_FREQ (CORE_CLOCK / 2) // == CPU freq / 2
|
||||||
|
|
||||||
/* TODO: move to config */
|
|
||||||
#define SENT_INPUT_GPIO Gpio::A1
|
|
||||||
|
|
||||||
/* TODO: implement helper to get AF from GPIO for TIM2 capture */
|
/* TODO: implement helper to get AF from GPIO for TIM2 capture */
|
||||||
#define SENT_INPUT_AF PAL_MODE_ALTERNATE(1)
|
#define SENT_INPUT_AF PAL_MODE_ALTERNATE(1)
|
||||||
|
@ -55,11 +52,10 @@ static ICUConfig icucfg_in1 =
|
||||||
|
|
||||||
void startSent()
|
void startSent()
|
||||||
{
|
{
|
||||||
/* SENT is inited last, if pin is unused - use it for SENT
|
brain_pin_e sentPin = engineConfiguration->sentInputPins[0];
|
||||||
* TODO: remove this when SENT options get integrated into settings */
|
|
||||||
if ((isBrainPinValid(SENT_INPUT_GPIO)) &&
|
if (isBrainPinValid(sentPin)) {
|
||||||
(getPinFunction(SENT_INPUT_GPIO) == NULL)) {
|
efiSetPadMode("SENT", sentPin, SENT_INPUT_AF);
|
||||||
efiSetPadMode("SENT", SENT_INPUT_GPIO, SENT_INPUT_AF);
|
|
||||||
|
|
||||||
icuStart(&SENT_ICU_UNIT, &icucfg_in1);
|
icuStart(&SENT_ICU_UNIT, &icucfg_in1);
|
||||||
icuStartCapture(&SENT_ICU_UNIT);
|
icuStartCapture(&SENT_ICU_UNIT);
|
||||||
|
@ -69,12 +65,14 @@ void startSent()
|
||||||
|
|
||||||
void stopSent()
|
void stopSent()
|
||||||
{
|
{
|
||||||
if (isBrainPinValid(SENT_INPUT_GPIO)) {
|
brain_pin_e sentPin = engineConfiguration->sentInputPins[0];
|
||||||
|
|
||||||
|
if (isBrainPinValid(sentPin)) {
|
||||||
icuDisableNotifications(&SENT_ICU_UNIT);
|
icuDisableNotifications(&SENT_ICU_UNIT);
|
||||||
icuStopCapture(&SENT_ICU_UNIT);
|
icuStopCapture(&SENT_ICU_UNIT);
|
||||||
icuStop(&SENT_ICU_UNIT);
|
icuStop(&SENT_ICU_UNIT);
|
||||||
|
|
||||||
efiSetPadUnused(SENT_INPUT_GPIO);
|
efiSetPadUnused(sentPin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue