Library 53- GPIO for STM32F4

GPIO is main thing when connecting your device with external things. As you know, ST started with HAL drivers and they want to remove STD periph drivers on which I’m working on this site.

So this is a next step, how to be independent of things you use. GPIO is used everywhere on my libs, and most problems will be with porting GPIO stuff to new system (when it will be need for that). I will start to migrate all my libs to my GPIO system (which will then be easily to port to HAL layer) so I will update my libs and you will be notified about that.

For start, I’ve update my USART library and it worked just great.

New system is more flexible to select which pins you want to use in your peripheral. I will update all my libs to this version.

Library

Features

  • Works with standard peripheral drivers
  • Works with HAL drivers
  • All GPIO functions included
  • Easy GPIO initialization
  • Version 1.1 – March 09, 2015
    • Added option to deinit GPIO pin

Dependencies

  • CMSIS
    • STM32F4xx
    • STM32F4xx RCC
    • STM32F4xx GPIO
  • TM
    • defines.h

Functions and enumerations

Below are listed all functions which can be used with GPIO.

Example

  • Bottom example just toggles leds, depending on which board you have selected on my Keil project template

Icon
TM STM32F4 GPIO Library

tilz0R

Owner of this site. Also electronic enthusiasts, web developer, 3D printer fan, handball player and more. Big fan of STM32F4 devices. In anticipation of the new Discovery board for STM32F7 lines.

You may also like...

Read before commenting!

Before you make a new comment, make sure you agree with things listed below:

  • - Read post to make sure if it is already posted what you are asking for,
  • - Make sure you have the latest version of libraries used in your project,
  • - Make a clean and grammatically correct written message,
  • - Report as many details as possible, including what have you done so far,
  • - Do NOT post any code here. Use Pastebin,
  • - Do NOT post any error codes here. Use Pastebin,
  • - Specify STM32Fxxx family and used Discovery/EVAL/Nucleo or custom made board,
  • - Make sure your clock is set correct for PLL,
  • - If you are using my HAL drivers, please check this post how to start.
Comment will be deleted on breaking these rules without notification!
  • TC Zeynel Abidin Delikan

    Dear TilzOR,

    Im working on STM32F429I Discovery kit very new.

    Firstly Thank you for your shareing.

    But ı didn’t work any examples on my kit ! I think ı make some mistake about lib’s.

    where can ı start to working with stm32F429I Discovery kit programming ?

  • Pingback: All STM32F4 libraries - STM32F4 Discovery()

  • Nayrio

    Hi Majerle,
    I’m not using the STM32 discovery but the stm32f401xe and I’m actually a little confused because I can’t get any gpio to work.
    I was looking you libs, and you’re not using the ‘hal’ ones. So I tried using yours but doesn’t seem to work neither
    Here’s the code i’m trying to get to work, nothing happens. http://pastebin.com/hCszBL3G
    Any idea what it could be

    • Hi,

      what is the difference between STM32 Discovery and STM32F401XE?
      This library, as mentioned above (if you read post you will see that) works with STD or HAL drivers!

      And, according to your example. what is result?
      LED is always ON? That’s because for loop is very fast done and your eye does not recognize LED blink. Increase for loop counter to 0xFFFFFF for example or even more. Second thing, set i variable to uint32_t with volatile so your compiler won’t throw it out.

      • Nayrio

        No, it doesn’t blink …
        I guess there are less periphs on the F401 than on the F429 but, it’s the same architecture.
        I’ve got a post on http://electronics.stackexchange.com/questions/183146/stm32f401-hello-world-code

        • Like on stack overflow, you might blow your pin.
          But question..from your asking I can “detect” that you are not really familiar with F4xx devices, so designing your board can be problem. If not, I’m sorry.

          But, does you CPU even starts? Boot pins are OK?

          • Nayrio

            Indeed, I’m not familiar with the F4 and tbh it’s quite different from the F103…
            The board starts, I’m able to upload my firmware (bootloader response) altough I don’t know if it even runs. But none of the GPIOs work…

          • You can try to go to debug. If processor comes to int main() function, then it starts.
            Is BOOT0 set to low? VCAP pin has 1.25V with 2u2F capacitor?

            This is not software problem. F401 is the same arhitecture as F429 and others, so software works here also. GPIOC is available on F401 also. PC13 has really only 3 mA so try on another pin also.

          • Nayrio

            BOOT0 is set to LOW yes, 4.7uF on VCAP1 yes.
            Ok so could it be that since the PC13 has only 3mA, when setting it to HIGH the voltage collapses and stm32f4 reboots (in a loop?)

          • Maybe there is a logic which resets MCU with this detect.
            Technically, 2u2F should be on VCAP pin.
            You can increase resistor to let’s say 10k on LED. You will still see if it blinks or not.