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?
Solved! Go to Solution.
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
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
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.