lpc176x: Move irq handler code above irq setup

Only code movement.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor
2019-08-22 09:16:37 -04:00
parent 44f862388f
commit 6409eda058
3 changed files with 80 additions and 75 deletions

View File

@@ -36,6 +36,22 @@ static struct {
enum { ADC_DONE=0x0100 };
// ADC hardware irq handler
void __visible
ADC_IRQHandler(void)
{
uint32_t pos = adc_status.pos, chan = adc_status.chan & 0xff;
uint32_t result = (&LPC_ADC->ADDR0)[chan];
if (pos >= ARRAY_SIZE(adc_status.samples))
// All samples complete
return;
if (pos >= ARRAY_SIZE(adc_status.samples) - 2)
// Turn off burst mode
LPC_ADC->ADCR = adc_status.adcr | (1 << chan);
adc_status.samples[pos++] = (result >> 4) & 0x0fff;
adc_status.pos = pos;
}
struct gpio_adc
gpio_adc_setup(uint8_t pin)
{
@@ -64,22 +80,6 @@ gpio_adc_setup(uint8_t pin)
return (struct gpio_adc){ .chan = chan };
}
// ADC hardware irq handler
void __visible
ADC_IRQHandler(void)
{
uint32_t pos = adc_status.pos, chan = adc_status.chan & 0xff;
uint32_t result = (&LPC_ADC->ADDR0)[chan];
if (pos >= ARRAY_SIZE(adc_status.samples))
// All samples complete
return;
if (pos >= ARRAY_SIZE(adc_status.samples) - 2)
// Turn off burst mode
LPC_ADC->ADCR = adc_status.adcr | (1 << chan);
adc_status.samples[pos++] = (result >> 4) & 0x0fff;
adc_status.pos = pos;
}
// Try to sample a value. Returns zero if sample ready, otherwise
// returns the number of clock ticks the caller should wait before
// retrying this function.