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

Mohibullah Sheikh

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.

srdjan.veljkovic

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.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Convert Unsigned Char * to uint16_t *

Why does the C compiler allow silent casting from uint16_t to an enum type?

Problem with cast from argv[] argument to uint16_t

argument of type "int" incompatible with parameter of type "int"

How to fix argument of type is incompatible with parameter of type

Argument of type "int" is incompatible with parameter of type "int *"

argument of type "char *" is incompatible with parameter of type "LPCWSTR"

unsigned char array incompatible with pointer parameter

C++ argument COLORREF of type is incompatible with parameter of type char

argument of type "const char *" is incompatible with parameter of type "char"

Error: argument of type "HNode *" is incompatible with parameter type "HNode *"

Argument of type "const char*" is incompatible with parameter of type "char*". But why? :(

Argument of type "const char *" is incompatible with parameter of type "char *"

Default argument of type "const char *" is incompatible with parameter of type "char *"

Why is an argument of type double ** incompatible with a parameter of type const double **

OpenGL C++ Argument of type void is incompatible with parameter of type void(*)()

Argument of type "const char **" is incompatible with parameter of type "const char *"

IntelliSense: argument of type "_TCHAR *" is incompatible with parameter of type "const char *"

"argument of type ”int(*)()“ is incompatible with parameter of type int" error?

argument of type "const char *" is incompatible with parameter of type "LPCWSTR"

Argument of type "const char*" is incompatible with parameter of type "Person"

Argument type "WCHAR *" is incompatible with parameter of type "const char *"

LPCWSTR ERROR C++ argument of type is incompatible with parameter of type

argument of type "int *" is incompatible with parameter of type "int (*)[1000]"

Argument of type int is incompatible with parameter type Uint8*

CUDA: argument of type float * is incompatible with parameter of type float (*)[32768]

Argument of type "const wchar_t*" is incompatible with parameter of type "LPTSTR"

compare void* with uint16_t

Returning an offset with uint16_t values

TOP Ranking

  1. 1

    Failed to listen on localhost:8000 (reason: Cannot assign requested address)

  2. 2

    Loopback Error: connect ECONNREFUSED 127.0.0.1:3306 (MAMP)

  3. 3

    How to import an asset in swift using Bundle.main.path() in a react-native native module

  4. 4

    pump.io port in URL

  5. 5

    Compiler error CS0246 (type or namespace not found) on using Ninject in ASP.NET vNext

  6. 6

    BigQuery - concatenate ignoring NULL

  7. 7

    ngClass error (Can't bind ngClass since it isn't a known property of div) in Angular 11.0.3

  8. 8

    ggplotly no applicable method for 'plotly_build' applied to an object of class "NULL" if statements

  9. 9

    Spring Boot JPA PostgreSQL Web App - Internal Authentication Error

  10. 10

    How to remove the extra space from right in a webview?

  11. 11

    java.lang.NullPointerException: Cannot read the array length because "<local3>" is null

  12. 12

    Jquery different data trapped from direct mousedown event and simulation via $(this).trigger('mousedown');

  13. 13

    flutter: dropdown item programmatically unselect problem

  14. 14

    How to use merge windows unallocated space into Ubuntu using GParted?

  15. 15

    Change dd-mm-yyyy date format of dataframe date column to yyyy-mm-dd

  16. 16

    Nuget add packages gives access denied errors

  17. 17

    Svchost high CPU from Microsoft.BingWeather app errors

  18. 18

    Can't pre-populate phone number and message body in SMS link on iPhones when SMS app is not running in the background

  19. 19

    12.04.3--- Dconf Editor won't show com>canonical>unity option

  20. 20

    Any way to remove trailing whitespace *FOR EDITED* lines in Eclipse [for Java]?

  21. 21

    maven-jaxb2-plugin cannot generate classes due to two declarations cause a collision in ObjectFactory class

HotTag

Archive