forked from raspberrypi/pico-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhello_universal.c
50 lines (46 loc) · 1.2 KB
/
hello_universal.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
42
43
44
45
46
47
48
49
50
/**
* Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <stdio.h>
#include "pico/stdlib.h"
#include "pico/bootrom.h"
#include "boot/picoboot.h"
int main() {
stdio_init_all();
#ifdef PICO_DEFAULT_LED_PIN
gpio_init(PICO_DEFAULT_LED_PIN);
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
bool toggle = true;
gpio_put(PICO_DEFAULT_LED_PIN, toggle);
#endif
uint reboot_count = 0;
while (reboot_count < 10) {
printf("Hello, world!\n");
#if PICO_RP2350
printf("I'm an RP2350 ");
#ifdef __riscv
printf("running RISC-V\n");
#else
printf("running ARM\n");
#endif
reboot_count++;
#else
printf("I'm an RP2040\n");
#endif
#ifdef PICO_DEFAULT_LED_PIN
toggle = !toggle;
gpio_put(PICO_DEFAULT_LED_PIN, toggle);
sleep_ms(1000);
#endif
}
#if PICO_RP2350
#ifdef __riscv
rom_reboot(REBOOT2_FLAG_REBOOT_TYPE_NORMAL | REBOOT2_FLAG_REBOOT_TO_ARM, 1000, 0, 0);
#else
rom_reboot(REBOOT2_FLAG_REBOOT_TYPE_NORMAL | REBOOT2_FLAG_REBOOT_TO_RISCV, 1000, 0, 0);
#endif
printf("Rebooting to other architecture\n");
#endif
}