G-CAMS-DATU/applications/IO/inout.h
2024-07-12 16:22:49 +08:00

113 lines
3.1 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* 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 IN0 0x22 //1
#define IN1 0x23 //2 锁1状态
#define IN2 0x5 //3 锁2状态
#define IN3 0x6 //4 锁3状态
#define IN4 0x7 //5 右盖板检测
#define IN5 0x24 //6 左盖板检测
#define IN6 0x8 //7 启停
#define IN7 0x29 //8 主轴
#define OUT0 GET_PIN(A, 11) //1
#define OUT1 GET_PIN(C, 8) //2
#define OUT2 GET_PIN(C, 7) //3
#define OUT3 GET_PIN(B, 12) //4
#define OUT4 GET_PIN(B, 13) //5
#define OUT5 GET_PIN(B, 14)//6
#define OUT6 GET_PIN(B, 15) //7
#define OUT7 GET_PIN(C, 6) //8
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; // 针数更新标志位
rt_uint8_t log;
rt_uint8_t Value;
} Flag; // IO状态
typedef struct
{
rt_uint8_t InputType; // 输入类型
rt_uint8_t Key; // 键值
} Out; // 输出IO状态
typedef struct
{
Out IO_Out[8]; // IO输出端口状态
Data IO_Data[8]; // 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);
//获取端口电平值
rt_uint8_t get_IO_Value();
rt_uint8_t get_IO_NeedleCountUpdateFlag();
void set_IO_NeedleCountUpdateFlag(rt_uint8_t flag);
void set_IO_Needle_io(rt_uint8_t io);
//控制台更改电平
void IO_key();
rt_uint32_t get_IO_NeedleCount_sum();
void set_IO_NeedleCount_sum(rt_uint8_t count);
void updateKeyValue(void);
void updateNeedleCount(void);
void set_IO_log(rt_uint8_t log);
#endif /* APPLICATIONS_IO_INOUT_H_ */