forked from RIOT-OS/RIOT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
49 lines (43 loc) · 1.22 KB
/
main.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
/*
* Copyright (C) 2023 Otto-von-Guericke-Universität Magdeburg
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
#include "board.h"
#include "periph/pio.h"
#include <stdio.h>
/* see blink.c */
pio_program_t pio_blink_export_program(void);
/* see blink.c */
int pio_blink_write_program(pio_t pio, pio_program_t *pro);
/* see blink.c */
int pio_blink_init(pio_t pio, pio_sm_t sm, const pio_program_t *pro,
gpio_t pin);
int main(void)
{
pio_program_t blink = pio_blink_export_program();
pio_t pio;
pio_sm_t sm;
if (pio_alloc_program_sm_lock_any(&pio, &sm, &blink)) {
puts("No PIO resources available.");
return 1;
}
if (pio_blink_write_program(pio, &blink)) {
puts("Program could not be written.");
return -1;
}
gpio_t blink_gpio = PIO_BLINK_PIN; /* see Makefile */
if (blink_gpio == GPIO_UNDEF) {
#ifdef LED0_PIN
blink_gpio = LED0_PIN;
#endif
}
if (pio_blink_init(pio, sm, &blink, blink_gpio)) {
puts("PIO blink initialization failed");
return 1;
}
pio_sm_start(pio, sm);
return 0;
}