extra flexibility to facilitate ports
This commit is contained in:
parent
965cdd466c
commit
1c49d77fff
|
@ -32,6 +32,17 @@ static inline bool isAdcChannelValid(adc_channel_e hwChannel) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined(GPT_FREQ_FAST) || !defined(GPT_PERIOD_FAST)
|
||||||
|
/**
|
||||||
|
* 8000 RPM is 133Hz
|
||||||
|
* If we want to sample MAP once per 5 degrees we need 133Hz * (360 / 5) = 9576Hz of fast ADC
|
||||||
|
*/
|
||||||
|
// todo: migrate to continuous ADC mode? probably not - we cannot afford the callback in
|
||||||
|
// todo: continuous mode. todo: look into our options
|
||||||
|
#define GPT_FREQ_FAST 100000 /* PWM clock frequency. I wonder what does this setting mean? */
|
||||||
|
#define GPT_PERIOD_FAST 10 /* PWM period (in PWM ticks). */
|
||||||
|
#endif /* GPT_FREQ_FAST GPT_PERIOD_FAST */
|
||||||
|
|
||||||
#if HAL_USE_ADC
|
#if HAL_USE_ADC
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
@ -70,17 +81,6 @@ void removeChannel(const char *name, adc_channel_e setting);
|
||||||
|
|
||||||
#define adcToVoltsDivided(adc, hwChannel) (adcToVolts(adc) * getAnalogInputDividerCoefficient(hwChannel))
|
#define adcToVoltsDivided(adc, hwChannel) (adcToVolts(adc) * getAnalogInputDividerCoefficient(hwChannel))
|
||||||
|
|
||||||
#if !defined(GPT_FREQ_FAST) || !defined(GPT_PERIOD_FAST)
|
|
||||||
/**
|
|
||||||
* 8000 RPM is 133Hz
|
|
||||||
* If we want to sample MAP once per 5 degrees we need 133Hz * (360 / 5) = 9576Hz of fast ADC
|
|
||||||
*/
|
|
||||||
// todo: migrate to continuous ADC mode? probably not - we cannot afford the callback in
|
|
||||||
// todo: continuous mode. todo: look into our options
|
|
||||||
#define GPT_FREQ_FAST 100000 /* PWM clock frequency. I wonder what does this setting mean? */
|
|
||||||
#define GPT_PERIOD_FAST 10 /* PWM period (in PWM ticks). */
|
|
||||||
#endif /* GPT_FREQ_FAST GPT_PERIOD_FAST */
|
|
||||||
|
|
||||||
// This callback is called by the ADC driver when a new fast ADC sample is ready
|
// This callback is called by the ADC driver when a new fast ADC sample is ready
|
||||||
void onFastAdcComplete(adcsample_t* samples);
|
void onFastAdcComplete(adcsample_t* samples);
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,9 @@
|
||||||
#define DELTA_THRESHOLD_CNT_LOW (GPT_FREQ_FAST / GPT_PERIOD_FAST / 32) // ~1/32 second?
|
#define DELTA_THRESHOLD_CNT_LOW (GPT_FREQ_FAST / GPT_PERIOD_FAST / 32) // ~1/32 second?
|
||||||
#define DELTA_THRESHOLD_CNT_HIGH (GPT_FREQ_FAST / GPT_PERIOD_FAST / 4) // ~1/4 second?
|
#define DELTA_THRESHOLD_CNT_HIGH (GPT_FREQ_FAST / GPT_PERIOD_FAST / 4) // ~1/4 second?
|
||||||
|
|
||||||
|
#if HAL_USE_ADC
|
||||||
#define triggerVoltsToAdcDivided(volts) (voltsToAdc(volts) / trigAdcState.triggerInputDividerCoefficient)
|
#define triggerVoltsToAdcDivided(volts) (voltsToAdc(volts) / trigAdcState.triggerInputDividerCoefficient)
|
||||||
|
#endif // HAL_USE_ADC
|
||||||
|
|
||||||
// hardware-dependent part
|
// hardware-dependent part
|
||||||
#if (EFI_SHAFT_POSITION_INPUT && HAL_TRIGGER_USE_ADC && HAL_USE_ADC) || defined(__DOXYGEN__)
|
#if (EFI_SHAFT_POSITION_INPUT && HAL_TRIGGER_USE_ADC && HAL_USE_ADC) || defined(__DOXYGEN__)
|
||||||
|
@ -178,7 +180,7 @@ void onTriggerChanged(efitick_t stamp, bool isPrimary, bool isRising) {
|
||||||
|
|
||||||
|
|
||||||
void TriggerAdcDetector::init() {
|
void TriggerAdcDetector::init() {
|
||||||
#if ! EFI_SIMULATOR
|
#if ! EFI_SIMULATOR && HAL_USE_ADC
|
||||||
|
|
||||||
// todo: move some of these to config
|
// todo: move some of these to config
|
||||||
|
|
||||||
|
@ -212,7 +214,7 @@ void TriggerAdcDetector::init() {
|
||||||
modeSwitchCnt = 0;
|
modeSwitchCnt = 0;
|
||||||
|
|
||||||
reset();
|
reset();
|
||||||
#endif // ! EFI_SIMULATOR
|
#endif // ! EFI_SIMULATOR && HAL_USE_ADC
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerAdcDetector::reset() {
|
void TriggerAdcDetector::reset() {
|
||||||
|
|
Loading…
Reference in New Issue