#include #include #include #include #include #include //#include //#include //#include "linux_arb_usb.h" #define HANDLE int long int Read_ARB_USB(HANDLE hCom,unsigned long arb_addr,int *data){ unsigned char message[2]; int num_bytes_written; message[0] = ((arb_addr >> 8) & 0x07); message[1] = arb_addr & 0xff; num_bytes_written = (int)write(hCom,message,2); if(num_bytes_written != 2) printf("Write Error\n"); if(2 != read(hCom,message,2)) return -1; *data = 0xffff & ((message[0] << 8) | message[1]); return 0; } void Write_ARB_USB(HANDLE hCom,unsigned long int arb_addr, unsigned int arb_data){ unsigned char message[4]; int num_bytes_written; message[0] = (arb_addr >> 8) & 0x07; message[1] = arb_addr & 0xff; message[2] = (arb_data >> 8) & 0xff; message[3] = arb_data & 0xff; num_bytes_written = (int)write(hCom,message,4); if(num_bytes_written != 4) printf("Write Error\n"); return; } int open_usb_port(const char* name){ int port; port = open(name,O_RDWR | O_NOCTTY | O_NDELAY); return port; } void close_usb_port(HANDLE port){ close(port); }