First of all congrats for your awesome forum and support. I'm a newbie and most of my questions are already reported so most of the times i don't even need to ask for a solution, just needed to search a little bit.
So for all the community that have been helping me indirectly, my sincere thank you.
But this time i don't find the solution to my problem. I feel like it's a very primitive question but i can't figure out (shame on me!).
I doing a USB-HDI project and i studied the USB specifications until i found the LUFA project and man... that saved my ass!
The LUFA project saved me a lot of time implementing the boring USB work on device side, specially because i'm not a master of programming.
I adopted the "CLASS_GENERIC_HID" demo to my project and now i can send and receive data packets.
The problem is that when i send a data packet from the device (ATMEGA16U2) i can't block the program flow until the response data from the host (PC) is received.
I want to do this only in one part of my work (in one function) and not in the entire solution.
I Tried to do something like this:
On "CALLBACK_HID_Device_ProcessHIDReport" function i put a global variable "flag_data_recived" that change it's state to 1 every time that this function is processed.
On my function that i want to wait for data from the host i block the program flow using a while condition associated with the global variable that i created previously.
Something like that:
// continue data flow
The problem is, with that the program never process the "CALLBACK_HID_Device_ProcessHIDReport" and obviously never jump the while condition. Which is very strange to me because the "CALLBACK_HID_Device_ProcessHIDReport" function is activated by interrupts.
Can you give a simple explanation for what are happening there? There is a better solution to this?
Thanks in advance!