-
Notifications
You must be signed in to change notification settings - Fork 104
/
Copy pathhello_dormant_gpio.c
executable file
·41 lines (31 loc) · 1 KB
/
hello_dormant_gpio.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/**
* Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <stdio.h>
#include "pico/stdlib.h"
#include "pico/sleep.h"
#define WAKE_GPIO 10
int main() {
stdio_init_all();
printf("Hello Dormant GPIO!\n");
printf("Test starting in 10s\n");
sleep_ms(10000);
while(true) {
printf("Switching to XOSC\n");
uart_default_tx_wait_blocking();
// Set the crystal oscillator as the dormant clock source, UART will be reconfigured from here
// This is necessary before sending the pico into dormancy
sleep_run_from_xosc();
printf("Going dormant until GPIO %d goes edge high\n", WAKE_GPIO);
uart_default_tx_wait_blocking();
// Go to sleep until we see a high edge on GPIO 10
sleep_goto_dormant_until_edge_high(WAKE_GPIO);
// Re-enabling clock sources and generators.
sleep_power_up();
printf("Now awake for 10s\n");
sleep_ms(1000 * 10);
}
return 0;
}