Commit 1b577524 authored by Johann Fischer's avatar Johann Fischer Committed by Kumar Gala
Browse files

usb: add callback codes for Set/Clear Feature ENDPOINT_HALT



Add callback codes for Set/Clear Feature ENDPOINT_HALT.
These can be used to inform a function that the device stack has
received Set/Clear Feature request ENDPOINT_HALT. The function can
then abort or restart the transfer accordingly.

Signed-off-by: default avatarJohann Fischer <j.fischer@phytec.de>
parent cc5ae491
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -40,6 +40,8 @@ enum usb_dc_status_code {
	USB_DC_SUSPEND,      /* USB connection suspended by the HOST */
	USB_DC_RESUME,       /* USB connection resumed by the HOST */
	USB_DC_INTERFACE,    /* USB interface selected */
	USB_DC_SET_HALT,     /* Set Feature ENDPOINT_HALT received */
	USB_DC_CLEAR_HALT,   /* Clear Feature ENDPOINT_HALT received */
	USB_DC_UNKNOWN       /* Initial USB connection status */
};

+12 −5
Original line number Diff line number Diff line
@@ -726,11 +726,12 @@ static bool usb_handle_std_endpoint_req(struct usb_setup_packet *setup,
		s32_t *len, u8_t **data_buf)
{
	u8_t *data = *data_buf;
	u8_t ep = setup->wIndex;

	switch (setup->bRequest) {
	case REQ_GET_STATUS:
		/* bit 0 = endpointed halted or not */
		usb_dc_ep_is_stalled(setup->wIndex, &data[0]);
		usb_dc_ep_is_stalled(ep, &data[0]);
		data[1] = 0;
		*len = 2;
		break;
@@ -738,8 +739,11 @@ static bool usb_handle_std_endpoint_req(struct usb_setup_packet *setup,
	case REQ_CLEAR_FEATURE:
		if (setup->wValue == FEA_ENDPOINT_HALT) {
			/* clear HALT by unstalling */
			SYS_LOG_INF("... EP clear halt %x\n", setup->wIndex);
			usb_dc_ep_clear_stall(setup->wIndex);
			SYS_LOG_INF("... EP clear halt %x\n", ep);
			usb_dc_ep_clear_stall(ep);
			if (usb_dev.status_callback) {
				usb_dev.status_callback(USB_DC_CLEAR_HALT, &ep);
			}
			break;
		}
		/* only ENDPOINT_HALT defined for endpoints */
@@ -748,8 +752,11 @@ static bool usb_handle_std_endpoint_req(struct usb_setup_packet *setup,
	case REQ_SET_FEATURE:
		if (setup->wValue == FEA_ENDPOINT_HALT) {
			/* set HALT by stalling */
			SYS_LOG_INF("--- EP SET halt %x\n", setup->wIndex);
			usb_dc_ep_set_stall(setup->wIndex);
			SYS_LOG_INF("--- EP SET halt %x\n", ep);
			usb_dc_ep_set_stall(ep);
			if (usb_dev.status_callback) {
				usb_dev.status_callback(USB_DC_SET_HALT, &ep);
			}
			break;
		}
		/* only ENDPOINT_HALT defined for endpoints */