I am trying to compile a USB HID example code on Keil for a STM32F4-Discovery. This code allows me to send and receive message to and from a software called "USB HID Demonstrator".
But I have a problem in the USBD_HID_DataOut
function. The line:
USB_OTG_ReadPacket((USB_OTG_CORE_HANDLE*)pdev, *Buffer, HID_OUT_PACKET);
Gives me an error:
error #167: argument of type "uint8_t" is incompatible with parameter of type "uint8_t *"
When I suppress the *
of Buffer
, the code compiles but doesn't seem to work (the buffer values received don't match what is expected but I'm perhaps mistaken about that)
and actually the second argument of USB_OTG_ReadPacket
must be a pointer so I don't understand why this error occurs.
The Buffer
variable is defined as follow: uint8_t Buffer[6];
So is there a problem with the compiler? Do I have to deal with special issues copying this project code into Keil since it was first created for Atollic?
Or is there simply a mistake in the link?
It doesn't make sense to pass *Buffer
, because that means the same as Buffer[0]
. Why would you write *Buffer
instead of Buffer[0]
in the first place? Buffer
isn't even declared as a pointer, so why would you dereference it? (You can, but it just doesn't look right.)
If the function expects a pointer, than passing Buffer
is correct, since it means the same as &Buffer[0]
.
Try to clarify your question. What is it you want to pass to the function? Do you want to pass it the first uint8_t element in the Buffer array? In that case, you want to pass Buffer[0]
or *Buffer
(both mean the same thing.) Or do you want to pass a pointer to the array? In that case, pass Buffer
or &Buffer[0]
(both are equivalent.)