gpio相关的一些结构体和操作函数

一个芯片的gpio一般都会有如下一些结构体,用来描述该gpio所具备的所有功能, 以及如何配置一个gpio:

1. gpio_config_t --- 一个gpio的配置,这个结构体通常用来表示一个gpio的具体配置

/* Configuration parameters for one GPIO pin.*/
typedef struct
{       
    gpio_mode_t         mode;           /* Defines mode (SOFTWARE or Alternate). */
    gpio_direction_t    direction;      /* Define pin direction (in SOFTWARE mode only). */
    gpio_trig_t         trig;           /* Interrupt trigger (in SOFTWARE mode only) */
    gpio_debounce_t     debounce;       /* Debounce logic control for pin (in SOFTWARE mode only) */
} gpio_config_t;

2. gpio_mode_t,  --- gpio 的工作模式:

/* Defines pin assignment(Software mode or Alternate mode) */
typedef enum
{
    GPIO_MODE_LEAVE_UNCHANGED,      /* Parameter will be ignored by the function. */
    GPIO_MODE_SOFTWARE,             /* Pin connected to GPIO (SW controlled) */
    GPIO_MODE_ALT_FUNCTION_A,       /* Pin connected to alternate function 1 (HW periph 1) */
    GPIO_MODE_ALT_FUNCTION_B,       /* Pin connected to alternate function 2 (HW periph 2) */
    GPIO_MODE_ALT_FUNCTION_C        /* Pin connected to alternate function 3 (HW periph 3) */
} gpio_mode_t;
3. gpio_direction_t --- 该gpio的输入输出方向

/* Defines GPIO pin direction */
typedef enum
{
    GPIO_DIR_LEAVE_UNCHANGED,       /* Parameter will be ignored by the function. */
    GPIO_DIR_INPUT,                 /* GPIO set as input */
    GPIO_DIR_OUTPUT                 /* GPIO set as output */
} gpio_direction_t;
4. gpio_trig_t --- 该gpio的中断触发方式:

/* Interrupt trigger mode */
typedef enum
{
    GPIO_TRIG_LEAVE_UNCHANGED,      /* Parameter will be ignored by the function */
    GPIO_TRIG_DISABLE,              /* Triggers no IT */
    GPIO_TRIG_RISING_EDGE,          /* Triggers an IT on a rising edge */
    GPIO_TRIG_FALLING_EDGE,         /* Triggers an IT on a falling edge */
    GPIO_TRIG_BOTH_EDGES           /* Triggers an IT on a rising and a falling edge */
//    GPIO_TRIG_HIGH_LEVEL,           /* Triggers an IT on a high level */
//    GPIO_TRIG_LOW_LEVEL             /* Triggers an IT on a low level */
} gpio_trig_t;
5. gpio_debounce_t ---去偶功能使用情况


                
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值