aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--os/hal/include/usb.h12
-rw-r--r--os/hal/src/serial_usb.c14
-rw-r--r--os/hal/src/usb.c88
-rw-r--r--testhal/STM32/STM32F30x/USB_CDC_IAD/Makefile2
-rw-r--r--testhal/STM32/STM32F30x/USB_CDC_IAD/debug/STM32F30x-USB_CDC_IAD (OpenOCD, Flash and Run).launch2
-rw-r--r--testhal/STM32/STM32F30x/USB_CDC_IAD/main.c6
-rw-r--r--testhal/STM32/STM32F30x/USB_CDC_IAD/usbcfg.c40
7 files changed, 88 insertions, 76 deletions
diff --git a/os/hal/include/usb.h b/os/hal/include/usb.h
index a52480135..c85506403 100644
--- a/os/hal/include/usb.h
+++ b/os/hal/include/usb.h
@@ -349,8 +349,8 @@ typedef void (*usbeventcb_t)(USBDriver *usbp, usbevent_t event);
* @param[in] usbp pointer to the @p USBDriver object triggering the
* callback
* @return The request handling exit code.
- * @retval FALSE Request not recognized by the handler.
- * @retval TRUE Request handled.
+ * @retval false Request not recognized by the handler.
+ * @retval true Request handled.
*/
typedef bool (*usbreqhandler_t)(USBDriver *usbp);
@@ -425,8 +425,8 @@ typedef const USBDescriptor * (*usbgetdescriptor_t)(USBDriver *usbp,
* @param[in] usbp pointer to the @p USBDriver object
* @param[in] ep endpoint number
* @return The operation status.
- * @retval FALSE Endpoint ready.
- * @retval TRUE Endpoint transmitting.
+ * @retval false Endpoint ready.
+ * @retval true Endpoint transmitting.
*
* @iclass
*/
@@ -438,8 +438,8 @@ typedef const USBDescriptor * (*usbgetdescriptor_t)(USBDriver *usbp,
* @param[in] usbp pointer to the @p USBDriver object
* @param[in] ep endpoint number
* @return The operation status.
- * @retval FALSE Endpoint ready.
- * @retval TRUE Endpoint receiving.
+ * @retval false Endpoint ready.
+ * @retval true Endpoint receiving.
*
* @iclass
*/
diff --git a/os/hal/src/serial_usb.c b/os/hal/src/serial_usb.c
index a4b943f6a..7f837d37d 100644
--- a/os/hal/src/serial_usb.c
+++ b/os/hal/src/serial_usb.c
@@ -289,8 +289,8 @@ void sduConfigureHookI(SerialUSBDriver *sdup) {
*
* @param[in] usbp pointer to the @p USBDriver object
* @return The hook status.
- * @retval TRUE Message handled internally.
- * @retval FALSE Message not handled.
+ * @retval true Message handled internally.
+ * @retval false Message not handled.
*/
bool sduRequestsHook(USBDriver *usbp) {
@@ -298,19 +298,19 @@ bool sduRequestsHook(USBDriver *usbp) {
switch (usbp->setup[1]) {
case CDC_GET_LINE_CODING:
usbSetupTransfer(usbp, (uint8_t *)&linecoding, sizeof(linecoding), NULL);
- return TRUE;
+ return true;
case CDC_SET_LINE_CODING:
usbSetupTransfer(usbp, (uint8_t *)&linecoding, sizeof(linecoding), NULL);
- return TRUE;
+ return true;
case CDC_SET_CONTROL_LINE_STATE:
/* Nothing to do, there are no control lines.*/
usbSetupTransfer(usbp, NULL, 0, NULL);
- return TRUE;
+ return true;
default:
- return FALSE;
+ return false;
}
}
- return FALSE;
+ return false;
}
/**
diff --git a/os/hal/src/usb.c b/os/hal/src/usb.c
index e339af472..602115fbd 100644
--- a/os/hal/src/usb.c
+++ b/os/hal/src/usb.c
@@ -73,8 +73,8 @@ static void set_address(USBDriver *usbp) {
*
* @param[in] usbp pointer to the @p USBDriver object
* @return The request handling exit code.
- * @retval FALSE Request not recognized by the handler or error.
- * @retval TRUE Request handled.
+ * @retval false Request not recognized by the handler or error.
+ * @retval true Request handled.
*/
static bool default_handler(USBDriver *usbp) {
const USBDescriptor *dp;
@@ -86,25 +86,25 @@ static bool default_handler(USBDriver *usbp) {
case USB_RTYPE_RECIPIENT_DEVICE | (USB_REQ_GET_STATUS << 8):
/* Just returns the current status word.*/
usbSetupTransfer(usbp, (uint8_t *)&usbp->status, 2, NULL);
- return TRUE;
+ return true;
case USB_RTYPE_RECIPIENT_DEVICE | (USB_REQ_CLEAR_FEATURE << 8):
/* Only the DEVICE_REMOTE_WAKEUP is handled here, any other feature
number is handled as an error.*/
if (usbp->setup[2] == USB_FEATURE_DEVICE_REMOTE_WAKEUP) {
usbp->status &= ~2;
usbSetupTransfer(usbp, NULL, 0, NULL);
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
case USB_RTYPE_RECIPIENT_DEVICE | (USB_REQ_SET_FEATURE << 8):
/* Only the DEVICE_REMOTE_WAKEUP is handled here, any other feature
number is handled as an error.*/
if (usbp->setup[2] == USB_FEATURE_DEVICE_REMOTE_WAKEUP) {
usbp->status |= 2;
usbSetupTransfer(usbp, NULL, 0, NULL);
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
case USB_RTYPE_RECIPIENT_DEVICE | (USB_REQ_SET_ADDRESS << 8):
/* The SET_ADDRESS handling can be performed here or postponed after
the status packed depending on the USB_SET_ADDRESS_MODE low
@@ -117,20 +117,20 @@ static bool default_handler(USBDriver *usbp) {
#else
usbSetupTransfer(usbp, NULL, 0, set_address);
#endif
- return TRUE;
+ return true;
case USB_RTYPE_RECIPIENT_DEVICE | (USB_REQ_GET_DESCRIPTOR << 8):
/* Handling descriptor requests from the host.*/
dp = usbp->config->get_descriptor_cb(
usbp, usbp->setup[3], usbp->setup[2],
usbFetchWord(&usbp->setup[4]));
if (dp == NULL)
- return FALSE;
+ return false;
usbSetupTransfer(usbp, (uint8_t *)dp->ud_string, dp->ud_size, NULL);
- return TRUE;
+ return true;
case USB_RTYPE_RECIPIENT_DEVICE | (USB_REQ_GET_CONFIGURATION << 8):
/* Returning the last selected configuration.*/
usbSetupTransfer(usbp, &usbp->configuration, 1, NULL);
- return TRUE;
+ return true;
case USB_RTYPE_RECIPIENT_DEVICE | (USB_REQ_SET_CONFIGURATION << 8):
/* Handling configuration selection from the host.*/
usbp->configuration = usbp->setup[2];
@@ -140,43 +140,43 @@ static bool default_handler(USBDriver *usbp) {
usbp->state = USB_ACTIVE;
_usb_isr_invoke_event_cb(usbp, USB_EVENT_CONFIGURED);
usbSetupTransfer(usbp, NULL, 0, NULL);
- return TRUE;
+ return true;
case USB_RTYPE_RECIPIENT_INTERFACE | (USB_REQ_GET_STATUS << 8):
case USB_RTYPE_RECIPIENT_ENDPOINT | (USB_REQ_SYNCH_FRAME << 8):
/* Just sending two zero bytes, the application can change the behavior
using a hook..*/
usbSetupTransfer(usbp, (uint8_t *)zero_status, 2, NULL);
- return TRUE;
+ return true;
case USB_RTYPE_RECIPIENT_ENDPOINT | (USB_REQ_GET_STATUS << 8):
/* Sending the EP status.*/
if (usbp->setup[4] & 0x80) {
switch (usb_lld_get_status_in(usbp, usbp->setup[4] & 0x0F)) {
case EP_STATUS_STALLED:
usbSetupTransfer(usbp, (uint8_t *)halted_status, 2, NULL);
- return TRUE;
+ return true;
case EP_STATUS_ACTIVE:
usbSetupTransfer(usbp, (uint8_t *)active_status, 2, NULL);
- return TRUE;
+ return true;
default:
- return FALSE;
+ return false;
}
}
else {
switch (usb_lld_get_status_out(usbp, usbp->setup[4] & 0x0F)) {
case EP_STATUS_STALLED:
usbSetupTransfer(usbp, (uint8_t *)halted_status, 2, NULL);
- return TRUE;
+ return true;
case EP_STATUS_ACTIVE:
usbSetupTransfer(usbp, (uint8_t *)active_status, 2, NULL);
- return TRUE;
+ return true;
default:
- return FALSE;
+ return false;
}
}
case USB_RTYPE_RECIPIENT_ENDPOINT | (USB_REQ_CLEAR_FEATURE << 8):
/* Only ENDPOINT_HALT is handled as feature.*/
if (usbp->setup[2] != USB_FEATURE_ENDPOINT_HALT)
- return FALSE;
+ return false;
/* Clearing the EP status, not valid for EP0, it is ignored in that case.*/
if ((usbp->setup[4] & 0x0F) > 0) {
if (usbp->setup[4] & 0x80)
@@ -185,11 +185,11 @@ static bool default_handler(USBDriver *usbp) {
usb_lld_clear_out(usbp, usbp->setup[4] & 0x0F);
}
usbSetupTransfer(usbp, NULL, 0, NULL);
- return TRUE;
+ return true;
case USB_RTYPE_RECIPIENT_ENDPOINT | (USB_REQ_SET_FEATURE << 8):
/* Only ENDPOINT_HALT is handled as feature.*/
if (usbp->setup[2] != USB_FEATURE_ENDPOINT_HALT)
- return FALSE;
+ return false;
/* Stalling the EP, not valid for EP0, it is ignored in that case.*/
if ((usbp->setup[4] & 0x0F) > 0) {
if (usbp->setup[4] & 0x80)
@@ -198,7 +198,7 @@ static bool default_handler(USBDriver *usbp) {
usb_lld_stall_out(usbp, usbp->setup[4] & 0x0F);
}
usbSetupTransfer(usbp, NULL, 0, NULL);
- return TRUE;
+ return true;
case USB_RTYPE_RECIPIENT_DEVICE | (USB_REQ_SET_DESCRIPTOR << 8):
case USB_RTYPE_RECIPIENT_INTERFACE | (USB_REQ_CLEAR_FEATURE << 8):
case USB_RTYPE_RECIPIENT_INTERFACE | (USB_REQ_SET_FEATURE << 8):
@@ -207,7 +207,7 @@ static bool default_handler(USBDriver *usbp) {
/* All the above requests are not handled here, if you need them then
use the hook mechanism and provide handling.*/
default:
- return FALSE;
+ return false;
}
}
@@ -367,7 +367,7 @@ void usbDisableEndpointsI(USBDriver *usbp) {
void usbPrepareReceive(USBDriver *usbp, usbep_t ep, uint8_t *buf, size_t n) {
USBOutEndpointState *osp = usbp->epc[ep]->out_state;
- osp->rxqueued = FALSE;
+ osp->rxqueued = false;
osp->mode.linear.rxbuf = buf;
osp->rxsize = n;
osp->rxcnt = 0;
@@ -393,7 +393,7 @@ void usbPrepareTransmit(USBDriver *usbp, usbep_t ep,
const uint8_t *buf, size_t n) {
USBInEndpointState *isp = usbp->epc[ep]->in_state;
- isp->txqueued = FALSE;
+ isp->txqueued = false;
isp->mode.linear.txbuf = buf;
isp->txsize = n;
isp->txcnt = 0;
@@ -422,7 +422,7 @@ void usbPrepareQueuedReceive(USBDriver *usbp, usbep_t ep,
input_queue_t *iqp, size_t n) {
USBOutEndpointState *osp = usbp->epc[ep]->out_state;
- osp->rxqueued = TRUE;
+ osp->rxqueued = true;
osp->mode.queue.rxqueue = iqp;
osp->rxsize = n;
osp->rxcnt = 0;
@@ -448,7 +448,7 @@ void usbPrepareQueuedTransmit(USBDriver *usbp, usbep_t ep,
output_queue_t *oqp, size_t n) {
USBInEndpointState *isp = usbp->epc[ep]->in_state;
- isp->txqueued = TRUE;
+ isp->txqueued = true;
isp->mode.queue.txqueue = oqp;
isp->txsize = n;
isp->txcnt = 0;
@@ -465,8 +465,8 @@ void usbPrepareQueuedTransmit(USBDriver *usbp, usbep_t ep,
* @param[in] ep endpoint number
*
* @return The operation status.
- * @retval FALSE Operation started successfully.
- * @retval TRUE Endpoint busy, operation not started.
+ * @retval false Operation started successfully.
+ * @retval true Endpoint busy, operation not started.
*
* @iclass
*/
@@ -476,11 +476,11 @@ bool usbStartReceiveI(USBDriver *usbp, usbep_t ep) {
osalDbgCheck(usbp != NULL);
if (usbGetReceiveStatusI(usbp, ep))
- return TRUE;
+ return true;
usbp->receiving |= (1 << ep);
usb_lld_start_out(usbp, ep);
- return FALSE;
+ return false;
}
/**
@@ -492,8 +492,8 @@ bool usbStartReceiveI(USBDriver *usbp, usbep_t ep) {
* @param[in] ep endpoint number
*
* @return The operation status.
- * @retval FALSE Operation started successfully.
- * @retval TRUE Endpoint busy, operation not started.
+ * @retval false Operation started successfully.
+ * @retval true Endpoint busy, operation not started.
*
* @iclass
*/
@@ -503,11 +503,11 @@ bool usbStartTransmitI(USBDriver *usbp, usbep_t ep) {
osalDbgCheck(usbp != NULL);
if (usbGetTransmitStatusI(usbp, ep))
- return TRUE;
+ return true;
usbp->transmitting |= (1 << ep);
usb_lld_start_in(usbp, ep);
- return FALSE;
+ return false;
}
/**
@@ -517,8 +517,8 @@ bool usbStartTransmitI(USBDriver *usbp, usbep_t ep) {
* @param[in] ep endpoint number
*
* @return The operation status.
- * @retval FALSE Endpoint stalled.
- * @retval TRUE Endpoint busy, not stalled.
+ * @retval false Endpoint stalled.
+ * @retval true Endpoint busy, not stalled.
*
* @iclass
*/
@@ -528,10 +528,10 @@ bool usbStallReceiveI(USBDriver *usbp, usbep_t ep) {
osalDbgCheck(usbp != NULL);
if (usbGetReceiveStatusI(usbp, ep))
- return TRUE;
+ return true;
usb_lld_stall_out(usbp, ep);
- return FALSE;
+ return false;
}
/**
@@ -541,8 +541,8 @@ bool usbStallReceiveI(USBDriver *usbp, usbep_t ep) {
* @param[in] ep endpoint number
*
* @return The operation status.
- * @retval FALSE Endpoint stalled.
- * @retval TRUE Endpoint busy, not stalled.
+ * @retval false Endpoint stalled.
+ * @retval true Endpoint busy, not stalled.
*
* @iclass
*/
@@ -552,10 +552,10 @@ bool usbStallTransmitI(USBDriver *usbp, usbep_t ep) {
osalDbgCheck(usbp != NULL);
if (usbGetTransmitStatusI(usbp, ep))
- return TRUE;
+ return true;
usb_lld_stall_in(usbp, ep);
- return FALSE;
+ return false;
}
/**
diff --git a/testhal/STM32/STM32F30x/USB_CDC_IAD/Makefile b/testhal/STM32/STM32F30x/USB_CDC_IAD/Makefile
index 4b3d40da0..2c5d529b2 100644
--- a/testhal/STM32/STM32F30x/USB_CDC_IAD/Makefile
+++ b/testhal/STM32/STM32F30x/USB_CDC_IAD/Makefile
@@ -5,7 +5,7 @@
# Compiler options here.
ifeq ($(USE_OPT),)
- USE_OPT = -O2 -ggdb -fomit-frame-pointer -falign-functions=16
+ USE_OPT = -O0 -ggdb -fomit-frame-pointer -falign-functions=16
endif
# C specific options here (added to USE_OPT).
diff --git a/testhal/STM32/STM32F30x/USB_CDC_IAD/debug/STM32F30x-USB_CDC_IAD (OpenOCD, Flash and Run).launch b/testhal/STM32/STM32F30x/USB_CDC_IAD/debug/STM32F30x-USB_CDC_IAD (OpenOCD, Flash and Run).launch
index 17c974b1e..4ba94fc0d 100644
--- a/testhal/STM32/STM32F30x/USB_CDC_IAD/debug/STM32F30x-USB_CDC_IAD (OpenOCD, Flash and Run).launch
+++ b/testhal/STM32/STM32F30x/USB_CDC_IAD/debug/STM32F30x-USB_CDC_IAD (OpenOCD, Flash and Run).launch
@@ -33,7 +33,7 @@
<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/>
<stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_REGISTER_GROUPS" value=""/>
-<stringAttribute key="org.eclipse.cdt.launch.FORMAT" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&lt;contentList/&gt;"/>
+<stringAttribute key="org.eclipse.cdt.launch.FORMAT" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&lt;contentList&gt;&lt;content id=&quot;setup[7]-setup-usbp-default_handler-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;setup[6]-setup-usbp-default_handler-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;setup[5]-setup-usbp-default_handler-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;setup[4]-setup-usbp-default_handler-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;setup[3]-setup-usbp-default_handler-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;setup[2]-setup-usbp-default_handler-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;setup[1]-setup-usbp-default_handler-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;setup[0]-setup-usbp-default_handler-(format)&quot; val=&quot;4&quot;/&gt;&lt;/contentList&gt;"/>
<stringAttribute key="org.eclipse.cdt.launch.GLOBAL_VARIABLES" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;globalVariableList/&gt;&#13;&#10;"/>
<stringAttribute key="org.eclipse.cdt.launch.MEMORY_BLOCKS" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;memoryBlockExpressionList/&gt;&#13;&#10;"/>
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="./build/ch.elf"/>
diff --git a/testhal/STM32/STM32F30x/USB_CDC_IAD/main.c b/testhal/STM32/STM32F30x/USB_CDC_IAD/main.c
index af251fd18..b3d664317 100644
--- a/testhal/STM32/STM32F30x/USB_CDC_IAD/main.c
+++ b/testhal/STM32/STM32F30x/USB_CDC_IAD/main.c
@@ -189,8 +189,8 @@ int main(void) {
*/
sduObjectInit(&SDU1);
sduStart(&SDU1, &serusbcfg1);
-// sduObjectInit(&SDU2);
-// sduStart(&SDU2, &serusbcfg2);
+ sduObjectInit(&SDU2);
+ sduStart(&SDU2, &serusbcfg2);
/*
* Activates the USB driver and then the USB bus pull-up on D+.
@@ -223,14 +223,12 @@ int main(void) {
chThdRelease(shelltp1); /* Recovers memory of the previous shell. */
shelltp1 = NULL; /* Triggers spawning of a new shell. */
}
-#if 0
if (!shelltp2 && (SDU2.config->usbp->state == USB_ACTIVE))
shelltp2 = shellCreate(&shell_cfg2, SHELL_WA_SIZE, NORMALPRIO);
else if (chThdTerminatedX(shelltp2)) {
chThdRelease(shelltp2); /* Recovers memory of the previous shell. */
shelltp2 = NULL; /* Triggers spawning of a new shell. */
}
-#endif
chThdSleepMilliseconds(1000);
}
}
diff --git a/testhal/STM32/STM32F30x/USB_CDC_IAD/usbcfg.c b/testhal/STM32/STM32F30x/USB_CDC_IAD/usbcfg.c
index 3a06a9d2a..eb8fa26f1 100644
--- a/testhal/STM32/STM32F30x/USB_CDC_IAD/usbcfg.c
+++ b/testhal/STM32/STM32F30x/USB_CDC_IAD/usbcfg.c
@@ -29,7 +29,7 @@
/*
* Interfaces
*/
-#define USB_NUM_INTERFACES 2
+#define USB_NUM_INTERFACES 4
#define USB_CDC_CIF_NUM0 0
#define USB_CDC_DIF_NUM0 1
#define USB_CDC_CIF_NUM1 2
@@ -64,7 +64,7 @@ static const USBDescriptor vcom_device_descriptor = {
#define CDC_IF_DESC_SET_SIZE \
(USB_DESC_INTERFACE_SIZE + 5 + 5 + 4 + 5 + USB_DESC_ENDPOINT_SIZE + \
- USB_DESC_INTERFACE_SIZE + (USB_DESC_ENDPOINT_SIZE *2))
+ USB_DESC_INTERFACE_SIZE + (USB_DESC_ENDPOINT_SIZE * 2))
#define CDC_IF_DESC_SET(comIfNum, datIfNum, comInEp, datOutEp, datInEp) \
/* Interface Descriptor.*/ \
@@ -122,17 +122,17 @@ static const USBDescriptor vcom_device_descriptor = {
USB_DESC_ENDPOINT( \
datOutEp, /* bEndpointAddress. */ \
USB_EP_MODE_TYPE_BULK, /* bmAttributes. */ \
- 0x0040, /*ZZZZZ*/ /* wMaxPacketSize. */ \
+ 0x0040, /* wMaxPacketSize. */ \
0x00), /* bInterval. */ \
/* Endpoint, Bulk IN.*/ \
USB_DESC_ENDPOINT( \
datInEp, /* bEndpointAddress. */ \
USB_EP_MODE_TYPE_BULK, /* bmAttributes. */ \
- 0x0040, /*ZZZZZ*/ /* wMaxPacketSize. */ \
+ 0x0040, /* wMaxPacketSize. */ \
0x00) /* bInterval. */
-#define IAD_CDC_IF_DESC_SET_SIZE (USB_DESC_INTERFACE_ASSOCIATION_SIZE + \
- CDC_IF_DESC_SET_SIZE)
+#define IAD_CDC_IF_DESC_SET_SIZE \
+ (USB_DESC_INTERFACE_ASSOCIATION_SIZE + CDC_IF_DESC_SET_SIZE)
#define IAD_CDC_IF_DESC_SET(comIfNum, datIfNum, comInEp, datOutEp, datInEp) \
/* Interface Association Descriptor.*/ \
@@ -152,7 +152,7 @@ static const uint8_t vcom_configuration_descriptor_data[] = {
/* Configuration Descriptor.*/
USB_DESC_CONFIGURATION(
USB_DESC_CONFIGURATION_SIZE +
- (IAD_CDC_IF_DESC_SET_SIZE * 1), /* wTotalLength. */
+ (IAD_CDC_IF_DESC_SET_SIZE * 2), /* wTotalLength. */
USB_NUM_INTERFACES, /* bNumInterfaces. */
0x01, /* bConfigurationValue. */
0, /* iConfiguration. */
@@ -166,13 +166,13 @@ static const uint8_t vcom_configuration_descriptor_data[] = {
USB_ENDPOINT_OUT(USB_DATA_AVAILABLE_EP_A),
USB_ENDPOINT_IN(USB_DATA_REQUEST_EP_A)
),
-/* IAD_CDC_IF_DESC_SET(
+ IAD_CDC_IF_DESC_SET(
USB_CDC_CIF_NUM1,
USB_CDC_DIF_NUM1,
USB_ENDPOINT_IN(USB_INTERRUPT_REQUEST_EP_B),
USB_ENDPOINT_OUT(USB_DATA_AVAILABLE_EP_B),
USB_ENDPOINT_IN(USB_DATA_REQUEST_EP_B)
- ),*/
+ ),
};
/*
@@ -374,12 +374,12 @@ static void usb_event(USBDriver *usbp, usbevent_t event) {
must be used.*/
usbInitEndpointI(usbp, USB_INTERRUPT_REQUEST_EP_A, &ep1config);
usbInitEndpointI(usbp, USB_DATA_REQUEST_EP_A, &ep2config);
-// usbInitEndpointI(usbp, USB_INTERRUPT_REQUEST_EP_B, &ep3config);
-// usbInitEndpointI(usbp, USB_DATA_REQUEST_EP_B, &ep4config);
+ usbInitEndpointI(usbp, USB_INTERRUPT_REQUEST_EP_B, &ep3config);
+ usbInitEndpointI(usbp, USB_DATA_REQUEST_EP_B, &ep4config);
/* Resetting the state of the CDC subsystem.*/
sduConfigureHookI(&SDU1);
-// sduConfigureHookI(&SDU2);
+ sduConfigureHookI(&SDU2);
}
else if (usbp->state == USB_SELECTED) {
// usbDisableEndpointsI(usbp);
@@ -398,12 +398,26 @@ static void usb_event(USBDriver *usbp, usbevent_t event) {
}
/*
+ * Handling messages not implemented in the default handler nor in the
+ * SerialUSB handler.
+ */
+static bool requests_hook(USBDriver *usbp) {
+
+ if (((usbp->setup[0] & USB_RTYPE_RECIPIENT_MASK) == USB_RTYPE_RECIPIENT_INTERFACE) &&
+ (usbp->setup[1] == USB_REQ_SET_INTERFACE)) {
+ usbSetupTransfer(usbp, NULL, 0, NULL);
+ return true;
+ }
+ return sduRequestsHook(usbp);
+}
+
+/*
* USB driver configuration.
*/
const USBConfig usbcfg = {
usb_event,
get_descriptor,
- sduRequestsHook,
+ requests_hook,
NULL
};