Quellcode durchsuchen

Add CONSOLE_ENABLE build option to LUFA.

tags/v1.9
tmk vor 12 Jahren
Ursprung
Commit
e075361b6f
6 geänderte Dateien mit 152 neuen und 96 gelöschten Zeilen
  1. 10
    6
      common.mk
  2. 2
    1
      keyboard/hhkb/Makefile.lufa
  3. 1
    1
      keyboard/hhkb/config.h
  4. 70
    60
      protocol/lufa/descriptor.c
  5. 35
    15
      protocol/lufa/descriptor.h
  6. 34
    13
      protocol/lufa/lufa.c

+ 10
- 6
common.mk Datei anzeigen

OPT_DEFS += -DMOUSEKEY_ENABLE OPT_DEFS += -DMOUSEKEY_ENABLE
endif endif


ifdef PS2_MOUSE_ENABLE
SRC += $(COMMON_DIR)/ps2.c \
$(COMMON_DIR)/ps2_mouse.c
OPT_DEFS += -DPS2_MOUSE_ENABLE
endif

ifdef EXTRAKEY_ENABLE ifdef EXTRAKEY_ENABLE
OPT_DEFS += -DEXTRAKEY_ENABLE OPT_DEFS += -DEXTRAKEY_ENABLE
endif endif


ifdef CONSOLE_ENABLE
OPT_DEFS += -DCONSOLE_ENABLE
endif

ifdef NKRO_ENABLE ifdef NKRO_ENABLE
OPT_DEFS += -DNKRO_ENABLE OPT_DEFS += -DNKRO_ENABLE
endif endif


ifdef PS2_MOUSE_ENABLE
SRC += $(COMMON_DIR)/ps2.c \
$(COMMON_DIR)/ps2_mouse.c
OPT_DEFS += -DPS2_MOUSE_ENABLE
endif

ifdef $(or MOUSEKEY_ENABLE, PS2_MOUSE_ENABLE) ifdef $(or MOUSEKEY_ENABLE, PS2_MOUSE_ENABLE)
OPT_DEFS += -DMOUSE_ENABLE OPT_DEFS += -DMOUSE_ENABLE
endif endif

+ 2
- 1
keyboard/hhkb/Makefile.lufa Datei anzeigen

# comment out to disable the options. # comment out to disable the options.
# #
MOUSEKEY_ENABLE = yes # Mouse keys MOUSEKEY_ENABLE = yes # Mouse keys
EXTRAKEY_ENABLE = yes # Audio control and System control
EXTRAKEY_ENABLE = yes # Media control and System control
CONSOLE_ENABLE = yes # Console for debug
#NKRO_ENABLE = yes # USB Nkey Rollover #NKRO_ENABLE = yes # USB Nkey Rollover
#PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support #PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support



+ 1
- 1
keyboard/hhkb/config.h Datei anzeigen



#define VENDOR_ID 0xFEED #define VENDOR_ID 0xFEED
#define PRODUCT_ID 0xCAFE #define PRODUCT_ID 0xCAFE
#define DEVICE_VER 0x0101
#define DEVICE_VER 0x0103
#define MANUFACTURER t.m.k. #define MANUFACTURER t.m.k.
#define PRODUCT HHKB mod #define PRODUCT HHKB mod



+ 70
- 60
protocol/lufa/descriptor.c Datei anzeigen

HID_RI_END_COLLECTION(0), HID_RI_END_COLLECTION(0),
}; };


#ifdef MOUSE_ENABLE
const USB_Descriptor_HIDReport_Datatype_t PROGMEM MouseReport[] = const USB_Descriptor_HIDReport_Datatype_t PROGMEM MouseReport[] =
{ {
HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */ HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */
HID_RI_END_COLLECTION(0), HID_RI_END_COLLECTION(0),
HID_RI_END_COLLECTION(0), HID_RI_END_COLLECTION(0),
}; };

const USB_Descriptor_HIDReport_Datatype_t PROGMEM ConsoleReport[] =
{
HID_RI_USAGE_PAGE(16, 0xFF31), /* Vendor Page(PJRC Teensy compatible) */
HID_RI_USAGE(8, 0x74), /* Vendor Usage(PJRC Teensy compatible) */
HID_RI_COLLECTION(8, 0x01), /* Application */
HID_RI_USAGE(8, 0x75), /* Vendor Usage 0x75 */
HID_RI_LOGICAL_MINIMUM(8, 0x00),
HID_RI_LOGICAL_MAXIMUM(8, 0xFF),
HID_RI_REPORT_COUNT(8, CONSOLE_EPSIZE),
HID_RI_REPORT_SIZE(8, 0x08),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
HID_RI_USAGE(8, 0x76), /* Vendor Usage 0x76 */
HID_RI_LOGICAL_MINIMUM(8, 0x00),
HID_RI_LOGICAL_MAXIMUM(8, 0xFF),
HID_RI_REPORT_COUNT(8, CONSOLE_EPSIZE),
HID_RI_REPORT_SIZE(8, 0x08),
HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
HID_RI_END_COLLECTION(0),
};
#endif


#ifdef EXTRAKEY_ENABLE #ifdef EXTRAKEY_ENABLE
const USB_Descriptor_HIDReport_Datatype_t PROGMEM ExtraReport[] =
const USB_Descriptor_HIDReport_Datatype_t PROGMEM ExtrakeyReport[] =
{ {
HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */ HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */
HID_RI_USAGE(8, 0x80), /* System Control */ HID_RI_USAGE(8, 0x80), /* System Control */
}; };
#endif #endif


#ifdef CONSOLE_ENABLE
const USB_Descriptor_HIDReport_Datatype_t PROGMEM ConsoleReport[] =
{
HID_RI_USAGE_PAGE(16, 0xFF31), /* Vendor Page(PJRC Teensy compatible) */
HID_RI_USAGE(8, 0x74), /* Vendor Usage(PJRC Teensy compatible) */
HID_RI_COLLECTION(8, 0x01), /* Application */
HID_RI_USAGE(8, 0x75), /* Vendor Usage 0x75 */
HID_RI_LOGICAL_MINIMUM(8, 0x00),
HID_RI_LOGICAL_MAXIMUM(8, 0xFF),
HID_RI_REPORT_COUNT(8, CONSOLE_EPSIZE),
HID_RI_REPORT_SIZE(8, 0x08),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
HID_RI_USAGE(8, 0x76), /* Vendor Usage 0x76 */
HID_RI_LOGICAL_MINIMUM(8, 0x00),
HID_RI_LOGICAL_MAXIMUM(8, 0xFF),
HID_RI_REPORT_COUNT(8, CONSOLE_EPSIZE),
HID_RI_REPORT_SIZE(8, 0x08),
HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
HID_RI_END_COLLECTION(0),
};
#endif

#ifdef NKRO_ENABLE #ifdef NKRO_ENABLE
const USB_Descriptor_HIDReport_Datatype_t PROGMEM NKROReport[] = const USB_Descriptor_HIDReport_Datatype_t PROGMEM NKROReport[] =
{ {
#endif #endif


/* /*
* Console
* Extra
*/ */
.Console_Interface =
#ifdef EXTRAKEY_ENABLE
.Extrakey_Interface =
{ {
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},


.InterfaceNumber = CONSOLE_INTERFACE,
.InterfaceNumber = EXTRAKEY_INTERFACE,
.AlternateSetting = 0x00, .AlternateSetting = 0x00,


.TotalEndpoints = 2,
.TotalEndpoints = 1,


.Class = HID_CSCP_HIDClass, .Class = HID_CSCP_HIDClass,
.SubClass = HID_CSCP_NonBootSubclass, .SubClass = HID_CSCP_NonBootSubclass,
.InterfaceStrIndex = NO_DESCRIPTOR .InterfaceStrIndex = NO_DESCRIPTOR
}, },


.Console_HID =
.Extrakey_HID =
{ {
.Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID}, .Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID},


.CountryCode = 0x00, .CountryCode = 0x00,
.TotalReportDescriptors = 1, .TotalReportDescriptors = 1,
.HIDReportType = HID_DTYPE_Report, .HIDReportType = HID_DTYPE_Report,
.HIDReportLength = sizeof(ConsoleReport)
.HIDReportLength = sizeof(ExtrakeyReport)
}, },


.Console_INEndpoint =
.Extrakey_INEndpoint =
{ {
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},


.EndpointAddress = (ENDPOINT_DIR_IN | CONSOLE_IN_EPNUM),
.EndpointAddress = (ENDPOINT_DIR_IN | EXTRAKEY_IN_EPNUM),
.Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
.EndpointSize = CONSOLE_EPSIZE,
.PollingIntervalMS = 0x01
},

.Console_OUTEndpoint =
{
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},

.EndpointAddress = (ENDPOINT_DIR_OUT | CONSOLE_OUT_EPNUM),
.Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
.EndpointSize = CONSOLE_EPSIZE,
.EndpointSize = EXTRAKEY_EPSIZE,
.PollingIntervalMS = 0x01 .PollingIntervalMS = 0x01
}, },
#endif


/* /*
* Extra
* Console
*/ */
#ifdef EXTRAKEY_ENABLE
.Extra_Interface =
#ifdef CONSOLE_ENABLE
.Console_Interface =
{ {
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},


.InterfaceNumber = EXTRA_INTERFACE,
.InterfaceNumber = CONSOLE_INTERFACE,
.AlternateSetting = 0x00, .AlternateSetting = 0x00,


.TotalEndpoints = 1,
.TotalEndpoints = 2,


.Class = HID_CSCP_HIDClass, .Class = HID_CSCP_HIDClass,
.SubClass = HID_CSCP_NonBootSubclass, .SubClass = HID_CSCP_NonBootSubclass,
.InterfaceStrIndex = NO_DESCRIPTOR .InterfaceStrIndex = NO_DESCRIPTOR
}, },


.Extra_HID =
.Console_HID =
{ {
.Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID}, .Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID},


.CountryCode = 0x00, .CountryCode = 0x00,
.TotalReportDescriptors = 1, .TotalReportDescriptors = 1,
.HIDReportType = HID_DTYPE_Report, .HIDReportType = HID_DTYPE_Report,
.HIDReportLength = sizeof(ExtraReport)
.HIDReportLength = sizeof(ConsoleReport)
}, },


.Extra_INEndpoint =
.Console_INEndpoint =
{ {
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},


.EndpointAddress = (ENDPOINT_DIR_IN | EXTRA_IN_EPNUM),
.EndpointAddress = (ENDPOINT_DIR_IN | CONSOLE_IN_EPNUM),
.Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
.EndpointSize = EXTRA_EPSIZE,
.EndpointSize = CONSOLE_EPSIZE,
.PollingIntervalMS = 0x01
},

.Console_OUTEndpoint =
{
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},

.EndpointAddress = (ENDPOINT_DIR_OUT | CONSOLE_OUT_EPNUM),
.Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
.EndpointSize = CONSOLE_EPSIZE,
.PollingIntervalMS = 0x01 .PollingIntervalMS = 0x01
}, },
#endif #endif
Size = sizeof(USB_HID_Descriptor_HID_t); Size = sizeof(USB_HID_Descriptor_HID_t);
break; break;
#endif #endif
case CONSOLE_INTERFACE:
Address = &ConfigurationDescriptor.Console_HID;
#ifdef EXTRAKEY_ENABLE
case EXTRAKEY_INTERFACE:
Address = &ConfigurationDescriptor.Extrakey_HID;
Size = sizeof(USB_HID_Descriptor_HID_t); Size = sizeof(USB_HID_Descriptor_HID_t);
break; break;
#ifdef EXTRAKEY_ENABLE
case EXTRA_INTERFACE:
Address = &ConfigurationDescriptor.Extra_HID;
#endif
#ifdef CONSOLE_ENABLE
case CONSOLE_INTERFACE:
Address = &ConfigurationDescriptor.Console_HID;
Size = sizeof(USB_HID_Descriptor_HID_t); Size = sizeof(USB_HID_Descriptor_HID_t);
break; break;
#endif #endif
Size = sizeof(MouseReport); Size = sizeof(MouseReport);
break; break;
#endif #endif
#ifdef EXTRAKEY_ENABLE
case EXTRAKEY_INTERFACE:
Address = &ExtrakeyReport;
Size = sizeof(ExtrakeyReport);
break;
#endif
#ifdef CONSOLE_ENABLE
case CONSOLE_INTERFACE: case CONSOLE_INTERFACE:
Address = &ConsoleReport; Address = &ConsoleReport;
Size = sizeof(ConsoleReport); Size = sizeof(ConsoleReport);
break; break;
#ifdef EXTRAKEY_ENABLE
case EXTRA_INTERFACE:
Address = &ExtraReport;
Size = sizeof(ExtraReport);
break;
#endif #endif
} }
break; break;

+ 35
- 15
protocol/lufa/descriptor.h Datei anzeigen

USB_HID_Descriptor_HID_t Keyboard_HID; USB_HID_Descriptor_HID_t Keyboard_HID;
USB_Descriptor_Endpoint_t Keyboard_INEndpoint; USB_Descriptor_Endpoint_t Keyboard_INEndpoint;


// Mouse HID Interface
#ifdef MOUSE_ENABLE #ifdef MOUSE_ENABLE
// Mouse HID Interface
USB_Descriptor_Interface_t Mouse_Interface; USB_Descriptor_Interface_t Mouse_Interface;
USB_HID_Descriptor_HID_t Mouse_HID; USB_HID_Descriptor_HID_t Mouse_HID;
USB_Descriptor_Endpoint_t Mouse_INEndpoint; USB_Descriptor_Endpoint_t Mouse_INEndpoint;
#endif #endif


#ifdef EXTRAKEY_ENABLE
// Extrakey HID Interface
USB_Descriptor_Interface_t Extrakey_Interface;
USB_HID_Descriptor_HID_t Extrakey_HID;
USB_Descriptor_Endpoint_t Extrakey_INEndpoint;
#endif

#ifdef CONSOLE_ENABLE
// Console HID Interface // Console HID Interface
USB_Descriptor_Interface_t Console_Interface; USB_Descriptor_Interface_t Console_Interface;
USB_HID_Descriptor_HID_t Console_HID; USB_HID_Descriptor_HID_t Console_HID;
USB_Descriptor_Endpoint_t Console_INEndpoint; USB_Descriptor_Endpoint_t Console_INEndpoint;
USB_Descriptor_Endpoint_t Console_OUTEndpoint; USB_Descriptor_Endpoint_t Console_OUTEndpoint;

// Extra HID Interface
#ifdef EXTRAKEY_ENABLE
USB_Descriptor_Interface_t Extra_Interface;
USB_HID_Descriptor_HID_t Extra_HID;
USB_Descriptor_Endpoint_t Extra_INEndpoint;
#endif #endif
} USB_Descriptor_Configuration_t; } USB_Descriptor_Configuration_t;


#endif #endif


#ifdef EXTRAKEY_ENABLE #ifdef EXTRAKEY_ENABLE
# define EXTRA_INTERFACE (MOUSE_INTERFACE + 1)
# define EXTRAKEY_INTERFACE (MOUSE_INTERFACE + 1)
#else #else
# define EXTRA_INTERFACE MOUSE_INTERFACE
# define EXTRAKEY_INTERFACE MOUSE_INTERFACE
#endif #endif


#define CONSOLE_INTERFACE (EXTRA_INTERFACE + 1)
#ifdef CONSOLE_ENABLE
# define CONSOLE_INTERFACE (EXTRAKEY_INTERFACE + 1)
#else
# define CONSOLE_INTERFACE EXTRAKEY_INTERFACE
#endif




/* nubmer of interfaces */ /* nubmer of interfaces */


// Endopoint number and size // Endopoint number and size
#define KEYBOARD_IN_EPNUM 1 #define KEYBOARD_IN_EPNUM 1
#define MOUSE_IN_EPNUM 2
#define CONSOLE_IN_EPNUM 3
#define CONSOLE_OUT_EPNUM 4
#define EXTRA_IN_EPNUM 5

#ifdef MOUSE_ENABLE
# define MOUSE_IN_EPNUM (KEYBOARD_IN_EPNUM + 1)
#else
# define MOUSE_IN_EPNUM KEYBOARD_IN_EPNUM
#endif

#ifdef EXTRAKEY_ENABLE
# define EXTRAKEY_IN_EPNUM (MOUSE_IN_EPNUM + 1)
#else
# define EXTRAKEY_IN_EPNUM MOUSE_IN_EPNUM
#endif

#ifdef CONSOLE_ENABLE
# define CONSOLE_IN_EPNUM (EXTRAKEY_IN_EPNUM + 1)
# define CONSOLE_OUT_EPNUM (EXTRAKEY_IN_EPNUM + 2)
#endif



#define KEYBOARD_EPSIZE 8 #define KEYBOARD_EPSIZE 8
#define MOUSE_EPSIZE 8 #define MOUSE_EPSIZE 8
#define EXTRAKEY_EPSIZE 8
#define CONSOLE_EPSIZE 32 #define CONSOLE_EPSIZE 32
#define EXTRA_EPSIZE 8




uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,

+ 34
- 13
protocol/lufa/lufa.c Datei anzeigen

USB_Device_EnableSOFEvents(); USB_Device_EnableSOFEvents();
} }


#ifdef CONSOLE_ENABLE
static void Console_Task(void) static void Console_Task(void)
{ {
/* Device must be connected and configured for the task to run */ /* Device must be connected and configured for the task to run */


/* IN packet */ /* IN packet */
Endpoint_SelectEndpoint(CONSOLE_IN_EPNUM); Endpoint_SelectEndpoint(CONSOLE_IN_EPNUM);

// fill empty bank
while (Endpoint_IsReadWriteAllowed())
Endpoint_Write_8(0);

// flash senchar packet // flash senchar packet
if (Endpoint_IsINReady()) { if (Endpoint_IsINReady()) {
Endpoint_ClearIN(); Endpoint_ClearIN();


Endpoint_SelectEndpoint(ep); Endpoint_SelectEndpoint(ep);
} }
#else
static void Console_Task(void)
{
}
#endif




/******************************************************************************* /*******************************************************************************
{ {
} }


#define CONSOLE_TASK_INTERVAL 50
void EVENT_USB_Device_StartOfFrame(void) void EVENT_USB_Device_StartOfFrame(void)
{ {
static uint8_t interval;
if (++interval == CONSOLE_TASK_INTERVAL) {
Console_Task();
interval = 0;
}
Console_Task();
} }


/** Event handler for the USB_ConfigurationChanged event. /** Event handler for the USB_ConfigurationChanged event.


#ifdef EXTRAKEY_ENABLE #ifdef EXTRAKEY_ENABLE
/* Setup Extra HID Report Endpoint */ /* Setup Extra HID Report Endpoint */
ConfigSuccess &= Endpoint_ConfigureEndpoint(EXTRA_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN,
EXTRA_EPSIZE, ENDPOINT_BANK_SINGLE);
ConfigSuccess &= Endpoint_ConfigureEndpoint(EXTRAKEY_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN,
EXTRAKEY_EPSIZE, ENDPOINT_BANK_SINGLE);
#endif #endif


#ifdef CONSOLE_ENABLE
/* Setup Console HID Report Endpoints */ /* Setup Console HID Report Endpoints */
ConfigSuccess &= Endpoint_ConfigureEndpoint(CONSOLE_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN, ConfigSuccess &= Endpoint_ConfigureEndpoint(CONSOLE_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN,
CONSOLE_EPSIZE, ENDPOINT_BANK_DOUBLE); CONSOLE_EPSIZE, ENDPOINT_BANK_DOUBLE);
ConfigSuccess &= Endpoint_ConfigureEndpoint(CONSOLE_OUT_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_OUT, ConfigSuccess &= Endpoint_ConfigureEndpoint(CONSOLE_OUT_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_OUT,
CONSOLE_EPSIZE, ENDPOINT_BANK_SINGLE); CONSOLE_EPSIZE, ENDPOINT_BANK_SINGLE);
#endif
} }


/* /*
.report_id = REPORT_ID_SYSTEM, .report_id = REPORT_ID_SYSTEM,
.usage = data .usage = data
}; };
Endpoint_SelectEndpoint(EXTRA_IN_EPNUM);
Endpoint_SelectEndpoint(EXTRAKEY_IN_EPNUM);
if (Endpoint_IsReadWriteAllowed()) { if (Endpoint_IsReadWriteAllowed()) {
Endpoint_Write_Stream_LE(&r, sizeof(report_extra_t), NULL); Endpoint_Write_Stream_LE(&r, sizeof(report_extra_t), NULL);
Endpoint_ClearIN(); Endpoint_ClearIN();
.report_id = REPORT_ID_CONSUMER, .report_id = REPORT_ID_CONSUMER,
.usage = data .usage = data
}; };
Endpoint_SelectEndpoint(EXTRA_IN_EPNUM);
Endpoint_SelectEndpoint(EXTRAKEY_IN_EPNUM);
if (Endpoint_IsReadWriteAllowed()) { if (Endpoint_IsReadWriteAllowed()) {
Endpoint_Write_Stream_LE(&r, sizeof(report_extra_t), NULL); Endpoint_Write_Stream_LE(&r, sizeof(report_extra_t), NULL);
Endpoint_ClearIN(); Endpoint_ClearIN();
/******************************************************************************* /*******************************************************************************
* sendchar * sendchar
******************************************************************************/ ******************************************************************************/
#define SEND_TIMEOUT 10
#ifdef CONSOLE_ENABLE
#define SEND_TIMEOUT 5
int8_t sendchar(uint8_t c) int8_t sendchar(uint8_t c)
{ {
if (USB_DeviceState != DEVICE_STATE_Configured) if (USB_DeviceState != DEVICE_STATE_Configured)
return -1; return -1;


uint8_t ep = Endpoint_GetCurrentEndpoint();
Endpoint_SelectEndpoint(CONSOLE_IN_EPNUM); Endpoint_SelectEndpoint(CONSOLE_IN_EPNUM);


uint8_t timeout = SEND_TIMEOUT; uint8_t timeout = SEND_TIMEOUT;
case DEVICE_STATE_Suspended: case DEVICE_STATE_Suspended:
return -1; return -1;
} }
if (Endpoint_IsStalled())
if (Endpoint_IsStalled()) {
Endpoint_SelectEndpoint(ep);
return -1; return -1;
}
if (prevFN != USB_Device_GetFrameNumber()) { if (prevFN != USB_Device_GetFrameNumber()) {
if (!(timeout--))
if (!(timeout--)) {
Endpoint_SelectEndpoint(ep);
return -1; return -1;
}
prevFN = USB_Device_GetFrameNumber(); prevFN = USB_Device_GetFrameNumber();
} }
} }
if (!Endpoint_IsReadWriteAllowed()) if (!Endpoint_IsReadWriteAllowed())
Endpoint_ClearIN(); Endpoint_ClearIN();


Endpoint_SelectEndpoint(ep);
return 0;
}
#else
int8_t sendchar(uint8_t c)
{
return 0; return 0;
} }
#endif

Laden…
Abbrechen
Speichern