@@ -29,8 +29,12 @@ BUILD_ASSERT(!IS_ENABLED(CONFIG_SLM_START_SLEEP),
29
29
"CONFIG_SLM_START_SLEEP requires CONFIG_SLM_POWER_PIN to be defined." );
30
30
#endif
31
31
32
+ #if INDICATE_PIN_IS_ENABLED
32
33
static struct k_work_delayable indicate_work ;
34
+ #endif
35
+ #if POWER_PIN_IS_ENABLED
33
36
static atomic_t callback_wakeup_running ;
37
+ #endif
34
38
35
39
static int ext_xtal_control (bool xtal_on )
36
40
{
@@ -136,14 +140,14 @@ static void power_pin_callback_poweroff(const struct device *dev,
136
140
137
141
#endif /* POWER_PIN_IS_ENABLED */
138
142
143
+ #if INDICATE_PIN_IS_ENABLED
144
+
139
145
static void indicate_stop (void )
140
146
{
141
- #if (INDICATE_PIN_IS_ENABLED )
142
147
if (gpio_pin_set (gpio_dev , CONFIG_SLM_INDICATE_PIN , 0 ) != 0 ) {
143
148
LOG_WRN ("GPIO_0 set error" );
144
149
}
145
150
LOG_DBG ("Stop indicating" );
146
- #endif
147
151
}
148
152
149
153
static void indicate_wk (struct k_work * work )
@@ -153,6 +157,8 @@ static void indicate_wk(struct k_work *work)
153
157
indicate_stop ();
154
158
}
155
159
160
+ #endif /* INDICATE_PIN_IS_ENABLED */
161
+
156
162
#if POWER_PIN_IS_ENABLED
157
163
158
164
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 *)
177
183
int err ;
178
184
179
185
LOG_INF ("Resuming from idle." );
186
+
187
+ #if INDICATE_PIN_IS_ENABLED
180
188
if (k_work_delayable_is_pending (& indicate_work )) {
181
189
k_work_cancel_delayable (& indicate_work );
182
190
indicate_stop ();
183
191
}
192
+ #endif /* INDICATE_PIN_IS_ENABLED */
184
193
185
194
err = ext_xtal_control (true);
186
195
if (err < 0 ) {
@@ -216,25 +225,6 @@ static void power_pin_callback_wakeup(const struct device *dev,
216
225
k_work_submit (& work );
217
226
}
218
227
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
-
238
228
void slm_ctrl_pin_enter_idle (void )
239
229
{
240
230
LOG_INF ("Entering idle." );
@@ -280,6 +270,25 @@ void slm_ctrl_pin_enter_sleep_no_uninit(void)
280
270
281
271
#endif /* POWER_PIN_IS_ENABLED */
282
272
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
+
283
292
void slm_ctrl_pin_enter_shutdown (void )
284
293
{
285
294
LOG_INF ("Entering shutdown." );
@@ -319,7 +328,9 @@ int slm_ctrl_pin_init(void)
319
328
{
320
329
int err ;
321
330
331
+ #if INDICATE_PIN_IS_ENABLED
322
332
k_work_init_delayable (& indicate_work , indicate_wk );
333
+ #endif
323
334
324
335
err = ext_xtal_control (true);
325
336
if (err < 0 ) {
0 commit comments