aboutsummaryrefslogtreecommitdiff
path: root/tmk_core/protocol/vusb/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'tmk_core/protocol/vusb/main.c')
-rw-r--r--tmk_core/protocol/vusb/main.c37
1 files changed, 10 insertions, 27 deletions
diff --git a/tmk_core/protocol/vusb/main.c b/tmk_core/protocol/vusb/main.c
index b4063273d..a57df5ce0 100644
--- a/tmk_core/protocol/vusb/main.c
+++ b/tmk_core/protocol/vusb/main.c
@@ -7,19 +7,22 @@
7 * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) 7 * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
8 * This Revision: $Id: main.c 790 2010-05-30 21:00:26Z cs $ 8 * This Revision: $Id: main.c 790 2010-05-30 21:00:26Z cs $
9 */ 9 */
10
10#include <stdint.h> 11#include <stdint.h>
12
11#include <avr/interrupt.h> 13#include <avr/interrupt.h>
14#include <avr/power.h>
12#include <avr/wdt.h> 15#include <avr/wdt.h>
13#include <avr/sleep.h> 16#include <avr/sleep.h>
14#include <util/delay.h> 17
15#include <usbdrv/usbdrv.h> 18#include <usbdrv/usbdrv.h>
16#include <usbdrv/oddebug.h> 19
17#include "vusb.h" 20#include "vusb.h"
21
18#include "keyboard.h" 22#include "keyboard.h"
19#include "host.h" 23#include "host.h"
20#include "timer.h" 24#include "timer.h"
21#include "uart.h" 25#include "print.h"
22#include "debug.h"
23#include "suspend.h" 26#include "suspend.h"
24#include "wait.h" 27#include "wait.h"
25#include "sendchar.h" 28#include "sendchar.h"
@@ -28,8 +31,6 @@
28# include "sleep_led.h" 31# include "sleep_led.h"
29#endif 32#endif
30 33
31#define UART_BAUD_RATE 115200
32
33#ifdef CONSOLE_ENABLE 34#ifdef CONSOLE_ENABLE
34void console_task(void); 35void console_task(void);
35#endif 36#endif
@@ -47,7 +48,7 @@ static void initForUsbConnectivity(void) {
47 usbDeviceDisconnect(); /* do this while interrupts are disabled */ 48 usbDeviceDisconnect(); /* do this while interrupts are disabled */
48 while (--i) { /* fake USB disconnect for > 250 ms */ 49 while (--i) { /* fake USB disconnect for > 250 ms */
49 wdt_reset(); 50 wdt_reset();
50 _delay_ms(1); 51 wait_ms(1);
51 } 52 }
52 usbDeviceConnect(); 53 usbDeviceConnect();
53} 54}
@@ -60,7 +61,7 @@ static void usb_remote_wakeup(void) {
60 USBDDR = ddr_orig | USBMASK; 61 USBDDR = ddr_orig | USBMASK;
61 USBOUT ^= USBMASK; 62 USBOUT ^= USBMASK;
62 63
63 _delay_ms(25); 64 wait_ms(25);
64 65
65 USBOUT ^= USBMASK; 66 USBOUT ^= USBMASK;
66 USBDDR = ddr_orig; 67 USBDDR = ddr_orig;
@@ -74,7 +75,6 @@ static void usb_remote_wakeup(void) {
74 * FIXME: Needs doc 75 * FIXME: Needs doc
75 */ 76 */
76static void setup_usb(void) { 77static void setup_usb(void) {
77 // debug("initForUsbConnectivity()\n");
78 initForUsbConnectivity(); 78 initForUsbConnectivity();
79 79
80 // for Console_Task 80 // for Console_Task
@@ -95,10 +95,7 @@ int main(void) {
95#ifdef CLKPR 95#ifdef CLKPR
96 // avoid unintentional changes of clock frequency in devices that have a 96 // avoid unintentional changes of clock frequency in devices that have a
97 // clock prescaler 97 // clock prescaler
98 CLKPR = 0x80, CLKPR = 0; 98 clock_prescale_set(clock_div_1);
99#endif
100#ifndef NO_UART
101 uart_init(UART_BAUD_RATE);
102#endif 99#endif
103 keyboard_setup(); 100 keyboard_setup();
104 101
@@ -113,7 +110,6 @@ int main(void) {
113 sleep_led_init(); 110 sleep_led_init();
114#endif 111#endif
115 112
116 debug("main loop\n");
117 while (1) { 113 while (1) {
118#if USB_COUNT_SOF 114#if USB_COUNT_SOF
119 if (usbSofCount != 0) { 115 if (usbSofCount != 0) {
@@ -130,19 +126,6 @@ int main(void) {
130# ifdef SLEEP_LED_ENABLE 126# ifdef SLEEP_LED_ENABLE
131 sleep_led_enable(); 127 sleep_led_enable();
132# endif 128# endif
133 /*
134 uart_putchar('S');
135 _delay_ms(1);
136 cli();
137 set_sleep_mode(SLEEP_MODE_PWR_DOWN);
138 sleep_enable();
139 sleep_bod_disable();
140 sei();
141 sleep_cpu();
142 sleep_disable();
143 _delay_ms(10);
144 uart_putchar('W');
145 */
146 } 129 }
147 } 130 }
148#endif 131#endif