@@ -269,11 +269,11 @@ static int adc_nrfx_channel_setup(const struct device *dev,
269269 m_data .divide_single_ended_value &= ~BIT (channel_cfg -> channel_id );
270270 }
271271
272- nrfx_err_t ret = nrfx_saadc_channel_config (& cfg );
272+ err = nrfx_saadc_channel_config (& cfg );
273273
274- if (ret != NRFX_SUCCESS ) {
275- LOG_ERR ("Cannot configure channel %d: 0x%08x " , channel_cfg -> channel_id , ret );
276- return - EINVAL ;
274+ if (err != 0 ) {
275+ LOG_ERR ("Cannot configure channel %d: %d " , channel_cfg -> channel_id , err );
276+ return err ;
277277 }
278278
279279 return 0 ;
@@ -284,10 +284,10 @@ static void adc_context_start_sampling(struct adc_context *ctx)
284284 if (ctx -> sequence .calibrate ) {
285285 nrfx_saadc_offset_calibrate (event_handler );
286286 } else {
287- nrfx_err_t ret = nrfx_saadc_mode_trigger ();
287+ int ret = nrfx_saadc_mode_trigger ();
288288
289- if (ret != NRFX_SUCCESS ) {
290- LOG_ERR ("Cannot start sampling: 0x%08x " , ret );
289+ if (ret != 0 ) {
290+ LOG_ERR ("Cannot start sampling: %d " , ret );
291291 adc_context_complete (ctx , - EIO );
292292 }
293293 }
@@ -312,10 +312,9 @@ static void adc_context_update_buffer_pointer(struct adc_context *ctx, bool repe
312312 return ;
313313 }
314314
315- nrfx_err_t nrfx_err =
316- nrfx_saadc_buffer_set (samples_buffer , m_data .active_channel_cnt );
317- if (nrfx_err != NRFX_SUCCESS ) {
318- LOG_ERR ("Failed to set buffer: 0x%08x" , nrfx_err );
315+ error = nrfx_saadc_buffer_set (samples_buffer , m_data .active_channel_cnt );
316+ if (error != 0 ) {
317+ LOG_ERR ("Failed to set buffer: %d" , error );
319318 adc_context_complete (ctx , - EIO );
320319 }
321320 }
@@ -326,10 +325,10 @@ static inline void adc_context_enable_timer(struct adc_context *ctx)
326325 if (!m_data .internal_timer_enabled ) {
327326 k_timer_start (& m_data .timer , K_NO_WAIT , K_USEC (ctx -> options .interval_us ));
328327 } else {
329- nrfx_err_t ret = nrfx_saadc_mode_trigger ();
328+ int ret = nrfx_saadc_mode_trigger ();
330329
331- if (ret != NRFX_SUCCESS ) {
332- LOG_ERR ("Cannot start sampling: 0x%08x " , ret );
330+ if (ret != 0 ) {
331+ LOG_ERR ("Cannot start sampling: %d " , ret );
333332 adc_context_complete (& m_data .ctx , - EIO );
334333 }
335334 }
@@ -499,7 +498,6 @@ static inline uint16_t interval_to_cc(uint16_t interval_us)
499498static int start_read (const struct device * dev ,
500499 const struct adc_sequence * sequence )
501500{
502- nrfx_err_t nrfx_err ;
503501 int error ;
504502 uint32_t selected_channels = sequence -> channels ;
505503 nrf_saadc_resolution_t resolution ;
@@ -557,21 +555,21 @@ static int start_read(const struct device *dev,
557555
558556 m_data .internal_timer_enabled = true;
559557
560- nrfx_err = nrfx_saadc_advanced_mode_set (selected_channels , resolution , & adv_config ,
561- event_handler );
558+ error = nrfx_saadc_advanced_mode_set (selected_channels , resolution , & adv_config ,
559+ event_handler );
562560 } else {
563561 m_data .internal_timer_enabled = false;
564562
565- nrfx_err = nrfx_saadc_simple_mode_set (selected_channels , resolution , oversampling ,
566- event_handler );
563+ error = nrfx_saadc_simple_mode_set (selected_channels , resolution , oversampling ,
564+ event_handler );
567565 }
568566
569- if (nrfx_err != NRFX_SUCCESS ) {
570- return - EINVAL ;
567+ if (error != 0 ) {
568+ return error ;
571569 }
572570
573571 error = check_buffer_size (sequence , active_channel_cnt );
574- if (error ) {
572+ if (error != 0 ) {
575573 return error ;
576574 }
577575
@@ -592,14 +590,13 @@ static int start_read(const struct device *dev,
592590 /* Buffer is filled in chunks, each chunk composed of number of samples equal to number
593591 * of active channels. Buffer pointer is advanced and reloaded after each chunk.
594592 */
595- nrfx_err = nrfx_saadc_buffer_set (
596- samples_buffer ,
597- (m_data .internal_timer_enabled
598- ? (1 + sequence -> options -> extra_samplings )
599- : active_channel_cnt ));
600- if (nrfx_err != NRFX_SUCCESS ) {
601- LOG_ERR ("Failed to set buffer: 0x%08x" , nrfx_err );
602- return - EINVAL ;
593+ error = nrfx_saadc_buffer_set (samples_buffer ,
594+ (m_data .internal_timer_enabled
595+ ? (1 + sequence -> options -> extra_samplings )
596+ : active_channel_cnt ));
597+ if (error != 0 ) {
598+ LOG_ERR ("Failed to set buffer: %d" , error );
599+ return error ;
603600 }
604601
605602 adc_context_start_read (& m_data .ctx , sequence );
@@ -638,7 +635,7 @@ static int adc_nrfx_read_async(const struct device *dev,
638635
639636static void event_handler (const nrfx_saadc_evt_t * event )
640637{
641- nrfx_err_t err ;
638+ int err ;
642639
643640 if (event -> type == NRFX_SAADC_EVT_DONE ) {
644641 dmm_buffer_in_release (
@@ -657,8 +654,8 @@ static void event_handler(const nrfx_saadc_evt_t *event)
657654 adc_context_on_sampling_done (& m_data .ctx , DEVICE_DT_INST_GET (0 ));
658655 } else if (event -> type == NRFX_SAADC_EVT_CALIBRATEDONE ) {
659656 err = nrfx_saadc_mode_trigger ();
660- if (err != NRFX_SUCCESS ) {
661- LOG_ERR ("Cannot start sampling: 0x%08x " , err );
657+ if (err != 0 ) {
658+ LOG_ERR ("Cannot start sampling: %d " , err );
662659 adc_context_complete (& m_data .ctx , - EIO );
663660 }
664661 } else if (event -> type == NRFX_SAADC_EVT_FINISHED ) {
@@ -668,13 +665,13 @@ static void event_handler(const nrfx_saadc_evt_t *event)
668665
669666static int init_saadc (const struct device * dev )
670667{
671- nrfx_err_t err ;
668+ int err ;
672669
673670 k_timer_init (& m_data .timer , external_timer_expired_handler , NULL );
674671
675672 /* The priority value passed here is ignored (see nrfx_glue.h). */
676673 err = nrfx_saadc_init (0 );
677- if (err != NRFX_SUCCESS ) {
674+ if (err != 0 ) {
678675 LOG_ERR ("Failed to initialize device: %s" , dev -> name );
679676 return - EIO ;
680677 }
0 commit comments