# make flip-ee = Download the eeprom file to the device, using Atmel FLIP | # make flip-ee = Download the eeprom file to the device, using Atmel FLIP | ||||
# (must have Atmel FLIP installed). | # (must have Atmel FLIP installed). | ||||
# | # | ||||
# make debug = Start either simulavr or avarice as specified for debugging, | |||||
# make debug = Start either simulavr or avarice as specified for debugging, | |||||
# with avr-gdb or avr-insight as the front end for debugging. | # with avr-gdb or avr-insight as the front end for debugging. | ||||
# | # | ||||
# make filename.s = Just compile filename.c into the assembler code only. | # make filename.s = Just compile filename.c into the assembler code only. | ||||
MOUSEKEY_ENABLE = yes # Mouse keys | MOUSEKEY_ENABLE = yes # Mouse keys | ||||
EXTRAKEY_ENABLE = yes # Media control and System control | EXTRAKEY_ENABLE = yes # Media control and System control | ||||
CONSOLE_ENABLE = yes # Console for debug | CONSOLE_ENABLE = yes # Console for debug | ||||
#COMMAND_ENABLE = yes # Commands for debug and configuration | |||||
#NKRO_ENABLE = yes # USB Nkey Rollover | #NKRO_ENABLE = yes # USB Nkey Rollover | ||||
# Boot Section Size in bytes | # Boot Section Size in bytes | ||||
# LUFA bootloader 4096 | # LUFA bootloader 4096 | ||||
OPT_DEFS += -DBOOTLOADER_SIZE=4096 | OPT_DEFS += -DBOOTLOADER_SIZE=4096 | ||||
#LDFLAGS += -Wl,--relax | |||||
#OPT_DEFS += -DNO_ACTION_TAPPING | |||||
#OPT_DEFS += -DNO_ACTION_LAYER | |||||
#OPT_DEFS += -DNO_ACTION_MACRO | |||||
SRC = \ | SRC = \ | ||||
keymap_common.c \ | keymap_common.c \ |
static void HID_setup() | static void HID_setup() | ||||
{ | { | ||||
if (usb_host.Init() == -1) { | if (usb_host.Init() == -1) { | ||||
debug("HID init: failed\n"); | |||||
LED_TX_OFF; | LED_TX_OFF; | ||||
} | } | ||||
_delay_ms(200); | _delay_ms(200); | ||||
kbd.SetReportParser(0, (HIDReportParser*)&kbd_parser); | kbd.SetReportParser(0, (HIDReportParser*)&kbd_parser); | ||||
} | } | ||||
LED_TX_ON; | LED_TX_ON; | ||||
debug_enable = true; | debug_enable = true; | ||||
/* | |||||
debug_matrix = true; | |||||
debug_keyboard = true; | |||||
debug_mouse = true; | |||||
*/ | |||||
host_set_driver(&lufa_driver); | host_set_driver(&lufa_driver); | ||||
keyboard_init(); | keyboard_init(); | ||||
LUFA_setup(); | LUFA_setup(); | ||||
HID_setup(); | |||||
/* NOTE: Don't insert time consuming job here. | |||||
* It'll cause unclear initialization failure when DFU reset(worm start). | |||||
*/ | |||||
sei(); | sei(); | ||||
uint8_t ret; | |||||
// wait for startup of sendchar routine | // wait for startup of sendchar routine | ||||
while (USB_DeviceState != DEVICE_STATE_Configured) ; | while (USB_DeviceState != DEVICE_STATE_Configured) ; | ||||
if (debug_enable) { | if (debug_enable) { | ||||
_delay_ms(1000); | _delay_ms(1000); | ||||
} | } | ||||
debug("init: start\n"); | |||||
HID_setup(); | |||||
debug("init: done\n"); | debug("init: done\n"); | ||||
uint16_t timer; | uint16_t timer; | ||||
// to see loop pulse with oscillo scope | |||||
DDRF = (1<<7); | |||||
for (;;) { | for (;;) { | ||||
PORTF ^= (1<<7); | |||||
keyboard_task(); | keyboard_task(); | ||||
timer = timer_read(); | timer = timer_read(); | ||||
USB_USBTask(); | USB_USBTask(); | ||||
#endif | #endif | ||||
} | } | ||||
return 0; | return 0; | ||||
} | } |