ME11B Sample Code in Maxim Integrated Team

Dependencies:   BMI160 max32630hsp3 MemoryLCD USBDevice

Fork of Host_Software_MAX32664GWEB_HR_EXTENDED by Seyhmus Cacina

Committer:
seyhmus.cacina
Date:
Mon Mar 18 10:21:53 2019 +0300
Revision:
0:ac4dea3e2894
ME11B Sample Code First Commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
seyhmus.cacina 0:ac4dea3e2894 1 /* Copyright (c) 2010-2011 mbed.org, MIT License
seyhmus.cacina 0:ac4dea3e2894 2 *
seyhmus.cacina 0:ac4dea3e2894 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
seyhmus.cacina 0:ac4dea3e2894 4 * and associated documentation files (the "Software"), to deal in the Software without
seyhmus.cacina 0:ac4dea3e2894 5 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
seyhmus.cacina 0:ac4dea3e2894 6 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
seyhmus.cacina 0:ac4dea3e2894 7 * Software is furnished to do so, subject to the following conditions:
seyhmus.cacina 0:ac4dea3e2894 8 *
seyhmus.cacina 0:ac4dea3e2894 9 * The above copyright notice and this permission notice shall be included in all copies or
seyhmus.cacina 0:ac4dea3e2894 10 * substantial portions of the Software.
seyhmus.cacina 0:ac4dea3e2894 11 *
seyhmus.cacina 0:ac4dea3e2894 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
seyhmus.cacina 0:ac4dea3e2894 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
seyhmus.cacina 0:ac4dea3e2894 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
seyhmus.cacina 0:ac4dea3e2894 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
seyhmus.cacina 0:ac4dea3e2894 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
seyhmus.cacina 0:ac4dea3e2894 17 */
seyhmus.cacina 0:ac4dea3e2894 18
seyhmus.cacina 0:ac4dea3e2894 19 #ifndef USBDEVICE_TYPES_H
seyhmus.cacina 0:ac4dea3e2894 20 #define USBDEVICE_TYPES_H
seyhmus.cacina 0:ac4dea3e2894 21
seyhmus.cacina 0:ac4dea3e2894 22 #include <stdint.h>
seyhmus.cacina 0:ac4dea3e2894 23
seyhmus.cacina 0:ac4dea3e2894 24 /* Standard requests */
seyhmus.cacina 0:ac4dea3e2894 25 #define GET_STATUS (0)
seyhmus.cacina 0:ac4dea3e2894 26 #define CLEAR_FEATURE (1)
seyhmus.cacina 0:ac4dea3e2894 27 #define SET_FEATURE (3)
seyhmus.cacina 0:ac4dea3e2894 28 #define SET_ADDRESS (5)
seyhmus.cacina 0:ac4dea3e2894 29 #define GET_DESCRIPTOR (6)
seyhmus.cacina 0:ac4dea3e2894 30 #define SET_DESCRIPTOR (7)
seyhmus.cacina 0:ac4dea3e2894 31 #define GET_CONFIGURATION (8)
seyhmus.cacina 0:ac4dea3e2894 32 #define SET_CONFIGURATION (9)
seyhmus.cacina 0:ac4dea3e2894 33 #define GET_INTERFACE (10)
seyhmus.cacina 0:ac4dea3e2894 34 #define SET_INTERFACE (11)
seyhmus.cacina 0:ac4dea3e2894 35
seyhmus.cacina 0:ac4dea3e2894 36 /* bmRequestType.dataTransferDirection */
seyhmus.cacina 0:ac4dea3e2894 37 #define HOST_TO_DEVICE (0)
seyhmus.cacina 0:ac4dea3e2894 38 #define DEVICE_TO_HOST (1)
seyhmus.cacina 0:ac4dea3e2894 39
seyhmus.cacina 0:ac4dea3e2894 40 /* bmRequestType.Type*/
seyhmus.cacina 0:ac4dea3e2894 41 #define STANDARD_TYPE (0)
seyhmus.cacina 0:ac4dea3e2894 42 #define CLASS_TYPE (1)
seyhmus.cacina 0:ac4dea3e2894 43 #define VENDOR_TYPE (2)
seyhmus.cacina 0:ac4dea3e2894 44 #define RESERVED_TYPE (3)
seyhmus.cacina 0:ac4dea3e2894 45
seyhmus.cacina 0:ac4dea3e2894 46 /* bmRequestType.Recipient */
seyhmus.cacina 0:ac4dea3e2894 47 #define DEVICE_RECIPIENT (0)
seyhmus.cacina 0:ac4dea3e2894 48 #define INTERFACE_RECIPIENT (1)
seyhmus.cacina 0:ac4dea3e2894 49 #define ENDPOINT_RECIPIENT (2)
seyhmus.cacina 0:ac4dea3e2894 50 #define OTHER_RECIPIENT (3)
seyhmus.cacina 0:ac4dea3e2894 51
seyhmus.cacina 0:ac4dea3e2894 52 /* Descriptors */
seyhmus.cacina 0:ac4dea3e2894 53 #define DESCRIPTOR_TYPE(wValue) (wValue >> 8)
seyhmus.cacina 0:ac4dea3e2894 54 #define DESCRIPTOR_INDEX(wValue) (wValue & 0xff)
seyhmus.cacina 0:ac4dea3e2894 55
seyhmus.cacina 0:ac4dea3e2894 56 typedef struct {
seyhmus.cacina 0:ac4dea3e2894 57 struct {
seyhmus.cacina 0:ac4dea3e2894 58 uint8_t dataTransferDirection;
seyhmus.cacina 0:ac4dea3e2894 59 uint8_t Type;
seyhmus.cacina 0:ac4dea3e2894 60 uint8_t Recipient;
seyhmus.cacina 0:ac4dea3e2894 61 } bmRequestType;
seyhmus.cacina 0:ac4dea3e2894 62 uint8_t bRequest;
seyhmus.cacina 0:ac4dea3e2894 63 uint16_t wValue;
seyhmus.cacina 0:ac4dea3e2894 64 uint16_t wIndex;
seyhmus.cacina 0:ac4dea3e2894 65 uint16_t wLength;
seyhmus.cacina 0:ac4dea3e2894 66 } SETUP_PACKET;
seyhmus.cacina 0:ac4dea3e2894 67
seyhmus.cacina 0:ac4dea3e2894 68 typedef struct {
seyhmus.cacina 0:ac4dea3e2894 69 SETUP_PACKET setup;
seyhmus.cacina 0:ac4dea3e2894 70 uint8_t *ptr;
seyhmus.cacina 0:ac4dea3e2894 71 uint32_t remaining;
seyhmus.cacina 0:ac4dea3e2894 72 uint8_t direction;
seyhmus.cacina 0:ac4dea3e2894 73 bool zlp;
seyhmus.cacina 0:ac4dea3e2894 74 bool notify;
seyhmus.cacina 0:ac4dea3e2894 75 } CONTROL_TRANSFER;
seyhmus.cacina 0:ac4dea3e2894 76
seyhmus.cacina 0:ac4dea3e2894 77 typedef enum {ATTACHED, POWERED, DEFAULT, ADDRESS, CONFIGURED} DEVICE_STATE;
seyhmus.cacina 0:ac4dea3e2894 78
seyhmus.cacina 0:ac4dea3e2894 79 typedef struct {
seyhmus.cacina 0:ac4dea3e2894 80 volatile DEVICE_STATE state;
seyhmus.cacina 0:ac4dea3e2894 81 uint8_t configuration;
seyhmus.cacina 0:ac4dea3e2894 82 bool suspended;
seyhmus.cacina 0:ac4dea3e2894 83 } USB_DEVICE;
seyhmus.cacina 0:ac4dea3e2894 84
seyhmus.cacina 0:ac4dea3e2894 85 #endif