summaryrefslogtreecommitdiff
path: root/tmk_core/protocol
diff options
context:
space:
mode:
Diffstat (limited to 'tmk_core/protocol')
-rw-r--r--tmk_core/protocol/vusb.mk7
-rw-r--r--tmk_core/protocol/vusb/main.c37
-rw-r--r--tmk_core/protocol/vusb/sendchar_usart.c19
-rw-r--r--tmk_core/protocol/vusb/vusb.c102
4 files changed, 53 insertions, 112 deletions
diff --git a/tmk_core/protocol/vusb.mk b/tmk_core/protocol/vusb.mk
index 5e564f7480..1de6003089 100644
--- a/tmk_core/protocol/vusb.mk
+++ b/tmk_core/protocol/vusb.mk
@@ -9,13 +9,6 @@ SRC += $(VUSB_DIR)/main.c \
$(VUSB_PATH)/usbdrv/usbdrvasm.S \
$(VUSB_PATH)/usbdrv/oddebug.c
-ifneq ($(strip $(CONSOLE_ENABLE)), yes)
-ifndef NO_UART
-SRC += $(COMMON_DIR)/sendchar_uart.c \
- $(COMMON_DIR)/uart.c
-endif
-endif
-
# Search Path
VPATH += $(TMK_PATH)/$(VUSB_DIR)
VPATH += $(VUSB_PATH)
diff --git a/tmk_core/protocol/vusb/main.c b/tmk_core/protocol/vusb/main.c
index b4063273da..a57df5ce06 100644
--- a/tmk_core/protocol/vusb/main.c
+++ b/tmk_core/protocol/vusb/main.c
@@ -7,19 +7,22 @@
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
* This Revision: $Id: main.c 790 2010-05-30 21:00:26Z cs $
*/
+
#include <stdint.h>
+
#include <avr/interrupt.h>
+#include <avr/power.h>
#include <avr/wdt.h>
#include <avr/sleep.h>
-#include <util/delay.h>
+
#include <usbdrv/usbdrv.h>
-#include <usbdrv/oddebug.h>
+
#include "vusb.h"
+
#include "keyboard.h"
#include "host.h"
#include "timer.h"
-#include "uart.h"
-#include "debug.h"
+#include "print.h"
#include "suspend.h"
#include "wait.h"
#include "sendchar.h"
@@ -28,8 +31,6 @@
# include "sleep_led.h"
#endif
-#define UART_BAUD_RATE 115200
-
#ifdef CONSOLE_ENABLE
void console_task(void);
#endif
@@ -47,7 +48,7 @@ static void initForUsbConnectivity(void) {
usbDeviceDisconnect(); /* do this while interrupts are disabled */
while (--i) { /* fake USB disconnect for > 250 ms */
wdt_reset();
- _delay_ms(1);
+ wait_ms(1);
}
usbDeviceConnect();
}
@@ -60,7 +61,7 @@ static void usb_remote_wakeup(void) {
USBDDR = ddr_orig | USBMASK;
USBOUT ^= USBMASK;
- _delay_ms(25);
+ wait_ms(25);
USBOUT ^= USBMASK;
USBDDR = ddr_orig;
@@ -74,7 +75,6 @@ static void usb_remote_wakeup(void) {
* FIXME: Needs doc
*/
static void setup_usb(void) {
- // debug("initForUsbConnectivity()\n");
initForUsbConnectivity();
// for Console_Task
@@ -95,10 +95,7 @@ int main(void) {
#ifdef CLKPR
// avoid unintentional changes of clock frequency in devices that have a
// clock prescaler
- CLKPR = 0x80, CLKPR = 0;
-#endif
-#ifndef NO_UART
- uart_init(UART_BAUD_RATE);
+ clock_prescale_set(clock_div_1);
#endif
keyboard_setup();
@@ -113,7 +110,6 @@ int main(void) {
sleep_led_init();
#endif
- debug("main loop\n");
while (1) {
#if USB_COUNT_SOF
if (usbSofCount != 0) {
@@ -130,19 +126,6 @@ int main(void) {
# ifdef SLEEP_LED_ENABLE
sleep_led_enable();
# endif
- /*
- uart_putchar('S');
- _delay_ms(1);
- cli();
- set_sleep_mode(SLEEP_MODE_PWR_DOWN);
- sleep_enable();
- sleep_bod_disable();
- sei();
- sleep_cpu();
- sleep_disable();
- _delay_ms(10);
- uart_putchar('W');
- */
}
}
#endif
diff --git a/tmk_core/protocol/vusb/sendchar_usart.c b/tmk_core/protocol/vusb/sendchar_usart.c
deleted file mode 100644
index a920a9a536..0000000000
--- a/tmk_core/protocol/vusb/sendchar_usart.c
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH
- * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
- */
-#include <stdint.h>
-#include <usbdrv/oddebug.h>
-#include "sendchar.h"
-
-#if DEBUG_LEVEL > 0
-/* from oddebug.c */
-int8_t sendchar(uint8_t c) {
- while (!(ODDBG_USR & (1 << ODDBG_UDRE)))
- ; /* wait for data register empty */
- ODDBG_UDR = c;
- return 1;
-}
-#else
-int8_t sendchar(uint8_t c) { return 1; }
-#endif
diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c
index f4727a0c38..735a1c1d30 100644
--- a/tmk_core/protocol/vusb/vusb.c
+++ b/tmk_core/protocol/vusb/vusb.c
@@ -15,10 +15,12 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <avr/wdt.h>
-#include <util/delay.h>
#include <stdint.h>
+
+#include <avr/wdt.h>
+
#include <usbdrv/usbdrv.h>
+
#include "usbconfig.h"
#include "host.h"
#include "report.h"
@@ -26,6 +28,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "vusb.h"
#include "print.h"
#include "debug.h"
+#include "wait.h"
#include "usb_descriptor_common.h"
#ifdef RAW_ENABLE
@@ -56,7 +59,7 @@ enum usb_interfaces {
#ifdef CONSOLE_ENABLE
CONSOLE_INTERFACE = NEXT_INTERFACE,
#endif
- TOTAL_INTERFACES = NEXT_INTERFACE,
+ TOTAL_INTERFACES = NEXT_INTERFACE
};
#define MAX_INTERFACES 2
@@ -86,19 +89,13 @@ void vusb_transfer_keyboard(void) {
usbSetInterrupt((void *)&kbuf[kbuf_tail], sizeof(report_keyboard_t));
kbuf_tail = (kbuf_tail + 1) % KBUF_SIZE;
if (debug_keyboard) {
- print("V-USB: kbuf[");
- pdec(kbuf_tail);
- print("->");
- pdec(kbuf_head);
- print("](");
- phex((kbuf_head < kbuf_tail) ? (KBUF_SIZE - kbuf_tail + kbuf_head) : (kbuf_head - kbuf_tail));
- print(")\n");
+ dprintf("V-USB: kbuf[%d->%d](%02X)\n", kbuf_tail, kbuf_head, (kbuf_head < kbuf_tail) ? (KBUF_SIZE - kbuf_tail + kbuf_head) : (kbuf_head - kbuf_tail));
}
}
break;
}
usbPoll();
- _delay_ms(1);
+ wait_ms(1);
}
}
@@ -220,7 +217,7 @@ static void send_keyboard(report_keyboard_t *report) {
kbuf[kbuf_head] = *report;
kbuf_head = next;
} else {
- debug("kbuf: full\n");
+ dprint("kbuf: full\n");
}
// NOTE: send key strokes of Macro
@@ -283,37 +280,35 @@ usbMsgLen_t usbFunctionSetup(uchar data[8]) {
if ((rq->bmRequestType & USBRQ_TYPE_MASK) == USBRQ_TYPE_CLASS) { /* class request type */
if (rq->bRequest == USBRQ_HID_GET_REPORT) {
- debug("GET_REPORT:");
+ dprint("GET_REPORT:");
if (rq->wIndex.word == KEYBOARD_INTERFACE) {
usbMsgPtr = (usbMsgPtr_t)&keyboard_report_sent;
return sizeof(keyboard_report_sent);
}
} else if (rq->bRequest == USBRQ_HID_GET_IDLE) {
- debug("GET_IDLE: ");
- // debug_hex(vusb_idle_rate);
+ dprint("GET_IDLE:");
usbMsgPtr = (usbMsgPtr_t)&vusb_idle_rate;
return 1;
} else if (rq->bRequest == USBRQ_HID_SET_IDLE) {
vusb_idle_rate = rq->wValue.bytes[1];
- debug("SET_IDLE: ");
- debug_hex(vusb_idle_rate);
+ dprintf("SET_IDLE: %02X", vusb_idle_rate);
} else if (rq->bRequest == USBRQ_HID_SET_REPORT) {
- debug("SET_REPORT: ");
+ dprint("SET_REPORT:");
// Report Type: 0x02(Out)/ReportID: 0x00(none) && Interface: 0(keyboard)
if (rq->wValue.word == 0x0200 && rq->wIndex.word == KEYBOARD_INTERFACE) {
- debug("SET_LED: ");
+ dprint("SET_LED:");
last_req.kind = SET_LED;
last_req.len = rq->wLength.word;
}
return USB_NO_MSG; // to get data in usbFunctionWrite
} else {
- debug("UNKNOWN:");
+ dprint("UNKNOWN:");
}
} else {
- debug("VENDOR:");
+ dprint("VENDOR:");
/* no vendor specific requests implemented */
}
- debug("\n");
+ dprint("\n");
return 0; /* default for not implemented requests: return no data back to host */
}
@@ -323,9 +318,7 @@ uchar usbFunctionWrite(uchar *data, uchar len) {
}
switch (last_req.kind) {
case SET_LED:
- debug("SET_LED: ");
- debug_hex(data[0]);
- debug("\n");
+ dprintf("SET_LED: %02X\n", data[0]);
keyboard_led_state = data[0];
last_req.len = 0;
return 1;
@@ -342,13 +335,13 @@ void usbFunctionWriteOut(uchar *data, uchar len) {
#ifdef RAW_ENABLE
// Data from host must be divided every 8bytes
if (len != 8) {
- debug("RAW: invalid length");
+ dprint("RAW: invalid length\n");
raw_output_received_bytes = 0;
return;
}
if (raw_output_received_bytes + len > RAW_BUFFER_SIZE) {
- debug("RAW: buffer full");
+ dprint("RAW: buffer full\n");
raw_output_received_bytes = 0;
} else {
for (uint8_t i = 0; i < 8; i++) {
@@ -404,29 +397,6 @@ const PROGMEM uchar keyboard_hid_report[] = {
0xC0 // End Collection
};
-#ifdef RAW_ENABLE
-const PROGMEM uchar raw_hid_report[] = {
- 0x06, RAW_USAGE_PAGE_LO, RAW_USAGE_PAGE_HI, // Usage Page (Vendor Defined)
- 0x09, RAW_USAGE_ID, // Usage (Vendor Defined)
- 0xA1, 0x01, // Collection (Application)
- // Data to host
- 0x09, 0x62, // Usage (Vendor Defined)
- 0x15, 0x00, // Logical Minimum (0)
- 0x26, 0xFF, 0x00, // Logical Maximum (255)
- 0x95, RAW_BUFFER_SIZE, // Report Count
- 0x75, 0x08, // Report Size (8)
- 0x81, 0x02, // Input (Data, Variable, Absolute)
- // Data from host
- 0x09, 0x63, // Usage (Vendor Defined)
- 0x15, 0x00, // Logical Minimum (0)
- 0x26, 0xFF, 0x00, // Logical Maximum (255)
- 0x95, RAW_BUFFER_SIZE, // Report Count
- 0x75, 0x08, // Report Size (8)
- 0x91, 0x02, // Output (Data, Variable, Absolute)
- 0xC0 // End Collection
-};
-#endif
-
#if defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE)
const PROGMEM uchar mouse_extra_hid_report[] = {
# ifdef MOUSE_ENABLE
@@ -511,6 +481,29 @@ const PROGMEM uchar mouse_extra_hid_report[] = {
};
#endif
+#ifdef RAW_ENABLE
+const PROGMEM uchar raw_hid_report[] = {
+ 0x06, RAW_USAGE_PAGE_LO, RAW_USAGE_PAGE_HI, // Usage Page (Vendor Defined)
+ 0x09, RAW_USAGE_ID, // Usage (Vendor Defined)
+ 0xA1, 0x01, // Collection (Application)
+ // Data to host
+ 0x09, 0x62, // Usage (Vendor Defined)
+ 0x15, 0x00, // Logical Minimum (0)
+ 0x26, 0xFF, 0x00, // Logical Maximum (255)
+ 0x95, RAW_BUFFER_SIZE, // Report Count
+ 0x75, 0x08, // Report Size (8)
+ 0x81, 0x02, // Input (Data, Variable, Absolute)
+ // Data from host
+ 0x09, 0x63, // Usage (Vendor Defined)
+ 0x15, 0x00, // Logical Minimum (0)
+ 0x26, 0xFF, 0x00, // Logical Maximum (255)
+ 0x95, RAW_BUFFER_SIZE, // Report Count
+ 0x75, 0x08, // Report Size (8)
+ 0x91, 0x02, // Output (Data, Variable, Absolute)
+ 0xC0 // End Collection
+};
+#endif
+
#if defined(CONSOLE_ENABLE)
const PROGMEM uchar console_hid_report[] = {
0x06, 0x31, 0xFF, // Usage Page (Vendor Defined - PJRC Teensy compatible)
@@ -801,14 +794,6 @@ const PROGMEM usbConfigurationDescriptor_t usbConfigurationDescriptor = {
USB_PUBLIC usbMsgLen_t usbFunctionDescriptor(struct usbRequest *rq) {
usbMsgLen_t len = 0;
- /*
- debug("usbFunctionDescriptor: ");
- debug_hex(rq->bmRequestType); debug(" ");
- debug_hex(rq->bRequest); debug(" ");
- debug_hex16(rq->wValue.word); debug(" ");
- debug_hex16(rq->wIndex.word); debug(" ");
- debug_hex16(rq->wLength.word); debug("\n");
- */
switch (rq->wValue.bytes[1]) {
case USBDESCR_DEVICE:
usbMsgPtr = (usbMsgPtr_t)&usbDeviceDescriptor;
@@ -892,6 +877,5 @@ USB_PUBLIC usbMsgLen_t usbFunctionDescriptor(struct usbRequest *rq) {
}
break;
}
- // debug("desc len: "); debug_hex(len); debug("\n");
return len;
}