nkjnm

Dependencies:   MAX44000 nexpaq_mdk

Fork of LED_Demo by Maxim nexpaq

Committer:
nitsshukla
Date:
Fri Nov 04 12:06:04 2016 +0000
Revision:
7:3a65ef12ba31
Parent:
1:55a6170b404f
kghj;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nexpaq 1:55a6170b404f 1 /* Copyright (c) 2010-2011 mbed.org, MIT License
nexpaq 1:55a6170b404f 2 *
nexpaq 1:55a6170b404f 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
nexpaq 1:55a6170b404f 4 * and associated documentation files (the "Software"), to deal in the Software without
nexpaq 1:55a6170b404f 5 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
nexpaq 1:55a6170b404f 6 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
nexpaq 1:55a6170b404f 7 * Software is furnished to do so, subject to the following conditions:
nexpaq 1:55a6170b404f 8 *
nexpaq 1:55a6170b404f 9 * The above copyright notice and this permission notice shall be included in all copies or
nexpaq 1:55a6170b404f 10 * substantial portions of the Software.
nexpaq 1:55a6170b404f 11 *
nexpaq 1:55a6170b404f 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
nexpaq 1:55a6170b404f 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
nexpaq 1:55a6170b404f 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
nexpaq 1:55a6170b404f 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
nexpaq 1:55a6170b404f 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
nexpaq 1:55a6170b404f 17 */
nexpaq 1:55a6170b404f 18
nexpaq 1:55a6170b404f 19 #ifndef USBBUSINTERFACE_H
nexpaq 1:55a6170b404f 20 #define USBBUSINTERFACE_H
nexpaq 1:55a6170b404f 21
nexpaq 1:55a6170b404f 22 #include "mbed.h"
nexpaq 1:55a6170b404f 23 #include "USBEndpoints.h"
nexpaq 1:55a6170b404f 24 #include "toolchain.h"
nexpaq 1:55a6170b404f 25
nexpaq 1:55a6170b404f 26 //#ifdef __GNUC__
nexpaq 1:55a6170b404f 27 //#define __packed __attribute__ ((__packed__))
nexpaq 1:55a6170b404f 28 //#endif
nexpaq 1:55a6170b404f 29
nexpaq 1:55a6170b404f 30 class USBHAL {
nexpaq 1:55a6170b404f 31 public:
nexpaq 1:55a6170b404f 32 /* Configuration */
nexpaq 1:55a6170b404f 33 USBHAL();
nexpaq 1:55a6170b404f 34 ~USBHAL();
nexpaq 1:55a6170b404f 35 void connect(void);
nexpaq 1:55a6170b404f 36 void disconnect(void);
nexpaq 1:55a6170b404f 37 void configureDevice(void);
nexpaq 1:55a6170b404f 38 void unconfigureDevice(void);
nexpaq 1:55a6170b404f 39 void setAddress(uint8_t address);
nexpaq 1:55a6170b404f 40 void remoteWakeup(void);
nexpaq 1:55a6170b404f 41
nexpaq 1:55a6170b404f 42 /* Endpoint 0 */
nexpaq 1:55a6170b404f 43 void EP0setup(uint8_t *buffer);
nexpaq 1:55a6170b404f 44 void EP0read(void);
nexpaq 1:55a6170b404f 45 void EP0readStage(void);
nexpaq 1:55a6170b404f 46 uint32_t EP0getReadResult(uint8_t *buffer);
nexpaq 1:55a6170b404f 47 void EP0write(uint8_t *buffer, uint32_t size);
nexpaq 1:55a6170b404f 48 void EP0getWriteResult(void);
nexpaq 1:55a6170b404f 49 void EP0stall(void);
nexpaq 1:55a6170b404f 50
nexpaq 1:55a6170b404f 51 /* Other endpoints */
nexpaq 1:55a6170b404f 52 EP_STATUS endpointRead(uint8_t endpoint, uint32_t maximumSize);
nexpaq 1:55a6170b404f 53 EP_STATUS endpointReadResult(uint8_t endpoint, uint8_t *data, uint32_t *bytesRead);
nexpaq 1:55a6170b404f 54 EP_STATUS endpointWrite(uint8_t endpoint, uint8_t *data, uint32_t size);
nexpaq 1:55a6170b404f 55 EP_STATUS endpointWriteResult(uint8_t endpoint);
nexpaq 1:55a6170b404f 56 void stallEndpoint(uint8_t endpoint);
nexpaq 1:55a6170b404f 57 void unstallEndpoint(uint8_t endpoint);
nexpaq 1:55a6170b404f 58 bool realiseEndpoint(uint8_t endpoint, uint32_t maxPacket, uint32_t options);
nexpaq 1:55a6170b404f 59 bool getEndpointStallState(unsigned char endpoint);
nexpaq 1:55a6170b404f 60 uint32_t endpointReadcore(uint8_t endpoint, uint8_t *buffer);
nexpaq 1:55a6170b404f 61
nexpaq 1:55a6170b404f 62 protected:
nexpaq 1:55a6170b404f 63 virtual void busReset(void){};
nexpaq 1:55a6170b404f 64 virtual void EP0setupCallback(void){};
nexpaq 1:55a6170b404f 65 virtual void EP0out(void){};
nexpaq 1:55a6170b404f 66 virtual void EP0in(void){};
nexpaq 1:55a6170b404f 67 virtual void connectStateChanged(unsigned int connected){};
nexpaq 1:55a6170b404f 68 virtual void suspendStateChanged(unsigned int suspended){};
nexpaq 1:55a6170b404f 69 virtual void SOF(int frameNumber){};
nexpaq 1:55a6170b404f 70
nexpaq 1:55a6170b404f 71 virtual bool EP1_OUT_callback(){return false;};
nexpaq 1:55a6170b404f 72 virtual bool EP1_IN_callback(){return false;};
nexpaq 1:55a6170b404f 73 virtual bool EP2_OUT_callback(){return false;};
nexpaq 1:55a6170b404f 74 virtual bool EP2_IN_callback(){return false;};
nexpaq 1:55a6170b404f 75 virtual bool EP3_OUT_callback(){return false;};
nexpaq 1:55a6170b404f 76 virtual bool EP3_IN_callback(){return false;};
nexpaq 1:55a6170b404f 77 #if !defined(TARGET_STM32F4)
nexpaq 1:55a6170b404f 78 virtual bool EP4_OUT_callback(){return false;};
nexpaq 1:55a6170b404f 79 virtual bool EP4_IN_callback(){return false;};
nexpaq 1:55a6170b404f 80 #if !(defined(TARGET_LPC11UXX) || defined(TARGET_LPC11U6X) || defined(TARGET_LPC1347) || defined(TARGET_LPC1549))
nexpaq 1:55a6170b404f 81 virtual bool EP5_OUT_callback(){return false;};
nexpaq 1:55a6170b404f 82 virtual bool EP5_IN_callback(){return false;};
nexpaq 1:55a6170b404f 83 virtual bool EP6_OUT_callback(){return false;};
nexpaq 1:55a6170b404f 84 virtual bool EP6_IN_callback(){return false;};
nexpaq 1:55a6170b404f 85 virtual bool EP7_OUT_callback(){return false;};
nexpaq 1:55a6170b404f 86 virtual bool EP7_IN_callback(){return false;};
nexpaq 1:55a6170b404f 87 virtual bool EP8_OUT_callback(){return false;};
nexpaq 1:55a6170b404f 88 virtual bool EP8_IN_callback(){return false;};
nexpaq 1:55a6170b404f 89 virtual bool EP9_OUT_callback(){return false;};
nexpaq 1:55a6170b404f 90 virtual bool EP9_IN_callback(){return false;};
nexpaq 1:55a6170b404f 91 virtual bool EP10_OUT_callback(){return false;};
nexpaq 1:55a6170b404f 92 virtual bool EP10_IN_callback(){return false;};
nexpaq 1:55a6170b404f 93 virtual bool EP11_OUT_callback(){return false;};
nexpaq 1:55a6170b404f 94 virtual bool EP11_IN_callback(){return false;};
nexpaq 1:55a6170b404f 95 virtual bool EP12_OUT_callback(){return false;};
nexpaq 1:55a6170b404f 96 virtual bool EP12_IN_callback(){return false;};
nexpaq 1:55a6170b404f 97 virtual bool EP13_OUT_callback(){return false;};
nexpaq 1:55a6170b404f 98 virtual bool EP13_IN_callback(){return false;};
nexpaq 1:55a6170b404f 99 virtual bool EP14_OUT_callback(){return false;};
nexpaq 1:55a6170b404f 100 virtual bool EP14_IN_callback(){return false;};
nexpaq 1:55a6170b404f 101 virtual bool EP15_OUT_callback(){return false;};
nexpaq 1:55a6170b404f 102 virtual bool EP15_IN_callback(){return false;};
nexpaq 1:55a6170b404f 103 #endif
nexpaq 1:55a6170b404f 104 #endif
nexpaq 1:55a6170b404f 105
nexpaq 1:55a6170b404f 106 private:
nexpaq 1:55a6170b404f 107 void usbisr(void);
nexpaq 1:55a6170b404f 108 static void _usbisr(void);
nexpaq 1:55a6170b404f 109 static USBHAL * instance;
nexpaq 1:55a6170b404f 110
nexpaq 1:55a6170b404f 111 #if defined(TARGET_LPC11UXX) || defined(TARGET_LPC11U6X) || defined(TARGET_LPC1347) || defined(TARGET_LPC1549)
nexpaq 1:55a6170b404f 112 bool (USBHAL::*epCallback[10 - 2])(void);
nexpaq 1:55a6170b404f 113 #elif defined(TARGET_STM32F4)
nexpaq 1:55a6170b404f 114 bool (USBHAL::*epCallback[8 - 2])(void);
nexpaq 1:55a6170b404f 115 #else
nexpaq 1:55a6170b404f 116 bool (USBHAL::*epCallback[32 - 2])(void);
nexpaq 1:55a6170b404f 117 #endif
nexpaq 1:55a6170b404f 118
nexpaq 1:55a6170b404f 119
nexpaq 1:55a6170b404f 120 };
nexpaq 1:55a6170b404f 121 #endif