This program operates a pH meter and requires an Excel spreadsheet template available at www.kissinstrments.com

Dependencies:   mbed

Committer:
KISScientific
Date:
Fri Jul 22 00:03:25 2016 +0000
Revision:
0:f6b418db17d2
pH-V12 version 1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
KISScientific 0:f6b418db17d2 1 /* Copyright (c) 2010-2011 mbed.org, MIT License
KISScientific 0:f6b418db17d2 2 *
KISScientific 0:f6b418db17d2 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
KISScientific 0:f6b418db17d2 4 * and associated documentation files (the "Software"), to deal in the Software without
KISScientific 0:f6b418db17d2 5 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
KISScientific 0:f6b418db17d2 6 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
KISScientific 0:f6b418db17d2 7 * Software is furnished to do so, subject to the following conditions:
KISScientific 0:f6b418db17d2 8 *
KISScientific 0:f6b418db17d2 9 * The above copyright notice and this permission notice shall be included in all copies or
KISScientific 0:f6b418db17d2 10 * substantial portions of the Software.
KISScientific 0:f6b418db17d2 11 *
KISScientific 0:f6b418db17d2 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
KISScientific 0:f6b418db17d2 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
KISScientific 0:f6b418db17d2 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
KISScientific 0:f6b418db17d2 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
KISScientific 0:f6b418db17d2 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
KISScientific 0:f6b418db17d2 17 */
KISScientific 0:f6b418db17d2 18
KISScientific 0:f6b418db17d2 19 #ifndef USB_HID_H
KISScientific 0:f6b418db17d2 20 #define USB_HID_H
KISScientific 0:f6b418db17d2 21
KISScientific 0:f6b418db17d2 22 /* These headers are included for child class. */
KISScientific 0:f6b418db17d2 23 #include "USBEndpoints.h"
KISScientific 0:f6b418db17d2 24 #include "USBDescriptor.h"
KISScientific 0:f6b418db17d2 25 #include "USBDevice_Types.h"
KISScientific 0:f6b418db17d2 26
KISScientific 0:f6b418db17d2 27 #include "USBHID_Types.h"
KISScientific 0:f6b418db17d2 28 #include "USBDevice.h"
KISScientific 0:f6b418db17d2 29
KISScientific 0:f6b418db17d2 30
KISScientific 0:f6b418db17d2 31 /**
KISScientific 0:f6b418db17d2 32 * USBHID example
KISScientific 0:f6b418db17d2 33 * @code
KISScientific 0:f6b418db17d2 34 * #include "mbed.h"
KISScientific 0:f6b418db17d2 35 * #include "USBHID.h"
KISScientific 0:f6b418db17d2 36 *
KISScientific 0:f6b418db17d2 37 * USBHID hid;
KISScientific 0:f6b418db17d2 38 * HID_REPORT recv;
KISScientific 0:f6b418db17d2 39 * BusOut leds(LED1,LED2,LED3,LED4);
KISScientific 0:f6b418db17d2 40 *
KISScientific 0:f6b418db17d2 41 * int main(void) {
KISScientific 0:f6b418db17d2 42 * while (1) {
KISScientific 0:f6b418db17d2 43 * hid.read(&recv);
KISScientific 0:f6b418db17d2 44 * leds = recv.data[0];
KISScientific 0:f6b418db17d2 45 * }
KISScientific 0:f6b418db17d2 46 * }
KISScientific 0:f6b418db17d2 47 * @endcode
KISScientific 0:f6b418db17d2 48 */
KISScientific 0:f6b418db17d2 49
KISScientific 0:f6b418db17d2 50 class USBHID: public USBDevice {
KISScientific 0:f6b418db17d2 51 public:
KISScientific 0:f6b418db17d2 52
KISScientific 0:f6b418db17d2 53 /**
KISScientific 0:f6b418db17d2 54 * Constructor
KISScientific 0:f6b418db17d2 55 *
KISScientific 0:f6b418db17d2 56 * @param output_report_length Maximum length of a sent report (up to 64 bytes) (default: 64 bytes)
KISScientific 0:f6b418db17d2 57 * @param input_report_length Maximum length of a received report (up to 64 bytes) (default: 64 bytes)
KISScientific 0:f6b418db17d2 58 * @param vendor_id Your vendor_id
KISScientific 0:f6b418db17d2 59 * @param product_id Your product_id
KISScientific 0:f6b418db17d2 60 * @param product_release Your preoduct_release
KISScientific 0:f6b418db17d2 61 * @param connect Connect the device
KISScientific 0:f6b418db17d2 62 */
KISScientific 0:f6b418db17d2 63 USBHID(uint8_t output_report_length = 64, uint8_t input_report_length = 64, uint16_t vendor_id = 0x1234, uint16_t product_id = 0x0006, uint16_t product_release = 0x0001, bool connect = true);
KISScientific 0:f6b418db17d2 64
KISScientific 0:f6b418db17d2 65
KISScientific 0:f6b418db17d2 66 /**
KISScientific 0:f6b418db17d2 67 * Send a Report. warning: blocking
KISScientific 0:f6b418db17d2 68 *
KISScientific 0:f6b418db17d2 69 * @param report Report which will be sent (a report is defined by all data and the length)
KISScientific 0:f6b418db17d2 70 * @returns true if successful
KISScientific 0:f6b418db17d2 71 */
KISScientific 0:f6b418db17d2 72 bool send(HID_REPORT *report);
KISScientific 0:f6b418db17d2 73
KISScientific 0:f6b418db17d2 74
KISScientific 0:f6b418db17d2 75 /**
KISScientific 0:f6b418db17d2 76 * Send a Report. warning: non blocking
KISScientific 0:f6b418db17d2 77 *
KISScientific 0:f6b418db17d2 78 * @param report Report which will be sent (a report is defined by all data and the length)
KISScientific 0:f6b418db17d2 79 * @returns true if successful
KISScientific 0:f6b418db17d2 80 */
KISScientific 0:f6b418db17d2 81 bool sendNB(HID_REPORT *report);
KISScientific 0:f6b418db17d2 82
KISScientific 0:f6b418db17d2 83 /**
KISScientific 0:f6b418db17d2 84 * Read a report: blocking
KISScientific 0:f6b418db17d2 85 *
KISScientific 0:f6b418db17d2 86 * @param report pointer to the report to fill
KISScientific 0:f6b418db17d2 87 * @returns true if successful
KISScientific 0:f6b418db17d2 88 */
KISScientific 0:f6b418db17d2 89 bool read(HID_REPORT * report);
KISScientific 0:f6b418db17d2 90
KISScientific 0:f6b418db17d2 91 /**
KISScientific 0:f6b418db17d2 92 * Read a report: non blocking
KISScientific 0:f6b418db17d2 93 *
KISScientific 0:f6b418db17d2 94 * @param report pointer to the report to fill
KISScientific 0:f6b418db17d2 95 * @returns true if successful
KISScientific 0:f6b418db17d2 96 */
KISScientific 0:f6b418db17d2 97 bool readNB(HID_REPORT * report);
KISScientific 0:f6b418db17d2 98
KISScientific 0:f6b418db17d2 99 protected:
KISScientific 0:f6b418db17d2 100 uint16_t reportLength;
KISScientific 0:f6b418db17d2 101
KISScientific 0:f6b418db17d2 102 /*
KISScientific 0:f6b418db17d2 103 * Get the Report descriptor
KISScientific 0:f6b418db17d2 104 *
KISScientific 0:f6b418db17d2 105 * @returns pointer to the report descriptor
KISScientific 0:f6b418db17d2 106 */
KISScientific 0:f6b418db17d2 107 virtual uint8_t * reportDesc();
KISScientific 0:f6b418db17d2 108
KISScientific 0:f6b418db17d2 109 /*
KISScientific 0:f6b418db17d2 110 * Get the length of the report descriptor
KISScientific 0:f6b418db17d2 111 *
KISScientific 0:f6b418db17d2 112 * @returns the length of the report descriptor
KISScientific 0:f6b418db17d2 113 */
KISScientific 0:f6b418db17d2 114 virtual uint16_t reportDescLength();
KISScientific 0:f6b418db17d2 115
KISScientific 0:f6b418db17d2 116 /*
KISScientific 0:f6b418db17d2 117 * Get string product descriptor
KISScientific 0:f6b418db17d2 118 *
KISScientific 0:f6b418db17d2 119 * @returns pointer to the string product descriptor
KISScientific 0:f6b418db17d2 120 */
KISScientific 0:f6b418db17d2 121 virtual uint8_t * stringIproductDesc();
KISScientific 0:f6b418db17d2 122
KISScientific 0:f6b418db17d2 123 /*
KISScientific 0:f6b418db17d2 124 * Get string interface descriptor
KISScientific 0:f6b418db17d2 125 *
KISScientific 0:f6b418db17d2 126 * @returns pointer to the string interface descriptor
KISScientific 0:f6b418db17d2 127 */
KISScientific 0:f6b418db17d2 128 virtual uint8_t * stringIinterfaceDesc();
KISScientific 0:f6b418db17d2 129
KISScientific 0:f6b418db17d2 130 /*
KISScientific 0:f6b418db17d2 131 * Get configuration descriptor
KISScientific 0:f6b418db17d2 132 *
KISScientific 0:f6b418db17d2 133 * @returns pointer to the configuration descriptor
KISScientific 0:f6b418db17d2 134 */
KISScientific 0:f6b418db17d2 135 virtual uint8_t * configurationDesc();
KISScientific 0:f6b418db17d2 136
KISScientific 0:f6b418db17d2 137
KISScientific 0:f6b418db17d2 138 /*
KISScientific 0:f6b418db17d2 139 * HID Report received by SET_REPORT request. Warning: Called in ISR context
KISScientific 0:f6b418db17d2 140 * First byte of data will be the report ID
KISScientific 0:f6b418db17d2 141 *
KISScientific 0:f6b418db17d2 142 * @param report Data and length received
KISScientific 0:f6b418db17d2 143 */
KISScientific 0:f6b418db17d2 144 virtual void HID_callbackSetReport(HID_REPORT *report){};
KISScientific 0:f6b418db17d2 145
KISScientific 0:f6b418db17d2 146
KISScientific 0:f6b418db17d2 147 /*
KISScientific 0:f6b418db17d2 148 * Called by USBDevice on Endpoint0 request. Warning: Called in ISR context
KISScientific 0:f6b418db17d2 149 * This is used to handle extensions to standard requests
KISScientific 0:f6b418db17d2 150 * and class specific requests
KISScientific 0:f6b418db17d2 151 *
KISScientific 0:f6b418db17d2 152 * @returns true if class handles this request
KISScientific 0:f6b418db17d2 153 */
KISScientific 0:f6b418db17d2 154 virtual bool USBCallback_request();
KISScientific 0:f6b418db17d2 155
KISScientific 0:f6b418db17d2 156
KISScientific 0:f6b418db17d2 157 /*
KISScientific 0:f6b418db17d2 158 * Called by USBDevice layer. Set configuration of the device.
KISScientific 0:f6b418db17d2 159 * For instance, you can add all endpoints that you need on this function.
KISScientific 0:f6b418db17d2 160 *
KISScientific 0:f6b418db17d2 161 * @param configuration Number of the configuration
KISScientific 0:f6b418db17d2 162 * @returns true if class handles this request
KISScientific 0:f6b418db17d2 163 */
KISScientific 0:f6b418db17d2 164 virtual bool USBCallback_setConfiguration(uint8_t configuration);
KISScientific 0:f6b418db17d2 165
KISScientific 0:f6b418db17d2 166 private:
KISScientific 0:f6b418db17d2 167 HID_REPORT outputReport;
KISScientific 0:f6b418db17d2 168 uint8_t output_length;
KISScientific 0:f6b418db17d2 169 uint8_t input_length;
KISScientific 0:f6b418db17d2 170 };
KISScientific 0:f6b418db17d2 171
KISScientific 0:f6b418db17d2 172 #endif