Skip to content

Commit 1e37cd2

Browse files
trantanenrlubos
authored andcommitted
lib: modem_slm: Rename "wakeup" config and API to "power pin"
Renamed CONFIG_MODEM_SLM_WAKEUP_PIN and CONFIG_MODEM_SLM_WAKEUP_TIME to CONFIG_MODEM_SLM_POWER_PIN and CONFIG_MODEM_SLM_POWER_PIN_TIME, respectively. Renamed modem_slm_wake_up() function to modem_slm_power_pin_toggle(). These backwards incompatible changes are done because wakeup pin is not just for wake up after PR #14112. Jira: LRCS-87 Signed-off-by: Tommi Rantanen <[email protected]>
1 parent d99cc8e commit 1e37cd2

File tree

10 files changed

+64
-39
lines changed

10 files changed

+64
-39
lines changed

doc/nrf/libraries/modem/modem_slm.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Overview
1616
The Modem SLM library allows you to perform the following functions:
1717

1818
* Manage the serial interface so that the application only decides which UART device to use and configures its DTS.
19-
* Manage the GPIO pins, with support for bidirectional indication and wakeup.
19+
* Manage the GPIO pins, with support for bidirectional indication and power pin.
2020
* Send modem or SLM proprietary AT commands, receive responses and notifications, similar to the :ref:`lib_at_host` library.
2121
Received AT responses or notifications can be parsed by the :ref:`at_parser_readme` library.
2222
* Send raw data in SLM data mode.
@@ -33,8 +33,8 @@ Configure the following Kconfig options to enable this library:
3333

3434
* :kconfig:option:`CONFIG_MODEM_SLM` - Enables the Modem SLM library.
3535
* :kconfig:option:`CONFIG_MODEM_SLM_DMA_MAXLEN` - Configures UART RX EasyDMA buffer size, which is configured to 1024 bytes by default.
36-
* :kconfig:option:`CONFIG_MODEM_SLM_WAKEUP_PIN` - Configures the mandatory wake-up GPIO, which is not configured by default.
37-
* :kconfig:option:`CONFIG_MODEM_SLM_WAKEUP_TIME` - Sets the toggle time value in milliseconds for wake-up GPIO, by default 100 ms.
36+
* :kconfig:option:`CONFIG_MODEM_SLM_POWER_PIN` - Configures the mandatory power pin GPIO, which is not configured by default.
37+
* :kconfig:option:`CONFIG_MODEM_SLM_POWER_PIN_TIME` - Sets the toggle time value in milliseconds for power pin GPIO, by default 100 ms.
3838

3939
Optionally configure the following Kconfig options based on need:
4040

doc/nrf/releases_and_maturity/migration/migration_guide_3.0.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,17 @@ Download client
367367
368368
err = downloader_deinit(&dl);
369369
370+
Modem SLM
371+
---------
372+
373+
.. toggle::
374+
375+
For applications and samples using the :ref:`lib_modem_slm` library:
376+
377+
* Replace the ``CONFIG_MODEM_SLM_WAKEUP_PIN`` Kconfig option with :kconfig:option:`CONFIG_MODEM_SLM_POWER_PIN`.
378+
* Replace the ``CONFIG_MODEM_SLM_WAKEUP_TIME`` Kconfig option with :kconfig:option:`CONFIG_MODEM_SLM_POWER_PIN_TIME`.
379+
* Replace the :c:func:`modem_slm_wake_up` function with :c:func:`modem_slm_power_pin_toggle`.
380+
370381
Protocols
371382
=========
372383

doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -976,6 +976,14 @@ Modem libraries
976976

977977
* Deprecated the :c:func:`modem_info_type_get` function in favor of the :c:func:`modem_info_data_type_get` function.
978978

979+
* :ref:`lib_modem_slm` library:
980+
981+
* Updated:
982+
983+
* By renaming the ``CONFIG_MODEM_SLM_WAKEUP_PIN`` and ``CONFIG_MODEM_SLM_WAKEUP_TIME`` Kconfig options to
984+
:kconfig:option:`CONFIG_MODEM_SLM_POWER_PIN` and :kconfig:option:`CONFIG_MODEM_SLM_POWER_PIN_TIME`, respectively.
985+
* By renaming the :c:func:`modem_slm_wake_up` function to :c:func:`modem_slm_power_pin_toggle`.
986+
979987
Multiprotocol Service Layer libraries
980988
-------------------------------------
981989

include/modem/modem_slm.h

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ typedef void (*slm_data_handler_t)(const uint8_t *data, size_t datalen);
5959
/**
6060
* @typedef slm_ind_handler_t
6161
*
62-
* Handler to handle MODEM_SLM_INDICATE_PIN signal from SLM.
62+
* Handler to handle @kconfig{CONFIG_MODEM_SLM_INDICATE_PIN} signal from SLM.
6363
*/
6464
typedef void (*slm_ind_handler_t)(void);
6565

@@ -77,22 +77,26 @@ int modem_slm_init(slm_data_handler_t handler);
7777
int modem_slm_uninit(void);
7878

7979
/**
80-
* @brief Register callback for MODEM_SLM_INDICATE_PIN indication
80+
* @brief Register callback for @kconfig{CONFIG_MODEM_SLM_INDICATE_PIN} indication
8181
*
8282
* @param handler Pointer to a handler function of type @ref slm_ind_handler_t.
8383
* @param wakeup Enable/disable System Off wakeup by GPIO Sense.
8484
*
8585
* @retval Zero Success.
86-
* @retval -EFAULT if MODEM_SLM_INDICATE_PIN is not defined.
86+
* @retval -EFAULT if @kconfig{CONFIG_MODEM_SLM_INDICATE_PIN} is not defined.
8787
*/
8888
int modem_slm_register_ind(slm_ind_handler_t handler, bool wakeup);
8989

9090
/**
91-
* @brief Wakeup nRF9160 SiP via MODEM_SLM_WAKEUP_PIN
91+
* @brief Toggle power pin of the nRF91 Series device configured with
92+
* @kconfig{CONFIG_MODEM_SLM_POWER_PIN}.
93+
*
94+
* The pin is enabled for the time specified in @kconfig{CONFIG_MODEM_SLM_POWER_PIN_TIME}
95+
* and then disabled.
9296
*
9397
* @return Zero on success, non-zero otherwise.
9498
*/
95-
int modem_slm_wake_up(void);
99+
int modem_slm_power_pin_toggle(void);
96100

97101
/**
98102
* @brief Reset the RX function of the serial interface

lib/modem_slm/Kconfig

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ config MODEM_SLM_SHELL
2424
bool "SLM Shell"
2525
depends on SHELL
2626
help
27-
Adds AT command capability to shell. The shell command is "slm"
27+
Adds AT command capability to shell. The shell command is "slm".
2828

2929
choice
3030
prompt "AT command terminator"
@@ -44,23 +44,23 @@ choice
4444
bool "CR+LF Termination"
4545
endchoice
4646

47-
config MODEM_SLM_WAKEUP_PIN
48-
int "Wakeup pin"
47+
config MODEM_SLM_POWER_PIN
48+
int "Power pin"
4949
default -1
5050
help
51-
Interface GPIO to wake up nRF9160 from sleep or exit SLM idle
51+
Interface GPIO to toggle power pin of the nRF91 Series device.
5252

53-
config MODEM_SLM_WAKEUP_TIME
54-
int "wakeup period"
53+
config MODEM_SLM_POWER_PIN_TIME
54+
int "Power pin active time"
5555
default 100
5656
help
57-
GPIO active time in milliseconds. This setting specify the period length for the pin to be active
57+
GPIO active time in milliseconds. This setting specifies the period length for the pin to be active.
5858

5959
config MODEM_SLM_INDICATE_PIN
6060
int "Indicate pin"
6161
default -1
6262
help
63-
Interface GPIO pin used by SLM to indicate that data is available or an unexpected reset has occurred
63+
Interface GPIO pin used by SLM to indicate that data is available or an unexpected reset has occurred.
6464

6565
module = MODEM_SLM
6666
module-str = Modem SLM

lib/modem_slm/modem_slm.c

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
LOG_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
5050
static 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;
5353
static 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

127127
static 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

590592
SHELL_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
);

samples/cellular/slm_shell/boards/nrf52840dk_nrf52840.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111
CONFIG_NRFX_UARTE1=y
1212
CONFIG_UART_1_INTERRUPT_DRIVEN=n
1313
CONFIG_UART_1_ASYNC=y
14-
CONFIG_MODEM_SLM_WAKEUP_PIN=11
14+
CONFIG_MODEM_SLM_POWER_PIN=11
1515
CONFIG_MODEM_SLM_INDICATE_PIN=13

samples/cellular/slm_shell/boards/nrf5340dk_nrf5340_cpuapp.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111
CONFIG_NRFX_UARTE2=y
1212
CONFIG_UART_2_INTERRUPT_DRIVEN=n
1313
CONFIG_UART_2_ASYNC=y
14-
CONFIG_MODEM_SLM_WAKEUP_PIN=23
14+
CONFIG_MODEM_SLM_POWER_PIN=23
1515
CONFIG_MODEM_SLM_INDICATE_PIN=28

samples/cellular/slm_shell/boards/nrf7002dk_nrf5340_cpuapp.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111
CONFIG_NRFX_UARTE2=y
1212
CONFIG_UART_2_INTERRUPT_DRIVEN=n
1313
CONFIG_UART_2_ASYNC=y
14-
CONFIG_MODEM_SLM_WAKEUP_PIN=30
14+
CONFIG_MODEM_SLM_POWER_PIN=30
1515
CONFIG_MODEM_SLM_INDICATE_PIN=31

samples/cellular/slm_shell/src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ void slm_shell_indication_handler(void)
3232
int err;
3333

3434
LOG_INF("SLM indicate pin triggered");
35-
err = modem_slm_wake_up();
35+
err = modem_slm_power_pin_toggle();
3636
if (err) {
3737
LOG_ERR("Failed to toggle power pin");
3838
}

0 commit comments

Comments
 (0)