#include "lufa.h"
#include "print.h"
#include "sendchar.h"
+#include "rn42.h"
+#include "rn42_task.h"
+#include "serial.h"
+#include "keyboard.h"
+#include "keycode.h"
+#include "action.h"
+#include "action_util.h"
+#include "wait.h"
+#include "suart.h"
+static int8_t sendchar_func(uint8_t c)
+{
+ sendchar(c); // LUFA
+ xmit(c); // SUART
+ return 0;
+}
static void SetupHardware(void)
{
// for Console_Task
USB_Device_EnableSOFEvents();
- print_set_sendchar(sendchar);
+ print_set_sendchar(sendchar_func);
+
+ // SUART PD0:output, PD1:input
+ DDRD |= (1<<0);
+ PORTD |= (1<<0);
+ DDRD &= ~(1<<1);
+ PORTD |= (1<<1);
}
int main(void) __attribute__ ((weak));
SetupHardware();
sei();
- /* wait for USB startup & debug output */
- while (USB_DeviceState != DEVICE_STATE_Configured) {
+ /* wait for USB startup to get ready for debug output */
+ uint8_t timeout = 255; // timeout when USB is not available(Bluetooth)
+ while (timeout-- && USB_DeviceState != DEVICE_STATE_Configured) {
+ wait_ms(4);
#if defined(INTERRUPT_CONTROL_ENDPOINT)
;
#else
}
print("USB configured.\n");
+ rn42_init();
+ rn42_task_init();
+ print("RN-42 init\n");
+
/* init modules */
keyboard_init();
- host_set_driver(&lufa_driver);
+
+ if (!rn42_rts()) {
+ host_set_driver(&rn42_driver);
+ } else {
+ host_set_driver(&lufa_driver);
+ }
+
#ifdef SLEEP_LED_ENABLE
sleep_led_init();
#endif
#if !defined(INTERRUPT_CONTROL_ENDPOINT)
USB_USBTask();
#endif
+
+ rn42_task();
}
}
-