diff options
Diffstat (limited to 'lib/lufa/Demos/Device/Incomplete/TestAndMeasurement/TestAndMeasurement.h')
| -rw-r--r-- | lib/lufa/Demos/Device/Incomplete/TestAndMeasurement/TestAndMeasurement.h | 150 |
1 files changed, 150 insertions, 0 deletions
diff --git a/lib/lufa/Demos/Device/Incomplete/TestAndMeasurement/TestAndMeasurement.h b/lib/lufa/Demos/Device/Incomplete/TestAndMeasurement/TestAndMeasurement.h new file mode 100644 index 000000000..50e865bed --- /dev/null +++ b/lib/lufa/Demos/Device/Incomplete/TestAndMeasurement/TestAndMeasurement.h | |||
| @@ -0,0 +1,150 @@ | |||
| 1 | /* | ||
| 2 | LUFA Library | ||
| 3 | Copyright (C) Dean Camera, 2017. | ||
| 4 | |||
| 5 | dean [at] fourwalledcubicle [dot] com | ||
| 6 | www.lufa-lib.org | ||
| 7 | */ | ||
| 8 | |||
| 9 | /* | ||
| 10 | Copyright 2017 Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||
| 11 | |||
| 12 | Permission to use, copy, modify, distribute, and sell this | ||
| 13 | software and its documentation for any purpose is hereby granted | ||
| 14 | without fee, provided that the above copyright notice appear in | ||
| 15 | all copies and that both that the copyright notice and this | ||
| 16 | permission notice and warranty disclaimer appear in supporting | ||
| 17 | documentation, and that the name of the author not be used in | ||
| 18 | advertising or publicity pertaining to distribution of the | ||
| 19 | software without specific, written prior permission. | ||
| 20 | |||
| 21 | The author disclaims all warranties with regard to this | ||
| 22 | software, including all implied warranties of merchantability | ||
| 23 | and fitness. In no event shall the author be liable for any | ||
| 24 | special, indirect or consequential damages or any damages | ||
| 25 | whatsoever resulting from loss of use, data or profits, whether | ||
| 26 | in an action of contract, negligence or other tortious action, | ||
| 27 | arising out of or in connection with the use or performance of | ||
| 28 | this software. | ||
| 29 | */ | ||
| 30 | |||
| 31 | #ifndef _TESTANDMEASUREMENT_H_ | ||
| 32 | #define _TESTANDMEASUREMENT_H_ | ||
| 33 | |||
| 34 | /* Includes: */ | ||
| 35 | #include <avr/io.h> | ||
| 36 | #include <avr/wdt.h> | ||
| 37 | #include <avr/power.h> | ||
| 38 | #include <avr/interrupt.h> | ||
| 39 | |||
| 40 | #include "Descriptors.h" | ||
| 41 | |||
| 42 | #include <LUFA/Drivers/Board/LEDs.h> | ||
| 43 | #include <LUFA/Drivers/USB/USB.h> | ||
| 44 | #include <LUFA/Platform/Platform.h> | ||
| 45 | |||
| 46 | /* Macros: */ | ||
| 47 | /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ | ||
| 48 | #define LEDMASK_USB_NOTREADY LEDS_LED1 | ||
| 49 | |||
| 50 | /** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */ | ||
| 51 | #define LEDMASK_USB_ENUMERATING (LEDS_LED2 | LEDS_LED3) | ||
| 52 | |||
| 53 | /** LED mask for the library LED driver, to indicate that the USB interface is ready. */ | ||
| 54 | #define LEDMASK_USB_READY (LEDS_LED2 | LEDS_LED4) | ||
| 55 | |||
| 56 | /** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */ | ||
| 57 | #define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3) | ||
| 58 | |||
| 59 | /** LED mask for the library LED driver, to indicate that the USB interface is busy. */ | ||
| 60 | #define LEDMASK_USB_BUSY LEDS_LED2 | ||
| 61 | |||
| 62 | #define Req_InitiateAbortBulkOut 0x01 | ||
| 63 | #define Req_CheckAbortBulkOutStatus 0x02 | ||
| 64 | #define Req_InitiateAbortBulkIn 0x03 | ||
| 65 | #define Req_CheckAbortBulkInStatus 0x04 | ||
| 66 | #define Req_InitiateClear 0x05 | ||
| 67 | #define Req_CheckClearStatus 0x06 | ||
| 68 | #define Req_GetCapabilities 0x07 | ||
| 69 | #define Req_IndicatorPulse 0x40 | ||
| 70 | |||
| 71 | #define TMC_STATUS_SUCCESS 0x01 | ||
| 72 | #define TMC_STATUS_PENDING 0x02 | ||
| 73 | #define TMC_STATUS_FAILED 0x80 | ||
| 74 | #define TMC_STATUS_TRANSFER_NOT_IN_PROGRESS 0x81 | ||
| 75 | #define TMC_STATUS_SPLIT_NOT_IN_PROGRESS 0x82 | ||
| 76 | #define TMC_STATUS_SPLIT_IN_PROGRESS 0x83 | ||
| 77 | |||
| 78 | #define TMC_MESSAGEID_DEV_DEP_MSG_OUT 0x01 | ||
| 79 | #define TMC_MESSAGEID_DEV_DEP_MSG_IN 0x02 | ||
| 80 | #define TMC_MESSAGEID_DEV_VENDOR_OUT 0x7E | ||
| 81 | #define TMC_MESSAGEID_DEV_VENDOR_IN 0x7F | ||
| 82 | |||
| 83 | /* Type Defines */ | ||
| 84 | typedef struct | ||
| 85 | { | ||
| 86 | uint8_t Status; | ||
| 87 | uint8_t Reserved; | ||
| 88 | |||
| 89 | uint16_t TMCVersion; | ||
| 90 | |||
| 91 | struct | ||
| 92 | { | ||
| 93 | unsigned ListenOnly : 1; | ||
| 94 | unsigned TalkOnly : 1; | ||
| 95 | unsigned PulseIndicateSupported : 1; | ||
| 96 | unsigned Reserved : 5; | ||
| 97 | } Interface; | ||
| 98 | |||
| 99 | struct | ||
| 100 | { | ||
| 101 | unsigned SupportsAbortINOnMatch : 1; | ||
| 102 | unsigned Reserved : 7; | ||
| 103 | } Device; | ||
| 104 | |||
| 105 | uint8_t Reserved2[6]; | ||
| 106 | uint8_t Reserved3[12]; | ||
| 107 | } TMC_Capabilities_t; | ||
| 108 | |||
| 109 | typedef struct | ||
| 110 | { | ||
| 111 | uint8_t LastMessageTransaction; | ||
| 112 | uint8_t TermChar; | ||
| 113 | uint8_t Reserved[2]; | ||
| 114 | } TMC_DevOUTMessageHeader_t; | ||
| 115 | |||
| 116 | typedef struct | ||
| 117 | { | ||
| 118 | uint8_t LastMessageTransaction; | ||
| 119 | uint8_t Reserved[3]; | ||
| 120 | } TMC_DevINMessageHeader_t; | ||
| 121 | |||
| 122 | typedef struct | ||
| 123 | { | ||
| 124 | uint8_t MessageID; | ||
| 125 | uint8_t Tag; | ||
| 126 | uint8_t InverseTag; | ||
| 127 | uint8_t Reserved; | ||
| 128 | uint32_t TransferSize; | ||
| 129 | |||
| 130 | union | ||
| 131 | { | ||
| 132 | TMC_DevOUTMessageHeader_t DeviceOUT; | ||
| 133 | TMC_DevINMessageHeader_t DeviceIN; | ||
| 134 | uint32_t VendorSpecific; | ||
| 135 | } MessageIDSpecific; | ||
| 136 | } TMC_MessageHeader_t; | ||
| 137 | |||
| 138 | /* Function Prototypes: */ | ||
| 139 | void SetupHardware(void); | ||
| 140 | void TMC_Task(void); | ||
| 141 | bool ReadTMCHeader(TMC_MessageHeader_t* const MessageHeader); | ||
| 142 | bool WriteTMCHeader(TMC_MessageHeader_t* const MessageHeader); | ||
| 143 | |||
| 144 | void EVENT_USB_Device_Connect(void); | ||
| 145 | void EVENT_USB_Device_Disconnect(void); | ||
| 146 | void EVENT_USB_Device_ConfigurationChanged(void); | ||
| 147 | void EVENT_USB_Device_ControlRequest(void); | ||
| 148 | |||
| 149 | #endif | ||
| 150 | |||
