Open Lighting Architecture  0.9.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SunliteFirmwareLoader.h
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 2 of the License, or
5  * (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU Library General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
15  *
16  * SunliteFirmwareLoader.h
17  * Load the firmware onto a USBDMX2 device
18  * Copyright (C) 2010 Simon Newton
19  *
20  * The Soundlite USBDMX2 interfaces require firmware to be loaded when they're
21  * connected, this performs that job.
22  */
23 
24 #ifndef PLUGINS_USBDMX_SUNLITEFIRMWARELOADER_H_
25 #define PLUGINS_USBDMX_SUNLITEFIRMWARELOADER_H_
26 
27 #include <libusb.h>
28 #include "ola/base/Macro.h"
29 #include "plugins/usbdmx/FirmwareLoader.h"
30 
31 namespace ola {
32 namespace plugin {
33 namespace usbdmx {
34 
36  public:
37  explicit SunliteFirmwareLoader(libusb_device *usb_device)
38  : m_device(usb_device) {}
40 
41  bool LoadFirmware();
42 
43  private:
44  libusb_device *m_device;
45 
46  static const int INTERFACE_NUMBER = 0; // the device only has 1 interface
47  static const uint8_t UPLOAD_REQUEST_TYPE = 0x40;
48  static const uint8_t UPLOAD_REQUEST = 0xa0;
49  static const unsigned int UPLOAD_TIMEOUT = 300; // ms
50 
51  DISALLOW_COPY_AND_ASSIGN(SunliteFirmwareLoader);
52 };
53 } // namespace usbdmx
54 } // namespace plugin
55 } // namespace ola
56 #endif // PLUGINS_USBDMX_SUNLITEFIRMWARELOADER_H_