summaryrefslogtreecommitdiff
path: root/demos/host/src/main.c
diff options
context:
space:
mode:
authorhathach <[email protected]>2013-04-15 17:30:36 +0800
committerhathach <[email protected]>2013-04-15 17:30:36 +0800
commit54221bb73b99544a1e7d4470e089b4f79ab044c9 (patch)
treed8bf304a9504b6a5a2cc68000d468acbd7711f12 /demos/host/src/main.c
parentaddbe3ed56ec1eec7e4209bf705dc81ae55e467f (diff)
move code in host demo to /src in prepare for support freeRTOS projects
Diffstat (limited to 'demos/host/src/main.c')
-rw-r--r--demos/host/src/main.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/demos/host/src/main.c b/demos/host/src/main.c
new file mode 100644
index 000000000..7b935670c
--- /dev/null
+++ b/demos/host/src/main.c
@@ -0,0 +1,50 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "boards/board.h"
+#include "tusb.h"
+
+#if defined(__CODE_RED)
+ #include <cr_section_macros.h>
+ #include <NXP/crp.h>
+ // Variable to store CRP value in. Will be placed automatically
+ // by the linker when "Enable Code Read Protect" selected.
+ // See crp.h header for more information
+ __CRP const unsigned int CRP_WORD = CRP_NO_CRP ;
+#endif
+
+int main(void)
+{
+ uint32_t current_tick = system_ticks;
+
+ board_init();
+ tusb_init();
+
+ //------------- application task init -------------//
+ keyboard_app_init();
+ mouse_app_init();
+
+ printf("reset\n");
+ while (1)
+ {
+ tusb_task_runner();
+ keyboard_app_task();
+ mouse_app_task();
+
+ if (current_tick + CFG_TICKS_PER_SECOND < system_ticks)
+ {
+ static uint8_t timeout_10_ms = 0;
+ timeout_10_ms = (timeout_10_ms+1) % 10;
+ if (timeout_10_ms % 10 == 0)
+ {
+ printf("tinyusb: " __DATE__ "\t" __TIME__ "\n"); // toggle leds on EA4357 is quite troublesome
+ }
+
+ current_tick += CFG_TICKS_PER_SECOND;
+ board_leds(0x01, (current_tick/CFG_TICKS_PER_SECOND)%2); /* Toggle LED once per second */
+ }
+ }
+
+ return 0;
+}