2012-11-27 17:51:59 +07:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <cr_section_macros.h>
|
|
|
|
#include <NXP/crp.h>
|
2012-12-07 17:59:46 +07:00
|
|
|
#include "boards/board.h"
|
2012-11-27 17:51:59 +07:00
|
|
|
#include "tusb.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 ;
|
|
|
|
|
|
|
|
int main(void)
|
|
|
|
{
|
2012-12-18 15:08:30 +07:00
|
|
|
uint32_t current_tick = system_ticks;
|
2012-11-28 11:53:23 +07:00
|
|
|
|
2012-12-04 18:18:29 +07:00
|
|
|
board_init();
|
2012-11-27 17:51:59 +07:00
|
|
|
tusb_init();
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
{
|
2012-12-18 15:08:30 +07:00
|
|
|
if (current_tick + 1000 < system_ticks)
|
2012-11-28 11:53:23 +07:00
|
|
|
{
|
2012-12-07 17:59:46 +07:00
|
|
|
current_tick += 1000;
|
|
|
|
board_leds(0x01, (current_tick/1000)%2); /* Toggle LED once per second */
|
2012-11-28 11:53:23 +07:00
|
|
|
|
2013-01-17 14:40:46 +07:00
|
|
|
printf("tinyusb: " __DATE__ "\t" __TIME__ "\n");
|
2012-12-18 15:08:30 +07:00
|
|
|
|
2013-01-17 14:40:46 +07:00
|
|
|
#if !(defined TUSB_CFG_DEVICE_CDC) && 0
|
2012-11-28 11:53:23 +07:00
|
|
|
if (usb_isConfigured())
|
|
|
|
{
|
2012-12-20 16:59:43 +07:00
|
|
|
#ifdef TUSB_CFG_DEVICE_HID_KEYBOARD
|
2012-11-28 11:53:23 +07:00
|
|
|
uint8_t keys[6] = {HID_USAGE_KEYBOARD_aA};
|
2012-11-29 17:52:57 +07:00
|
|
|
tusb_hid_keyboard_sendKeys(0x00, keys, 1);
|
2012-11-28 11:53:23 +07:00
|
|
|
#endif
|
2012-11-27 17:51:59 +07:00
|
|
|
|
2012-12-20 16:59:43 +07:00
|
|
|
#ifdef TUSB_CFG_DEVICE_HID_MOUSE
|
2012-11-29 17:52:57 +07:00
|
|
|
tusb_hid_mouse_send(0, 10, 10);
|
2012-11-28 11:53:23 +07:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
2012-11-29 17:52:57 +07:00
|
|
|
|
2013-01-17 14:40:46 +07:00
|
|
|
#if defined TUSB_CFG_DEVICE_CDC && 0
|
2012-12-07 10:53:52 +07:00
|
|
|
if (usb_isConfigured())
|
|
|
|
{
|
|
|
|
uint8_t cdc_char;
|
|
|
|
if( tusb_cdc_getc(&cdc_char) )
|
|
|
|
{
|
|
|
|
switch (cdc_char)
|
|
|
|
{
|
2012-12-20 16:59:43 +07:00
|
|
|
#ifdef TUSB_CFG_DEVICE_HID_KEYBOARD
|
2012-12-07 10:53:52 +07:00
|
|
|
case '1' :
|
|
|
|
{
|
|
|
|
uint8_t keys[6] = {HID_USAGE_KEYBOARD_aA + 'e' - 'a'};
|
|
|
|
tusb_hid_keyboard_sendKeys(0x08, keys, 1); // windows + E --> open explorer
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
|
2012-12-20 16:59:43 +07:00
|
|
|
#ifdef TUSB_CFG_DEVICE_HID_MOUSE
|
2012-12-07 10:53:52 +07:00
|
|
|
case '2' :
|
|
|
|
tusb_hid_mouse_send(0, 10, 10);
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
default :
|
|
|
|
cdc_char = toupper(cdc_char);
|
|
|
|
tusb_cdc_putc(cdc_char);
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2012-11-27 17:51:59 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|