Why does the user need to provide DeviceData in every Processor Expert LDD API call?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Why does the user need to provide DeviceData in every Processor Expert LDD API call?

Jump to solution
1,026 Views
stephenlangstaf
Contributor III

If I create an instance of a driver using Processor Expert, why do I have to pass a DeviceData pointer into the API?

 

For example, if I create a component for the blue LED on my FRDM-KL25Z board named 'LED_BLUE' and of type 'BitIO_LDD', files are created called 'LED_BLUE.c' and 'LED_BLUE.h' and the API functions are prefixed by the name LED_BLUE (e.g. LED_BLUE_Init(), LED_BLUE_PutVal()).

 

I would have thought that this would be enough context for the component to know what object we are talking about without also having to pass LED_BLUE_DeviceData as the first parameter of each function.

 

Couldn't the component store a reference to its own DeviceData? Is there something I am missing?

Labels (1)
0 Kudos
Reply
1 Solution
828 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello Stephen:

Some components require this DeviceData pointer to maintain portability or RTOS compatibility, since this handler stores configuration parameters, component status, events, etc.

However in the case of BitIO_LDD, you are correct that this is a weakness of Processor Expert generated code. Colleague Erich Styger suggests a workaround in his blog:

Optimized BitIO_LDD Programming with Processor Expert | MCU on Eclipse

Regards!

Jorge_Gonzalez

View solution in original post

0 Kudos
Reply
2 Replies
829 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello Stephen:

Some components require this DeviceData pointer to maintain portability or RTOS compatibility, since this handler stores configuration parameters, component status, events, etc.

However in the case of BitIO_LDD, you are correct that this is a weakness of Processor Expert generated code. Colleague Erich Styger suggests a workaround in his blog:

Optimized BitIO_LDD Programming with Processor Expert | MCU on Eclipse

Regards!

Jorge_Gonzalez

0 Kudos
Reply
828 Views
stephenlangstaf
Contributor III

Thanks Jorge,

I see now there is a high(er) level driver 'BitIO' that wraps the 'BitIO_LDD' driver calls, providing the useless DeviceData pointer so I don't have to.

Thanks again,

Steve.

0 Kudos
Reply