forked from solderparty/i2c_puppet
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathmain.c
More file actions
62 lines (46 loc) · 1.09 KB
/
main.c
File metadata and controls
62 lines (46 loc) · 1.09 KB
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
#include <pico/stdlib.h>
#include <stdio.h>
#include <tusb.h>
#include "backlight.h"
#include "debug.h"
#include "gpioexp.h"
#include "interrupt.h"
#include "keyboard.h"
#include "puppet_i2c.h"
#include "reg.h"
#include "touchpad.h"
#include "usb.h"
#include "pi.h"
// since the SDK doesn't support per-GPIO irq, we use this global irq and forward it
static void gpio_irq(uint gpio, uint32_t events)
{
// printf("%s: gpio %d, events 0x%02X\r\n", __func__, gpio, events);
touchpad_gpio_irq(gpio, events);
gpioexp_gpio_irq(gpio, events);
}
// TODO: Microphone
int main(void)
{
// The here order is important because it determines callback call order
usb_init();
#ifndef NDEBUG
debug_init();
#endif
reg_init();
backlight_init();
gpioexp_init();
keyboard_init();
touchpad_init();
interrupt_init();
puppet_i2c_init();
// For now, the `gpio` param is ignored and all enabled GPIOs generate the irq
gpio_set_irq_enabled_with_callback(0xFF, 0, true, &gpio_irq);
pi_init(); //turns on the pi
#ifndef NDEBUG
printf("Starting main loop\r\n");
#endif
while (true) {
__wfe();
}
return 0;
}