@@ -170,6 +170,12 @@ static int init(const struct device *dev)
170170
171171 result = gpio_pin_configure_dt (& cfg -> rst_gpio , GPIO_OUTPUT_HIGH );
172172
173+ cxd5605_setup_interrupts (dev );
174+ /* setup shim callbacks */
175+ cxd5605_lib_init (dev );
176+ cxd5605_register_resp_callback (dev , driver_cxd5605_resp_cb );
177+ cxd5605_register_nmea_callback (dev , driver_cxd5605_nmea_cb );
178+
173179 return result ;
174180}
175181
@@ -429,11 +435,6 @@ static int cxd5605_attr_set(const struct device *dev,
429435 uint8_t min = 0 ;
430436 uint8_t sec = 0 ;
431437
432-
433- const struct cxd5605_config * config = dev -> config ;
434- const struct gpio_dt_spec * pwr_gpio = & config -> pwr_gpio ;
435- const struct gpio_dt_spec * rst_gpio = & config -> rst_gpio ;
436-
437438 if (chan != SENSOR_CHAN_AMBIENT_TEMP && chan != SENSOR_CHAN_ALL ) {
438439 return - ENOTSUP ;
439440 }
@@ -459,6 +460,9 @@ static int cxd5605_attr_set(const struct device *dev,
459460 __FILE__ , __LINE__ , result );
460461 return result ;
461462 }
463+ drv_data -> op_mode = val [0 ].val1 ;
464+ drv_data -> pos_cycle = val [0 ].val2 ;
465+ drv_data -> sleep_time = val [1 ].val1 ;
462466 break ;
463467
464468 case SENSOR_ATTR_CXD5605_PULSE :
@@ -508,6 +512,7 @@ static int cxd5605_attr_set(const struct device *dev,
508512 __FILE__ , __LINE__ , result );
509513 return result ;
510514 }
515+ drv_data -> selected_sentences = val -> val1 ;
511516 break ;
512517
513518 case SENSOR_ATTR_CXD5605_HOT_START :
@@ -580,39 +585,10 @@ static int cxd5605_attr_set(const struct device *dev,
580585 }
581586 break ;
582587
583- case SENSOR_ATTR_CXD5605_PWR_CTRL :
584- if (val -> val1 == 0 ) {
585- result = gpio_pin_configure_dt (pwr_gpio , GPIO_OUTPUT_LOW );
586- result = gpio_pin_configure_dt (rst_gpio , GPIO_OUTPUT_LOW );
587- } else {
588- result = gpio_pin_configure_dt (pwr_gpio , GPIO_OUTPUT_HIGH );
589- result = gpio_pin_configure_dt (rst_gpio , GPIO_OUTPUT_HIGH );
590- }
591- break ;
592-
593- case SENSOR_ATTR_CXD5605_CALLBACK :
594- init (dev );
595- LOG_DBG ("Got CXD5605_ALERT_INTERRUPTS\n" );
596- cxd5605_setup_interrupts (dev );
597- /* setup shim callbacks */
598- #ifdef DEBUG
599- printf ("[driver] register driver callback\n" );
600- #endif
601- cxd5605_lib_init (dev );
602- cxd5605_register_resp_callback (dev , driver_cxd5605_resp_cb );
603- cxd5605_register_nmea_callback (dev , driver_cxd5605_nmea_cb );
604- return 0 ;
605-
606588 default :
607589 return - ENOTSUP ;
608590 }
609591
610- if (drv_data -> cxd5605_cmd != SENSOR_ATTR_CXD5605_PWR_CTRL ) {
611- result = cxd5605_wait_fetch (dev );
612- if (result < 0 ) {
613- return result ;
614- }
615- }
616592
617593 return 0 ;
618594}
@@ -684,6 +660,7 @@ static int cxd5605_driver_pm_action(const struct device *dev,
684660{
685661 const struct cxd5605_config * config = dev -> config ;
686662 const struct gpio_dt_spec * rst_gpio = & config -> rst_gpio ;
663+ struct cxd5605_data * drv_data = dev -> data ;
687664
688665 int result = 0 ;
689666
@@ -699,6 +676,11 @@ static int cxd5605_driver_pm_action(const struct device *dev,
699676 if (result < 0 ) {
700677 printk ("ERROR: I2C interface not working (CXD5605 driver)\n" );
701678 }
679+ if (drv_data -> pps_cb ) {
680+ cxd5605_pulse (dev , 1 );
681+ }
682+ cxd5605_operating_mode (dev , drv_data -> op_mode , drv_data -> pos_cycle , drv_data -> sleep_time );
683+ cxd5605_sentence_select (dev , drv_data -> selected_sentences );
702684
703685 case PM_DEVICE_ACTION_SUSPEND :
704686 cxd5605_sleep (dev , 0 );
0 commit comments