Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
usbhost.h
00001 /* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. 00002 00003 This program is free software; you can redistribute it and/or modify 00004 it under the terms of the GNU General Public License as published by 00005 the Free Software Foundation; either version 2 of the License, or 00006 (at your option) any later version. 00007 00008 This program is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 GNU General Public License for more details. 00012 00013 You should have received a copy of the GNU General Public License 00014 along with this program; if not, write to the Free Software 00015 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00016 00017 Contact information 00018 ------------------- 00019 00020 Circuits At Home, LTD 00021 Web : http://www.circuitsathome.com 00022 e-mail : support@circuitsathome.com 00023 */ 00024 /* MAX3421E-based USB Host Library header file */ 00025 00026 //warning 00027 //#define _usb_h_ 00028 //#define MBED_H 00029 00030 #ifndef usbhost_h 00031 #define usbhost_h 00032 00033 //#define DEBUGMODE 00034 #ifdef DEBUGMODE 00035 #define DEBUG(x, ...) printf("[%s:%d]" x "\n", __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__); 00036 #else 00037 #define DEBUG(...) while (0); 00038 #endif 00039 00040 #if !defined(_usb_h_) // || defined(_USBHOST_H_) 00041 #error "Never include usbhost.h directly; include Usb.h instead" 00042 #else 00043 #define _USBHOST_H_ 00044 00045 #if USING_SPI4TEENSY3 00046 #include <spi4teensy3.h> 00047 #include <sys/types.h> 00048 #endif 00049 00050 typedef enum 00051 { 00052 vbus_on = 0, 00053 vbus_off = GPX_VBDET 00054 } VBUS_t; 00055 00056 class MAX3421E : public SPI 00057 { 00058 //static 00059 uint8_t vbusState; 00060 00061 public: 00062 MAX3421E(PinName mosi, PinName miso, PinName sclk, PinName ssel, PinName intr); 00063 void regWr(uint8_t reg, uint8_t data); 00064 uint8_t *bytesWr(uint8_t reg, uint8_t nbytes, uint8_t *data_p); 00065 void gpioWr(uint8_t data); 00066 uint8_t regRd(uint8_t reg); 00067 uint8_t *bytesRd(uint8_t reg, uint8_t nbytes, uint8_t *data_p); 00068 uint8_t gpioRd(); 00069 uint8_t gpioRdOutput(); 00070 uint16_t reset(); 00071 int8_t Init(); 00072 int8_t Init(int mseconds); 00073 00074 void vbusPower(VBUS_t state) 00075 { 00076 regWr(rPINCTL, (bmFDUPSPI | bmINTLEVEL | state)); 00077 } 00078 00079 uint8_t getVbusState(void) 00080 { 00081 return vbusState; 00082 }; 00083 void busprobe(); 00084 uint8_t GpxHandler(); 00085 uint8_t IntHandler(); 00086 uint8_t Task(); 00087 00088 00089 private: 00090 DigitalOut _ss; 00091 DigitalIn _intr; 00092 00093 }; 00094 00095 00096 #endif // _USBHOST_H_ 00097 #endif //usbhost_h
Generated on Thu Jul 14 2022 08:33:41 by
1.7.2