diff options
| author | hathach <[email protected]> | 2013-04-22 12:10:52 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2013-04-22 12:10:52 +0700 |
| commit | 8cc4c6f52d61abaadec99dbcc9f20f566982db2b (patch) | |
| tree | ebabfef0e91807c5866ec3da2cf709f144e0c85b /demos/host/src | |
| parent | 799c709524132cbf3442ce5c49fbf844f8ac0e70 (diff) | |
change the board_leds API to on_mask, off_mask
getting led toggling per second on host demo
add greeting message
Diffstat (limited to 'demos/host/src')
| -rw-r--r-- | demos/host/src/main.c | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/demos/host/src/main.c b/demos/host/src/main.c index 3e5110a39..35cb0eacc 100644 --- a/demos/host/src/main.c +++ b/demos/host/src/main.c @@ -17,18 +17,20 @@ __CRP const unsigned int CRP_WORD = CRP_NO_CRP ; #endif +void print_greeting(void); int main(void) { uint32_t current_tick = system_ticks; board_init(); + print_greeting(); + tusb_init(); //------------- application task init -------------// keyboard_app_init(); mouse_app_init(); - printf("reset\n"); while (1) { tusb_task_runner(); @@ -37,17 +39,30 @@ int main(void) 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) + current_tick += CFG_TICKS_PER_SECOND; + + /* Toggle LED once per second */ + if ( (current_tick/CFG_TICKS_PER_SECOND) % 2) { - printf("tinyusb: " __DATE__ "\t" __TIME__ "\n"); // toggle leds on EA4357 is quite troublesome + board_leds(0x01, 0x00); + } + else + { + board_leds(0x00, 0x01); } - - current_tick += CFG_TICKS_PER_SECOND; - board_leds(0x01, (current_tick/CFG_TICKS_PER_SECOND)%2); /* Toggle LED once per second */ } } return 0; } + +void print_greeting(void) +{ + printf("\ +--------------------------------------------------------------------\ +- 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" + ); +} |
