-
Notifications
You must be signed in to change notification settings - Fork 28
/
main.c
34 lines (26 loc) · 822 Bytes
/
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
#include "Delay.H"
#include "usb_endp.h"
#include "usb_hid_keyboard.h"
#include <stdio.h>
#include "ch554_platform.h"
uint8_t keyState, kbdModifier, kbdKey;
void main(void) {
CH554_Init();
printf("start ...\n");
keyState = KBD_STATE_IDLE;
while(1) {
while(keyState == KBD_STATE_IDLE);
keyState = KBD_STATE_KEYDOWN;
USB_Keyboard_SendKey(kbdModifier, kbdKey);
while(keyState == KBD_STATE_KEYDOWN);
USB_Keyboard_SendKey(0, 0);
}
}
/*
* According to SDCC specification, interrupt handlers MUST be placed within the file which contains
* the void main(void) function, otherwise SDCC won't be able to recognize it. It's not a bug but a feature.
* If you know how to fix this, please let me know.
*/
void USBInterruptEntry(void) interrupt INT_NO_USB {
USBInterrupt();
}