X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Flpc%2Fao_adc_lpc.c;h=1fbf13660a5969739cf496d602acf699e4abb371;hb=HEAD;hp=6324155977a7a4a538bf3cdbd051e274fae42a33;hpb=0686a7b8aec524d81bda4c572549a3a068ce0eed;p=fw%2Faltos diff --git a/src/lpc/ao_adc_lpc.c b/src/lpc/ao_adc_lpc.c index 63241559..1fbf1366 100644 --- a/src/lpc/ao_adc_lpc.c +++ b/src/lpc/ao_adc_lpc.c @@ -57,7 +57,10 @@ /* ADC clock is divided by this value + 1, which ensures that * the ADC clock will be strictly less than 4.5MHz as required */ -#define AO_ADC_CLKDIV (AO_LPC_SYSCLK / 450000) +#ifndef AO_LPC_ADC_CLOCK +#define AO_LPC_ADC_CLOCK 4500000 +#endif +#define AO_ADC_CLKDIV (AO_LPC_SYSCLK / AO_LPC_ADC_CLOCK) static uint8_t ao_adc_ready; static uint8_t ao_adc_sequence; @@ -79,7 +82,7 @@ static const uint8_t ao_adc_mask_seq[AO_ADC_NUM] = { 1 << 4, #endif #if AO_ADC_5 - 1 << 6, + 1 << 5, #endif #if AO_ADC_6 1 << 6, @@ -92,7 +95,7 @@ static const uint8_t ao_adc_mask_seq[AO_ADC_NUM] = { #define sample(id) (*out++ = (uint16_t) lpc_adc.dr[id] >> 1) static inline void lpc_adc_start(void) { - lpc_adc.cr = ((ao_adc_mask_seq[ao_adc_sequence] << LPC_ADC_CR_SEL) | + lpc_adc.cr = (((uint32_t) ao_adc_mask_seq[ao_adc_sequence] << LPC_ADC_CR_SEL) | (AO_ADC_CLKDIV << LPC_ADC_CR_CLKDIV) | (0 << LPC_ADC_CR_BURST) | (LPC_ADC_CR_CLKS_11 << LPC_ADC_CR_CLKS) | @@ -160,7 +163,7 @@ void ao_adc_init(void) { lpc_scb.sysahbclkctrl |= (1 << LPC_SCB_SYSAHBCLKCTRL_ADC); - lpc_scb.pdruncfg &= ~(1 << LPC_SCB_PDRUNCFG_ADC_PD); + lpc_scb.pdruncfg &= ~(1UL << LPC_SCB_PDRUNCFG_ADC_PD); /* Enable interrupt when channel is complete */ lpc_adc.inten = (1 << LPC_ADC_INTEN_ADGINTEN);