CJ125: prepare ADC (#542)
This commit is contained in:
parent
d6383d2457
commit
bf181f88d8
|
@ -550,14 +550,18 @@ static void setAdcDebugReporting(int value) {
|
|||
scheduleMsg(&logger, "adcDebug=%d", adcDebugReporting);
|
||||
}
|
||||
|
||||
void waitForSlowAdc() {
|
||||
void waitForSlowAdc(int lastAdcCounter) {
|
||||
// we use slowAdcCounter instead of slowAdc.conversionCount because we need ADC_COMPLETE state
|
||||
// todo: use sync.objects?
|
||||
while (slowAdcCounter < 1) {
|
||||
while (slowAdcCounter <= lastAdcCounter) {
|
||||
chThdSleepMilliseconds(1);
|
||||
}
|
||||
}
|
||||
|
||||
int getSlowAdcCounter() {
|
||||
return slowAdcCounter;
|
||||
}
|
||||
|
||||
static void adc_callback_slow(ADCDriver *adcp, adcsample_t *buffer, size_t n) {
|
||||
(void) buffer;
|
||||
(void) n;
|
||||
|
@ -618,6 +622,11 @@ static void configureInputs(void) {
|
|||
addChannel("OilP", engineConfiguration->oilPressure.hwChannel, ADC_SLOW);
|
||||
addChannel("AC", engineConfiguration->acSwitchAdc, ADC_SLOW);
|
||||
|
||||
if (boardConfiguration->isCJ125Enabled) {
|
||||
addChannel("cj125ur", engineConfiguration->cj125ur, ADC_SLOW);
|
||||
addChannel("cj125ua", engineConfiguration->cj125ua, ADC_SLOW);
|
||||
}
|
||||
|
||||
for (int i = 0; i < FSIO_ANALOG_INPUT_COUNT ; i++) {
|
||||
addChannel("FSIOadc", engineConfiguration->fsioAdc[i], ADC_SLOW);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,9 @@ adc_channel_e getAdcChannel(brain_pin_e pin);
|
|||
brain_pin_e getAdcChannelBrainPin(const char *msg, adc_channel_e hwChannel);
|
||||
|
||||
// wait until at least 1 slowADC sampling is complete
|
||||
void waitForSlowAdc();
|
||||
void waitForSlowAdc(int lastAdcCounter = 0);
|
||||
// get a number of completed slowADC samples
|
||||
int getSlowAdcCounter();
|
||||
|
||||
int getAdcHardwareIndexByInternalIndex(int index);
|
||||
|
||||
|
|
Loading…
Reference in New Issue