Giter Site home page Giter Site logo

io_input_filter's Introduction

io_input_filter IO输入滤波软件包

1 介绍

io_input_filter 软件包提供一个有效的输入滤波功能,它会检测引脚电平的稳定状态,直到检测到持续稳定后才会触发状态改变,软件包提供简单易用的接口函数,用户可通过调整IIF_TIMESIIF_PERIOD两个宏来改变滤波条件。

2 使用方法

2.1 配置宏

IIF_TIMES       // 滤波次数,连续 IIF_TIMES 次读取引脚电平持续为高/低的次数
IIF_PERIOD      // 滤波周期,每隔 IIF_PERIOD 毫秒读取一次引脚电平
IIF_DEBUG_MODE  // IIF调试信息输出

2.2 接口说明

2.2.1 数据结构:

struct io_input_filter
{
    uint8_t pin_id;           // 引脚id,可以由 GET_PIN() 获取
    uint8_t pin_status;       // 滤波后的引脚状态,高/低
    uint8_t filter_counts;    // 当前引脚电平已经持续稳定的次数
    struct io_input_filter *next;    // 单向链表 next
};

2.2.2 函数说明:

  1. void iif_init(void); 初始化函数,使用之前请先进行初始化。

  2. int iif_add_pin(rt_base_t pin); 将一个引脚加入滤波控制器中,例如:

#define IO_IN1  GET_PIN(D, 11)
iif_add_pin(IO_IN1);
  1. int iif_read_pin(rt_base_t pin); 读取引脚状态,例如:
if(iif_read_pin(IO_IN1) == PIN_HIGH)
	rt_kprintf("IO_IN1 Changed to HIGH\n");
else
	rt_kprintf("IO_IN1 Changed to LOW\n");

3 注意事项

软件包需要使能软件定时器RT_USING_TIMER_SOFT

4 联系方式

https://github.com/lizdDong/io_input_filter

io_input_filter's People

Contributors

lizddong avatar zhkag avatar

Watchers

 avatar

Forkers

lycchang zhkag

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.