A optical beam breaker detector that appears to aPC as a USB keyboard, typing characters when the beam is broken

Dependencies:   mbed

Committer:
chris
Date:
Thu May 12 16:46:53 2011 +0000
Revision:
1:45de28d7be8e
Parent:
0:9d0f47bc66da

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
chris 0:9d0f47bc66da 1 /* usbdc.h */
chris 0:9d0f47bc66da 2 /* USB device controller */
chris 0:9d0f47bc66da 3 /* Copyright (c) Phil Wright 2008 */
chris 0:9d0f47bc66da 4
chris 0:9d0f47bc66da 5 #ifndef USBDC_H
chris 0:9d0f47bc66da 6 #define USBDC_H
chris 0:9d0f47bc66da 7
chris 0:9d0f47bc66da 8 /* Endpoints */
chris 0:9d0f47bc66da 9 #define EP0OUT (0) /* Control */
chris 0:9d0f47bc66da 10 #define EP0IN (1) /* Control */
chris 0:9d0f47bc66da 11 #define EP1OUT (2) /* Interrupt */
chris 0:9d0f47bc66da 12 #define EP1IN (3) /* Interrupt */
chris 0:9d0f47bc66da 13 #define EP2OUT (4) /* Bulk */
chris 0:9d0f47bc66da 14 #define EP2IN (5) /* Bulk */
chris 0:9d0f47bc66da 15
chris 0:9d0f47bc66da 16 #include "mbed.h"
chris 0:9d0f47bc66da 17
chris 0:9d0f47bc66da 18 class usbdc : public Base
chris 0:9d0f47bc66da 19 {
chris 0:9d0f47bc66da 20 public:
chris 0:9d0f47bc66da 21 usbdc();
chris 0:9d0f47bc66da 22 void connect(void);
chris 0:9d0f47bc66da 23 void disconnect(void);
chris 0:9d0f47bc66da 24 protected:
chris 0:9d0f47bc66da 25 void setAddress(unsigned char address);
chris 0:9d0f47bc66da 26 void realiseEndpoint(unsigned char endpoint, unsigned long maxPacket);
chris 0:9d0f47bc66da 27 void enableEndpointEvent(unsigned char endpoint);
chris 0:9d0f47bc66da 28 void disableEndpointEvent(unsigned char endpoint);
chris 0:9d0f47bc66da 29 void stallEndpoint(unsigned char endpoint);
chris 0:9d0f47bc66da 30 void unstallEndpoint(unsigned char endpoint);
chris 0:9d0f47bc66da 31 bool getEndpointStallState(unsigned char endpoint);
chris 0:9d0f47bc66da 32 void configureDevice(void);
chris 0:9d0f47bc66da 33 void unconfigureDevice(void);
chris 0:9d0f47bc66da 34 unsigned long endpointRead(unsigned char endpoint, unsigned char *buffer);
chris 0:9d0f47bc66da 35 void endpointWrite(unsigned char endpoint, unsigned char *buffer, unsigned long size);
chris 0:9d0f47bc66da 36 void enableEvents(void);
chris 0:9d0f47bc66da 37 void disableEvents(void);
chris 0:9d0f47bc66da 38 virtual void deviceEventReset(void);
chris 0:9d0f47bc66da 39 virtual void deviceEventFrame(void);
chris 0:9d0f47bc66da 40 virtual void endpointEventEP0Setup(void);
chris 0:9d0f47bc66da 41 virtual void endpointEventEP0In(void);
chris 0:9d0f47bc66da 42 virtual void endpointEventEP0Out(void);
chris 0:9d0f47bc66da 43 virtual void endpointEventEP1In(void);
chris 0:9d0f47bc66da 44 virtual void endpointEventEP1Out(void);
chris 0:9d0f47bc66da 45 virtual void endpointEventEP2In(void);
chris 0:9d0f47bc66da 46 virtual void endpointEventEP2Out(void);
chris 0:9d0f47bc66da 47 private:
chris 0:9d0f47bc66da 48 void SIECommand(unsigned long command);
chris 0:9d0f47bc66da 49 void SIEWriteData(unsigned char data);
chris 0:9d0f47bc66da 50 unsigned char SIEReadData(unsigned long command);
chris 0:9d0f47bc66da 51 void setDeviceStatus(unsigned char status);
chris 0:9d0f47bc66da 52 void setEndpointStatus(unsigned char endpoint, unsigned char status);
chris 0:9d0f47bc66da 53 unsigned char getDeviceStatus(void);
chris 0:9d0f47bc66da 54 unsigned char selectEndpoint(unsigned char endpoint);
chris 0:9d0f47bc66da 55 unsigned char selectEndpointClearInterrupt(unsigned char endpoint);
chris 0:9d0f47bc66da 56 unsigned char clearBuffer(void);
chris 0:9d0f47bc66da 57 void validateBuffer(void);
chris 0:9d0f47bc66da 58 void usbisr(void);
chris 0:9d0f47bc66da 59 unsigned long endpointStallState;
chris 0:9d0f47bc66da 60 static void _usbisr(void);
chris 0:9d0f47bc66da 61 static usbdc *instance;
chris 0:9d0f47bc66da 62 };
chris 0:9d0f47bc66da 63
chris 0:9d0f47bc66da 64
chris 0:9d0f47bc66da 65 #endif