summaryrefslogtreecommitdiff
path: root/main.c
blob: 65db34df33bdbc7db1da0523a4e4e319e57d5141 (plain)
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
/* pico-sdk */
#include <stdio.h>
#include "pico/stdlib.h"

/* TinyUSB */
#include "bsp/board_api.h"
#include "tusb.h"

/* local */
#include "usb_keyboard.h"

int main() {
	/* pico-sdk initialization */
	stdio_uart_init();
	gpio_init(PICO_DEFAULT_LED_PIN);
	gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);

	usb_keyboard_init();

	/* TinyUSB initialization */
	board_init();
	tud_init(BOARD_TUD_RHPORT);
	if (board_init_after_tusb)
		board_init_after_tusb();

	/* Event loop. */
	for (;;) {
		tud_task();
		usb_keyboard_task();
		if (usb_keyboard_is_flushed()) {
			char *msg = "Hello world!\n";
			for (size_t i = 0; i < strlen(msg); i++)
				usb_keyboard_send_char(msg[i]);
		}
	}
}