AnsweredAssumed Answered

Single GPIO initialization for both F1 and F3/F4 series

Question asked by elia.st on May 4, 2015
Hi,

I'm trying to write a custom initialization for GPIO of F1 and F3/F4 series. I've defined most of the MODE and IO types but stuct at alternate input mode. F1 series puts the pin to input mode while F3/F4 just sets AF mode. So I've come up with the following pseudocode.

    // alternate function input
    #if defined(__F3) || defined(__F4)
    // F3 series (later F4 as well)
    AF_INPUT_PN     => .GPIO_Mode = GPIO_Mode_AF, .GPIO_PuPd = GPIO_PuPd_NOPULL //omit .GPIO_OType
    AF_INPUT_PU     => .GPIO_Mode = GPIO_Mode_AF, .GPIO_PuPd = GPIO_PuPd_UP //omit .GPIO_OType
    AF_INPUT_PD     => .GPIO_Mode = GPIO_Mode_AF, .GPIO_PuPd = GPIO_PuPd_DOWN //omit .GPIO_OType
    + GPIO_PinAFConfig(...)
    #else // __F1 series
    // F1 series
    AF_INPUT_PN     => .GPIO_Mode = GPIO_Mode_IN_FLOATING
    AF_INPUT_PU     => .GPIO_Mode = GPIO_Mode_IPU
    AF_INPUT_PD     => .GPIO_Mode = GPIO_Mode_IPD
    + GPIO_PinRemapConfig(...)
    #endif


Do you think it is correct?

Outcomes