Search code examples
carmembeddedmicrocontrollercortex-m

Can anyone explain this complicated pointer expression?


I found this below code line which is a function call at driver library. I am trying to understand this pointer expression. But it is hard to understand.

ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);

Below code lines are definition of components of above code.

#define SYSCTL_PERIPH_GPIOA     0xf0000800  // GPIO A
#define ROM_SysCtlPeripheralEnable                                            \
    ((void (*)(uint32_t ui32Peripheral))ROM_SYSCTLTABLE[6])
#define ROM_SYSCTLTABLE         ((uint32_t *)(ROM_APITABLE[13]))   
#define ROM_APITABLE            ((uint32_t *)0x01000010)

Solution

  • ROM_SYSCTLTABLE[6] 
    

    holds a some data.That data is memory location where a function is stored.This function takes argument of type uint32_t and returns nothing. When you write

    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    

    It means that you are calling that function by passing argument as 0xf0000800