cancel
Showing results for 
Search instead for 
Did you mean: 

Configure GPIO through registers

StanCosgrove
Associate II

Hi i m learning to configure GPIO using registers, and come across the following code, can anyone kindly help to advise the following? what does the whole sentence do? what does the (volatile....) means, what does GPIO_OUT_DATA(0) does and what does  + SOC_GPIO_0_REGS means? 

 

#define GPIOSR_ADDR      (*(volatile unsigned int *)(GPIO_OUT_DATA(0) + SOC_GPIO_0_REGS))

1 REPLY 1
Sarra.S
ST Employee

Hello @StanCosgrove

'volatile' tells the compiler that the memory location can change unexpectedly, so it prevents it from optimizing the code related to this memory access.

GPIO_OUT_DATA(0): this macro likely returns the base address of the GPIO output data register port 0 

SOC_GPIO_0_REGS: this likely adds the offset of the GPIO base address to get the final memory address 

Overall, this code defines a mem address that can be used for read/write data from GPIO 

Please refer to the GPIO functional description (paragraph 4) in AN4899

 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.