88 lines
2.3 KiB
C
88 lines
2.3 KiB
C
|
|
/*
|
|||
|
|
* Copyright (c) 2006-2021, RT-Thread Development Team
|
|||
|
|
*
|
|||
|
|
* SPDX-License-Identifier: Apache-2.0
|
|||
|
|
*
|
|||
|
|
* Change Logs:
|
|||
|
|
* Date Author Notes
|
|||
|
|
* 2024-05-06 lijian the first version
|
|||
|
|
*/
|
|||
|
|
#ifndef APPLICATIONS_IO_INOUT_H_
|
|||
|
|
#define APPLICATIONS_IO_INOUT_H_
|
|||
|
|
|
|||
|
|
#include <rtthread.h>
|
|||
|
|
#include <drv_common.h>
|
|||
|
|
#include <rtdevice.h>
|
|||
|
|
|
|||
|
|
#define OUTPUT_NUM 8
|
|||
|
|
#define INPUT_NUM 8
|
|||
|
|
|
|||
|
|
#define IN1 0x22
|
|||
|
|
#define IN2 0x23
|
|||
|
|
#define IN3 0x24
|
|||
|
|
#define IN4 0x5
|
|||
|
|
#define IN5 0x6
|
|||
|
|
#define IN6 0x7
|
|||
|
|
#define IN7 0x8
|
|||
|
|
#define IN8 0x29
|
|||
|
|
|
|||
|
|
|
|||
|
|
typedef struct
|
|||
|
|
{
|
|||
|
|
rt_uint8_t Key; // 电平键值
|
|||
|
|
rt_uint8_t Key_Flag; // 电平键值
|
|||
|
|
rt_uint8_t InputType; // 输入类型 0输入 1转速 2针数
|
|||
|
|
rt_uint32_t Temp_Count; //中断触发次数
|
|||
|
|
rt_uint32_t Count; // 高低电平交替后触发次数
|
|||
|
|
rt_uint32_t NeedleCount; // 当前针数
|
|||
|
|
rt_uint32_t NeedleCount_last; // 当前针数
|
|||
|
|
rt_uint32_t NeedleCount_Sum; // 总针数
|
|||
|
|
rt_uint32_t Speed; // 速度
|
|||
|
|
rt_uint32_t Month_Count; // 月电平触发次数
|
|||
|
|
rt_uint32_t Month_NeedleCount_Sum; // 月总针数
|
|||
|
|
rt_uint32_t Old_Count; // 总电平触发次数
|
|||
|
|
rt_uint32_t Old_NeedleCount_Sum; // 总总针数
|
|||
|
|
} Data; // IO数据
|
|||
|
|
|
|||
|
|
|
|||
|
|
typedef struct
|
|||
|
|
{
|
|||
|
|
rt_uint32_t Ok_Num; // 产量
|
|||
|
|
rt_uint32_t Month_Num; // 月总产量
|
|||
|
|
rt_uint32_t Old_Num; // 历史产量
|
|||
|
|
rt_uint8_t Write_Flag; // 写入eeprom标志位:1已写入 0未写入
|
|||
|
|
rt_uint8_t Speed_io;//速度端口
|
|||
|
|
rt_uint8_t Needle_io;//针数端口
|
|||
|
|
rt_uint8_t SpeedUpdateFlag; // 速度更新标志位
|
|||
|
|
rt_uint8_t NeedleCountUpdateFlag; // 针数更新标志位
|
|||
|
|
} Flag; // IO状态
|
|||
|
|
|
|||
|
|
typedef struct
|
|||
|
|
{
|
|||
|
|
rt_uint8_t InputType; // 输入类型
|
|||
|
|
rt_uint8_t Key; // 键值
|
|||
|
|
} Out; // 输出IO状态
|
|||
|
|
|
|||
|
|
typedef struct
|
|||
|
|
{
|
|||
|
|
Out IO_Out[15]; // IO输出端口状态
|
|||
|
|
Data IO_Data[15]; // IO当前数据
|
|||
|
|
Flag IO_Flag; // IO状态
|
|||
|
|
|
|||
|
|
} IO_t; //IO结构体
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 输入引脚初始化
|
|||
|
|
*/
|
|||
|
|
void gpio_input_init(void);
|
|||
|
|
|
|||
|
|
//输出引脚初始化
|
|||
|
|
void gpio_output_init(void);
|
|||
|
|
|
|||
|
|
//获取端口电平触发次数
|
|||
|
|
rt_uint32_t get_IO_count(rt_uint8_t io);
|
|||
|
|
|
|||
|
|
//控制台更改电平
|
|||
|
|
void IO_key();
|
|||
|
|
#endif /* APPLICATIONS_IO_INOUT_H_ */
|