AnsweredAssumed Answered

SDK_2.3.0_MKE06Z128xxx4中,GPIO_PinInit()是否有问题?SDK只对base->PDDR进行了初始化,是否还应对base->PIDR初始化?

Question asked by YUDONG JIN on Mar 12, 2018
Latest reply on Mar 27, 2018 by Daniel Chen

原SDK如下,无法进行GPIO输入操作:

   if (config->pinDirection == kGPIO_DigitalInput)
    {
        base->PDDR &= ~(1U << ((uint32_t)pin + (shift * PIN_NUMBERS_EACH_PORT)));
    }
    else
    {
        GPIO_PinWrite(port, pin, config->outputLogic);
        base->PDDR |= (1U << ((uint32_t)pin + (shift * PIN_NUMBERS_EACH_PORT)));
    }

改成下列后,可以进行GPIO输入操作了

    if (config->pinDirection == kGPIO_DigitalInput)
    {
        base->PDDR &= ~(1U << ((uint32_t)pin + (shift * PIN_NUMBERS_EACH_PORT)));
        base->PIDR &= ~(1U << ((uint32_t)pin + (shift * PIN_NUMBERS_EACH_PORT)));
    }
    else
    {
        GPIO_PinWrite(port, pin, config->outputLogic);
        base->PDDR |= (1U << ((uint32_t)pin + (shift * PIN_NUMBERS_EACH_PORT)));
        base->PIDR |= (1U << ((uint32_t)pin + (shift * PIN_NUMBERS_EACH_PORT)));
    }

是否原SDK有问题?还是我的方法有问题?

Outcomes