1515
1616LOG_MODULE_REGISTER (mdm_slm , CONFIG_MODEM_SLM_LOG_LEVEL );
1717
18- BUILD_ASSERT (CONFIG_MODEM_SLM_WAKEUP_PIN >= 0 , "Wake up pin not configured" );
18+ BUILD_ASSERT (CONFIG_MODEM_SLM_POWER_PIN >= 0 , "Power pin not configured" );
1919
2020#define UART_RX_BUF_NUM 2
2121#define UART_RX_LEN CONFIG_MODEM_SLM_DMA_MAXLEN
@@ -49,7 +49,7 @@ static const struct device *gpio_dev = DEVICE_DT_GET(DT_CHOSEN(ncs_slm_gpio));
4949#else
5050static const struct device * gpio_dev = DEVICE_DT_GET (DT_NODELABEL (gpio0 ));
5151#endif
52- static struct k_work_delayable gpio_wakeup_work ;
52+ static struct k_work_delayable gpio_power_pin_disable_work ;
5353static slm_ind_handler_t ind_handler ;
5454
5555#if defined(CONFIG_MODEM_SLM_SHELL )
@@ -111,17 +111,17 @@ static void indicate_pin_disable(void)
111111#endif
112112}
113113
114- static void gpio_wakeup_wk (struct k_work * work )
114+ static void gpio_power_pin_disable_work_fn (struct k_work * work )
115115{
116116 ARG_UNUSED (work );
117117
118- if (gpio_pin_set (gpio_dev , CONFIG_MODEM_SLM_WAKEUP_PIN , 0 ) != 0 ) {
118+ if (gpio_pin_set (gpio_dev , CONFIG_MODEM_SLM_POWER_PIN , 0 ) != 0 ) {
119119 LOG_WRN ("GPIO set error" );
120120 }
121121 /* When SLM is woken up, indicate pin must be enabled */
122122 (void )indicate_pin_enable ();
123123
124- LOG_INF ("Stop wake-up " );
124+ LOG_INF ("Disable power pin " );
125125}
126126
127127static void slm_data_wk (struct k_work * work )
@@ -374,9 +374,9 @@ static void gpio_cb_func(const struct device *dev, struct gpio_callback *gpio_cb
374374 return ;
375375 }
376376
377- if (k_work_delayable_is_pending (& gpio_wakeup_work )) {
378- (void )k_work_cancel_delayable (& gpio_wakeup_work );
379- (void )gpio_pin_set (gpio_dev , CONFIG_MODEM_SLM_WAKEUP_PIN , 0 );
377+ if (k_work_delayable_is_pending (& gpio_power_pin_disable_work )) {
378+ (void )k_work_cancel_delayable (& gpio_power_pin_disable_work );
379+ (void )gpio_pin_set (gpio_dev , CONFIG_MODEM_SLM_POWER_PIN , 0 );
380380 } else {
381381 /* Disable indicate pin so that callbacks doesn't keep on coming. */
382382 indicate_pin_disable ();
@@ -400,7 +400,7 @@ static int gpio_init(void)
400400 return - ENODEV ;
401401 }
402402
403- err = gpio_pin_configure (gpio_dev , CONFIG_MODEM_SLM_WAKEUP_PIN ,
403+ err = gpio_pin_configure (gpio_dev , CONFIG_MODEM_SLM_POWER_PIN ,
404404 GPIO_OUTPUT_INACTIVE | GPIO_ACTIVE_LOW );
405405 if (err ) {
406406 LOG_ERR ("GPIO config error: %d" , err );
@@ -437,7 +437,7 @@ int modem_slm_init(slm_data_handler_t handler)
437437 return - EFAULT ;
438438 }
439439
440- k_work_init_delayable (& gpio_wakeup_work , gpio_wakeup_wk );
440+ k_work_init_delayable (& gpio_power_pin_disable_work , gpio_power_pin_disable_work_fn );
441441 k_work_init (& slm_data_work , slm_data_wk );
442442 k_work_init_delayable (& uart_recovery_work , uart_recovery_wk );
443443
@@ -455,7 +455,7 @@ int modem_slm_uninit(void)
455455 uart_rx_disable (uart_dev );
456456 k_sleep (K_MSEC (10 ));
457457
458- gpio_pin_configure (gpio_dev , CONFIG_MODEM_SLM_WAKEUP_PIN , GPIO_DISCONNECTED );
458+ gpio_pin_configure (gpio_dev , CONFIG_MODEM_SLM_POWER_PIN , GPIO_DISCONNECTED );
459459
460460 indicate_pin_disable ();
461461
@@ -474,7 +474,7 @@ int modem_slm_register_ind(slm_ind_handler_t handler, bool wakeup)
474474 if (wakeup ) {
475475 /*
476476 * Due to errata 4, Always configure PIN_CNF[n].INPUT before PIN_CNF[n].SENSE.
477- * At this moment WAKEUP_PIN has already been configured as INPUT at init_gpio().
477+ * At this moment indicate pin has already been configured as INPUT at init_gpio().
478478 */
479479 nrf_gpio_cfg_sense_set (CONFIG_MODEM_SLM_INDICATE_PIN , NRF_GPIO_PIN_SENSE_LOW );
480480 }
@@ -485,21 +485,23 @@ int modem_slm_register_ind(slm_ind_handler_t handler, bool wakeup)
485485#endif
486486}
487487
488- int modem_slm_wake_up (void )
488+ int modem_slm_power_pin_toggle (void )
489489{
490490 int err ;
491491
492- if (k_work_delayable_is_pending (& gpio_wakeup_work )) {
492+ if (k_work_delayable_is_pending (& gpio_power_pin_disable_work )) {
493493 return 0 ;
494494 }
495495
496- LOG_INF ("Start wake-up " );
496+ LOG_INF ("Enable power pin " );
497497
498- err = gpio_pin_set (gpio_dev , CONFIG_MODEM_SLM_WAKEUP_PIN , 1 );
498+ err = gpio_pin_set (gpio_dev , CONFIG_MODEM_SLM_POWER_PIN , 1 );
499499 if (err ) {
500500 LOG_ERR ("GPIO set error: %d" , err );
501501 } else {
502- k_work_reschedule (& gpio_wakeup_work , K_MSEC (CONFIG_MODEM_SLM_WAKEUP_TIME ));
502+ k_work_reschedule (
503+ & gpio_power_pin_disable_work ,
504+ K_MSEC (CONFIG_MODEM_SLM_POWER_PIN_TIME ));
503505 }
504506
505507 return 0 ;
@@ -578,7 +580,7 @@ int modem_slm_shell_slmsh_powerpin(const struct shell *shell, size_t argc, char
578580{
579581 int err ;
580582
581- err = modem_slm_wake_up ();
583+ err = modem_slm_power_pin_toggle ();
582584 if (err ) {
583585 LOG_ERR ("Failed to toggle power pin" );
584586 }
@@ -589,7 +591,7 @@ SHELL_CMD_REGISTER(slm, NULL, "Send AT commands to SLM device", modem_slm_shell)
589591
590592SHELL_STATIC_SUBCMD_SET_CREATE (
591593 sub_slmsh ,
592- SHELL_CMD (powerpin , NULL , "Toggle power pin configured with CONFIG_SLM_POWER_PIN " ,
594+ SHELL_CMD (powerpin , NULL , "Toggle power pin configured with CONFIG_MODEM_SLM_POWER_PIN " ,
593595 modem_slm_shell_slmsh_powerpin ),
594596 SHELL_SUBCMD_SET_END
595597);
0 commit comments