@@ -221,7 +221,7 @@ static int adc_xec_read_async(const struct device *dev,
221
221
}
222
222
#endif /* CONFIG_ADC_ASYNC */
223
223
224
- static void xec_adc_get_sample (const struct device * dev )
224
+ static int xec_adc_get_sample (const struct device * dev )
225
225
{
226
226
struct adc_xec_regs * adc_regs = ADC_XEC_REG_BASE ;
227
227
struct adc_xec_data * data = dev -> data ;
@@ -240,7 +240,6 @@ static void xec_adc_get_sample(const struct device *dev)
240
240
bit = find_lsb_set (channels );
241
241
while (bit != 0 ) {
242
242
idx = bit - 1 ;
243
-
244
243
* data -> buffer = (uint16_t )adc_regs -> channel_read_reg [idx ];
245
244
data -> buffer ++ ;
246
245
@@ -250,13 +249,23 @@ static void xec_adc_get_sample(const struct device *dev)
250
249
251
250
/* Clear the status register */
252
251
adc_regs -> status_reg = ch_status ;
252
+
253
+ /* Return error when requested ADC conversion was incomplete
254
+ * for some channels.
255
+ */
256
+ if (ch_status != adc_regs -> single_reg ) {
257
+ return - EIO ;
258
+ }
259
+
260
+ return 0 ;
253
261
}
254
262
255
263
static void adc_xec_isr (const struct device * dev )
256
264
{
257
265
struct adc_xec_regs * adc_regs = ADC_XEC_REG_BASE ;
258
266
struct adc_xec_data * data = dev -> data ;
259
267
uint32_t reg ;
268
+ int ret ;
260
269
261
270
/* Clear START_SINGLE bit and clear SINGLE_DONE_STATUS */
262
271
reg = adc_regs -> control_reg ;
@@ -267,9 +276,12 @@ static void adc_xec_isr(const struct device *dev)
267
276
/* Also clear GIRQ source status bit */
268
277
MCHP_GIRQ_SRC (MCHP_ADC_GIRQ ) = MCHP_ADC_SNG_DONE_GIRQ_VAL ;
269
278
270
- xec_adc_get_sample (dev );
271
-
272
- adc_context_on_sampling_done (& data -> ctx , dev );
279
+ ret = xec_adc_get_sample (dev );
280
+ if (ret ) {
281
+ adc_context_complete (& data -> ctx , ret );
282
+ } else {
283
+ adc_context_on_sampling_done (& data -> ctx , dev );
284
+ }
273
285
274
286
LOG_DBG ("ADC ISR triggered." );
275
287
}
0 commit comments