Example self-announcing webserver which controls a servo through a smallHTML userinterface.

Dependencies:   mbed

Committer:
dirkx
Date:
Sat Aug 14 15:56:01 2010 +0000
Revision:
0:a259777c45a3

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dirkx 0:a259777c45a3 1
dirkx 0:a259777c45a3 2 /*
dirkx 0:a259777c45a3 3 Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
dirkx 0:a259777c45a3 4
dirkx 0:a259777c45a3 5 Permission is hereby granted, free of charge, to any person obtaining a copy
dirkx 0:a259777c45a3 6 of this software and associated documentation files (the "Software"), to deal
dirkx 0:a259777c45a3 7 in the Software without restriction, including without limitation the rights
dirkx 0:a259777c45a3 8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
dirkx 0:a259777c45a3 9 copies of the Software, and to permit persons to whom the Software is
dirkx 0:a259777c45a3 10 furnished to do so, subject to the following conditions:
dirkx 0:a259777c45a3 11
dirkx 0:a259777c45a3 12 The above copyright notice and this permission notice shall be included in
dirkx 0:a259777c45a3 13 all copies or substantial portions of the Software.
dirkx 0:a259777c45a3 14
dirkx 0:a259777c45a3 15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
dirkx 0:a259777c45a3 16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
dirkx 0:a259777c45a3 17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
dirkx 0:a259777c45a3 18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
dirkx 0:a259777c45a3 19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
dirkx 0:a259777c45a3 20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
dirkx 0:a259777c45a3 21 THE SOFTWARE.
dirkx 0:a259777c45a3 22 */
dirkx 0:a259777c45a3 23
dirkx 0:a259777c45a3 24 #ifndef USB_SERIAL_H
dirkx 0:a259777c45a3 25 #define USB_SERIAL_H
dirkx 0:a259777c45a3 26
dirkx 0:a259777c45a3 27 //DG 2010
dirkx 0:a259777c45a3 28 //Essentially a clone of Serial if
dirkx 0:a259777c45a3 29 #include "Stream.h"
dirkx 0:a259777c45a3 30 #include "mbed.h"
dirkx 0:a259777c45a3 31
dirkx 0:a259777c45a3 32 namespace mbed {
dirkx 0:a259777c45a3 33
dirkx 0:a259777c45a3 34 class UsbSerial : public Stream {
dirkx 0:a259777c45a3 35
dirkx 0:a259777c45a3 36 public:
dirkx 0:a259777c45a3 37
dirkx 0:a259777c45a3 38 UsbSerial(int usbDev, int usbIf, const char *name = NULL);
dirkx 0:a259777c45a3 39 virtual ~UsbSerial();
dirkx 0:a259777c45a3 40 //Apart from the ctor/dtor, exactly the same protos as Serial
dirkx 0:a259777c45a3 41
dirkx 0:a259777c45a3 42
dirkx 0:a259777c45a3 43 void baud(int baudrate);
dirkx 0:a259777c45a3 44
dirkx 0:a259777c45a3 45 enum Parity {
dirkx 0:a259777c45a3 46 None = 0,
dirkx 0:a259777c45a3 47 Odd = 1,
dirkx 0:a259777c45a3 48 Even = 2,
dirkx 0:a259777c45a3 49 Forced1 = 3,
dirkx 0:a259777c45a3 50 Forced0 = 4
dirkx 0:a259777c45a3 51 };
dirkx 0:a259777c45a3 52
dirkx 0:a259777c45a3 53 void format(int bits, int parity, int stop);
dirkx 0:a259777c45a3 54
dirkx 0:a259777c45a3 55
dirkx 0:a259777c45a3 56 #if 0 // Inhereted from Stream, for documentation only
dirkx 0:a259777c45a3 57
dirkx 0:a259777c45a3 58 /* Function: putc
dirkx 0:a259777c45a3 59 * Write a character
dirkx 0:a259777c45a3 60 *
dirkx 0:a259777c45a3 61 * Variables:
dirkx 0:a259777c45a3 62 * c - The character to write to the serial port
dirkx 0:a259777c45a3 63 */
dirkx 0:a259777c45a3 64 int putc(int c);
dirkx 0:a259777c45a3 65
dirkx 0:a259777c45a3 66 /* Function: getc
dirkx 0:a259777c45a3 67 * Read a character
dirkx 0:a259777c45a3 68 *
dirkx 0:a259777c45a3 69 * Variables:
dirkx 0:a259777c45a3 70 * returns - The character read from the serial port
dirkx 0:a259777c45a3 71 */
dirkx 0:a259777c45a3 72 int getc();
dirkx 0:a259777c45a3 73
dirkx 0:a259777c45a3 74 /* Function: printf
dirkx 0:a259777c45a3 75 * Write a formated string
dirkx 0:a259777c45a3 76 *
dirkx 0:a259777c45a3 77 * Variables:
dirkx 0:a259777c45a3 78 * format - A printf-style format string, followed by the
dirkx 0:a259777c45a3 79 * variables to use in formating the string.
dirkx 0:a259777c45a3 80 */
dirkx 0:a259777c45a3 81 int printf(const char* format, ...);
dirkx 0:a259777c45a3 82
dirkx 0:a259777c45a3 83 /* Function: scanf
dirkx 0:a259777c45a3 84 * Read a formated string
dirkx 0:a259777c45a3 85 *
dirkx 0:a259777c45a3 86 * Variables:
dirkx 0:a259777c45a3 87 * format - A scanf-style format string,
dirkx 0:a259777c45a3 88 * followed by the pointers to variables to store the results.
dirkx 0:a259777c45a3 89 */
dirkx 0:a259777c45a3 90 int scanf(const char* format, ...);
dirkx 0:a259777c45a3 91
dirkx 0:a259777c45a3 92 #endif
dirkx 0:a259777c45a3 93
dirkx 0:a259777c45a3 94 /* Function: readable
dirkx 0:a259777c45a3 95 * Determine if there is a character available to read
dirkx 0:a259777c45a3 96 *
dirkx 0:a259777c45a3 97 * Variables:
dirkx 0:a259777c45a3 98 * returns - 1 if there is a character available to read, else 0
dirkx 0:a259777c45a3 99 */
dirkx 0:a259777c45a3 100 int readable();
dirkx 0:a259777c45a3 101
dirkx 0:a259777c45a3 102 /* Function: writeable
dirkx 0:a259777c45a3 103 * Determine if there is space available to write a character
dirkx 0:a259777c45a3 104 *
dirkx 0:a259777c45a3 105 * Variables:
dirkx 0:a259777c45a3 106 * returns - 1 if there is space to write a character, else 0
dirkx 0:a259777c45a3 107 */
dirkx 0:a259777c45a3 108 int writeable();
dirkx 0:a259777c45a3 109
dirkx 0:a259777c45a3 110 virtual const struct rpc_method *get_rpc_methods();
dirkx 0:a259777c45a3 111 static struct rpc_class *get_rpc_class();
dirkx 0:a259777c45a3 112
dirkx 0:a259777c45a3 113 protected:
dirkx 0:a259777c45a3 114
dirkx 0:a259777c45a3 115 virtual int _getc();
dirkx 0:a259777c45a3 116 virtual int _putc(int c);
dirkx 0:a259777c45a3 117
dirkx 0:a259777c45a3 118 private:
dirkx 0:a259777c45a3 119
dirkx 0:a259777c45a3 120 void startTx();
dirkx 0:a259777c45a3 121 void startRx();
dirkx 0:a259777c45a3 122
dirkx 0:a259777c45a3 123 Timeout m_txTimeout;
dirkx 0:a259777c45a3 124
dirkx 0:a259777c45a3 125 volatile char* m_inBufEven;
dirkx 0:a259777c45a3 126 volatile char* m_inBufOdd;
dirkx 0:a259777c45a3 127 volatile char* m_inBufUsr;
dirkx 0:a259777c45a3 128 volatile char* m_inBufTrmt;
dirkx 0:a259777c45a3 129
dirkx 0:a259777c45a3 130 volatile char* m_outBufEven;
dirkx 0:a259777c45a3 131 volatile char* m_outBufOdd;
dirkx 0:a259777c45a3 132 volatile char* m_outBufUsr;
dirkx 0:a259777c45a3 133 volatile char* m_outBufTrmt;
dirkx 0:a259777c45a3 134
dirkx 0:a259777c45a3 135 volatile int m_inBufLen;
dirkx 0:a259777c45a3 136 volatile int m_outBufLen;
dirkx 0:a259777c45a3 137
dirkx 0:a259777c45a3 138 volatile char* m_pInBufPos;
dirkx 0:a259777c45a3 139 volatile char* m_pOutBufPos;
dirkx 0:a259777c45a3 140
dirkx 0:a259777c45a3 141
dirkx 0:a259777c45a3 142
dirkx 0:a259777c45a3 143 };
dirkx 0:a259777c45a3 144
dirkx 0:a259777c45a3 145 }
dirkx 0:a259777c45a3 146
dirkx 0:a259777c45a3 147
dirkx 0:a259777c45a3 148
dirkx 0:a259777c45a3 149 #endif