diff options
Diffstat (limited to 'lib/lufa/Demos/Device/Incomplete/TestAndMeasurement')
6 files changed, 0 insertions, 1104 deletions
diff --git a/lib/lufa/Demos/Device/Incomplete/TestAndMeasurement/Config/LUFAConfig.h b/lib/lufa/Demos/Device/Incomplete/TestAndMeasurement/Config/LUFAConfig.h deleted file mode 100644 index 0ec4635eb0..0000000000 --- a/lib/lufa/Demos/Device/Incomplete/TestAndMeasurement/Config/LUFAConfig.h +++ /dev/null @@ -1,126 +0,0 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2017. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2017 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaims all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * \brief LUFA Library Configuration Header File - * - * This header file is used to configure LUFA's compile time options, - * as an alternative to the compile time constants supplied through - * a makefile. - * - * For information on what each token does, refer to the LUFA - * manual section "Summary of Compile Tokens". - */ - -#ifndef _LUFA_CONFIG_H_ -#define _LUFA_CONFIG_H_ - - #if (ARCH == ARCH_AVR8) - - /* Non-USB Related Configuration Tokens: */ -// #define DISABLE_TERMINAL_CODES - - /* USB Class Driver Related Tokens: */ -// #define HID_HOST_BOOT_PROTOCOL_ONLY -// #define HID_STATETABLE_STACK_DEPTH {Insert Value Here} -// #define HID_USAGE_STACK_DEPTH {Insert Value Here} -// #define HID_MAX_COLLECTIONS {Insert Value Here} -// #define HID_MAX_REPORTITEMS {Insert Value Here} -// #define HID_MAX_REPORT_IDS {Insert Value Here} -// #define NO_CLASS_DRIVER_AUTOFLUSH - - /* General USB Driver Related Tokens: */ -// #define ORDERED_EP_CONFIG - #define USE_STATIC_OPTIONS (USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL) - #define USB_DEVICE_ONLY -// #define USB_HOST_ONLY -// #define USB_STREAM_TIMEOUT_MS {Insert Value Here} -// #define NO_LIMITED_CONTROLLER_CONNECT -// #define NO_SOF_EVENTS - - /* USB Device Mode Driver Related Tokens: */ -// #define USE_RAM_DESCRIPTORS - #define USE_FLASH_DESCRIPTORS -// #define USE_EEPROM_DESCRIPTORS -// #define NO_INTERNAL_SERIAL - #define FIXED_CONTROL_ENDPOINT_SIZE 8 -// #define DEVICE_STATE_AS_GPIOR {Insert Value Here} - #define FIXED_NUM_CONFIGURATIONS 1 -// #define CONTROL_ONLY_DEVICE - #define INTERRUPT_CONTROL_ENDPOINT -// #define NO_DEVICE_REMOTE_WAKEUP -// #define NO_DEVICE_SELF_POWER - - /* USB Host Mode Driver Related Tokens: */ -// #define HOST_STATE_AS_GPIOR {Insert Value Here} -// #define USB_HOST_TIMEOUT_MS {Insert Value Here} -// #define HOST_DEVICE_SETTLE_DELAY_MS {Insert Value Here} -// #define NO_AUTO_VBUS_MANAGEMENT -// #define INVERTED_VBUS_ENABLE_LINE - - #elif (ARCH == ARCH_XMEGA) - - /* Non-USB Related Configuration Tokens: */ -// #define DISABLE_TERMINAL_CODES - - /* USB Class Driver Related Tokens: */ -// #define HID_HOST_BOOT_PROTOCOL_ONLY -// #define HID_STATETABLE_STACK_DEPTH {Insert Value Here} -// #define HID_USAGE_STACK_DEPTH {Insert Value Here} -// #define HID_MAX_COLLECTIONS {Insert Value Here} -// #define HID_MAX_REPORTITEMS {Insert Value Here} -// #define HID_MAX_REPORT_IDS {Insert Value Here} -// #define NO_CLASS_DRIVER_AUTOFLUSH - - /* General USB Driver Related Tokens: */ - #define USE_STATIC_OPTIONS (USB_DEVICE_OPT_FULLSPEED | USB_OPT_RC32MCLKSRC | USB_OPT_BUSEVENT_PRIHIGH) -// #define USB_STREAM_TIMEOUT_MS {Insert Value Here} -// #define NO_LIMITED_CONTROLLER_CONNECT -// #define NO_SOF_EVENTS - - /* USB Device Mode Driver Related Tokens: */ -// #define USE_RAM_DESCRIPTORS - #define USE_FLASH_DESCRIPTORS -// #define USE_EEPROM_DESCRIPTORS -// #define NO_INTERNAL_SERIAL - #define FIXED_CONTROL_ENDPOINT_SIZE 8 -// #define DEVICE_STATE_AS_GPIOR {Insert Value Here} - #define FIXED_NUM_CONFIGURATIONS 1 -// #define CONTROL_ONLY_DEVICE - #define MAX_ENDPOINT_INDEX 4 -// #define NO_DEVICE_REMOTE_WAKEUP -// #define NO_DEVICE_SELF_POWER - - #else - - #error Unsupported architecture for this LUFA configuration file. - - #endif -#endif diff --git a/lib/lufa/Demos/Device/Incomplete/TestAndMeasurement/Descriptors.c b/lib/lufa/Demos/Device/Incomplete/TestAndMeasurement/Descriptors.c deleted file mode 100644 index 96596c1619..0000000000 --- a/lib/lufa/Demos/Device/Incomplete/TestAndMeasurement/Descriptors.c +++ /dev/null @@ -1,205 +0,0 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2017. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2017 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Copyright 2010 Peter Lawrence (majbthrd [at] gmail [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaims all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * - * USB Device Descriptors, for library use when in USB device mode. Descriptors are special - * computer-readable structures which the host requests upon device enumeration, to determine - * the device's capabilities and functions. - */ - -#include "Descriptors.h" - - -/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall - * device characteristics, including the supported USB version, control endpoint size and the - * number of device configurations. The descriptor is read out by the USB host when the enumeration - * process begins. - */ -const USB_Descriptor_Device_t PROGMEM DeviceDescriptor = -{ - .Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device}, - - .USBSpecification = VERSION_BCD(1,1,0), - .Class = 0x00, - .SubClass = 0x00, - .Protocol = 0x00, - - .Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE, - - .VendorID = 0x03EB, - .ProductID = 0x2065, - .ReleaseNumber = VERSION_BCD(0,0,1), - - .ManufacturerStrIndex = STRING_ID_Manufacturer, - .ProductStrIndex = STRING_ID_Product, - .SerialNumStrIndex = USE_INTERNAL_SERIAL, - - .NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS -}; - -/** Configuration descriptor structure. This descriptor, located in FLASH memory, describes the usage - * of the device in one of its supported configurations, including information about any device interfaces - * and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting - * a configuration so that the host may correctly communicate with the USB device. - */ -const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = -{ - .Config = - { - .Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration}, - - .TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t), - .TotalInterfaces = 1, - - .ConfigurationNumber = 1, - .ConfigurationStrIndex = NO_DESCRIPTOR, - - .ConfigAttributes = (USB_CONFIG_ATTR_RESERVED | USB_CONFIG_ATTR_SELFPOWERED), - - .MaxPowerConsumption = USB_CONFIG_POWER_MA(100) - }, - - .TM_Interface = - { - .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, - - .InterfaceNumber = INTERFACE_ID_TestAndMeasurement, - .AlternateSetting = 0x00, - - .TotalEndpoints = 3, - - .Class = 0xFE, - .SubClass = 0x03, - .Protocol = 0x01, - - .InterfaceStrIndex = NO_DESCRIPTOR - }, - - .TM_DataOutEndpoint = - { - .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, - - .EndpointAddress = TMC_OUT_EPADDR, - .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), - .EndpointSize = TMC_IO_EPSIZE, - .PollingIntervalMS = 0x05 - }, - - .TM_DataInEndpoint = - { - .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, - - .EndpointAddress = TMC_IN_EPADDR, - .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), - .EndpointSize = TMC_IO_EPSIZE, - .PollingIntervalMS = 0x05 - }, - - .TM_NotificationEndpoint = - { - .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, - - .EndpointAddress = TMC_NOTIFICATION_EPADDR, - .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), - .EndpointSize = TMC_NOTIFICATION_EPSIZE, - .PollingIntervalMS = 0xFF - } -}; - -/** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests - * the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate - * via the language ID table available at USB.org what languages the device supports for its string descriptors. - */ -const USB_Descriptor_String_t PROGMEM LanguageString = USB_STRING_DESCRIPTOR_ARRAY(LANGUAGE_ID_ENG); - -/** Manufacturer descriptor string. This is a Unicode string containing the manufacturer's details in human readable - * form, and is read out upon request by the host when the appropriate string ID is requested, listed in the Device - * Descriptor. - */ -const USB_Descriptor_String_t PROGMEM ManufacturerString = USB_STRING_DESCRIPTOR(L"Dean Camera"); - -/** Product descriptor string. This is a Unicode string containing the product's details in human readable form, - * and is read out upon request by the host when the appropriate string ID is requested, listed in the Device - * Descriptor. - */ -const USB_Descriptor_String_t PROGMEM ProductString = USB_STRING_DESCRIPTOR(L"LUFA TMC Demo"); - -/** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors" - * documentation) by the application code so that the address and size of a requested descriptor can be given - * to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function - * is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the - * USB host. - */ -uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, - const uint16_t wIndex, - const void** const DescriptorAddress) -{ - const uint8_t DescriptorType = (wValue >> 8); - const uint8_t DescriptorNumber = (wValue & 0xFF); - - const void* Address = NULL; - uint16_t Size = NO_DESCRIPTOR; - - switch (DescriptorType) - { - case DTYPE_Device: - Address = &DeviceDescriptor; - Size = sizeof(USB_Descriptor_Device_t); - break; - case DTYPE_Configuration: - Address = &ConfigurationDescriptor; - Size = sizeof(USB_Descriptor_Configuration_t); - break; - case DTYPE_String: - switch (DescriptorNumber) - { - case STRING_ID_Language: - Address = &LanguageString; - Size = pgm_read_byte(&LanguageString.Header.Size); - break; - case STRING_ID_Manufacturer: - Address = &ManufacturerString; - Size = pgm_read_byte(&ManufacturerString.Header.Size); - break; - case STRING_ID_Product: - Address = &ProductString; - Size = pgm_read_byte(&ProductString.Header.Size); - break; - } - - break; - } - - *DescriptorAddress = Address; - return Size; -} - diff --git a/lib/lufa/Demos/Device/Incomplete/TestAndMeasurement/Descriptors.h b/lib/lufa/Demos/Device/Incomplete/TestAndMeasurement/Descriptors.h deleted file mode 100644 index 628b63a503..0000000000 --- a/lib/lufa/Demos/Device/Incomplete/TestAndMeasurement/Descriptors.h +++ /dev/null @@ -1,104 +0,0 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2017. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2017 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Copyright 2010 Peter Lawrence (majbthrd [at] gmail [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaims all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * - * Header file for Descriptors.c. - */ - -#ifndef _DESCRIPTORS_H_ -#define _DESCRIPTORS_H_ - - /* Includes: */ - #include <avr/pgmspace.h> - - #include <LUFA/Drivers/USB/USB.h> - - /* Macros: */ - /** Endpoint address of the TMC notification IN endpoint. */ - #define TMC_NOTIFICATION_EPADDR (ENDPOINT_DIR_IN | 2) - - /** Endpoint address of the TMC device-to-host data IN endpoint. */ - #define TMC_IN_EPADDR (ENDPOINT_DIR_IN | 3) - - /** Endpoint address of the TMC host-to-device data OUT endpoint. */ - #define TMC_OUT_EPADDR (ENDPOINT_DIR_OUT | 4) - - /** Size in bytes of the TMC data endpoints. */ - #define TMC_IO_EPSIZE 64 - - /** Size in bytes of the TMC notification endpoint. */ - #define TMC_NOTIFICATION_EPSIZE 8 - - /* Type Defines: */ - /** Type define for the device configuration descriptor structure. This must be defined in the - * application code, as the configuration descriptor contains several sub-descriptors which - * vary between devices, and which describe the device's usage to the host. - */ - typedef struct - { - USB_Descriptor_Configuration_Header_t Config; - - // Test and Measurement Interface - USB_Descriptor_Interface_t TM_Interface; - USB_Descriptor_Endpoint_t TM_DataOutEndpoint; - USB_Descriptor_Endpoint_t TM_DataInEndpoint; - USB_Descriptor_Endpoint_t TM_NotificationEndpoint; - } USB_Descriptor_Configuration_t; - - /** Enum for the device interface descriptor IDs within the device. Each interface descriptor - * should have a unique ID index associated with it, which can be used to refer to the - * interface from other descriptors. - */ - enum InterfaceDescriptors_t - { - INTERFACE_ID_TestAndMeasurement = 0, /**< Test and measurement interface descriptor ID */ - }; - - /** Enum for the device string descriptor IDs within the device. Each string descriptor should - * have a unique ID index associated with it, which can be used to refer to the string from - * other descriptors. - */ - enum StringDescriptors_t - { - STRING_ID_Language = 0, /**< Supported Languages string descriptor ID (must be zero) */ - STRING_ID_Manufacturer = 1, /**< Manufacturer string ID */ - STRING_ID_Product = 2, /**< Product string ID */ - }; - - /* Function Prototypes: */ - uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, - const uint16_t wIndex, - const void** const DescriptorAddress) - ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3); - -#endif - diff --git a/lib/lufa/Demos/Device/Incomplete/TestAndMeasurement/TestAndMeasurement.c b/lib/lufa/Demos/Device/Incomplete/TestAndMeasurement/TestAndMeasurement.c deleted file mode 100644 index c324be2d13..0000000000 --- a/lib/lufa/Demos/Device/Incomplete/TestAndMeasurement/TestAndMeasurement.c +++ /dev/null @@ -1,476 +0,0 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2017. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2017 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaims all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -#include "TestAndMeasurement.h" - -/** Contains the (usually static) capabilities of the TMC device. This table is requested by the - * host upon enumeration to give it information on what features of the Test and Measurement USB - * Class the device supports. - */ -TMC_Capabilities_t Capabilities = - { - .Status = TMC_STATUS_SUCCESS, - .TMCVersion = VERSION_BCD(1.00), - - .Interface = - { - .ListenOnly = false, - .TalkOnly = false, - .PulseIndicateSupported = false, - }, - - .Device = - { - .SupportsAbortINOnMatch = false, - }, - }; - -/** Current TMC control request that is being processed */ -static uint8_t RequestInProgress = 0; - -/** Stream callback abort flag for bulk IN data */ -static bool IsTMCBulkINReset = false; - -/** Stream callback abort flag for bulk OUT data */ -static bool IsTMCBulkOUTReset = false; - -/** Last used tag value for data transfers */ -static uint8_t CurrentTransferTag = 0; - -/** Length of last data transfer, for reporting to the host in case an in-progress transfer is aborted */ -static uint16_t LastTransferLength = 0; - -/** Buffer to hold the next message to sent to the TMC host */ -static uint8_t NextResponseBuffer[64]; - -/** Indicates the length of the next response to send */ -static uint8_t NextResponseLen; - -/** Main program entry point. This routine contains the overall program flow, including initial - * setup of all components and the main program loop. - */ -int main(void) -{ - SetupHardware(); - - LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); - GlobalInterruptEnable(); - - for (;;) - { - TMC_Task(); - USB_USBTask(); - } -} - -/** Configures the board hardware and chip peripherals for the demo's functionality. */ -void SetupHardware(void) -{ -#if (ARCH == ARCH_AVR8) - /* Disable watchdog if enabled by bootloader/fuses */ - MCUSR &= ~(1 << WDRF); - wdt_disable(); - - /* Disable clock division */ - clock_prescale_set(clock_div_1); -#elif (ARCH == ARCH_XMEGA) - /* Start the PLL to multiply the 2MHz RC oscillator to 32MHz and switch the CPU core to run from it */ - XMEGACLK_StartPLL(CLOCK_SRC_INT_RC2MHZ, 2000000, F_CPU); - XMEGACLK_SetCPUClockSource(CLOCK_SRC_PLL); - - /* Start the 32MHz internal RC oscillator and start the DFLL to increase it to 48MHz using the USB SOF as a reference */ - XMEGACLK_StartInternalOscillator(CLOCK_SRC_INT_RC32MHZ); - XMEGACLK_StartDFLL(CLOCK_SRC_INT_RC32MHZ, DFLL_REF_INT_USBSOF, F_USB); - - PMIC.CTRL = PMIC_LOLVLEN_bm | PMIC_MEDLVLEN_bm | PMIC_HILVLEN_bm; -#endif - - /* Hardware Initialization */ - LEDs_Init(); - USB_Init(); -} - -/** Event handler for the USB_Connect event. This indicates that the device is enumerating via the status LEDs and - * starts the library USB task to begin the enumeration and USB management process. - */ -void EVENT_USB_Device_Connect(void) -{ - LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING); -} - -/** Event handler for the USB_Disconnect event. This indicates that the device is no longer connected to a host via - * the status LEDs and stops the USB management and CDC management tasks. - */ -void EVENT_USB_Device_Disconnect(void) -{ - LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); -} - -/** Event handler for the USB_ConfigurationChanged event. This is fired when the host set the current configuration - * of the USB device after enumeration - the device endpoints are configured and the CDC management task started. - */ -void EVENT_USB_Device_ConfigurationChanged(void) -{ - bool ConfigSuccess = true; - - /* Setup TMC In, Out and Notification Endpoints */ - ConfigSuccess &= Endpoint_ConfigureEndpoint(TMC_NOTIFICATION_EPADDR, EP_TYPE_INTERRUPT, TMC_IO_EPSIZE, 1); - ConfigSuccess &= Endpoint_ConfigureEndpoint(TMC_IN_EPADDR, EP_TYPE_BULK, TMC_IO_EPSIZE, 1); - ConfigSuccess &= Endpoint_ConfigureEndpoint(TMC_OUT_EPADDR, EP_TYPE_BULK, TMC_IO_EPSIZE, 1); - - /* Indicate endpoint configuration success or failure */ - LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR); -} - -/** Event handler for the USB_ControlRequest event. This is used to catch and process control requests sent to - * the device from the USB host before passing along unhandled control requests to the library for processing - * internally. - */ -void EVENT_USB_Device_ControlRequest(void) -{ - uint8_t TMCRequestStatus = TMC_STATUS_SUCCESS; - - /* Process TMC specific control requests */ - switch (USB_ControlRequest.bRequest) - { - case Req_InitiateAbortBulkOut: - if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_ENDPOINT)) - { - /* Check that no split transaction is already in progress and the data transfer tag is valid */ - if (RequestInProgress != 0) - { - TMCRequestStatus = TMC_STATUS_SPLIT_IN_PROGRESS; - } - else if (USB_ControlRequest.wValue != CurrentTransferTag) - { - TMCRequestStatus = TMC_STATUS_TRANSFER_NOT_IN_PROGRESS; - } - else - { - /* Indicate that all in-progress/pending data OUT requests should be aborted */ - IsTMCBulkOUTReset = true; - - /* Save the split request for later checking when a new request is received */ - RequestInProgress = Req_InitiateAbortBulkOut; - } - - Endpoint_ClearSETUP(); - - /* Write the request response byte */ - Endpoint_Write_8(TMCRequestStatus); - - Endpoint_ClearIN(); - Endpoint_ClearStatusStage(); - } - - break; - case Req_CheckAbortBulkOutStatus: - if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_ENDPOINT)) - { - /* Check that an ABORT BULK OUT transaction has been requested and that the request has completed */ - if (RequestInProgress != Req_InitiateAbortBulkOut) - TMCRequestStatus = TMC_STATUS_SPLIT_NOT_IN_PROGRESS; - else if (IsTMCBulkOUTReset) - TMCRequestStatus = TMC_STATUS_PENDING; - else - RequestInProgress = 0; - - Endpoint_ClearSETUP(); - - /* Write the request response bytes */ - Endpoint_Write_8(TMCRequestStatus); - Endpoint_Write_16_LE(0); - Endpoint_Write_32_LE(LastTransferLength); - - Endpoint_ClearIN(); - Endpoint_ClearStatusStage(); - } - - break; - case Req_InitiateAbortBulkIn: - if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_ENDPOINT)) - { - /* Check that no split transaction is already in progress and the data transfer tag is valid */ - if (RequestInProgress != 0) - { - TMCRequestStatus = TMC_STATUS_SPLIT_IN_PROGRESS; - } - else if (USB_ControlRequest.wValue != CurrentTransferTag) - { - TMCRequestStatus = TMC_STATUS_TRANSFER_NOT_IN_PROGRESS; - } - else - { - /* Indicate that all in-progress/pending data IN requests should be aborted */ - IsTMCBulkINReset = true; - - /* Save the split request for later checking when a new request is received */ - RequestInProgress = Req_InitiateAbortBulkIn; - } - - Endpoint_ClearSETUP(); - - /* Write the request response bytes */ - Endpoint_Write_8(TMCRequestStatus); - Endpoint_Write_8(CurrentTransferTag); - - Endpoint_ClearIN(); - Endpoint_ClearStatusStage(); - } - - break; - case Req_CheckAbortBulkInStatus: - if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_ENDPOINT)) - { - /* Check that an ABORT BULK IN transaction has been requested and that the request has completed */ - if (RequestInProgress != Req_InitiateAbortBulkIn) - TMCRequestStatus = TMC_STATUS_SPLIT_NOT_IN_PROGRESS; - else if (IsTMCBulkINReset) - TMCRequestStatus = TMC_STATUS_PENDING; - else - RequestInProgress = 0; - - Endpoint_ClearSETUP(); - - /* Write the request response bytes */ - Endpoint_Write_8(TMCRequestStatus); - Endpoint_Write_16_LE(0); - Endpoint_Write_32_LE(LastTransferLength); - - Endpoint_ClearIN(); - Endpoint_ClearStatusStage(); - } - - break; - case Req_InitiateClear: - if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) - { - /* Check that no split transaction is already in progress */ - if (RequestInProgress != 0) - { - Endpoint_Write_8(TMC_STATUS_SPLIT_IN_PROGRESS); - } - else - { - /* Indicate that all in-progress/pending data IN and OUT requests should be aborted */ - IsTMCBulkINReset = true; - IsTMCBulkOUTReset = true; - - /* Save the split request for later checking when a new request is received */ - RequestInProgress = Req_InitiateClear; - } - - Endpoint_ClearSETUP(); - - /* Write the request response byte */ - Endpoint_Write_8(TMCRequestStatus); - - Endpoint_ClearIN(); - Endpoint_ClearStatusStage(); - } - - break; - case Req_CheckClearStatus: - if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) - { - /* Check that a CLEAR transaction has been requested and that the request has completed */ - if (RequestInProgress != Req_InitiateClear) - TMCRequestStatus = TMC_STATUS_SPLIT_NOT_IN_PROGRESS; - else if (IsTMCBulkINReset || IsTMCBulkOUTReset) - TMCRequestStatus = TMC_STATUS_PENDING; - else - RequestInProgress = 0; - - Endpoint_ClearSETUP(); - - /* Write the request response bytes */ - Endpoint_Write_8(TMCRequestStatus); - Endpoint_Write_8(0); - - Endpoint_ClearIN(); - Endpoint_ClearStatusStage(); - } - - break; - case Req_GetCapabilities: - if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) - { - Endpoint_ClearSETUP(); - - /* Write the device capabilities to the control endpoint */ - Endpoint_Write_Control_Stream_LE(&Capabilities, sizeof(TMC_Capabilities_t)); - Endpoint_ClearOUT(); - } - - break; - } -} - -void ProcessSentMessage(uint8_t* const Data, const uint8_t Length) -{ - if (strncmp((char*)Data, "*IDN?", 5) == 0) - strcpy((char*)NextResponseBuffer, "LUFA TMC DEMO"); - - NextResponseLen = strlen((char*)NextResponseBuffer); -} - -uint8_t GetNextMessage(uint8_t* const Data) -{ - strcpy((char*)NextResponseBuffer, "LUFA TMC DEMO"); - - NextResponseLen = strlen((char*)NextResponseBuffer); -// --- - uint8_t DataLen = MIN(NextResponseLen, 64); - - strlcpy((char*)Data, (char*)NextResponseBuffer, DataLen); - - return DataLen; -} - -/** Function to manage TMC data transmission and reception to and from the host. */ -void TMC_Task(void) -{ - /* Device must be connected and configured for the task to run */ - if (USB_DeviceState != DEVICE_STATE_Configured) - return; - - TMC_MessageHeader_t MessageHeader; - uint8_t MessagePayload[128]; - - /* Try to read in a TMC message from the interface, process if one is available */ - if (ReadTMCHeader(&MessageHeader)) - { - /* Indicate busy */ - LEDs_SetAllLEDs(LEDMASK_USB_BUSY); - - switch (MessageHeader.MessageID) - { - case TMC_MESSAGEID_DEV_DEP_MSG_OUT: - LastTransferLength = 0; - while (Endpoint_Read_Stream_LE(MessagePayload, MIN(MessageHeader.TransferSize, sizeof(MessagePayload)), &LastTransferLength) == - ENDPOINT_RWSTREAM_IncompleteTransfer) - { - if (IsTMCBulkOUTReset) - break; - } - - Endpoint_ClearOUT(); - - ProcessSentMessage(MessagePayload, LastTransferLength); - break; - case TMC_MESSAGEID_DEV_DEP_MSG_IN: - Endpoint_ClearOUT(); - - MessageHeader.TransferSize = GetNextMessage(MessagePayload); - MessageHeader.MessageIDSpecific.DeviceOUT.LastMessageTransaction = true; - WriteTMCHeader(&MessageHeader); - - LastTransferLength = 0; - while (Endpoint_Write_Stream_LE(MessagePayload, MessageHeader.TransferSize, &LastTransferLength) == - ENDPOINT_RWSTREAM_IncompleteTransfer) - { - if (IsTMCBulkINReset) - break; - } - - Endpoint_ClearIN(); - break; - default: - Endpoint_StallTransaction(); - break; - } - - LEDs_SetAllLEDs(LEDMASK_USB_READY); - } - - /* All pending data has been processed - reset the data abort flags */ - IsTMCBulkINReset = false; - IsTMCBulkOUTReset = false; -} - -/** Attempts to read in the TMC message header from the TMC interface. - * - * \param[out] MessageHeader Pointer to a location where the read header (if any) should be stored - * - * \return Boolean \c true if a header was read, \c false otherwise - */ -bool ReadTMCHeader(TMC_MessageHeader_t* const MessageHeader) -{ - uint16_t BytesTransferred; - uint8_t ErrorCode; - - /* Select the Data Out endpoint */ - Endpoint_SelectEndpoint(TMC_OUT_EPADDR); - - /* Abort if no command has been sent from the host */ - if (!(Endpoint_IsOUTReceived())) - return false; - - /* Read in the header of the command from the host */ - BytesTransferred = 0; - while ((ErrorCode = Endpoint_Read_Stream_LE(MessageHeader, sizeof(TMC_MessageHeader_t), &BytesTransferred)) == - ENDPOINT_RWSTREAM_IncompleteTransfer) - { - if (IsTMCBulkOUTReset) - break; - } - - /* Store the new command tag value for later use */ - CurrentTransferTag = MessageHeader->Tag; - - /* Indicate if the command has been aborted or not */ - return (!(IsTMCBulkOUTReset) && (ErrorCode == ENDPOINT_RWSTREAM_NoError)); -} - -bool WriteTMCHeader(TMC_MessageHeader_t* const MessageHeader) -{ - uint16_t BytesTransferred; - uint8_t ErrorCode; - - /* Set the message tag of the command header */ - MessageHeader->Tag = CurrentTransferTag; - MessageHeader->InverseTag = ~CurrentTransferTag; - - /* Select the Data In endpoint */ - Endpoint_SelectEndpoint(TMC_IN_EPADDR); - - /* Send the command header to the host */ - BytesTransferred = 0; - while ((ErrorCode = Endpoint_Write_Stream_LE(MessageHeader, sizeof(TMC_MessageHeader_t), &BytesTransferred)) == - ENDPOINT_RWSTREAM_IncompleteTransfer) - { - if (IsTMCBulkINReset) - break; - } - - /* Indicate if the command has been aborted or not */ - return (!(IsTMCBulkINReset) && (ErrorCode == ENDPOINT_RWSTREAM_NoError)); -} - diff --git a/lib/lufa/Demos/Device/Incomplete/TestAndMeasurement/TestAndMeasurement.h b/lib/lufa/Demos/Device/Incomplete/TestAndMeasurement/TestAndMeasurement.h deleted file mode 100644 index 50e865bedd..0000000000 --- a/lib/lufa/Demos/Device/Incomplete/TestAndMeasurement/TestAndMeasurement.h +++ /dev/null @@ -1,150 +0,0 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2017. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2017 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaims all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -#ifndef _TESTANDMEASUREMENT_H_ -#define _TESTANDMEASUREMENT_H_ - - /* Includes: */ - #include <avr/io.h> - #include <avr/wdt.h> - #include <avr/power.h> - #include <avr/interrupt.h> - - #include "Descriptors.h" - - #include <LUFA/Drivers/Board/LEDs.h> - #include <LUFA/Drivers/USB/USB.h> - #include <LUFA/Platform/Platform.h> - - /* Macros: */ - /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ - #define LEDMASK_USB_NOTREADY LEDS_LED1 - - /** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */ - #define LEDMASK_USB_ENUMERATING (LEDS_LED2 | LEDS_LED3) - - /** LED mask for the library LED driver, to indicate that the USB interface is ready. */ - #define LEDMASK_USB_READY (LEDS_LED2 | LEDS_LED4) - - /** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */ - #define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3) - - /** LED mask for the library LED driver, to indicate that the USB interface is busy. */ - #define LEDMASK_USB_BUSY LEDS_LED2 - - #define Req_InitiateAbortBulkOut 0x01 - #define Req_CheckAbortBulkOutStatus 0x02 - #define Req_InitiateAbortBulkIn 0x03 - #define Req_CheckAbortBulkInStatus 0x04 - #define Req_InitiateClear 0x05 - #define Req_CheckClearStatus 0x06 - #define Req_GetCapabilities 0x07 - #define Req_IndicatorPulse 0x40 - - #define TMC_STATUS_SUCCESS 0x01 - #define TMC_STATUS_PENDING 0x02 - #define TMC_STATUS_FAILED 0x80 - #define TMC_STATUS_TRANSFER_NOT_IN_PROGRESS 0x81 - #define TMC_STATUS_SPLIT_NOT_IN_PROGRESS 0x82 - #define TMC_STATUS_SPLIT_IN_PROGRESS 0x83 - - #define TMC_MESSAGEID_DEV_DEP_MSG_OUT 0x01 - #define TMC_MESSAGEID_DEV_DEP_MSG_IN 0x02 - #define TMC_MESSAGEID_DEV_VENDOR_OUT 0x7E - #define TMC_MESSAGEID_DEV_VENDOR_IN 0x7F - - /* Type Defines */ - typedef struct - { - uint8_t Status; - uint8_t Reserved; - - uint16_t TMCVersion; - - struct - { - unsigned ListenOnly : 1; - unsigned TalkOnly : 1; - unsigned PulseIndicateSupported : 1; - unsigned Reserved : 5; - } Interface; - - struct - { - unsigned SupportsAbortINOnMatch : 1; - unsigned Reserved : 7; - } Device; - - uint8_t Reserved2[6]; - uint8_t Reserved3[12]; - } TMC_Capabilities_t; - - typedef struct - { - uint8_t LastMessageTransaction; - uint8_t TermChar; - uint8_t Reserved[2]; - } TMC_DevOUTMessageHeader_t; - - typedef struct - { - uint8_t LastMessageTransaction; - uint8_t Reserved[3]; - } TMC_DevINMessageHeader_t; - - typedef struct - { - uint8_t MessageID; - uint8_t Tag; - uint8_t InverseTag; - uint8_t Reserved; - uint32_t TransferSize; - - union - { - TMC_DevOUTMessageHeader_t DeviceOUT; - TMC_DevINMessageHeader_t DeviceIN; - uint32_t VendorSpecific; - } MessageIDSpecific; - } TMC_MessageHeader_t; - - /* Function Prototypes: */ - void SetupHardware(void); - void TMC_Task(void); - bool ReadTMCHeader(TMC_MessageHeader_t* const MessageHeader); - bool WriteTMCHeader(TMC_MessageHeader_t* const MessageHeader); - - void EVENT_USB_Device_Connect(void); - void EVENT_USB_Device_Disconnect(void); - void EVENT_USB_Device_ConfigurationChanged(void); - void EVENT_USB_Device_ControlRequest(void); - -#endif - diff --git a/lib/lufa/Demos/Device/Incomplete/TestAndMeasurement/makefile b/lib/lufa/Demos/Device/Incomplete/TestAndMeasurement/makefile deleted file mode 100644 index e0d89ccd70..0000000000 --- a/lib/lufa/Demos/Device/Incomplete/TestAndMeasurement/makefile +++ /dev/null @@ -1,43 +0,0 @@ -# -# LUFA Library -# Copyright (C) Dean Camera, 2017. -# -# dean [at] fourwalledcubicle [dot] com -# www.lufa-lib.org -# -# -------------------------------------- -# LUFA Project Makefile. -# -------------------------------------- - -# Run "make help" for target help. - -MCU = at90usb1287 -ARCH = AVR8 -BOARD = USBKEY -F_CPU = 8000000 -F_USB = $(F_CPU) -OPTIMIZATION = s -TARGET = TestAndMeasurement -SRC = $(TARGET).c Descriptors.c $(LUFA_SRC_USB) $(LUFA_SRC_USBCLASS) -LUFA_PATH = ../../../../LUFA -CC_FLAGS = -DUSE_LUFA_CONFIG_HEADER -IConfig/ -LD_FLAGS = - -# Default target -all: - -# Include LUFA-specific DMBS extension modules -DMBS_LUFA_PATH ?= $(LUFA_PATH)/Build/LUFA -include $(DMBS_LUFA_PATH)/lufa-sources.mk -include $(DMBS_LUFA_PATH)/lufa-gcc.mk - -# Include common DMBS build system modules -DMBS_PATH ?= $(LUFA_PATH)/Build/DMBS/DMBS -include $(DMBS_PATH)/core.mk -include $(DMBS_PATH)/cppcheck.mk -include $(DMBS_PATH)/doxygen.mk -include $(DMBS_PATH)/dfu.mk -include $(DMBS_PATH)/gcc.mk -include $(DMBS_PATH)/hid.mk -include $(DMBS_PATH)/avrdude.mk -include $(DMBS_PATH)/atprogram.mk |