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.

mistake of "typedef struct *_Obj *I_Handle" in f2802x includes

Other Parts Discussed in Thread: CONTROLSUITE

I am using controlSUITE, and found this in gpioExample:

((GPIO_Obj *)myGpio)->GPASET = 0xAAAAAAAA;

obviously myGpio is *GPIO_Obj, the conversion is not needed, and I found this:

typedef struct GPIO_Obj   *GPIO_Handle;

that means:

typedef struct struct {} *GPIO_Handle;

it should be:

typedef GPIO_Obj   *GPIO_Handle;

such mistake is also in :

$ grep -RG "typedef struct .*Handle" *
f2802x/v210/f2802x_common/include/adc.h:typedef struct ADC_Obj *ADC_Handle;
f2802x/v210/f2802x_common/include/cap.h:typedef struct CAP_Obj *CAP_Handle;
f2802x/v210/f2802x_common/include/clk.h:typedef struct CLK_Obj *CLK_Handle;
f2802x/v210/f2802x_common/include/comp.h:typedef struct COMP_Obj *COMP_Handle;
f2802x/v210/f2802x_common/include/cpu.h:typedef struct CPU_Obj *CPU_Handle;
f2802x/v210/f2802x_common/include/flash.h:typedef struct FLASH_Obj *FLASH_Handle;
f2802x/v210/f2802x_common/include/gpio.h:typedef struct GPIO_Obj *GPIO_Handle;
f2802x/v210/f2802x_common/include/i2c.h:typedef struct I2C_Obj *I2C_Handle;
f2802x/v210/f2802x_common/include/osc.h:typedef struct OSC_Obj *OSC_Handle;
f2802x/v210/f2802x_common/include/pie.h:typedef struct PIE_Obj *PIE_Handle;
f2802x/v210/f2802x_common/include/pll.h:typedef struct PLL_Obj *PLL_Handle;
f2802x/v210/f2802x_common/include/pwm.h:typedef struct PWM_Obj *PWM_Handle;
f2802x/v210/f2802x_common/include/pwr.h:typedef struct PWR_Obj *PWR_Handle;
f2802x/v210/f2802x_common/include/sci.h:typedef struct SCI_Obj *SCI_Handle;
f2802x/v210/f2802x_common/include/spi.h:typedef struct SPI_Obj *SPI_Handle;
f2802x/v210/f2802x_common/include/timer.h:typedef struct TIMER_Obj *TIMER_Handle;
f2802x/v210/f2802x_common/include/wdog.h:typedef struct WDOG_Obj *WDOG_Handle;
f2802x0/v110/......

Hope to fix :)

  • Hi Larry,

    This one was a little over my head, but I consulted with the original author of these drivers and he had this to say:

    "We want to use 

    typedef struct  _GPIO_Obj_ *GPIO_Handle;

     (Note the underscore before and after the object name).  This typedef

     typedef struct  GPIO_Obj *GPIO_Handle;

     which created a namespace collision when the code is used in C++.  It does not show up in C.

     Regarding the e2e post, what is proposed will work, but we want to force users to pass handles to functions and not addresses of objects.  Thus, by having a handle defined as a struct and is the first argument to a function, if someone passes the address of the object, the compiler will complain.  "

    I also received a guide which goes over some of the methodology behind this:

    8686.Introduction to Structures and Objects.docx 

    Long story short, this works as is and will not be changed.

    BR,

  • Trey German said:

    "We want to use 

    typedef struct  _GPIO_Obj_ *GPIO_Handle;

     (Note the underscore before and after the object name).

    However actual it is typedef struct  GPIO_Obj *GPIO_Handle; ?