Files
433_STM32/Core/Inc/io_monitor.h

103 lines
2.7 KiB
C
Raw Permalink Normal View History

/**
******************************************************************************
* @file io_monitor.h
* @brief IO状态监控模块头文件
* @author Application Layer
* @version 1.1
******************************************************************************
* @attention
* (DI1-DI4)
* +IO状态变化
*
*
*
* v1.1 -
******************************************************************************
*/
#ifndef __IO_MONITOR_H
#define __IO_MONITOR_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stdbool.h>
#define IO_CHANNEL_COUNT 4
#define IO_SCAN_PERIOD_MS 10
#define IO_DEBOUNCE_COUNT 3
/**
* @brief IO事件回调函数类型
* @note IO状态变化时调用
* @param channel: (0-3DI1-DI4)
* @param state: (0=LOW, 1=HIGH)
* @param event_msg:
*/
typedef void (*io_event_callback_t)(uint8_t channel, uint8_t state, const char *event_msg);
/**
* @brief IO监控模块
* @note IO电平
* @param
* @retval
*/
void IO_Monitor_Init(void);
/**
* @brief IO监控任务处理函数
* @note 10ms扫描一次IO状态
*
* @param
* @retval
*/
void IO_Monitor_Task(void);
/**
* @brief IO状态
* @note
* @param channel: (0-3DI1-DI4)
* @retval 0: LOW, 1: HIGH
*/
uint8_t IO_Monitor_GetState(uint8_t channel);
/**
* @brief IO通道状态
* @note 4
* @param
* @retval (bit0=DI1, bit1=DI2, bit2=DI3, bit3=DI4)
*/
uint8_t IO_Monitor_GetAllStates(void);
/**
* @brief /IO状态变化上报
* @note
* @param enable: true=, false=
* @retval
*/
void IO_Monitor_EnableReport(bool enable);
/**
* @brief IO状态变化次数统计
* @note
* @param channel: (0-3)
* @retval
*/
uint32_t IO_Monitor_GetChangeCount(uint8_t channel);
/**
* @brief IO事件回调函数
* @note IO状态变化将通过回调函数上报
* @param callback: NULL则使用默认UART2输出
* @retval
*/
void IO_Monitor_SetEventCallback(io_event_callback_t callback);
#ifdef __cplusplus
}
#endif
#endif