Slingshot Controller

Dependencies:   ADXL345 DebounceIn USBDevice mbed

Committer:
Brandon
Date:
Wed Oct 17 16:33:04 2012 +0000
Revision:
1:2721dc2acc2c
Parent:
0:cf17ea89fd09
Updated comments, added names, cleaned old code.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Brandon 0:cf17ea89fd09 1 /* Copyright (c) 2010-2011 mbed.org, MIT License
Brandon 0:cf17ea89fd09 2 *
Brandon 0:cf17ea89fd09 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
Brandon 0:cf17ea89fd09 4 * and associated documentation files (the "Software"), to deal in the Software without
Brandon 0:cf17ea89fd09 5 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
Brandon 0:cf17ea89fd09 6 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
Brandon 0:cf17ea89fd09 7 * Software is furnished to do so, subject to the following conditions:
Brandon 0:cf17ea89fd09 8 *
Brandon 0:cf17ea89fd09 9 * The above copyright notice and this permission notice shall be included in all copies or
Brandon 0:cf17ea89fd09 10 * substantial portions of the Software.
Brandon 0:cf17ea89fd09 11 *
Brandon 0:cf17ea89fd09 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
Brandon 0:cf17ea89fd09 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
Brandon 0:cf17ea89fd09 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
Brandon 0:cf17ea89fd09 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
Brandon 0:cf17ea89fd09 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Brandon 0:cf17ea89fd09 17 */
Brandon 0:cf17ea89fd09 18
Brandon 0:cf17ea89fd09 19 #ifndef USBCDC_H
Brandon 0:cf17ea89fd09 20 #define USBCDC_H
Brandon 0:cf17ea89fd09 21
Brandon 0:cf17ea89fd09 22 /* These headers are included for child class. */
Brandon 0:cf17ea89fd09 23 #include "USBEndpoints.h"
Brandon 0:cf17ea89fd09 24 #include "USBDescriptor.h"
Brandon 0:cf17ea89fd09 25 #include "USBDevice_Types.h"
Brandon 0:cf17ea89fd09 26
Brandon 0:cf17ea89fd09 27 #include "USBDevice.h"
Brandon 0:cf17ea89fd09 28
Brandon 0:cf17ea89fd09 29 class USBCDC: public USBDevice {
Brandon 0:cf17ea89fd09 30 public:
Brandon 0:cf17ea89fd09 31
Brandon 0:cf17ea89fd09 32 /*
Brandon 0:cf17ea89fd09 33 * Constructor
Brandon 0:cf17ea89fd09 34 *
Brandon 0:cf17ea89fd09 35 * @param vendor_id Your vendor_id
Brandon 0:cf17ea89fd09 36 * @param product_id Your product_id
Brandon 0:cf17ea89fd09 37 * @param product_release Your preoduct_release
Brandon 0:cf17ea89fd09 38 */
Brandon 0:cf17ea89fd09 39 USBCDC(uint16_t vendor_id, uint16_t product_id, uint16_t product_release);
Brandon 0:cf17ea89fd09 40
Brandon 0:cf17ea89fd09 41 protected:
Brandon 0:cf17ea89fd09 42
Brandon 0:cf17ea89fd09 43 /*
Brandon 0:cf17ea89fd09 44 * Get device descriptor. Warning: this method has to store the length of the report descriptor in reportLength.
Brandon 0:cf17ea89fd09 45 *
Brandon 0:cf17ea89fd09 46 * @returns pointer to the device descriptor
Brandon 0:cf17ea89fd09 47 */
Brandon 0:cf17ea89fd09 48 virtual uint8_t * deviceDesc();
Brandon 0:cf17ea89fd09 49
Brandon 0:cf17ea89fd09 50 /*
Brandon 0:cf17ea89fd09 51 * Get string product descriptor
Brandon 0:cf17ea89fd09 52 *
Brandon 0:cf17ea89fd09 53 * @returns pointer to the string product descriptor
Brandon 0:cf17ea89fd09 54 */
Brandon 0:cf17ea89fd09 55 virtual uint8_t * stringIproductDesc();
Brandon 0:cf17ea89fd09 56
Brandon 0:cf17ea89fd09 57 /*
Brandon 0:cf17ea89fd09 58 * Get string interface descriptor
Brandon 0:cf17ea89fd09 59 *
Brandon 0:cf17ea89fd09 60 * @returns pointer to the string interface descriptor
Brandon 0:cf17ea89fd09 61 */
Brandon 0:cf17ea89fd09 62 virtual uint8_t * stringIinterfaceDesc();
Brandon 0:cf17ea89fd09 63
Brandon 0:cf17ea89fd09 64 /*
Brandon 0:cf17ea89fd09 65 * Get configuration descriptor
Brandon 0:cf17ea89fd09 66 *
Brandon 0:cf17ea89fd09 67 * @returns pointer to the configuration descriptor
Brandon 0:cf17ea89fd09 68 */
Brandon 0:cf17ea89fd09 69 virtual uint8_t * configurationDesc();
Brandon 0:cf17ea89fd09 70
Brandon 0:cf17ea89fd09 71 /*
Brandon 0:cf17ea89fd09 72 * Send a buffer
Brandon 0:cf17ea89fd09 73 *
Brandon 0:cf17ea89fd09 74 * @param endpoint endpoint which will be sent the buffer
Brandon 0:cf17ea89fd09 75 * @param buffer buffer to be sent
Brandon 0:cf17ea89fd09 76 * @param size length of the buffer
Brandon 0:cf17ea89fd09 77 * @returns true if successful
Brandon 0:cf17ea89fd09 78 */
Brandon 0:cf17ea89fd09 79 bool send(uint8_t * buffer, uint32_t size);
Brandon 0:cf17ea89fd09 80
Brandon 0:cf17ea89fd09 81 /*
Brandon 0:cf17ea89fd09 82 * Read a buffer from a certain endpoint. Warning: blocking
Brandon 0:cf17ea89fd09 83 *
Brandon 0:cf17ea89fd09 84 * @param endpoint endpoint to read
Brandon 0:cf17ea89fd09 85 * @param buffer buffer where will be stored bytes
Brandon 0:cf17ea89fd09 86 * @param size the number of bytes read will be stored in *size
Brandon 0:cf17ea89fd09 87 * @param maxSize the maximum length that can be read
Brandon 0:cf17ea89fd09 88 * @returns true if successful
Brandon 0:cf17ea89fd09 89 */
Brandon 0:cf17ea89fd09 90 bool readEP(uint8_t * buffer, uint32_t * size);
Brandon 0:cf17ea89fd09 91
Brandon 0:cf17ea89fd09 92 /*
Brandon 0:cf17ea89fd09 93 * Read a buffer from a certain endpoint. Warning: non blocking
Brandon 0:cf17ea89fd09 94 *
Brandon 0:cf17ea89fd09 95 * @param endpoint endpoint to read
Brandon 0:cf17ea89fd09 96 * @param buffer buffer where will be stored bytes
Brandon 0:cf17ea89fd09 97 * @param size the number of bytes read will be stored in *size
Brandon 0:cf17ea89fd09 98 * @param maxSize the maximum length that can be read
Brandon 0:cf17ea89fd09 99 * @returns true if successful
Brandon 0:cf17ea89fd09 100 */
Brandon 0:cf17ea89fd09 101 bool readEP_NB(uint8_t * buffer, uint32_t * size);
Brandon 0:cf17ea89fd09 102
Brandon 0:cf17ea89fd09 103 virtual bool USBCallback_request();
Brandon 0:cf17ea89fd09 104 virtual bool USBCallback_setConfiguration(uint8_t configuration);
Brandon 0:cf17ea89fd09 105
Brandon 0:cf17ea89fd09 106 };
Brandon 0:cf17ea89fd09 107
Brandon 0:cf17ea89fd09 108 #endif