Satellite Observers Workbench. NOT yet complete, just published for forum posters to \"cherry pick\" pieces of code as requiered as an example.

Dependencies:   mbed

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?

UserRevisionLine numberNew 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 #ifndef USBEH_CONTROLLER_H
AjK 0:0a841b89d614 24 #define USBEH_CONTROLLER_H
AjK 0:0a841b89d614 25
AjK 0:0a841b89d614 26 #include "usbeh.h"
AjK 0:0a841b89d614 27 #include "usbeh_device.h"
AjK 0:0a841b89d614 28 #include "usbeh_endpoint.h"
AjK 0:0a841b89d614 29
AjK 0:0a841b89d614 30 class USBEH_Controller {
AjK 0:0a841b89d614 31
AjK 0:0a841b89d614 32 public:
AjK 0:0a841b89d614 33
AjK 0:0a841b89d614 34 USBEH_HCCA hcca;
AjK 0:0a841b89d614 35 USBEH_Endpoint endpoints[USBEH_MAX_ENDPOINTS_TOTAL];
AjK 0:0a841b89d614 36 USBEH_Endpoint endpointZero;
AjK 0:0a841b89d614 37 USBEH_HCTD commonTail;
AjK 0:0a841b89d614 38 USBEH_Setup setupZero;
AjK 0:0a841b89d614 39 USBEH_Device devices[USBEH_MAX_DEVICES];
AjK 0:0a841b89d614 40
AjK 0:0a841b89d614 41 USBEH_U32 frameNumber;
AjK 0:0a841b89d614 42 USBEH_U08 callbacksPending;
AjK 0:0a841b89d614 43 USBEH_U08 rootHubStatusChange;
AjK 0:0a841b89d614 44 USBEH_U08 unused0;
AjK 0:0a841b89d614 45 USBEH_U08 unused1;
AjK 0:0a841b89d614 46 USBEH_U08 connectPending;
AjK 0:0a841b89d614 47 USBEH_U08 connectCountdown;
AjK 0:0a841b89d614 48 USBEH_U08 connectHub;
AjK 0:0a841b89d614 49 USBEH_U08 connectPort;
AjK 0:0a841b89d614 50
AjK 0:0a841b89d614 51 USBEH_U08 SRAM[0];
AjK 0:0a841b89d614 52
AjK 0:0a841b89d614 53 // Methods.
AjK 0:0a841b89d614 54 void init(void);
AjK 0:0a841b89d614 55 void process(void);
AjK 0:0a841b89d614 56 int initHub(int device);
AjK 0:0a841b89d614 57 int transfer(USBEH_Endpoint *endpoint, int token, USBEH_U08 *data, int length, int state);
AjK 0:0a841b89d614 58 bool remove(USBEH_HCED *ed, volatile USBEH_HCED **queue);
AjK 0:0a841b89d614 59 void release(USBEH_Endpoint *endpoint);
AjK 0:0a841b89d614 60 int addEndpoint(int device, USBEH_endpointDescriptor *endpoint);
AjK 0:0a841b89d614 61 int addEndpoint(int device, int endpoint, int attributes, int maxPacketSize, int interval);
AjK 0:0a841b89d614 62 int addDevice(int hub, int port, bool isLowSpeed);
AjK 0:0a841b89d614 63 int addDeviceCore(int hub, int port, bool isLowSpeed);
AjK 0:0a841b89d614 64 int setConfigurationAndInterface(int device, int configuration, int interfaceNumber, USBEH_deviceDescriptor *desc);
AjK 0:0a841b89d614 65 void processDoneQueue(USBEH_U32 tdList);
AjK 0:0a841b89d614 66 void resetPort(int hub, int port);
AjK 0:0a841b89d614 67 void connect(int hub, int port, bool lowSpeed);
AjK 0:0a841b89d614 68 void disconnect(int hub, int port);
AjK 0:0a841b89d614 69 void hubStatusChange(int hub, int port, USBEH_U32 status);
AjK 0:0a841b89d614 70 void delayMS(int ms);
AjK 0:0a841b89d614 71 void initHW(USBEH_HCCA *cca);
AjK 0:0a841b89d614 72 void hubInterrupt(int device);
AjK 0:0a841b89d614 73 static void hubInterruptCallback(int device, int endpoint, int status, USBEH_U08 *data, int length, void *userData);
AjK 0:0a841b89d614 74 USBEH_HCTD * reverse(USBEH_HCTD *current);
AjK 0:0a841b89d614 75 USBEH_Endpoint * getEndpoint(int device, int ep);
AjK 0:0a841b89d614 76 USBEH_Endpoint * allocateEndpoint(int device, int endpointAddress, int type, int maxPacketSize);
AjK 0:0a841b89d614 77
AjK 0:0a841b89d614 78 };
AjK 0:0a841b89d614 79
AjK 0:0a841b89d614 80
AjK 0:0a841b89d614 81 // END #ifndef USBEH_CONTROLLER_H
AjK 0:0a841b89d614 82 #endif