rusefi-1/firmware/hw_layer/adc_inputs.h

54 lines
1.5 KiB
C
Raw Normal View History

2015-07-10 06:01:56 -07:00
/**
* @file adc_inputs.h
2017-11-24 14:40:20 -08:00
* @brief Low level internal ADC code
2015-07-10 06:01:56 -07:00
*
* @date Jan 14, 2013
2020-01-07 21:02:40 -08:00
* @author Andrey Belomutskiy, (c) 2012-2020
2015-07-10 06:01:56 -07:00
*/
2020-02-18 05:16:19 -08:00
#pragma once
2015-07-10 06:01:56 -07:00
2018-09-16 19:26:57 -07:00
#include "global.h"
2019-01-31 08:57:15 -08:00
#include "adc_math.h"
2015-07-10 06:01:56 -07:00
2019-04-12 17:52:51 -07:00
#if HAL_USE_ADC
2015-07-10 06:01:56 -07:00
const char * getAdcMode(adc_channel_e hwChannel);
void initAdcInputs();
2017-04-21 17:07:17 -07:00
// deprecated - migrate to 'getAdcChannelBrainPin'
int getAdcChannelPin(adc_channel_e hwChannel);
// deprecated - migrate to 'getAdcChannelBrainPin'
2016-12-27 11:04:04 -08:00
ioportid_t getAdcChannelPort(const char *msg, adc_channel_e hwChannel);
2017-04-21 17:07:17 -07:00
2015-07-10 06:01:56 -07:00
adc_channel_e getAdcChannel(brain_pin_e pin);
2017-04-21 17:07:17 -07:00
brain_pin_e getAdcChannelBrainPin(const char *msg, adc_channel_e hwChannel);
2015-07-10 06:01:56 -07:00
// wait until at least 1 slowADC sampling is complete
2018-01-22 14:45:10 -08:00
void waitForSlowAdc(int lastAdcCounter = 0);
// get a number of completed slowADC samples
int getSlowAdcCounter();
2015-07-10 06:01:56 -07:00
int getAdcHardwareIndexByInternalIndex(int index);
2016-09-09 21:02:11 -07:00
void printFullAdcReportIfNeeded(Logging *log);
2015-07-10 06:01:56 -07:00
int getInternalAdcValue(const char *msg, adc_channel_e index);
2016-07-19 19:03:16 -07:00
float getMCUInternalTemperature(void);
2015-07-10 06:01:56 -07:00
void addChannel(const char *name, adc_channel_e setting, adc_channel_mode_e mode);
void removeChannel(const char *name, adc_channel_e setting);
2015-07-10 06:01:56 -07:00
// max(ADC_BUF_DEPTH_SLOW, ADC_BUF_DEPTH_FAST)
2016-01-20 19:01:35 -08:00
#define MAX_ADC_GRP_BUF_DEPTH 8
2015-07-10 06:01:56 -07:00
#define getAdcValue(msg, hwChannel) getInternalAdcValue(msg, hwChannel)
// todo: migrate to adcToVoltageInputDividerCoefficient
#define adcToVoltsDivided(adc) (adcToVolts(adc) * engineConfiguration->analogInputDividerCoefficient)
#else
2016-01-11 16:02:19 -08:00
#define getAdcValue(msg, channel) 0
2015-07-10 06:01:56 -07:00
#endif /* HAL_USE_ADC */