How does the HAL/LL function LL_GPIO_SetPinMode() work?
Ok, I scratched my head long enough and now my hope lies with the ST Community. =)
I would like to understand how this code in the header file stm32f1xx_ll_gpio.h works. In particular, what does (Pin >> 24) do? I suspect that the code sets two registers: GPIOx_BSRR and GPIOx_CRL. Here:
Pin = LL_GPIO_PIN_5
GPIOx = GPIOC
Thank you.
__STATIC_INLINE void LL_GPIO_SetPinMode(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t Mode)
{
register uint32_t *pReg = (uint32_t *)((uint32_t)(&GPIOx->CRL) + (Pin >> 24));
MODIFY_REG(*pReg, ((GPIO_CRL_CNF0 | GPIO_CRL_MODE0) << (POSITION_VAL(Pin) * 4U)),
Mode << (POSITION_VAL(Pin) * 4U)));
}
