zynq_7010/zynq_7010_code/UsbEndpoint.h

66 lines
1.3 KiB
C
Raw Permalink Normal View History

2023-07-17 03:29:37 +00:00
/*
* ====================================================
* 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