ryou sato / Mbed 2 deprecated LPC11U35_CTswitch_relay

Dependencies:   mbed LPC11U35_MCP41HV51-503EST

Committer:
ryousato
Date:
Mon Aug 17 01:01:49 2020 +0000
Revision:
0:df1e1f84ded8
1

Who changed what in which revision?

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