2015-07-10 06:01:56 -07:00
|
|
|
/**
|
|
|
|
* @file trigger_input.h
|
|
|
|
* @brief Position sensor hardware layer
|
|
|
|
*
|
|
|
|
* @date Dec 30, 2012
|
2020-01-07 21:02:40 -08:00
|
|
|
* @author Andrey Belomutskiy, (c) 2012-2020
|
2015-07-10 06:01:56 -07:00
|
|
|
*/
|
|
|
|
|
2020-04-01 18:32:21 -07:00
|
|
|
#pragma once
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2019-11-11 19:19:35 -08:00
|
|
|
#include "trigger_structure.h"
|
|
|
|
#include "trigger_central.h"
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2021-11-16 01:15:29 -08:00
|
|
|
void turnOnTriggerInputPins();
|
|
|
|
void applyNewTriggerInputPins();
|
|
|
|
void startTriggerInputPins();
|
|
|
|
void stopTriggerInputPins();
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2021-11-16 01:15:29 -08:00
|
|
|
void stopTriggerDebugPins();
|
|
|
|
void startTriggerDebugPins();
|
2021-07-14 22:28:44 -07:00
|
|
|
|
2021-10-06 10:57:04 -07:00
|
|
|
#if HAL_USE_ADC
|
|
|
|
typedef adcsample_t triggerAdcSample_t;
|
2021-12-01 11:17:16 -08:00
|
|
|
#else
|
|
|
|
typedef uint16_t triggerAdcSample_t;
|
2021-10-06 10:57:04 -07:00
|
|
|
#endif /* HAL_USE_ADC */
|
|
|
|
|
2020-09-09 07:21:14 -07:00
|
|
|
// This detector has 2 modes for low-RPM (ADC) and fast-RPM (EXTI)
|
|
|
|
enum triggerAdcMode_t {
|
2021-10-06 10:57:04 -07:00
|
|
|
TRIGGER_ADC_NONE = 0,
|
|
|
|
TRIGGER_ADC_ADC,
|
|
|
|
TRIGGER_ADC_EXTI,
|
2020-09-09 07:21:14 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
adc_channel_e getAdcChannelForTrigger(void);
|
|
|
|
void addAdcChannelForTrigger(void);
|
2021-10-06 10:57:04 -07:00
|
|
|
void triggerAdcCallback(triggerAdcSample_t value);
|
2020-09-09 07:21:14 -07:00
|
|
|
|
2021-10-06 10:57:04 -07:00
|
|
|
void setTriggerAdcMode(triggerAdcMode_t adcMode);
|
|
|
|
void onTriggerChanged(efitick_t stamp, bool isPrimary, bool isRising);
|