简体   繁体   中英

Error[Pe167]: argument of type “uint16_t *” is incompatible with parameter of type “unsigned char *”

I want to establish communication between tablet and stm32 via usb, for which i had added usb libraries in the code. On adding libraries in code i got this error.

Error[Pe167]: argument of type "uint16_t *" is incompatible with parameter of type "unsigned char *"

I am using IAR Embedded Workbench EWARM Tool for stm32 coding.Error is comming on return line of function shown below.

static USBH_Status USBH_ADK_getProtocol ( USB_OTG_CORE_HANDLE *pdev, USBH_HOST *phost)
{
phost->Control.setup.b.bmRequestType = USB_D2H | USB_REQ_TYPE_VENDOR | USB_REQ_RECIPIENT_DEVICE;
phost->Control.setup.b.bRequest = ACCESSORY_GET_PROTOCOL;
phost->Control.setup.b.wValue.w = 0;
phost->Control.setup.b.wIndex.w = 0;
phost->Control.setup.b.wLength.w = 2;
 abc= ADK_Machine.protocol;
/* Control Request */
return USBH_CtlReq(pdev, phost, &ADK_Machine.protocol , 2 );
}

And the function USBH_CtlReq is

USBH_Status USBH_CtlReq     (USB_OTG_CORE_HANDLE *pdev, 
                         USBH_HOST           *phost, 
                         uint8_t             *buff,
                         uint16_t            length)
{
USBH_Status status;
status = USBH_BUSY;

switch (phost->RequestState)
{
case CMD_SEND:
/* Start a SETUP transfer */
USBH_SubmitSetupRequest(phost, buff, length);
phost->RequestState = CMD_WAIT;
status = USBH_BUSY;
break;

case CMD_WAIT:
 if (phost->Control.state == CTRL_COMPLETE ) 
{
  /* Commands successfully sent and Response Received  */       
  phost->RequestState = CMD_SEND;
  phost->Control.state =CTRL_IDLE;  
  status = USBH_OK;      
}
else if  (phost->Control.state == CTRL_ERROR)
{
  /* Failure Mode */
  phost->RequestState = CMD_SEND;
  status = USBH_FAIL;
}   
 else if  (phost->Control.state == CTRL_STALLED )
{
  /* Commands successfully sent and Response Received  */       
  phost->RequestState = CMD_SEND;
  status = USBH_NOT_SUPPORTED;
}
break;

default:
break; 
}
return status;
}

can any one please help me in solving this problem.Thanks in advance.

AFAICT, in the line:

return USBH_CtlReq(pdev, phost, &ADK_Machine.protocol , 2 );

the ADK_Machine.protocol is an uint16_t . If that's true, than, taking its address will yield a uint16_t * , which is not convertible to uint8_t* that USBH_CtlReq expects.

A lot of low-level "sending" functions in C declare arguments as uint8_t* or unsigned char* , to indicate that they are expecting "bytes". In principle, they could just as well declare void* .

But, in this case, the only thing to do is cast, like:

return USBH_CtlReq(pdev, phost, (uint8_t*)&ADK_Machine.protocol , 2 );

Of course, you need to be mindful that this will not take care of endianness.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM