max4146x_comp

Dependencies:   MAX14690

Committer:
sdivarci
Date:
Sun Oct 25 20:10:02 2020 +0000
Revision:
0:0061165683ee
sdivarci

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sdivarci 0:0061165683ee 1 /* Copyright (c) 2010-2011 mbed.org, MIT License
sdivarci 0:0061165683ee 2 *
sdivarci 0:0061165683ee 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
sdivarci 0:0061165683ee 4 * and associated documentation files (the "Software"), to deal in the Software without
sdivarci 0:0061165683ee 5 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
sdivarci 0:0061165683ee 6 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
sdivarci 0:0061165683ee 7 * Software is furnished to do so, subject to the following conditions:
sdivarci 0:0061165683ee 8 *
sdivarci 0:0061165683ee 9 * The above copyright notice and this permission notice shall be included in all copies or
sdivarci 0:0061165683ee 10 * substantial portions of the Software.
sdivarci 0:0061165683ee 11 *
sdivarci 0:0061165683ee 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
sdivarci 0:0061165683ee 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
sdivarci 0:0061165683ee 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
sdivarci 0:0061165683ee 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
sdivarci 0:0061165683ee 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
sdivarci 0:0061165683ee 17 */
sdivarci 0:0061165683ee 18
sdivarci 0:0061165683ee 19 /* Standard descriptor types */
sdivarci 0:0061165683ee 20 #define DEVICE_DESCRIPTOR (1)
sdivarci 0:0061165683ee 21 #define CONFIGURATION_DESCRIPTOR (2)
sdivarci 0:0061165683ee 22 #define STRING_DESCRIPTOR (3)
sdivarci 0:0061165683ee 23 #define INTERFACE_DESCRIPTOR (4)
sdivarci 0:0061165683ee 24 #define ENDPOINT_DESCRIPTOR (5)
sdivarci 0:0061165683ee 25 #define QUALIFIER_DESCRIPTOR (6)
sdivarci 0:0061165683ee 26
sdivarci 0:0061165683ee 27 /* Standard descriptor lengths */
sdivarci 0:0061165683ee 28 #define DEVICE_DESCRIPTOR_LENGTH (0x12)
sdivarci 0:0061165683ee 29 #define CONFIGURATION_DESCRIPTOR_LENGTH (0x09)
sdivarci 0:0061165683ee 30 #define INTERFACE_DESCRIPTOR_LENGTH (0x09)
sdivarci 0:0061165683ee 31 #define ENDPOINT_DESCRIPTOR_LENGTH (0x07)
sdivarci 0:0061165683ee 32
sdivarci 0:0061165683ee 33
sdivarci 0:0061165683ee 34 /*string offset*/
sdivarci 0:0061165683ee 35 #define STRING_OFFSET_LANGID (0)
sdivarci 0:0061165683ee 36 #define STRING_OFFSET_IMANUFACTURER (1)
sdivarci 0:0061165683ee 37 #define STRING_OFFSET_IPRODUCT (2)
sdivarci 0:0061165683ee 38 #define STRING_OFFSET_ISERIAL (3)
sdivarci 0:0061165683ee 39 #define STRING_OFFSET_ICONFIGURATION (4)
sdivarci 0:0061165683ee 40 #define STRING_OFFSET_IINTERFACE (5)
sdivarci 0:0061165683ee 41
sdivarci 0:0061165683ee 42 /* USB Specification Release Number */
sdivarci 0:0061165683ee 43 #define USB_VERSION_2_0 (0x0200)
sdivarci 0:0061165683ee 44
sdivarci 0:0061165683ee 45 /* Least/Most significant byte of short integer */
sdivarci 0:0061165683ee 46 #define LSB(n) ((n)&0xff)
sdivarci 0:0061165683ee 47 #define MSB(n) (((n)&0xff00)>>8)
sdivarci 0:0061165683ee 48
sdivarci 0:0061165683ee 49 /* Convert physical endpoint number to descriptor endpoint number */
sdivarci 0:0061165683ee 50 #define PHY_TO_DESC(endpoint) (((endpoint)>>1) | (((endpoint) & 1) ? 0x80:0))
sdivarci 0:0061165683ee 51
sdivarci 0:0061165683ee 52 /* bmAttributes in configuration descriptor */
sdivarci 0:0061165683ee 53 /* C_RESERVED must always be set */
sdivarci 0:0061165683ee 54 #define C_RESERVED (1U<<7)
sdivarci 0:0061165683ee 55 #define C_SELF_POWERED (1U<<6)
sdivarci 0:0061165683ee 56 #define C_REMOTE_WAKEUP (1U<<5)
sdivarci 0:0061165683ee 57
sdivarci 0:0061165683ee 58 /* bMaxPower in configuration descriptor */
sdivarci 0:0061165683ee 59 #define C_POWER(mA) ((mA)/2)
sdivarci 0:0061165683ee 60
sdivarci 0:0061165683ee 61 /* bmAttributes in endpoint descriptor */
sdivarci 0:0061165683ee 62 #define E_CONTROL (0x00)
sdivarci 0:0061165683ee 63 #define E_ISOCHRONOUS (0x01)
sdivarci 0:0061165683ee 64 #define E_BULK (0x02)
sdivarci 0:0061165683ee 65 #define E_INTERRUPT (0x03)
sdivarci 0:0061165683ee 66
sdivarci 0:0061165683ee 67 /* For isochronous endpoints only: */
sdivarci 0:0061165683ee 68 #define E_NO_SYNCHRONIZATION (0x00)
sdivarci 0:0061165683ee 69 #define E_ASYNCHRONOUS (0x04)
sdivarci 0:0061165683ee 70 #define E_ADAPTIVE (0x08)
sdivarci 0:0061165683ee 71 #define E_SYNCHRONOUS (0x0C)
sdivarci 0:0061165683ee 72 #define E_DATA (0x00)
sdivarci 0:0061165683ee 73 #define E_FEEDBACK (0x10)
sdivarci 0:0061165683ee 74 #define E_IMPLICIT_FEEDBACK (0x20)