-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathmain.c
86 lines (63 loc) · 1.78 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include "pico/stdlib.h"
#include "hardware/gpio.h"
#include "pico/printf.h"
#include "lerp/task.h"
#include "lerp/circ.h"
#include "lerp/io.h"
#include "lerp/debug.h"
#include "config/config.h"
#include "swd.h"
#include "adi.h"
#include "flash.h"
#include "uart.h"
#include "tusb.h"
#include "filedata.h"
#include "gdb.h"
#include "cmdline.h"
#include "pico/cyw43_arch.h"
/**
* @brief Main polling function called regularly by lerp_task
*
* We need to do time sensitive things here and we mustn't block.
*
*/
void main_poll() {
// make sure usb/wifi is running and we're processing data...
io_poll();
// make sure the PIO blocks are managed...
swd_pio_poll();
// see if we need to transfer any uart data
dbg_uart_poll();
// handle any debug output...
debug_poll();
}
int main() {
// Take us to 150Mhz (for future rmii support)
set_sys_clock_khz(150 * 1000, true);
// Initialise the configuration system
config_init();
// Initialise the USB stack...
tusb_init();
// Initialise the PIO SWD system...
if (swd_init() != SWD_OK)
lerp_panic("unable to init SWD");
// Experiment with wireless on the pico-w
//io_init();
cmdline_init();
// Initialise the UART
dbg_uart_init();
// Create the GDB server task..
gdb_init();
// See if we have enough information to start the wifi...
// This is horrible here, needs to be a separate func/file with wifi/net related stuff.
if (*cf->main->wifi.ssid && *cf->main->wifi.creds) {
cyw43_arch_wifi_connect_async(cf->main->wifi.ssid, cf->main->wifi.creds, CYW43_AUTH_WPA2_AES_PSK);
}
// And start the scheduler...
leos_init(main_poll);
leos_start();
}