当前位置:网站首页>华大4A0GPIO设置

华大4A0GPIO设置

2022-06-24 19:32:00 纸带

typedef struct
{
    uint16_t u16PinState;     /*!< Set pin state to High or Low, @ref GPIO_PinState_Sel for details       */
    uint16_t u16PinDir;       /*!< Pin mode setting, @ref GPIO_PinDirection_Sel for details               */
    uint16_t u16PinOType;     /*!< Output type setting, @ref GPIO_PinOutType_Sel for details              */
    uint16_t u16PinDrv;       /*!< Pin drive capacity setting, @ref GPIO_PinDrv_Sel for details           */
    uint16_t u16Latch;        /*!< Pin latch setting, @ref GPIO_PinLatch_Sel for details                  */
    uint16_t u16PullUp;       /*!< Internal pull-up resistor setting, @ref GPIO_PinPU_Sel for details     */
    uint16_t u16Invert;       /*!< Pin input/output invert setting, @ref GPIO_PinInvert_Sel               */
    uint16_t u16PinIType;     /*!< Input type setting, @ref GPIO_PinInType_Sel                            */
    uint16_t u16ExInt;        /*!< External interrupt pin setting, @ref GPIO_PinExInt_Sel for details     */
    uint16_t u16PinAttr;      /*!< Digital or analog attribute setting, @ref GPIO_PinMode_Sel for details */
} stc_gpio_init_t;
        pstcGpioInit->u16PinState   = PIN_STATE_RESET;//设置引脚状态是高低电平
        pstcGpioInit->u16PinDir     = PIN_DIR_IN;//设置输入还是输出
        pstcGpioInit->u16PinOType   = PIN_OTYPE_CMOS;//设置是NMOS还是PMOS输出
        pstcGpioInit->u16PinDrv     = PIN_DRV_LOW;//设置推挽输出方式,是高低中速输出
        pstcGpioInit->u16Latch      = PIN_LATCH_OFF;//锁存使能//锁存失能
        pstcGpioInit->u16PullUp     = PIN_PU_OFF;/内部上拉的使能调节
        pstcGpioInit->u16Invert     = PIN_INVERT_OFF;//输入输出。反转使能
        pstcGpioInit->u16PinIType   = PIN_ITYPE_SMT;//输入的方式分为SMT输入CMOS的输入
        pstcGpioInit->u16ExInt      = PIN_EXINT_OFF;//外部中断
        pstcGpioInit->u16PinAttr    = PIN_ATTR_DIGITAL;//数字和模拟属性

 关于4A0的一个运用的一般步骤:

    stc_gpio_init_t stcGpioInit;//声明一个gpio的配置struct.

    /* Register write enable for some required peripherals. */
    Peripheral_WE();

    /* LED initialize */
    (void)GPIO_StructInit(&stcGpioInit);//关于gpio各个属性的设置。
    (void)GPIO_Init(LED_GREEN_PORT, LED_GREEN_PIN, &stcGpioInit);//某一个引脚的设置,在来一个初始化。

    /* Register write protected for some required peripherals. */
    Peripheral_WP();

    /* "Turn off" LED before set to output */
    GPIO_ResetPins(LED_GREEN_PORT, LED_GREEN_PIN);//设置单独的高低电平输出输入

    /* Output enable */
    GPIO_OE(LED_GREEN_PORT, LED_GREEN_PIN, Enable);//设置高低电平的输出
    for (;;)
    {
        /* LED */
        GPIO_SetPins(LED_GREEN_PORT, LED_GREEN_PIN);//
        DDL_DelayMS(2000UL);//延时
        GPIO_ResetPins(LED_GREEN_PORT, LED_GREEN_PIN);//
        DDL_DelayMS(2000UL);//延时
        /* De-init port if necessary */
        //GPIO_DeInit();
    }

原网站

版权声明
本文为[纸带]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_39657978/article/details/125420871