joecongmin 发表于 2022-9-4 21:40:35

GPIO例子程序

技术支持:
          您好!我在KEIL 例子程序_v4.02中找不到操作I/O口的GPIO例子工程,请问哪一个工程是操作GPIO口的 ,谢谢

顾博文 发表于 2022-9-5 10:49:02

    FL_EXTI_CommonInitTypeDefextiCommonInitStruct = {0};

    //用到的GPIO引脚    设为输入
    gpioInitStruct.pin      = FL_GPIO_PIN_6;
    gpioInitStruct.mode       = FL_GPIO_MODE_INPUT;//输入
    gpioInitStruct.outputType = FL_GPIO_OUTPUT_PUSHPULL;
    gpioInitStruct.pull       = FL_ENABLE;
    gpioInitStruct.remapPin   = FL_DISABLE;
    FL_GPIO_Init(GPIOC, &gpioInitStruct);


FL_GPIO_GetInputPin(GPIOC,FL_GPIO_PIN_6); //获取输入

    //用到的GPIO引脚    设为输出
    gpioInitStruct.pin      = FL_GPIO_PIN_6;
    gpioInitStruct.mode       = FL_GPIO_MODE_OUTPUT//输出
    gpioInitStruct.outputType = FL_GPIO_OUTPUT_PUSHPULL;
    gpioInitStruct.pull       = FL_ENABLE;
    gpioInitStruct.remapPin   = FL_DISABLE;
    FL_GPIO_Init(GPIOC, &gpioInitStruct);

FL_GPIO_SetOutputPin((GPIOC,FL_GPIO_PIN_6); //输出高
FL_GPIO_ResetOutputPin((GPIOC,FL_GPIO_PIN_6); //输出低      


    //用到的GPIO引脚    设为模拟
    gpioInitStruct.pin      = FL_GPIO_PIN_6;
    gpioInitStruct.mode       = FL_GPIO_MODE_ANALOG//模拟
    gpioInitStruct.outputType = FL_GPIO_OUTPUT_PUSHPULL;
    gpioInitStruct.pull       = FL_ENABLE;
    gpioInitStruct.remapPin   = FL_DISABLE;
    FL_GPIO_Init(GPIOC, &gpioInitStruct);

    //用到的GPIO引脚    设为数字
    gpioInitStruct.pin      = FL_GPIO_PIN_6;
    gpioInitStruct.mode       = FL_GPIO_MODE_DIGITAL//数字
    gpioInitStruct.outputType = FL_GPIO_OUTPUT_PUSHPULL;
    gpioInitStruct.pull       = FL_ENABLE;
    gpioInitStruct.remapPin   = FL_DISABLE;//如果同一端口有两个数字功能,通过这里选
    FL_GPIO_Init(GPIOC, &gpioInitStruct);

joecongmin 发表于 2022-9-5 22:03:38

好的,非常感谢了
页: [1]
查看完整版本: GPIO例子程序