modded version Dirk-Willem van Gulik's Bonjour/Zerconf library http://mbed.org/users/dirkx/code/Bonjour/

Dependents:   OSCtoCVConverter

Fork of Bonjour by Dirk-Willem van Gulik (NXP/mbed)

Committer:
dirkx
Date:
Wed Jul 21 19:25:56 2010 +0000
Revision:
0:355018f44c9f

        

Who changed what in which revision?

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