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.

[solved]GPIO example -missing field?

Hi,

That's will be a basic question. I am examining the GPIO example in dvdsk.

The pin1 is set to output using

CSL_FINS( gpioRegs->DIR01, GPIO_DIR01_DIR1, CSL_GPIO_DIR01_DIR1_OUT );

But there is no GPIO_DIR01_DIR1 defined in the code, altough it compiles without any error.

GPIO_DIR01_DIR1 is supposed to represent the field 1 of the DIR01 register. But somehow it doesn't exist in the code.

Thanks.

 

  • I took a look around my DVSDK and could not find a GPIO example like you are referencing, so I am curious what version of the DVSDK you are using and what folder the example is under?

    As a more general response to this, if the code is compiling and linking than the value must be defined somewhere, perhaps a nested header file.

    EDIT: I just realized that based on prior posts you are probably working with DM6437, I will have to rethink this one.

  • So this time I think I have it, looking at the example in C:\dvsdk_1_01_00_15\psp_1_00_02_00\pspdrivers\soc\dm6437\examples\GPIO you are correct, the value GPIO_DIR01_DIR1 does not exist, even codesense cannot find it, yet it still builds...

    The reason for this can be found within cslr.h and the definition of the CSL_FINS() macro, the macro actually takes the values you put into CSL_FINS and adds to them to form the actual and correct value (i.e. it puts on a CSL_ and a _MASK to complete the value), since this is done as a preprocessor step it is completed before the compiler gets its hands on the code, so when you put GPIO_DIR01_DIR1 in there the compiler actually ends up seeing CSL_GPIO_DIR01_DIR1_MASK and CSL_GPIO_DIR01_DIR1_SHIFT (since the CSL_FMK macro is nested inside the CSL_FINS macro). To prove this out you can change the value that is passed into the second argument of CSL_FINS and observe the resulting error messages to see that what the macros are really doing. For example if you change the line to:

    CSL_FINS( gpioRegs->DIR01, GPIO_DIR01_DIR1OVERLYCOMPLEXMACRO, CSL_GPIO_DIR01_DIR1_OUT );

    Than you should get error messages like:

    "GPIO_example.c", line 77: error: identifier "CSL_GPIO_DIR01_DIR1OVERLYCOMPLEXMACRO_MASK" is undefined
    "GPIO_example.c", line 77: error: identifier "CSL_GPIO_DIR01_DIR1OVERLYCOMPLEXMACRO_SHIFT" is undefined

    Thus showing that the macro is adding in the CSL_ ... _MASK to the value.

  • Yes, later I noticed it was set up in the macro. This was the case first time I have seen such a thing.

    Thank you.