📄 ezusb_loader.h
字号:
/* * This file is part of Jelie, * (c) 2002 Julien Pilet <julien.pilet@epfl.ch> and * Stephane Magnenat <stephane.magnenat@epfl.ch> * * Jelie is free software; you can redistribute it * and/or modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the License, * or (at your option) any later version. * * Jelie is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Foobar; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *//*! \file * This is the definition of the EzUSB loader * * \author Julien Pilet <julien.pilet@epfl.ch> * \author Stephane Magnenat <stephane.magnenat@epfl.ch> */#ifndef _EZUSB_H_#define _EZUSB_H_#include <stdio.h>#include <ctype.h>#include <usb.h>//! EzUSB user-level program upload facility/*! This class provide all necessary facilities to upload a program into the EzUSB microcontroller. It is purely user space so no kernel driver is needed. It relays on the libusb that hide kernel's USB ioctl. */class EzUSB{protected: //! USB device Handle, used for device access struct usb_dev_handle* devHandle; //! Vendor identifier int idVendor; //! Product identifier int idProduct; //! Filename to open char filename[1024];protected: //! Internal structure for hex file struct intels { int addr, len; unsigned char * data; struct intels * nxt; } intels; //! Read Intel hex file int read_head(FILE * fh, struct intels * * doutp ); //! Send a control message int shunt(usb_dev_handle *pdev, int at, void *d, int len);public: //! EzUSB constructor /*! \param filename the firmware to load into the EzUSB device */ EzUSB(const char *filename=NULL); //! EzUSB destructor /*! close the handle to the device */ virtual ~EzUSB(); //! Reset the UBS device. Must be called when an OS asyncronous event (like SIGTERM) is caught virtual void forceClose(void); //! Parse command line and extract options /*! \param argc number of command line argument \param argv array of char* that contains the arguments \return nothing. */ void parseCmdLine(int argc, char *argv[]); //! Find the device, return false if device can't be found /*! \return true if device is found, false otherwise. */ bool findDevice(void); //! Download the firmware to the device /*! \return true if the firmware has sucessfully been downloaded into the EzUSB device, false otherwise. \param firmware the hex file containing the firmware. Will be overriden if the option -f <file> is provided and parsed by parseCmdLine */ bool downloadFirmware(const char *firmware);};#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -