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