This short program illustrates how to use the DS130x_I2C library. My objective is to share the same RTC with Microchip 18F MCU.
Dependencies: mbed DebugLibrary
NetServices/drv/usb/UsbHostMgr.h@0:f30e2135b0db, 2011-02-09 (annotated)
- Committer:
- Yann
- Date:
- Wed Feb 09 13:57:49 2011 +0000
- Revision:
- 0:f30e2135b0db
V0.0.0.1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Yann | 0:f30e2135b0db | 1 | /* |
Yann | 0:f30e2135b0db | 2 | Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com) |
Yann | 0:f30e2135b0db | 3 | |
Yann | 0:f30e2135b0db | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy |
Yann | 0:f30e2135b0db | 5 | of this software and associated documentation files (the "Software"), to deal |
Yann | 0:f30e2135b0db | 6 | in the Software without restriction, including without limitation the rights |
Yann | 0:f30e2135b0db | 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
Yann | 0:f30e2135b0db | 8 | copies of the Software, and to permit persons to whom the Software is |
Yann | 0:f30e2135b0db | 9 | furnished to do so, subject to the following conditions: |
Yann | 0:f30e2135b0db | 10 | |
Yann | 0:f30e2135b0db | 11 | The above copyright notice and this permission notice shall be included in |
Yann | 0:f30e2135b0db | 12 | all copies or substantial portions of the Software. |
Yann | 0:f30e2135b0db | 13 | |
Yann | 0:f30e2135b0db | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
Yann | 0:f30e2135b0db | 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
Yann | 0:f30e2135b0db | 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
Yann | 0:f30e2135b0db | 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
Yann | 0:f30e2135b0db | 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
Yann | 0:f30e2135b0db | 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
Yann | 0:f30e2135b0db | 20 | THE SOFTWARE. |
Yann | 0:f30e2135b0db | 21 | */ |
Yann | 0:f30e2135b0db | 22 | |
Yann | 0:f30e2135b0db | 23 | //Assigns addresses to connected devices... |
Yann | 0:f30e2135b0db | 24 | |
Yann | 0:f30e2135b0db | 25 | #ifndef USB_HOSTMGR_H |
Yann | 0:f30e2135b0db | 26 | #define USB_HOSTMGR_H |
Yann | 0:f30e2135b0db | 27 | |
Yann | 0:f30e2135b0db | 28 | #include "mbed.h" |
Yann | 0:f30e2135b0db | 29 | #include "UsbInc.h" |
Yann | 0:f30e2135b0db | 30 | #include "UsbDevice.h" |
Yann | 0:f30e2135b0db | 31 | |
Yann | 0:f30e2135b0db | 32 | #define USB_HOSTMGR_MAX_DEVS 2 //2 devices max for now... will be more when hubs are supported |
Yann | 0:f30e2135b0db | 33 | |
Yann | 0:f30e2135b0db | 34 | class UsbDevice; |
Yann | 0:f30e2135b0db | 35 | |
Yann | 0:f30e2135b0db | 36 | class UsbHostMgr //[0-1] inst |
Yann | 0:f30e2135b0db | 37 | { |
Yann | 0:f30e2135b0db | 38 | public: |
Yann | 0:f30e2135b0db | 39 | UsbHostMgr(); |
Yann | 0:f30e2135b0db | 40 | ~UsbHostMgr(); |
Yann | 0:f30e2135b0db | 41 | |
Yann | 0:f30e2135b0db | 42 | UsbErr init(); //Initialize host |
Yann | 0:f30e2135b0db | 43 | |
Yann | 0:f30e2135b0db | 44 | void poll(); //Enumerate connected devices, etc |
Yann | 0:f30e2135b0db | 45 | |
Yann | 0:f30e2135b0db | 46 | int devicesCount(); |
Yann | 0:f30e2135b0db | 47 | |
Yann | 0:f30e2135b0db | 48 | UsbDevice* getDevice(int item); |
Yann | 0:f30e2135b0db | 49 | void releaseDevice(UsbDevice* pDev); |
Yann | 0:f30e2135b0db | 50 | |
Yann | 0:f30e2135b0db | 51 | |
Yann | 0:f30e2135b0db | 52 | void UsbIrqhandler(); |
Yann | 0:f30e2135b0db | 53 | |
Yann | 0:f30e2135b0db | 54 | protected: |
Yann | 0:f30e2135b0db | 55 | void onUsbDeviceConnected(int hub, int port); |
Yann | 0:f30e2135b0db | 56 | void onUsbDeviceDisconnected(int hub, int port); |
Yann | 0:f30e2135b0db | 57 | |
Yann | 0:f30e2135b0db | 58 | friend class UsbDevice; |
Yann | 0:f30e2135b0db | 59 | void resetPort(int hub, int port); |
Yann | 0:f30e2135b0db | 60 | |
Yann | 0:f30e2135b0db | 61 | private: |
Yann | 0:f30e2135b0db | 62 | /* __align(8)*/ volatile HCCA* m_pHcca; |
Yann | 0:f30e2135b0db | 63 | |
Yann | 0:f30e2135b0db | 64 | UsbDevice* m_lpDevices[USB_HOSTMGR_MAX_DEVS]; |
Yann | 0:f30e2135b0db | 65 | }; |
Yann | 0:f30e2135b0db | 66 | |
Yann | 0:f30e2135b0db | 67 | #endif |