zynq_7010/zynq_7010_code/UsbEndpoint.h

66 lines
1.3 KiB
C++
Raw 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.

/*
* ====================================================
* 功能linux USB device USB通信 底层端点抽象
* 作者:彭明
* 生成时间2020/8/18
* 版本号v1.0
* ====================================================
*/
#ifndef IUSBENDPOINT_H
#define IUSBENDPOINT_H
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <map>
#include <errno.h>
#include "scanservices_utils.h"
using namespace std;
enum class HGUSB_ErrorCode
{
HG_USBSuccess=-1,
HG_USBOpenFailed,
HG_USBInvalidePtr,
HG_USBPCUnConnected
};
class UsbEndPoint
{
public:
enum class EndpointType
{
EP_Undefine,
EP_Control,
EP_Bulk_In,
EP_Bulk_Out,
Ep_Int
};
public:
UsbEndPoint(EndpointType eptype);
~UsbEndPoint();
int open();
void close();
int read(void* pdata,int length);
int write(void* pdata,int length);
int getEndpointType();
bool is_open();
private:
int m_fd;
EndpointType m_endpointtype;
std::map<EndpointType,std::string> map_endpoints={
{EndpointType::EP_Bulk_In,BULK_IN_PATH},
{EndpointType::EP_Bulk_Out,BULK_OUT_PATH},
{EndpointType::EP_Control,BULK_CTL_PATH},
{EndpointType::Ep_Int,BULK_INT_PATH}
};
};
#endif //IUSBENDPOINT_H