stm32: Minor whitespace changes to stm32f0_adc.c

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2021-12-19 02:54:40 -05:00
parent b710174107
commit 20ac48f680
1 changed files with 8 additions and 12 deletions

View File

@ -47,7 +47,7 @@ gpio_adc_setup(uint32_t pin)
enable_pclock(adc_base); enable_pclock(adc_base);
// 100: 41.5 ADC clock cycles // 100: 41.5 ADC clock cycles
adc->SMPR |= (~ADC_SMPR_SMP_Msk | ADC_SMPR_SMP_2 ); adc->SMPR |= ~ADC_SMPR_SMP_Msk | ADC_SMPR_SMP_2;
adc->CFGR2 |= ADC_CFGR2_CKMODE; adc->CFGR2 |= ADC_CFGR2_CKMODE;
adc->CFGR1 &= ~ADC_CFGR1_AUTOFF; adc->CFGR1 &= ~ADC_CFGR1_AUTOFF;
adc->CFGR1 |= ADC_CFGR1_EXTSEL; adc->CFGR1 |= ADC_CFGR1_EXTSEL;
@ -72,11 +72,10 @@ gpio_adc_setup(uint32_t pin)
} }
} }
if (pin == ADC_TEMPERATURE_PIN) { if (pin == ADC_TEMPERATURE_PIN)
ADC1_COMMON->CCR = ADC_CCR_TSEN; ADC1_COMMON->CCR = ADC_CCR_TSEN;
} else { else
gpio_peripheral(pin, GPIO_ANALOG, 0); gpio_peripheral(pin, GPIO_ANALOG, 0);
}
return (struct gpio_adc){ .adc = adc, .chan = 1 << chan }; return (struct gpio_adc){ .adc = adc, .chan = 1 << chan };
} }
@ -88,12 +87,10 @@ uint32_t
gpio_adc_sample(struct gpio_adc g) gpio_adc_sample(struct gpio_adc g)
{ {
ADC_TypeDef *adc = g.adc; ADC_TypeDef *adc = g.adc;
if ((adc->ISR & ADC_ISR_EOC) && (adc->CHSELR == g.chan)){ if (adc->ISR & ADC_ISR_EOC && adc->CHSELR == g.chan)
return 0; return 0;
} if (adc->CR & ADC_CR_ADSTART)
if (adc->CR & ADC_CR_ADSTART){
goto need_delay; goto need_delay;
}
adc->CHSELR = g.chan; adc->CHSELR = g.chan;
adc->CR |= ADC_CR_ADSTART; adc->CR |= ADC_CR_ADSTART;
@ -116,8 +113,7 @@ gpio_adc_cancel_sample(struct gpio_adc g)
{ {
ADC_TypeDef *adc = g.adc; ADC_TypeDef *adc = g.adc;
irqstatus_t flag = irq_save(); irqstatus_t flag = irq_save();
if (!(adc->ISR & ADC_ISR_EOC) && (adc->CHSELR == g.chan)){ if (!(adc->ISR & ADC_ISR_EOC) && adc->CHSELR == g.chan)
adc->CR |= ADC_CR_ADSTP; adc->CR |= ADC_CR_ADSTP;
}
irq_restore(flag); irq_restore(flag);
} }