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.

SitaraWare GPIOSetDirMode

Other Parts Discussed in Thread: AM1808

In the GPIOSetDirMode function in SitaraWare, the second argument is "the serial number of the GPIO pin." Where is this documented?

It's mentioned in the SitaraWare User's Guide, but finding it for a given pin isn't documented. The AM17x/AM18x GPIO User's Guide (SPRUFV2A) contains no mention of a serial number. The AM1808 datasheet (SPRS653B), which contains the Pin Map of the device, contains the GPx[y] names and the BGA grid references (e.g. V3 = GP7[13]), but still no mention of a serial number.

According to the SitaraWare Migration Notes, the pin serial number was used to keep the number of arguments the same. The first argument to the StellarisWare function was the base address of the relevant GPIO bank, but since Sitara only has one base register, I think that the first argument to this function could be made more useful; perhaps something that implies the bank you're trying to set. Perhaps, to be more like StellarisWare, some defines could be added like:

#define GPIO_O_DIR 0x0
#define GPIO_O_OUT_DATA 0x4
#define GPIO_O_SET_DATA 0x8
...
#define GPIO_O_INTSTAT 0x24

#define GPIO_BANK01_BASE (SOC_GPIO_0_REGS + 0x10)
#define GPIO_BANK23_BASE (SOC_GPIO_0_REGS + 0x38)

 

I accept that some things are going to change between these two platforms, but in the interests of migrating from Stellaris to Sitara, the very first function in the Migration Notes could have been made more consistent.

  • See table 1 in the GPIO UG. The first column 'GPIO Pin Number' is the value you need.

    I ran into the same issue recently and I already told the Sitaraware team that I see no reason why there can't be a header file which defines this values for a certain platform... So no need for PDF juggling.

    Regards.

  • Ah, there it is.

    On a similar note, the macro for calculating the offset of the GPIO direction register in include/hw/hw_gpio.h won't work intuitively:

    #define GPIO_DIR(n)        (0x10 + (0x28 * n))

    GPIO_DIR(0) will work correctly, but GPIO_DIR(1) will not. GPIO_DIR(1) will be the offset to DIR23 instead of DIR01.

    Do you know if anyone who was involved with the creation of StellarisWare is on the SitaraWare team? Should I bring up issues like these through the mailing list sitaraware_support@list.ti.com, or do they monitor the forums? Do they accept patches?

  • Eric,

    no, I think Sitaraware is done by different people really.

    Yes, I think we welcome feedback. Safe way would be to send the info (especially bugs) to the support list. I assume forums will be watched too but there is a chance it gets missed.

    Patches might make it easier to verify and confirm issues. But I can't speak for the team if and when any changes get accepted. 

    Regards.

  • Eric,

    In the macro #define GPIO_DIR(n)        (0x10 + (0x28 * n))   'n' refers to the register number (nth DIRxx register) and not the pin number. We will add appropriate comment in the header file.

    The GPIO DAL API's (in drivers/gpio.c) the function GPIODirModeSet() takes pin number as one of the parameters, calculates the register number and passes the register number to the above macro to calculate exact register address.

    So the above macro will work as expected.

     

    Regards

    Baskaran