X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;ds=sidebyside;f=bertos%2Fcpu%2Farm%2Fdrv%2Fadc_at91.h;h=2ec0cdb595af0f676a6ab3b2b13f91c4ad1f1f72;hb=25610f00d61ce1c762c99157977df8c58d05bd64;hp=07ef6a40927cd99e98d302d9f9ccb5036d006635;hpb=055132222c4380c116e15f66a9ab7e1f561d329e;p=bertos.git diff --git a/bertos/cpu/arm/drv/adc_at91.h b/bertos/cpu/arm/drv/adc_at91.h index 07ef6a40..2ec0cdb5 100644 --- a/bertos/cpu/arm/drv/adc_at91.h +++ b/bertos/cpu/arm/drv/adc_at91.h @@ -57,9 +57,10 @@ * Macro for computing correct value to write into ADC * register. */ -#define ADC_COMPUTED_PRESCALER ((CPU_FREQ/(2 * CONFIG_ADC_CLOCK)) - 1) -#define ADC_COMPUTED_STARTUPTIME (((CONFIG_ADC_STARTUP_TIME * CONFIG_ADC_CLOCK)/ 8000000UL) - 1) -#define ADC_COMPUTED_SHTIME (((CONFIG_ADC_SHTIME * CONFIG_ADC_CLOCK)/1000000000UL) - 1) +#define ADC_COMPUTED_PRESCALER (DIV_ROUNDUP(CPU_FREQ, 2 * CONFIG_ADC_CLOCK) - 1) +#define ADC_COMPUTED_CLOCK (CPU_FREQ / ((ADC_COMPUTED_PRESCALER + 1) * 2)) +#define ADC_COMPUTED_STARTUPTIME (((CONFIG_ADC_STARTUP_TIME * ADC_COMPUTED_CLOCK) / 8000000UL) - 1) +#define ADC_COMPUTED_SHTIME ((uint32_t)((CONFIG_ADC_SHTIME * (uint64_t)ADC_COMPUTED_CLOCK) / 1000000000UL) - 1) /** * Init pins macro for adc.