AnsweredAssumed Answered

Pot. problem in KSDK, fsl_gpio_driver.c, GPIO_DRV_OutputPinInit()

Question asked by Juergen Marquardt on Oct 15, 2015
Latest reply on Oct 16, 2015 by David E Seymour

Hi, found a problem in


* Function Name : GPIO_DRV_OutputPinInit
* Description   : Initialize one GPIO output pin used by board.
void GPIO_DRV_OutputPinInit(const gpio_output_pin_user_config_t *outputPin)
    /* Get actual port and pin number.*/
    uint32_t port = GPIO_EXTRACT_PORT(outputPin->pinName);
    uint32_t pin = GPIO_EXTRACT_PIN(outputPin->pinName);
    GPIO_Type * gpioBase = g_gpioBase[port];
    PORT_Type * portBase = g_portBase[port];

    /* Un-gate port clock*/

    /* Set current pin as gpio.*/
    PORT_HAL_SetMuxMode(portBase, pin, kPortMuxAsGpio);

    //--- changed sequence (WritePinOutput->SetPinDir) by JM 2015.10.15
    GPIO_HAL_WritePinOutput(gpioBase, pin, outputPin->config.outputLogic);

//**** This will set output to "0" and therefore cause a glicth if configured to "1" ****//
//****    /* Set current pin as digital output.*/
//****    GPIO_HAL_SetPinDir(gpioBase, pin, kGpioDigitalOutput);

    /* Configure GPIO output features. */
    GPIO_HAL_WritePinOutput(gpioBase, pin, outputPin->config.outputLogic);

    PORT_HAL_SetSlewRateMode(portBase, pin, outputPin->config.slewRate);
    PORT_HAL_SetDriveStrengthMode(portBase, pin, outputPin->config.driveStrength);
    PORT_HAL_SetOpenDrainCmd(portBase, pin, outputPin->config.isOpenDrainEnabled);

    //**** This will finally set output pin - with programmed characteristics - to configured value ****//
    GPIO_HAL_SetPinDir(gpioBase, pin, kGpioDigitalOutput);



Setting pin direction to output too early will cause a glitch to "0" if pin was configured to "1".
Also will set output not with programmed characteristics.
So, setting direction to output should be done at the end of this function, I think?
Best regards