*(uint32_t *)0x40021018 = 0x00000004;
after a few days, it will become tiresome to read and to remember all those addresses. I suggest you to use the header [0] that the ST provides for STM32F1, which is included in packages such as STMCubeF1 [1], STMCubeF0, etc.For instance, instead of using the memory address directly, you could just do
RCC->APB2ENR |= RCC_APB2ENR_IOPAEN;
so it's easier to remember what is what. STMCubeF1 is a big package, but you won't be using the API/drivers ST provides (such as HAL and LL), just the header. As I understand, the STM32 community kind of rejects this API as "bloated".I have some examples here if you would like to take a look:
https://github.com/dbolgheroni/arm-makefile/blob/master/drv/...
Cheers,
[0] https://github.com/dbolgheroni/arm-makefile/blob/master/stm3... [1] https://www.st.com/en/embedded-software/stm32cubef1.html