replace dcd_edpt_(clear)stall by usbd_edpt_(clear)stall
- remove dcd_edpt_stalled() from dcd porting
This commit is contained in:
		@@ -102,7 +102,6 @@ void dcd_set_config (uint8_t rhport, uint8_t config_num);
 | 
			
		||||
 *  - busy        : Check if endpoint transferring is complete (TODO remove)
 | 
			
		||||
 *  - stall       : stall endpoint
 | 
			
		||||
 *  - clear_stall : clear stall
 | 
			
		||||
 *  - stalled     : check if stalled ( TODO remove )
 | 
			
		||||
 *------------------------------------------------------------------*/
 | 
			
		||||
bool dcd_edpt_open        (uint8_t rhport, tusb_desc_endpoint_t const * p_endpoint_desc);
 | 
			
		||||
bool dcd_edpt_xfer        (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes);
 | 
			
		||||
@@ -110,7 +109,6 @@ bool dcd_edpt_busy        (uint8_t rhport, uint8_t ep_addr);
 | 
			
		||||
 | 
			
		||||
void dcd_edpt_stall       (uint8_t rhport, uint8_t ep_addr);
 | 
			
		||||
void dcd_edpt_clear_stall (uint8_t rhport, uint8_t ep_addr);
 | 
			
		||||
bool dcd_edpt_stalled     (uint8_t rhport, uint8_t ep_addr);
 | 
			
		||||
 | 
			
		||||
/*------------------------------------------------------------------*/
 | 
			
		||||
/* Event Function
 | 
			
		||||
 
 | 
			
		||||
@@ -44,9 +44,11 @@
 | 
			
		||||
typedef struct {
 | 
			
		||||
  uint8_t config_num;
 | 
			
		||||
 | 
			
		||||
  uint8_t itf2drv[16];  // map interface number to driver (0xff is invalid)
 | 
			
		||||
  uint8_t ep2drv[8][2]; // map endpoint to driver ( 0xff is invalid )
 | 
			
		||||
  uint8_t itf2drv[16];      // map interface number to driver (0xff is invalid)
 | 
			
		||||
  uint8_t ep2drv[8][2];     // map endpoint to driver ( 0xff is invalid )
 | 
			
		||||
 | 
			
		||||
  uint8_t ep_busy_mask[2];  // bit mask for busy endpoint
 | 
			
		||||
  uint8_t ep_stall_mask[2]; // bit mask for stalled endpoint
 | 
			
		||||
}usbd_device_t;
 | 
			
		||||
 | 
			
		||||
static usbd_device_t _usbd_dev = { 0 };
 | 
			
		||||
@@ -379,7 +381,7 @@ static bool process_control_request(uint8_t rhport, tusb_control_request_t const
 | 
			
		||||
    {
 | 
			
		||||
      case TUSB_REQ_GET_STATUS:
 | 
			
		||||
      {
 | 
			
		||||
        uint16_t status = dcd_edpt_stalled(rhport, tu_u16_low(p_request->wIndex)) ? 0x0001 : 0x0000;
 | 
			
		||||
        uint16_t status = usbd_edpt_stalled(rhport, tu_u16_low(p_request->wIndex)) ? 0x0001 : 0x0000;
 | 
			
		||||
        usbd_control_xfer(rhport, p_request, &status, 2);
 | 
			
		||||
      }
 | 
			
		||||
      break;
 | 
			
		||||
@@ -392,7 +394,7 @@ static bool process_control_request(uint8_t rhport, tusb_control_request_t const
 | 
			
		||||
 | 
			
		||||
      case TUSB_REQ_SET_FEATURE:
 | 
			
		||||
        // only endpoint feature is halted/stalled
 | 
			
		||||
        dcd_edpt_stall(rhport, tu_u16_low(p_request->wIndex));
 | 
			
		||||
        usbd_edpt_stall(rhport, tu_u16_low(p_request->wIndex));
 | 
			
		||||
        usbd_control_status(rhport, p_request);
 | 
			
		||||
      break;
 | 
			
		||||
 | 
			
		||||
@@ -650,4 +652,35 @@ void usbd_defer_func(osal_task_func_t func, void* param, bool in_isr)
 | 
			
		||||
  dcd_event_handler(&event, in_isr);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//--------------------------------------------------------------------+
 | 
			
		||||
// USBD Endpoint API
 | 
			
		||||
//--------------------------------------------------------------------+
 | 
			
		||||
void usbd_edpt_stall(uint8_t rhport, uint8_t ep_addr)
 | 
			
		||||
{
 | 
			
		||||
  uint8_t const epnum = tu_edpt_number(ep_addr);
 | 
			
		||||
  uint8_t const dir   = tu_edpt_dir(ep_addr);
 | 
			
		||||
 | 
			
		||||
  dcd_edpt_stall(rhport, ep_addr);
 | 
			
		||||
  _usbd_dev.ep_stall_mask[dir] = tu_bit_set(_usbd_dev.ep_stall_mask[dir], epnum);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void usbd_edpt_clear_stall(uint8_t rhport, uint8_t ep_addr)
 | 
			
		||||
{
 | 
			
		||||
  uint8_t const epnum = tu_edpt_number(ep_addr);
 | 
			
		||||
  uint8_t const dir   = tu_edpt_dir(ep_addr);
 | 
			
		||||
 | 
			
		||||
  dcd_edpt_clear_stall(rhport, ep_addr);
 | 
			
		||||
  _usbd_dev.ep_stall_mask[dir] = tu_bit_clear(_usbd_dev.ep_stall_mask[dir], epnum);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool usbd_edpt_stalled(uint8_t rhport, uint8_t ep_addr)
 | 
			
		||||
{
 | 
			
		||||
  (void) rhport;
 | 
			
		||||
 | 
			
		||||
  uint8_t const epnum = tu_edpt_number(ep_addr);
 | 
			
		||||
  uint8_t const dir   = tu_edpt_dir(ep_addr);
 | 
			
		||||
 | 
			
		||||
  return tu_bit_test(_usbd_dev.ep_stall_mask[dir], epnum);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 
 | 
			
		||||
@@ -38,7 +38,6 @@
 | 
			
		||||
// INCLUDE
 | 
			
		||||
//--------------------------------------------------------------------+
 | 
			
		||||
#include <common/tusb_common.h>
 | 
			
		||||
#include "osal/osal.h"
 | 
			
		||||
#include "device/dcd.h"
 | 
			
		||||
 | 
			
		||||
//--------------------------------------------------------------------+
 | 
			
		||||
 
 | 
			
		||||
@@ -52,6 +52,11 @@ bool usbd_control_status(uint8_t rhport, tusb_control_request_t const * request)
 | 
			
		||||
// Stall control endpoint (both IN and OUT) until new setup packet arrived
 | 
			
		||||
void usbd_control_stall(uint8_t rhport);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void usbd_edpt_stall(uint8_t rhport, uint8_t ep_addr);
 | 
			
		||||
void usbd_edpt_clear_stall(uint8_t rhport, uint8_t ep_addr);
 | 
			
		||||
bool usbd_edpt_stalled(uint8_t rhport, uint8_t ep_addr);
 | 
			
		||||
 | 
			
		||||
/*------------------------------------------------------------------*/
 | 
			
		||||
/* Helper
 | 
			
		||||
 *------------------------------------------------------------------*/
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user