查看: 3034|回复: 1

PD9和PD10如何设置为普通IO,用做输入

[复制链接]

3

主题

5

帖子

97

积分

中级工程师

Rank: 2

积分
97
发表于 2023-3-3 10:29:26 | 显示全部楼层 |阅读模式
PD9,PD10引脚默认为模拟,如何配置,让它作为普通IO口使用,用为输入检测高低电平?
回复

使用道具 举报

155

主题

847

帖子

4701

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
4701
发表于 2023-3-14 10:54:58 | 显示全部楼层
自己配置 io口的 功能  

FL_GPIO_InitTypeDef  gpioInitStruct= {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);
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表