Skip to content

Commit 8bd90a2

Browse files
trantanenrlubos
authored andcommitted
applications: serial_lte_modem: Fix compilation without pins
Fix compilation errors without power or indicate pins configured, i.e., having them -1. This is regression from PR #22870. Also added these configurations into twister runs. Jira: SLM-121 Signed-off-by: Tommi Rantanen <[email protected]> (cherry picked from commit 599a178)
1 parent 57e88d2 commit 8bd90a2

File tree

2 files changed

+72
-21
lines changed

2 files changed

+72
-21
lines changed

applications/serial_lte_modem/sample.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,46 @@ tests:
2222
- ci_build
2323
- sysbuild
2424
- ci_applications_serial_lte_modem
25+
applications.serial_lte_modem_no_power_indicate:
26+
sysbuild: true
27+
build_only: true
28+
extra_configs:
29+
- CONFIG_SLM_POWER_PIN=-1
30+
- CONFIG_SLM_INDICATE_PIN=-1
31+
platform_allow:
32+
- nrf9151dk/nrf9151/ns
33+
integration_platforms:
34+
- nrf9151dk/nrf9151/ns
35+
tags:
36+
- ci_build
37+
- sysbuild
38+
- ci_applications_serial_lte_modem
39+
applications.serial_lte_modem_no_power:
40+
sysbuild: true
41+
build_only: true
42+
extra_configs:
43+
- CONFIG_SLM_POWER_PIN=-1
44+
platform_allow:
45+
- nrf9151dk/nrf9151/ns
46+
integration_platforms:
47+
- nrf9151dk/nrf9151/ns
48+
tags:
49+
- ci_build
50+
- sysbuild
51+
- ci_applications_serial_lte_modem
52+
applications.serial_lte_modem_no_indicate:
53+
sysbuild: true
54+
build_only: true
55+
extra_configs:
56+
- CONFIG_SLM_INDICATE_PIN=-1
57+
platform_allow:
58+
- nrf9151dk/nrf9151/ns
59+
integration_platforms:
60+
- nrf9151dk/nrf9151/ns
61+
tags:
62+
- ci_build
63+
- sysbuild
64+
- ci_applications_serial_lte_modem
2565
applications.serial_lte_modem.extmcu:
2666
sysbuild: true
2767
build_only: true

applications/serial_lte_modem/src/slm_ctrl_pin.c

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,12 @@ BUILD_ASSERT(!IS_ENABLED(CONFIG_SLM_START_SLEEP),
2929
"CONFIG_SLM_START_SLEEP requires CONFIG_SLM_POWER_PIN to be defined.");
3030
#endif
3131

32+
#if INDICATE_PIN_IS_ENABLED
3233
static struct k_work_delayable indicate_work;
34+
#endif
35+
#if POWER_PIN_IS_ENABLED
3336
static atomic_t callback_wakeup_running;
37+
#endif
3438

3539
static int ext_xtal_control(bool xtal_on)
3640
{
@@ -136,14 +140,14 @@ static void power_pin_callback_poweroff(const struct device *dev,
136140

137141
#endif /* POWER_PIN_IS_ENABLED */
138142

143+
#if INDICATE_PIN_IS_ENABLED
144+
139145
static void indicate_stop(void)
140146
{
141-
#if (INDICATE_PIN_IS_ENABLED)
142147
if (gpio_pin_set(gpio_dev, CONFIG_SLM_INDICATE_PIN, 0) != 0) {
143148
LOG_WRN("GPIO_0 set error");
144149
}
145150
LOG_DBG("Stop indicating");
146-
#endif
147151
}
148152

149153
static void indicate_wk(struct k_work *work)
@@ -153,6 +157,8 @@ static void indicate_wk(struct k_work *work)
153157
indicate_stop();
154158
}
155159

160+
#endif /* INDICATE_PIN_IS_ENABLED */
161+
156162
#if POWER_PIN_IS_ENABLED
157163

158164
static void power_pin_callback_enable_poweroff_fn(struct k_work *)
@@ -177,10 +183,13 @@ static void power_pin_callback_wakeup_work_fn(struct k_work *)
177183
int err;
178184

179185
LOG_INF("Resuming from idle.");
186+
187+
#if INDICATE_PIN_IS_ENABLED
180188
if (k_work_delayable_is_pending(&indicate_work)) {
181189
k_work_cancel_delayable(&indicate_work);
182190
indicate_stop();
183191
}
192+
#endif /* INDICATE_PIN_IS_ENABLED */
184193

185194
err = ext_xtal_control(true);
186195
if (err < 0) {
@@ -216,25 +225,6 @@ static void power_pin_callback_wakeup(const struct device *dev,
216225
k_work_submit(&work);
217226
}
218227

219-
int slm_ctrl_pin_indicate(void)
220-
{
221-
int err = 0;
222-
223-
#if (INDICATE_PIN_IS_ENABLED)
224-
if (k_work_delayable_is_pending(&indicate_work)) {
225-
return 0;
226-
}
227-
LOG_DBG("Start indicating");
228-
err = gpio_pin_set(gpio_dev, CONFIG_SLM_INDICATE_PIN, 1);
229-
if (err) {
230-
LOG_ERR("GPIO_0 set error: %d", err);
231-
} else {
232-
k_work_reschedule(&indicate_work, K_MSEC(CONFIG_SLM_INDICATE_TIME));
233-
}
234-
#endif
235-
return err;
236-
}
237-
238228
void slm_ctrl_pin_enter_idle(void)
239229
{
240230
LOG_INF("Entering idle.");
@@ -280,6 +270,25 @@ void slm_ctrl_pin_enter_sleep_no_uninit(void)
280270

281271
#endif /* POWER_PIN_IS_ENABLED */
282272

273+
int slm_ctrl_pin_indicate(void)
274+
{
275+
int err = 0;
276+
277+
#if INDICATE_PIN_IS_ENABLED
278+
if (k_work_delayable_is_pending(&indicate_work)) {
279+
return 0;
280+
}
281+
LOG_DBG("Start indicating");
282+
err = gpio_pin_set(gpio_dev, CONFIG_SLM_INDICATE_PIN, 1);
283+
if (err) {
284+
LOG_ERR("GPIO_0 set error: %d", err);
285+
} else {
286+
k_work_reschedule(&indicate_work, K_MSEC(CONFIG_SLM_INDICATE_TIME));
287+
}
288+
#endif
289+
return err;
290+
}
291+
283292
void slm_ctrl_pin_enter_shutdown(void)
284293
{
285294
LOG_INF("Entering shutdown.");
@@ -319,7 +328,9 @@ int slm_ctrl_pin_init(void)
319328
{
320329
int err;
321330

331+
#if INDICATE_PIN_IS_ENABLED
322332
k_work_init_delayable(&indicate_work, indicate_wk);
333+
#endif
323334

324335
err = ext_xtal_control(true);
325336
if (err < 0) {

0 commit comments

Comments
 (0)