2013-01-18 14:39:42 +07:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2012-12-10 16:10:24 +07:00
|
|
|
#include "boards/board.h"
|
|
|
|
#include "tusb.h"
|
|
|
|
|
2013-04-22 10:44:51 +07:00
|
|
|
#include "mouse_app.h"
|
|
|
|
#include "keyboard_app.h"
|
|
|
|
|
2012-12-10 16:10:24 +07:00
|
|
|
#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
|
|
|
|
|
2013-04-22 12:10:52 +07:00
|
|
|
void print_greeting(void);
|
2012-12-10 16:10:24 +07:00
|
|
|
int main(void)
|
|
|
|
{
|
2012-12-18 15:08:30 +07:00
|
|
|
uint32_t current_tick = system_ticks;
|
2012-12-10 16:10:24 +07:00
|
|
|
|
|
|
|
board_init();
|
2013-04-22 12:10:52 +07:00
|
|
|
print_greeting();
|
|
|
|
|
2013-01-18 14:39:42 +07:00
|
|
|
tusb_init();
|
2012-12-10 16:10:24 +07:00
|
|
|
|
2013-04-10 02:34:40 +07:00
|
|
|
//------------- application task init -------------//
|
2013-04-25 11:00:56 +07:00
|
|
|
#if TUSB_CFG_HOST_HID_KEYBOARD
|
2013-04-10 02:34:40 +07:00
|
|
|
keyboard_app_init();
|
2013-04-25 11:00:56 +07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if TUSB_CFG_HOST_HID_MOUSE
|
2013-04-10 02:34:40 +07:00
|
|
|
mouse_app_init();
|
2013-04-25 11:00:56 +07:00
|
|
|
#endif
|
2013-04-10 02:34:40 +07:00
|
|
|
|
2012-12-10 16:10:24 +07:00
|
|
|
while (1)
|
|
|
|
{
|
2013-04-24 17:53:43 +07:00
|
|
|
|
|
|
|
#if TUSB_CFG_OS == TUSB_OS_NONE
|
2013-03-12 20:04:29 +07:00
|
|
|
tusb_task_runner();
|
2013-04-24 17:53:43 +07:00
|
|
|
keyboard_app_task(NULL);
|
|
|
|
mouse_app_task(NULL);
|
|
|
|
#endif
|
2013-03-12 20:04:29 +07:00
|
|
|
|
2013-04-08 02:36:43 +07:00
|
|
|
if (current_tick + CFG_TICKS_PER_SECOND < system_ticks)
|
2012-12-10 16:10:24 +07:00
|
|
|
{
|
2013-04-22 12:10:52 +07:00
|
|
|
current_tick += CFG_TICKS_PER_SECOND;
|
|
|
|
|
|
|
|
/* Toggle LED once per second */
|
|
|
|
if ( (current_tick/CFG_TICKS_PER_SECOND) % 2)
|
2013-04-08 02:36:43 +07:00
|
|
|
{
|
2013-04-22 12:10:52 +07:00
|
|
|
board_leds(0x01, 0x00);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
board_leds(0x00, 0x01);
|
2013-04-08 02:36:43 +07:00
|
|
|
}
|
2012-12-10 16:10:24 +07:00
|
|
|
}
|
|
|
|
}
|
2013-01-18 14:39:42 +07:00
|
|
|
|
|
|
|
return 0;
|
2012-12-10 16:10:24 +07:00
|
|
|
}
|
2013-04-22 12:10:52 +07:00
|
|
|
|
|
|
|
void print_greeting(void)
|
|
|
|
{
|
2013-04-22 12:46:36 +07:00
|
|
|
printf("\r\n\
|
2013-04-22 12:10:52 +07:00
|
|
|
--------------------------------------------------------------------\
|
|
|
|
- Host Demo (a tinyusb example)\r\n\
|
|
|
|
- if you find any bugs or get any questions, feel free to file an\r\n\
|
|
|
|
- issue at https://github.com/hathach/tinyusb\r\n\
|
|
|
|
--------------------------------------------------------------------\r\n\r\n"
|
|
|
|
);
|
|
|
|
}
|