diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2018-12-26 16:50:44 -0500 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2019-01-07 19:33:26 -0500 |
commit | 94c86d6c6ce85143d47b79f7cc2680c6b0ee6889 (patch) | |
tree | a9b8e293c4ba986e306366f039d9b979086bb12b /src/sam3/adc.c | |
parent | e278552d44e2d795e335ec33f898c9d6e1413688 (diff) | |
download | kutter-94c86d6c6ce85143d47b79f7cc2680c6b0ee6889.tar.gz kutter-94c86d6c6ce85143d47b79f7cc2680c6b0ee6889.tar.xz kutter-94c86d6c6ce85143d47b79f7cc2680c6b0ee6889.zip |
sam3: Merge sam4e8e support into sam3 code
Most of the peripherals on the sam4e8e are similar to the ones on the
sam3x8e mcu. Merge the code together and use just one code directory.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/sam3/adc.c')
-rw-r--r-- | src/sam3/adc.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/sam3/adc.c b/src/sam3/adc.c index 4a4d2cf0..b9c5fb12 100644 --- a/src/sam3/adc.c +++ b/src/sam3/adc.c @@ -10,7 +10,6 @@ #include "compiler.h" // ARRAY_SIZE #include "gpio.h" // gpio_adc_setup #include "internal.h" // GPIO -#include "sam3x8e.h" // ADC #include "sched.h" // sched_shutdown static const uint8_t adc_pins[] = { @@ -43,7 +42,7 @@ gpio_adc_setup(uint8_t pin) | ADC_MR_STARTUP_SUT768 | ADC_MR_TRANSFER(1)); } - return (struct gpio_adc){ .bit = 1 << chan }; + return (struct gpio_adc){ .chan = 1 << chan }; } // Try to sample a value. Returns zero if sample ready, otherwise @@ -55,11 +54,11 @@ gpio_adc_sample(struct gpio_adc g) uint32_t chsr = ADC->ADC_CHSR & 0xffff; if (!chsr) { // Start sample - ADC->ADC_CHER = g.bit; + ADC->ADC_CHER = g.chan; ADC->ADC_CR = ADC_CR_START; goto need_delay; } - if (chsr != g.bit) + if (chsr != g.chan) // Sampling in progress on another channel goto need_delay; if (!(ADC->ADC_ISR & ADC_ISR_DRDY)) @@ -75,7 +74,7 @@ need_delay: uint16_t gpio_adc_read(struct gpio_adc g) { - ADC->ADC_CHDR = g.bit; + ADC->ADC_CHDR = g.chan; return ADC->ADC_LCDR; } @@ -84,7 +83,7 @@ void gpio_adc_cancel_sample(struct gpio_adc g) { irqstatus_t flag = irq_save(); - if ((ADC->ADC_CHSR & 0xffff) == g.bit) + if ((ADC->ADC_CHSR & 0xffff) == g.chan) gpio_adc_read(g); irq_restore(flag); } |