zynq_7010/DevUtil.h

159 lines
5.2 KiB
C
Raw Normal View History

2023-07-17 03:29:37 +00:00
#pragma once
#include <string>
#include <fstream>
#include <memory>
#include "scanservices_utils.h"
template<typename ... Args>
std::string string_format(const std::string& format, Args ... args) {
size_t size = snprintf(nullptr, 0, format.c_str(), args ...) + 1;
std::unique_ptr<char[]> buf(new char[size]);
snprintf(buf.get(), size, format.c_str(), args ...);
return std::string(buf.get(), buf.get() + size - 1);
}
template<typename T>
void write_dev(std::string path, T value) {
std::ofstream ofout(path);
ofout << value;
}
extern int read_dev_i(std::string path);
extern std::string read_dev_s(std::string path);
enum PIN_PORT_7010
{
//通道0-------------START
SCAN_SENSOR = 0 + 1019, //扫描传感器
HAVE_OR_NO_PAPER = 3 + 1019, //有无纸(0无纸1有纸)
OPEN_COVER_SENSOR = 4 + 1019, //是否开盖0未开盖1开盖
2023-08-31 08:37:05 +00:00
ULTRASONIC_SENSORS_OUT0 = 18 + 901,
ULTRASONIC_SENSORS_OUT1 = 17 + 901,
ULTRASONIC_SENSORS_ON = 20 + 901,
ULTRASONIC_SENSORS_ADJ = 19 + 901,
2023-07-17 03:29:37 +00:00
//通道0-------------END
SENSOR_POWER = 66 + 1019,
//通道1-------------START
BUTTON_1_POWER = 21+1019, //按键1 电源
BUTTON_2 = 22+1019, //按键2
BUTTON_3 = 23+1019, //按键3
LED_0_GREEN = 24+1019,
LED_1_WHITE = 25+1019,
LED_2_RED = 26+1019,
//PWM0 电机1-START
CUOZHI_PIN_DIR = 54+901, //方向0
CUOZHI_PIN_ENABEL = 55+901, //使能有效0
CUOZHI_PIN_RESET = 56+901, //重启 1电机转动一般默认为1
CUOZHI_PIN_SLEEP = 57+901, //睡眠 1电机转动一般默认为1
//PWM0 电机1-END
//PWM1 电机2-START
ZOUZHI_PIN_DIR = 59+901, //方向0
ZOUZHI_PIN_ENABEL = 60+901, //使能有效0
ZOUZHI_PIN_RESET = 61+901, //重启 1电机转动一般默认为1
ZOUZHI_PIN_SLEEP = 62+901, //睡眠 1电机转动一般默认为1
//PWM1 电机2-END
//通道1-------------END
MOTOR_POWER_1 = 64 + 901, //电机1 电源开关
MOTOR_POWER_2 = 65 + 901, //电机2 电源开关
};
enum PORTS
{
//Start = 171,
//Stop = 49,
//Power = 5,
Fpga_InitN = 7,//GPIO0_A7
Fpga_Load = 8,//GPIO0_B7
#ifndef G300
Power_12v_Off = 12,
#endif
//MotorPower = 48,
//CuoZhiMotor_Reset = 56,
//CuoZhiMotor_Sleep = 57,
//CuoZhiMotor_Enable = 58,
//CuoZhiMotor_Direction = 62,
//CuoZhiMotor_Decay = 63,
//CuoZhiMotor_Home = 184,
//CuoZhiMotor_Fault = 185,
//CuoZhiMotor_Mode0 = 59,
//CuoZhiMotor_Mode1 = 60,
//CuoZhiMotor_Mode2 = 61,
//Cover = 189,// 'GPIO6A5' opened:0 ; closed:1
//Paper = 225,// 'GPIO7B1' has paper:0 ; no paper:1
//Scan = 226,// 'GPIO7B2' no paper:0 ; has paper:1
//PaperJam = 102,
//Double_Paper = 219,// 'GPIO7A3' not doubled:0 ; doubled:1
SW_NOR_FLASH = 221,
//Double_Enable = 250,// 'GPIO8A2' off: 0 ; on: 1
//ZouZhiMotor_Reset = 64,
//ZouZhiMotor_Sleep = 65,
//ZouZhiMotor_Enable = 66,
//ZouZhiMotor_Direction = 70,
//ZouZhiMotor_Decay = 71,
//ZouZhiMotor_Home = 187,
//ZouZhiMotor_Fault = 188,
//ZouZhiMotor_Mode0 = 67,
//ZouZhiMotor_Mode1 = 68,
//ZouZhiMotor_Mode2 = 69,
CIS_3v3_Off = 96,
CIS_5v_En = 98,
Fpga_InitDone = 99,
Image_In_Transfer = 101,
Fpga_Reset = 232,
CIS_T_S0=190,
CIS_T_S1=191,
CIS_T_S2=234,
CIS_T_S3=233
};
// class DeviceExport {
// public:
// DeviceExport();
// private:
// #ifndef G300
// const int ports[42] = { Start , Stop, Power, Fpga_Load, Power_12v_Off, MotorPower, CuoZhiMotor_Reset, CuoZhiMotor_Sleep, CuoZhiMotor_Enable,
// CuoZhiMotor_Direction, CuoZhiMotor_Decay, CuoZhiMotor_Home, CuoZhiMotor_Fault , CuoZhiMotor_Mode0 ,
// CuoZhiMotor_Mode1, CuoZhiMotor_Mode2, Cover, Paper, Scan, PaperJam,Double_Paper, Double_Enable,
// ZouZhiMotor_Reset, ZouZhiMotor_Sleep, ZouZhiMotor_Enable, ZouZhiMotor_Direction, ZouZhiMotor_Decay,
// ZouZhiMotor_Home, ZouZhiMotor_Fault, ZouZhiMotor_Mode0, ZouZhiMotor_Mode1, ZouZhiMotor_Mode2,
// CIS_3v3_Off, CIS_5v_En, Fpga_InitDone, Image_In_Transfer, Fpga_Reset, SW_NOR_FLASH,CIS_T_S0,CIS_T_S1,CIS_T_S2,CIS_T_S3};
// #else
// const int ports[37] = { Start , Stop, Power, Fpga_Load, MotorPower, CuoZhiMotor_Reset, CuoZhiMotor_Sleep, CuoZhiMotor_Enable,
// CuoZhiMotor_Direction, CuoZhiMotor_Decay, CuoZhiMotor_Home, CuoZhiMotor_Fault , CuoZhiMotor_Mode0 ,
// CuoZhiMotor_Mode1, CuoZhiMotor_Mode2, Cover, Paper, Scan, PaperJam, Double_Paper, Double_Enable,
// ZouZhiMotor_Reset, ZouZhiMotor_Sleep, ZouZhiMotor_Enable, ZouZhiMotor_Direction, ZouZhiMotor_Decay,
// ZouZhiMotor_Home, ZouZhiMotor_Fault, ZouZhiMotor_Mode0, ZouZhiMotor_Mode1, ZouZhiMotor_Mode2,
// CIS_3v3_Off, CIS_5v_En, Fpga_InitDone, Image_In_Transfer, Fpga_Reset,Fpga_InitN };
// #endif
// const int pwms[2] = { 2, 3 };
// };
class DeviceExport
{
public:
DeviceExport();
private:
2023-08-31 08:37:05 +00:00
const int ports[17] = { MOTOR_POWER_1, CUOZHI_PIN_RESET, CUOZHI_PIN_SLEEP,CUOZHI_PIN_ENABEL, CUOZHI_PIN_DIR,
2023-07-17 03:29:37 +00:00
MOTOR_POWER_2, ZOUZHI_PIN_RESET, ZOUZHI_PIN_SLEEP,ZOUZHI_PIN_ENABEL, ZOUZHI_PIN_DIR,
2023-08-31 08:37:05 +00:00
SCAN_SENSOR,HAVE_OR_NO_PAPER, OPEN_COVER_SENSOR,ULTRASONIC_SENSORS_OUT0,ULTRASONIC_SENSORS_OUT1,ULTRASONIC_SENSORS_ON};
2023-07-17 03:29:37 +00:00
2023-08-31 08:37:05 +00:00
const int pwms[3] = { 0, 1 ,2};
2023-07-17 03:29:37 +00:00
};