I have been analysing the generated code from PEx for a while now. The Init() function returns a pointer to the private structure/device structure. Which we then use for all subsequent methods as the first parameter in order to specify which device is being called.
BUT - where does the *UserDataPtr come from? I searched in the components ".c" as well as ".h" file. It must be something I overlooked, but now I am really not getting where this pointer comes from. Or is it that a Null Pointer need not be declared and initialized?
If you need any more details, please let me know I will post screenshots.
Thanks
解決済! 解決策の投稿を見る。
That UserDataPtr comes from your application. You can pass NULL if you don't need such a pointer.
That pointer points to your own data structure where you can have in it whatever you want/need.
For example you can initialize device, and add with the user data pointer your own data to the device handle.
Whenever you get callbacks, you can then get that data through that pointer.
Erich
That UserDataPtr comes from your application. You can pass NULL if you don't need such a pointer.
That pointer points to your own data structure where you can have in it whatever you want/need.
For example you can initialize device, and add with the user data pointer your own data to the device handle.
Whenever you get callbacks, you can then get that data through that pointer.
Erich
When I mouse over to LDD_TUserData it shows that that is actually a typedef for void. So what its actually doing is void *UserDataPtr. It is mentioned that this is the RTOS Device Structure pointer. What does that mean? Wikipedia says that void *x makes x a NULL pointer. So I suppose that is default because I am programming bareboard with no seleceted OS? But I still can't figure out what is this RTOS Device Structure.
void *ptr is a pointer to 'void', and in C this is a pointer to 'anything'. A void pointer is an unspecified type pointer, and used for these kind of things.
I don't know to which Wikipedia article you are referring, but to me this is pretty basic C language.
Sorry for the confusion. What I meant was void * ptr with ptr = 0 results in a null pointer. I just added the Wikipedia reference to clear doubts if any...
Thanks for your answer Erich