-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
66 lines (53 loc) · 1.43 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
#include "tusb.h"
#include "pico/stdlib.h"
#include "msc_disk.h"
#define GPIO_LINUX 28
#define GPIO_WINDOWS 29
/*------------- MAIN -------------*/
int main(void)
{
// init device stack on configured roothub port
tusb_init();
gpio_init(GPIO_LINUX);
gpio_init(GPIO_WINDOWS);
gpio_set_dir(GPIO_LINUX, false);
gpio_set_dir(GPIO_WINDOWS, false);
gpio_pull_up(GPIO_LINUX);
gpio_pull_up(GPIO_WINDOWS);
while (1)
{
tud_task(); // tinyusb device task
if ( !gpio_get(GPIO_LINUX) && !gpio_get(GPIO_WINDOWS)){
setSwitchValue(CONFIG_DEFAULT);
} else if ( !gpio_get(GPIO_LINUX)){
setSwitchValue(CONFIG_LINUX);
} else if ( !gpio_get(GPIO_WINDOWS)){
setSwitchValue(CONFIG_WINDOWS);
} else { //neither are pulled down, switch in the middle
setSwitchValue(CONFIG_STOP);
}
}
return 0;
}
//--------------------------------------------------------------------+
// Device callbacks
//--------------------------------------------------------------------+
// Invoked when device is mounted
void tud_mount_cb(void)
{
}
// Invoked when device is unmounted
void tud_umount_cb(void)
{
}
// Invoked when usb bus is suspended
// remote_wakeup_en : if host allow us to perform remote wakeup
// Within 7ms, device must draw an average of current less than 2.5 mA from bus
void tud_suspend_cb(bool remote_wakeup_en)
{
(void) remote_wakeup_en;
}
// Invoked when usb bus is resumed
void tud_resume_cb(void)
{
}