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 #ifndef USBDEVICE_TYPES_H
sdivarci 0:0061165683ee 20 #define USBDEVICE_TYPES_H
sdivarci 0:0061165683ee 21
sdivarci 0:0061165683ee 22 #include <stdint.h>
sdivarci 0:0061165683ee 23
sdivarci 0:0061165683ee 24 /* Standard requests */
sdivarci 0:0061165683ee 25 #define GET_STATUS (0)
sdivarci 0:0061165683ee 26 #define CLEAR_FEATURE (1)
sdivarci 0:0061165683ee 27 #define SET_FEATURE (3)
sdivarci 0:0061165683ee 28 #define SET_ADDRESS (5)
sdivarci 0:0061165683ee 29 #define GET_DESCRIPTOR (6)
sdivarci 0:0061165683ee 30 #define SET_DESCRIPTOR (7)
sdivarci 0:0061165683ee 31 #define GET_CONFIGURATION (8)
sdivarci 0:0061165683ee 32 #define SET_CONFIGURATION (9)
sdivarci 0:0061165683ee 33 #define GET_INTERFACE (10)
sdivarci 0:0061165683ee 34 #define SET_INTERFACE (11)
sdivarci 0:0061165683ee 35
sdivarci 0:0061165683ee 36 /* bmRequestType.dataTransferDirection */
sdivarci 0:0061165683ee 37 #define HOST_TO_DEVICE (0)
sdivarci 0:0061165683ee 38 #define DEVICE_TO_HOST (1)
sdivarci 0:0061165683ee 39
sdivarci 0:0061165683ee 40 /* bmRequestType.Type*/
sdivarci 0:0061165683ee 41 #define STANDARD_TYPE (0)
sdivarci 0:0061165683ee 42 #define CLASS_TYPE (1)
sdivarci 0:0061165683ee 43 #define VENDOR_TYPE (2)
sdivarci 0:0061165683ee 44 #define RESERVED_TYPE (3)
sdivarci 0:0061165683ee 45
sdivarci 0:0061165683ee 46 /* bmRequestType.Recipient */
sdivarci 0:0061165683ee 47 #define DEVICE_RECIPIENT (0)
sdivarci 0:0061165683ee 48 #define INTERFACE_RECIPIENT (1)
sdivarci 0:0061165683ee 49 #define ENDPOINT_RECIPIENT (2)
sdivarci 0:0061165683ee 50 #define OTHER_RECIPIENT (3)
sdivarci 0:0061165683ee 51
sdivarci 0:0061165683ee 52 /* Descriptors */
sdivarci 0:0061165683ee 53 #define DESCRIPTOR_TYPE(wValue) (wValue >> 8)
sdivarci 0:0061165683ee 54 #define DESCRIPTOR_INDEX(wValue) (wValue & 0xff)
sdivarci 0:0061165683ee 55
sdivarci 0:0061165683ee 56 typedef struct {
sdivarci 0:0061165683ee 57 struct {
sdivarci 0:0061165683ee 58 uint8_t dataTransferDirection;
sdivarci 0:0061165683ee 59 uint8_t Type;
sdivarci 0:0061165683ee 60 uint8_t Recipient;
sdivarci 0:0061165683ee 61 } bmRequestType;
sdivarci 0:0061165683ee 62 uint8_t bRequest;
sdivarci 0:0061165683ee 63 uint16_t wValue;
sdivarci 0:0061165683ee 64 uint16_t wIndex;
sdivarci 0:0061165683ee 65 uint16_t wLength;
sdivarci 0:0061165683ee 66 } SETUP_PACKET;
sdivarci 0:0061165683ee 67
sdivarci 0:0061165683ee 68 typedef struct {
sdivarci 0:0061165683ee 69 SETUP_PACKET setup;
sdivarci 0:0061165683ee 70 uint8_t *ptr;
sdivarci 0:0061165683ee 71 uint32_t remaining;
sdivarci 0:0061165683ee 72 uint8_t direction;
sdivarci 0:0061165683ee 73 bool zlp;
sdivarci 0:0061165683ee 74 bool notify;
sdivarci 0:0061165683ee 75 } CONTROL_TRANSFER;
sdivarci 0:0061165683ee 76
sdivarci 0:0061165683ee 77 typedef enum {ATTACHED, POWERED, DEFAULT, ADDRESS, CONFIGURED} DEVICE_STATE;
sdivarci 0:0061165683ee 78
sdivarci 0:0061165683ee 79 typedef struct {
sdivarci 0:0061165683ee 80 volatile DEVICE_STATE state;
sdivarci 0:0061165683ee 81 uint8_t configuration;
sdivarci 0:0061165683ee 82 bool suspended;
sdivarci 0:0061165683ee 83 } USB_DEVICE;
sdivarci 0:0061165683ee 84
sdivarci 0:0061165683ee 85 #endif