You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
3.2 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace USB2XXX
{
class USB2DIO
{
//定义函数返回错误代码
public const Int32 DIO_SUCCESS = (0); //函数执行成功
public const Int32 DIO_ERR_NOT_SUPPORT = (-1); //适配器不支持该函数
public const Int32 DIO_ERR_USB_WRITE_FAIL = (-2); //USB写数据失败
public const Int32 DIO_ERR_USB_READ_FAIL = (-3); //USB读数据失败
public const Int32 DIO_ERR_CMD_FAIL = (-4); //命令执行失败
public const Int32 DIO_ERR_ARG = (-5); //传入函数参数异常
//DIO引脚宏定义
public const UInt32 DIO_PIN_LIN1 = 0x0001;
public const UInt32 DIO_PIN_LIN2 = 0x0002;
public const UInt32 DIO_PIN_LIN3 = 0x0004;
public const UInt32 DIO_PIN_LIN4 = 0x0008;
public const UInt32 DIO_PIN_DI0 = 0x0010;
public const UInt32 DIO_PIN_DI1 = 0x0020;
public const UInt32 DIO_PIN_DI2 = 0x0040;
public const UInt32 DIO_PIN_DI3 = 0x0080;
public const UInt32 DIO_PIN_DO0 = 0x0100;
public const UInt32 DIO_PIN_DO1 = 0x0200;
public const UInt32 DIO_PIN_DO2 = 0x0400;
public const UInt32 DIO_PIN_DO3 = 0x0800;
/**
* @brief DIO,DIO
* @param DevHandle @ref USB_ScanDevice
* @param[in] PinMask DIO @ref DIO
* @return
* @retval =0
* @retval <0
*/
[DllImport("USB2XXX.dll")]
public static extern Int32 DIO_Init(Int32 DevHandle,UInt32 PinMask);
/**
* @brief DIO
* @param DevHandle @ref USB_ScanDevice
* @param[in] PinMask DIO @ref DIO
* @return
* @retval =0
* @retval <0
*/
[DllImport("USB2XXX.dll")]
public static extern Int32 DIO_SetPins(Int32 DevHandle,UInt32 PinMask);
/**
* @brief DIO
* @param DevHandle @ref USB_ScanDevice
* @param[in] PinMask DIO @ref DIO
* @return
* @retval =0
* @retval <0
*/
[DllImport("USB2XXX.dll")]
public static extern Int32 DIO_ResetPins(Int32 DevHandle,UInt32 PinMask);
/**
* @brief PWM
* @param DevHandle @ref USB_ScanDevice
* @param[in] PinMask DIO @ref DIO
* @return
* @retval >=0
* @retval <0
*/
[DllImport("USB2XXX.dll")]
public static extern Int32 DIO_ReadPins(Int32 DevHandle,UInt32 PinMask);
}
}