make the whole debug interface conditional

master
Stefan Dorn 2016-06-13 23:39:48 +01:00
parent 6a2057e1da
commit b5c9da488a
1 changed files with 16 additions and 1 deletions

View File

@ -557,7 +557,9 @@ static const uint8_t PROGMEM endpoint_config_table[] = {
// enable, UECFG0X(type, direction), UECFG1X(size, bank, allocation)
1, EP_TYPE_INTERRUPT_IN, EP_SIZE(KEYBOARD_SIZE) | KEYBOARD_BUFFER, // 1
1, EP_TYPE_INTERRUPT_IN, EP_SIZE(EXTRA_SIZE) | EXTRA_BUFFER, // 2
#ifdef KBD_DEBUG
1, EP_TYPE_INTERRUPT_IN, EP_SIZE(DEBUG_TX_SIZE) | DEBUG_TX_BUFFER, // 3
#endif
0
};
@ -647,6 +649,7 @@ static const uint8_t PROGMEM extra_hid_report_desc[] = {
};
// debug messages
#ifdef KBD_DEBUG
static const uint8_t PROGMEM debug_hid_report_desc[] = {
0x06, 0x31, 0xFF, // Usage Page 0xFF31 (vendor defined)
0x09, 0x74, // Usage 0x74
@ -659,12 +662,18 @@ static const uint8_t PROGMEM debug_hid_report_desc[] = {
0x81, 0x02, // Input (array)
0xC0 // end collection
};
#endif
#ifdef KBD_DEBUG
#define KEYBOARD_HID_DESC_NUM 0
#define EXTRA_HID_DESC_NUM 1
#define DEBUG_HID_DESC_NUM 2
#define NUM_INTERFACES 3
#else
#define KEYBOARD_HID_DESC_NUM 0
#define EXTRA_HID_DESC_NUM 1
#define NUM_INTERFACES 2
#endif
#define KEYBOARD_HID_DESC_OFFSET (9+(9+9+7)*KEYBOARD_HID_DESC_NUM+9)
#define EXTRA_HID_DESC_OFFSET (9+(9+9+7)*EXTRA_HID_DESC_NUM+9)
@ -737,6 +746,7 @@ static const uint8_t PROGMEM config1_descriptor[CONFIG1_DESC_SIZE] = {
EXTRA_SIZE, 0, // wMaxPacketSize
10, // bInterval
#ifdef KBD_DEBUG
// interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12
9, // bLength
4, // bDescriptorType
@ -763,6 +773,7 @@ static const uint8_t PROGMEM config1_descriptor[CONFIG1_DESC_SIZE] = {
0x03, // bmAttributes (0x03=intr)
DEBUG_TX_SIZE, 0, // wMaxPacketSize
1, // bInterval
#endif
};
// If you're desperate for a little extra code memory, these strings
@ -798,9 +809,11 @@ static struct descriptor_list_struct {
// Extra HID Descriptor
{0x2100, EXTRA_INTERFACE, config1_descriptor + EXTRA_HID_DESC_OFFSET, 9},
{0x2200, EXTRA_INTERFACE, extra_hid_report_desc, sizeof(extra_hid_report_desc)},
#ifdef KBD_DEBUG
// debug descriptors
{0x2100, DEBUG_INTERFACE, config1_descriptor+DEBUG_HID_DESC_OFFSET, 9},
{0x2200, DEBUG_INTERFACE, debug_hid_report_desc, sizeof(debug_hid_report_desc)},
#endif
// STRING descriptors
{0x0300, 0x0000, (const uint8_t *)&string0, 4},
{0x0301, 0x0409, (const uint8_t *)&string1, sizeof(STR_MANUFACTURER)},
@ -1211,6 +1224,7 @@ int8_t usb_extra_consumer_send() {
// debug
// --------------------------------------------------------
#ifdef KBD_DEBUG
// transmit a character. 0 returned on success, -1 on error
int8_t usb_debug_putchar(uint8_t c) {
static uint8_t previous_timeout = 0;
@ -1294,6 +1308,7 @@ void debug_print_ptr(const char *s) {
}
usb_debug_flush_output();
}
#endif
#ifdef KBD_DEBUG
#define debug_print(s) debug_print_ptr(PSTR(s))