The preloaded firmware shipped on the mBot.

Dependencies:   mbed

Fork of Official_mBot by Fred Parker

Committer:
jeffknaggs
Date:
Tue Nov 25 14:49:40 2014 +0000
Revision:
1:ffd9a51e7d35
Parent:
0:865d42c46692
Initial commit.

Who changed what in which revision?

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