Skip to content

Commit 18dc21b

Browse files
AlessandroLuohenrikbrixandersen
authored andcommitted
drivers: adc: add adc disable to save power
Disables adc once conversion completes and enables again before sampling Signed-off-by: Hao Luo <[email protected]>
1 parent d6348cd commit 18dc21b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/adc/adc_ambiq.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ static void adc_ambiq_isr(const struct device *dev)
119119
&Sample);
120120
*data->buffer++ = Sample.ui32Sample;
121121
}
122+
am_hal_adc_disable(data->adcHandle);
122123
adc_context_on_sampling_done(&data->ctx, dev);
123124
}
124125
}
@@ -185,9 +186,6 @@ static int adc_ambiq_start_read(const struct device *dev, const struct adc_seque
185186
}
186187
__ASSERT_NO_MSG(channels == 0);
187188

188-
/* Enable the ADC. */
189-
am_hal_adc_enable(data->adcHandle);
190-
191189
data->active_channels = active_channels;
192190
data->buffer = sequence->buffer;
193191
/* Start ADC conversion */
@@ -269,6 +267,8 @@ static void adc_context_start_sampling(struct adc_context *ctx)
269267
struct adc_ambiq_data *data = CONTAINER_OF(ctx, struct adc_ambiq_data, ctx);
270268

271269
data->repeat_buffer = data->buffer;
270+
/* Enable the ADC. */
271+
am_hal_adc_enable(data->adcHandle);
272272
/*Trigger the ADC*/
273273
am_hal_adc_sw_trigger(data->adcHandle);
274274
}

0 commit comments

Comments
 (0)