IFA semiconductor also released the stdperiph_driver library file when it came out of this board.
You can see the following content according to the library and demonstration.
There is such a call in Main. C.
Performance_eval_ledtoggle (led4 );
The prototype of this function is from stm32f4_discovery.c, which is similar to the following:
Void pai_eval_ledon (led_typedef led)
{
Gpio_port [led]-> bsrrl = gpio_pin [led];
}
The definition of led_typedef is defined as Enum in stdperiph_driver.
Gpio_port is defined as a pointer of gpio_typedef struct.
Gpio_typedef * gpio_port [ledn] = {led4_gpio_port, led3_gpio_port, led5_gpio_port, led6_gpio_port };
Ledx_gpio_port is defined as gpiod with a macro.
Gpiod is defined as gpiod_base by macro
Gpiod_base is also defined as ahb1periph_base with an offset 0x0c00.
Familiar with arm, it is hard to know that the ahb1periph_base address is 0x40020000.
Therefore, gpio_typedef * gpio_port [] defines an array pointer pointing to the same address, that is, the address of gpio register.
Then, use the following struct as the bitband operation to observe the relationship between address offset and stm32_manual.
Typedef struct
{
_ IO uint32_t Moder ;/*! <Gpio port mode register, address offset: 0x00 */
_ IO uint32_t otyper ;/*! <Gpio port output type register, address offset: 0x04 */
_ IO uint32_t ospeedr ;/*! <Gpio port output speed register, address offset: 0x08 */
_ IO uint32_t pupdr ;/*! <Gpio port pull-up/pull-down register, address offset: 0x0c */
_ IO uint32_t IDR ;/*! <Gpio port input data register, address offset: 0x10 */
_ IO uint32_t ODR ;/*! <Gpio port output data register, address offset: 0x14 */
_ IO uint16_t bsrrl ;/*! <Gpio port bit set/Reset low register, address offset: 0x18 */
_ IO uint16_t bsrrh ;/*! <Gpio port bit set/Reset high register, address offset: 0x1a */
_ IO uint32_t lckr ;/*! <Gpio port configuration lock register, address offset: 0x1c */
_ IO uint32_t AFR [2];/*! <Gpio alternate function registers, address offset: 0x20-0x24 */
} Gpio_typedef;
?
?
Then, restore this sentence gpio_port [led]-> bsrrl = gpio_pin [led];
That is, the data 0x1000 is sent to the address 0x40020c18.
?
Then we can check the gpio_typedef and send the gpio port bit set/Reset low register to 0x1000.
Gpio has 16 I/O, so we compare the pin12 conversion, that is, 0001 0000 0000b
That is, 0x1000
For more information, see my previous article.
Stm32f4discovery led toggle (2)