Satellite Observers Workbench. NOT yet complete, just published for forum posters to \"cherry pick\" pieces of code as requiered as an example.
usbeh/usbeh_device.cpp@0:0a841b89d614, 2010-10-11 (annotated)
- Committer:
- AjK
- Date:
- Mon Oct 11 10:34:55 2010 +0000
- Revision:
- 0:0a841b89d614
Totally Alpha quality as this project isn\t completed. Just publishing it as it answers many questions asked in the forums
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AjK | 0:0a841b89d614 | 1 | /**************************************************************************** |
AjK | 0:0a841b89d614 | 2 | * Copyright 2010 Andy Kirkham, Stellar Technologies Ltd |
AjK | 0:0a841b89d614 | 3 | * |
AjK | 0:0a841b89d614 | 4 | * This file is part of the Satellite Observers Workbench (SOWB). |
AjK | 0:0a841b89d614 | 5 | * |
AjK | 0:0a841b89d614 | 6 | * SOWB is free software: you can redistribute it and/or modify |
AjK | 0:0a841b89d614 | 7 | * it under the terms of the GNU General Public License as published by |
AjK | 0:0a841b89d614 | 8 | * the Free Software Foundation, either version 3 of the License, or |
AjK | 0:0a841b89d614 | 9 | * (at your option) any later version. |
AjK | 0:0a841b89d614 | 10 | * |
AjK | 0:0a841b89d614 | 11 | * SOWB is distributed in the hope that it will be useful, |
AjK | 0:0a841b89d614 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
AjK | 0:0a841b89d614 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
AjK | 0:0a841b89d614 | 14 | * GNU General Public License for more details. |
AjK | 0:0a841b89d614 | 15 | * |
AjK | 0:0a841b89d614 | 16 | * You should have received a copy of the GNU General Public License |
AjK | 0:0a841b89d614 | 17 | * along with SOWB. If not, see <http://www.gnu.org/licenses/>. |
AjK | 0:0a841b89d614 | 18 | * |
AjK | 0:0a841b89d614 | 19 | * $Id: main.cpp 5 2010-07-12 20:51:11Z ajk $ |
AjK | 0:0a841b89d614 | 20 | * |
AjK | 0:0a841b89d614 | 21 | ***************************************************************************/ |
AjK | 0:0a841b89d614 | 22 | |
AjK | 0:0a841b89d614 | 23 | #include "sowb.h" |
AjK | 0:0a841b89d614 | 24 | #include "usbeh.h" |
AjK | 0:0a841b89d614 | 25 | #include "usbeh_endpoint.h" |
AjK | 0:0a841b89d614 | 26 | #include "usbeh_device.h" |
AjK | 0:0a841b89d614 | 27 | |
AjK | 0:0a841b89d614 | 28 | int USBEH_Device::init(USBEH_deviceDescriptor *d, int hub, int port, int addr, int lowSpeed) { |
AjK | 0:0a841b89d614 | 29 | this->hub = hub; |
AjK | 0:0a841b89d614 | 30 | this->port = port; |
AjK | 0:0a841b89d614 | 31 | this->addr = addr; |
AjK | 0:0a841b89d614 | 32 | this->flags = lowSpeed; |
AjK | 0:0a841b89d614 | 33 | memset(endpoints,0xFF,sizeof(endpoints)); |
AjK | 0:0a841b89d614 | 34 | return 0; |
AjK | 0:0a841b89d614 | 35 | } |
AjK | 0:0a841b89d614 | 36 | |
AjK | 0:0a841b89d614 | 37 | |
AjK | 0:0a841b89d614 | 38 | int USBEH_Device::setEndpointIndex (int endpoint, int endpointIndex) { |
AjK | 0:0a841b89d614 | 39 | for (int i = 0; i < 16; i += 2) { |
AjK | 0:0a841b89d614 | 40 | if (endpoints[i] == 0xFF) { |
AjK | 0:0a841b89d614 | 41 | endpoints[i+0] = endpoint; |
AjK | 0:0a841b89d614 | 42 | endpoints[i+1] = endpointIndex; |
AjK | 0:0a841b89d614 | 43 | return 0; |
AjK | 0:0a841b89d614 | 44 | } |
AjK | 0:0a841b89d614 | 45 | } |
AjK | 0:0a841b89d614 | 46 | return -1; |
AjK | 0:0a841b89d614 | 47 | } |
AjK | 0:0a841b89d614 | 48 | |
AjK | 0:0a841b89d614 | 49 | int USBEH_Device::getEndpointIndex (int endpoint) { |
AjK | 0:0a841b89d614 | 50 | for (int i = 0; i < 16; i += 2) { |
AjK | 0:0a841b89d614 | 51 | if (endpoints[i] == endpoint) return endpoints[i+1]; |
AjK | 0:0a841b89d614 | 52 | if (endpoints[i] == 0xFF) break; |
AjK | 0:0a841b89d614 | 53 | } |
AjK | 0:0a841b89d614 | 54 | return -1; |
AjK | 0:0a841b89d614 | 55 | } |