예제 #1
0
//-----------------------------------------------------------------
// usb_cdc_process_request:
//-----------------------------------------------------------------
void usb_cdc_process_request(unsigned char req, unsigned short wValue, unsigned short WIndex, unsigned char *data, unsigned short wLength)
{
	switch ( req )
	{
	case CDC_SEND_ENCAPSULATED_COMMAND:
        log_printf(USBLOG_CDC_INFO, "CDC: Send encap\n");
	    cdc_send_encapsulated_command();
	    break;
	case CDC_GET_ENCAPSULATED_RESPONSE:
        log_printf(USBLOG_CDC_INFO, "CDC: Get encap\n");
	    cdc_get_encapsulated_response(wLength);
	    break;
	case CDC_SET_LINE_CODING:
        log_printf(USBLOG_CDC_INFO, "CDC: Set line coding\n");
	    cdc_set_line_coding(data);
	    break;
	case CDC_GET_LINE_CODING:
        log_printf(USBLOG_CDC_INFO, "CDC: Get line coding\n");
	    cdc_get_line_coding(wLength);
	    break;
	case CDC_SET_CONTROL_LINE_STATE:
        log_printf(USBLOG_CDC_INFO, "CDC: Set line state\n");
	    cdc_set_control_line_state();
	    break;
	case CDC_SEND_BREAK:
        log_printf(USBLOG_CDC_INFO, "CDC: Send break\n");
	    cdc_send_break();
	    break;
	default:
        log_printf(USBLOG_CDC_INFO, "CDC: Unknown command\n");
		usbhw_control_endpoint_stall();
		break;
	}
}
예제 #2
0
//! This function is called by the standard USB read request function when
//! the USB request is not supported. This function returns true when the
//! request is processed. This function returns false if the request is not
//! supported. In this case, a STALL handshake will be automatically
//! sent by the standard USB read request function.
//!
bool usb_user_read_request(uint8_t type, uint8_t request)
{
  switch (request)
  {
    case GET_LINE_CODING:
      cdc_get_line_coding();
      return true;
      // No need to break here !

    case SET_LINE_CODING:
      cdc_set_line_coding();
      return true;
      // No need to break here !

    case SET_CONTROL_LINE_STATE:
      cdc_set_control_line_state();
      return true;
      // No need to break here !

    default:
      return false;
      // No need to break here !
  }
}
예제 #3
0
//! This function is called by the standard USB read request function when
//! the USB request is not supported. This function returns TRUE when the
//! request is processed. This function returns FALSE if the request is not
//! supported. In this case, a STALL handshake will be automatically
//! sent by the standard USB read request function.
//!
Bool usb_user_read_request(U8 type, U8 request)
{
    switch (request)
    {
    case GET_LINE_CODING:
        cdc_get_line_coding();
        return TRUE;
    // No need to break here !

    case SET_LINE_CODING:
        cdc_set_line_coding();
        return TRUE;
    // No need to break here !

    case SET_CONTROL_LINE_STATE:
        cdc_set_control_line_state();
        return TRUE;
    // No need to break here !

    default:
        return FALSE;
        // No need to break here !
    }
}
예제 #4
0
//! This function is called by the standard usb read request function when
//! the Usb request is not supported. This function returns TRUE when the
//! request is processed. This function returns FALSE if the request is not
//! supported. In this case, a STALL handshake will be automatically
//! sent by the standard usb read request function.
//!
//! @param type Not used
//! @param request Read request type
//!
//! @retval FALSE if unknown read type
//! @retval TRUE if request type is processed
//!
Bool usb_user_read_request(U8 type, U8 request)
{	
	U16 wLength;

	//Both protocols have two bytes we throw away
	Usb_read_byte();
	Usb_read_byte();

	switch(request)
	{
		case SEND_ENCAPSULATED_COMMAND:			
				Usb_read_byte();//wIndex LSB
				Usb_read_byte();//wIndex MSB

				LSB(wLength) = Usb_read_byte();
				MSB(wLength) = Usb_read_byte();
				return send_encapsulated_command(wLength);
      			break;

  		case GET_ENCAPSULATED_COMMAND:
				Usb_read_byte();//wIndex LSB
				Usb_read_byte();//wIndex MSB

				LSB(wLength) = Usb_read_byte();
				MSB(wLength) = Usb_read_byte();
				return get_encapsulated_command();
      			break;


        case MASS_STORAGE_RESET:
         		Usb_ack_receive_setup();
         		Usb_send_control_in();
         		return TRUE;
         		break;


		case GET_MAX_LUN:
         		Usb_ack_receive_setup();
         		Usb_write_byte( (get_nb_lun()-1) );
         		Usb_send_control_in();
         		ms_multiple_drive = 1;
         		return TRUE;
         		break;

	
	/* We don't have a real serial port - so these aren't applicable. We
	   advertise that we support nothing, so shouldn't get them anyway */
		case GET_LINE_CODING:
				cdc_get_line_coding();
				return TRUE;
      			break;

  		case SET_LINE_CODING:
				cdc_set_line_coding();
				return TRUE;
      			break;

		case SET_CONTROL_LINE_STATE:
				cdc_set_control_line_state();
      			return TRUE;
      			break;
     	default:
				break;

	}
	 
  	return FALSE;
}