This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Why Is DRV_Handle so Defined?

Other Parts Discussed in Thread: MOTORWARE, CONTROLSUITE

In motorware source file drv_obj.h

typedef struct _DRV_Obj_

{
ADC_Handle adcHandle; //!< the ADC handle
CLK_Handle clkHandle; //!< the clock handle

...

} DRV_Obj;

and

typedef struct DRV_Obj *DRV_Handle;

Why the handle was not defined as

typedef DRV_Obj *DRV_Handle;

If this way, in function (and other functions)

DRV_init(void *pMemory,const size_t numBytes) { }

handle = (DRV_Handle)pMemory;

// assign the object

obj = (DRV_Obj *)handle;

obj would be the same as handle, therefore, unnecessarily repeated, one could use handle as the pointer in operations and return it as it is at the end of the function.

Please comment.

  • Louis,

    A handle should not be defined as just a typedef (typedef _Object_  *ObjHandle) because that would allow object parameters to be accessed using pointers of type Object (which is not allowed as part of the software architecture).

     We use a structure name to ensure handles are passed to functions and not pointers to objects.   With another level of abstraction, the user would not be able to see the object definitions.  But we choose not to hide it.

    There are some items like this that we should more fully explain in the MotorWare coding standards document.

     

  • Now I understand the intention of the programming model. Thanks for your explanation.

  • Hi,

    Just thought I would add to this as fairly new to the C2000, but have been using the MSP430 and also the old LM3S Stellaris boards.

    I am used to changing all the registers on the MSP430 and seeing the C2000 software confused me at first (Still don't fully understand all the pointer magic).  From using the Stellaris LM3S I found the Peripheral Driver Library PDF invaluable, and there is one for the C2000 as well!

    It gives a good explanation on the programming model, in chapter 2 (page 7 and 8).  You can find it by navigating through the control suite software (as per the image below).  I did also look via the documentation searches for the C2000 but couldn't find it, this document should be front and center in my opinion as invaluable for anyone new to the C2000.

    Cheers,

    Ant

  • Ant,

    good post and glad you found what you needed.

    For those using MotorWare, the PDL document applies for the Software Driver Model.  MotorWare code is in the same style as the controlSUITE Software Driver Model.  Which is also very similar to the StellarisWare software you are familiar with.

    For MotorWare you get a complete listing of the APIs not in a document, but inside the MotorWare.exe though Doxygen generated HTML.  This allows you to navigate quite quickly inside of code and see where APIs are used and how they are related.