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**********************************************************************
*
* Function Name : GPIO_DRV_OutputPinInit
* Description   : Initialize one GPIO output pin used by board.
*
*END**************************************************************************/
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*/
    CLOCK_SYS_EnablePortClock(port);

    /* 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);

    #if FSL_FEATURE_PORT_HAS_SLEW_RATE
    PORT_HAL_SetSlewRateMode(portBase, pin, outputPin->config.slewRate);
    #endif
    #if FSL_FEATURE_PORT_HAS_DRIVE_STRENGTH
    PORT_HAL_SetDriveStrengthMode(portBase, pin, outputPin->config.driveStrength);
    #endif
    #if FSL_FEATURE_PORT_HAS_OPEN_DRAIN
    PORT_HAL_SetOpenDrainCmd(portBase, pin, outputPin->config.isOpenDrainEnabled);
    #endif

    //**** 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
Juergen

Outcomes