Add svn:eol-style property on all source files where it was missing. Fix line endings of all makefile, *.c and *.h files.
parent
393fc71d8e
commit
ef06eefc8b
@ -1,84 +1,84 @@
|
|||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2012.
|
Copyright (C) Dean Camera, 2012.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.lufa-lib.org
|
www.lufa-lib.org
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||||
Copyright 2010 Peter Lawrence (majbthrd [at] gmail [dot] com)
|
Copyright 2010 Peter Lawrence (majbthrd [at] gmail [dot] com)
|
||||||
|
|
||||||
Permission to use, copy, modify, distribute, and sell this
|
Permission to use, copy, modify, distribute, and sell this
|
||||||
software and its documentation for any purpose is hereby granted
|
software and its documentation for any purpose is hereby granted
|
||||||
without fee, provided that the above copyright notice appear in
|
without fee, provided that the above copyright notice appear in
|
||||||
all copies and that both that the copyright notice and this
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
software, including all implied warranties of merchantability
|
software, including all implied warranties of merchantability
|
||||||
and fitness. In no event shall the author be liable for any
|
and fitness. In no event shall the author be liable for any
|
||||||
special, indirect or consequential damages or any damages
|
special, indirect or consequential damages or any damages
|
||||||
whatsoever resulting from loss of use, data or profits, whether
|
whatsoever resulting from loss of use, data or profits, whether
|
||||||
in an action of contract, negligence or other tortious action,
|
in an action of contract, negligence or other tortious action,
|
||||||
arising out of or in connection with the use or performance of
|
arising out of or in connection with the use or performance of
|
||||||
this software.
|
this software.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \file
|
/** \file
|
||||||
*
|
*
|
||||||
* Header file for Descriptors.c.
|
* Header file for Descriptors.c.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _DESCRIPTORS_H_
|
#ifndef _DESCRIPTORS_H_
|
||||||
#define _DESCRIPTORS_H_
|
#define _DESCRIPTORS_H_
|
||||||
|
|
||||||
/* Includes: */
|
/* Includes: */
|
||||||
#include <avr/pgmspace.h>
|
#include <avr/pgmspace.h>
|
||||||
|
|
||||||
#include <LUFA/Drivers/USB/USB.h>
|
#include <LUFA/Drivers/USB/USB.h>
|
||||||
|
|
||||||
/* Macros: */
|
/* Macros: */
|
||||||
/** Endpoint address of the TMC notification IN endpoint. */
|
/** Endpoint address of the TMC notification IN endpoint. */
|
||||||
#define TMC_NOTIFICATION_EPADDR (ENDPOINT_DIR_IN | 2)
|
#define TMC_NOTIFICATION_EPADDR (ENDPOINT_DIR_IN | 2)
|
||||||
|
|
||||||
/** Endpoint address of the TMC device-to-host data IN endpoint. */
|
/** Endpoint address of the TMC device-to-host data IN endpoint. */
|
||||||
#define TMC_IN_EPADDR (ENDPOINT_DIR_IN | 3)
|
#define TMC_IN_EPADDR (ENDPOINT_DIR_IN | 3)
|
||||||
|
|
||||||
/** Endpoint address of the TMC host-to-device data OUT endpoint. */
|
/** Endpoint address of the TMC host-to-device data OUT endpoint. */
|
||||||
#define TMC_OUT_EPADDR (ENDPOINT_DIR_OUT | 4)
|
#define TMC_OUT_EPADDR (ENDPOINT_DIR_OUT | 4)
|
||||||
|
|
||||||
/** Size in bytes of the TMC data endpoints. */
|
/** Size in bytes of the TMC data endpoints. */
|
||||||
#define TMC_IO_EPSIZE 64
|
#define TMC_IO_EPSIZE 64
|
||||||
|
|
||||||
/** Size in bytes of the TMC notification endpoint. */
|
/** Size in bytes of the TMC notification endpoint. */
|
||||||
#define TMC_NOTIFICATION_EPSIZE 8
|
#define TMC_NOTIFICATION_EPSIZE 8
|
||||||
|
|
||||||
/* Type Defines: */
|
/* Type Defines: */
|
||||||
/** Type define for the device configuration descriptor structure. This must be defined in the
|
/** 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
|
* application code, as the configuration descriptor contains several sub-descriptors which
|
||||||
* vary between devices, and which describe the device's usage to the host.
|
* vary between devices, and which describe the device's usage to the host.
|
||||||
*/
|
*/
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
USB_Descriptor_Configuration_Header_t Config;
|
USB_Descriptor_Configuration_Header_t Config;
|
||||||
|
|
||||||
// Test and Measurement Interface
|
// Test and Measurement Interface
|
||||||
USB_Descriptor_Interface_t TM_Interface;
|
USB_Descriptor_Interface_t TM_Interface;
|
||||||
USB_Descriptor_Endpoint_t TM_DataOutEndpoint;
|
USB_Descriptor_Endpoint_t TM_DataOutEndpoint;
|
||||||
USB_Descriptor_Endpoint_t TM_DataInEndpoint;
|
USB_Descriptor_Endpoint_t TM_DataInEndpoint;
|
||||||
USB_Descriptor_Endpoint_t TM_NotificationEndpoint;
|
USB_Descriptor_Endpoint_t TM_NotificationEndpoint;
|
||||||
} USB_Descriptor_Configuration_t;
|
} USB_Descriptor_Configuration_t;
|
||||||
|
|
||||||
/* Function Prototypes: */
|
/* Function Prototypes: */
|
||||||
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
||||||
const uint8_t wIndex,
|
const uint8_t wIndex,
|
||||||
const void** const DescriptorAddress)
|
const void** const DescriptorAddress)
|
||||||
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1,149 +1,149 @@
|
|||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2012.
|
Copyright (C) Dean Camera, 2012.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.lufa-lib.org
|
www.lufa-lib.org
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||||
|
|
||||||
Permission to use, copy, modify, distribute, and sell this
|
Permission to use, copy, modify, distribute, and sell this
|
||||||
software and its documentation for any purpose is hereby granted
|
software and its documentation for any purpose is hereby granted
|
||||||
without fee, provided that the above copyright notice appear in
|
without fee, provided that the above copyright notice appear in
|
||||||
all copies and that both that the copyright notice and this
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
software, including all implied warranties of merchantability
|
software, including all implied warranties of merchantability
|
||||||
and fitness. In no event shall the author be liable for any
|
and fitness. In no event shall the author be liable for any
|
||||||
special, indirect or consequential damages or any damages
|
special, indirect or consequential damages or any damages
|
||||||
whatsoever resulting from loss of use, data or profits, whether
|
whatsoever resulting from loss of use, data or profits, whether
|
||||||
in an action of contract, negligence or other tortious action,
|
in an action of contract, negligence or other tortious action,
|
||||||
arising out of or in connection with the use or performance of
|
arising out of or in connection with the use or performance of
|
||||||
this software.
|
this software.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _TESTANDMEASUREMENT_H_
|
#ifndef _TESTANDMEASUREMENT_H_
|
||||||
#define _TESTANDMEASUREMENT_H_
|
#define _TESTANDMEASUREMENT_H_
|
||||||
|
|
||||||
/* Includes: */
|
/* Includes: */
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
#include <avr/wdt.h>
|
#include <avr/wdt.h>
|
||||||
#include <avr/power.h>
|
#include <avr/power.h>
|
||||||
#include <avr/interrupt.h>
|
#include <avr/interrupt.h>
|
||||||
|
|
||||||
#include "Descriptors.h"
|
#include "Descriptors.h"
|
||||||
|
|
||||||
#include <LUFA/Drivers/USB/USB.h>
|
#include <LUFA/Drivers/USB/USB.h>
|
||||||
#include <LUFA/Drivers/Board/LEDs.h>
|
#include <LUFA/Drivers/Board/LEDs.h>
|
||||||
|
|
||||||
/* Macros: */
|
/* Macros: */
|
||||||
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
|
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
|
||||||
#define LEDMASK_USB_NOTREADY LEDS_LED1
|
#define LEDMASK_USB_NOTREADY LEDS_LED1
|
||||||
|
|
||||||
/** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */
|
/** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */
|
||||||
#define LEDMASK_USB_ENUMERATING (LEDS_LED2 | LEDS_LED3)
|
#define LEDMASK_USB_ENUMERATING (LEDS_LED2 | LEDS_LED3)
|
||||||
|
|
||||||
/** LED mask for the library LED driver, to indicate that the USB interface is ready. */
|
/** LED mask for the library LED driver, to indicate that the USB interface is ready. */
|
||||||
#define LEDMASK_USB_READY (LEDS_LED2 | LEDS_LED4)
|
#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. */
|
/** 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)
|
#define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3)
|
||||||
|
|
||||||
/** LED mask for the library LED driver, to indicate that the USB interface is busy. */
|
/** LED mask for the library LED driver, to indicate that the USB interface is busy. */
|
||||||
#define LEDMASK_USB_BUSY LEDS_LED2
|
#define LEDMASK_USB_BUSY LEDS_LED2
|
||||||
|
|
||||||
#define Req_InitiateAbortBulkOut 0x01
|
#define Req_InitiateAbortBulkOut 0x01
|
||||||
#define Req_CheckAbortBulkOutStatus 0x02
|
#define Req_CheckAbortBulkOutStatus 0x02
|
||||||
#define Req_InitiateAbortBulkIn 0x03
|
#define Req_InitiateAbortBulkIn 0x03
|
||||||
#define Req_CheckAbortBulkInStatus 0x04
|
#define Req_CheckAbortBulkInStatus 0x04
|
||||||
#define Req_InitiateClear 0x05
|
#define Req_InitiateClear 0x05
|
||||||
#define Req_CheckClearStatus 0x06
|
#define Req_CheckClearStatus 0x06
|
||||||
#define Req_GetCapabilities 0x07
|
#define Req_GetCapabilities 0x07
|
||||||
#define Req_IndicatorPulse 0x40
|
#define Req_IndicatorPulse 0x40
|
||||||
|
|
||||||
#define TMC_STATUS_SUCCESS 0x01
|
#define TMC_STATUS_SUCCESS 0x01
|
||||||
#define TMC_STATUS_PENDING 0x02
|
#define TMC_STATUS_PENDING 0x02
|
||||||
#define TMC_STATUS_FAILED 0x80
|
#define TMC_STATUS_FAILED 0x80
|
||||||
#define TMC_STATUS_TRANSFER_NOT_IN_PROGRESS 0x81
|
#define TMC_STATUS_TRANSFER_NOT_IN_PROGRESS 0x81
|
||||||
#define TMC_STATUS_SPLIT_NOT_IN_PROGRESS 0x82
|
#define TMC_STATUS_SPLIT_NOT_IN_PROGRESS 0x82
|
||||||
#define TMC_STATUS_SPLIT_IN_PROGRESS 0x83
|
#define TMC_STATUS_SPLIT_IN_PROGRESS 0x83
|
||||||
|
|
||||||
#define TMC_MESSAGEID_DEV_DEP_MSG_OUT 0x01
|
#define TMC_MESSAGEID_DEV_DEP_MSG_OUT 0x01
|
||||||
#define TMC_MESSAGEID_DEV_DEP_MSG_IN 0x02
|
#define TMC_MESSAGEID_DEV_DEP_MSG_IN 0x02
|
||||||
#define TMC_MESSAGEID_DEV_VENDOR_OUT 0x7E
|
#define TMC_MESSAGEID_DEV_VENDOR_OUT 0x7E
|
||||||
#define TMC_MESSAGEID_DEV_VENDOR_IN 0x7F
|
#define TMC_MESSAGEID_DEV_VENDOR_IN 0x7F
|
||||||
|
|
||||||
/* Type Defines */
|
/* Type Defines */
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
uint8_t Status;
|
uint8_t Status;
|
||||||
uint8_t Reserved;
|
uint8_t Reserved;
|
||||||
|
|
||||||
uint16_t TMCVersion;
|
uint16_t TMCVersion;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
unsigned ListenOnly : 1;
|
unsigned ListenOnly : 1;
|
||||||
unsigned TalkOnly : 1;
|
unsigned TalkOnly : 1;
|
||||||
unsigned PulseIndicateSupported : 1;
|
unsigned PulseIndicateSupported : 1;
|
||||||
unsigned Reserved : 5;
|
unsigned Reserved : 5;
|
||||||
} Interface;
|
} Interface;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
unsigned SupportsAbortINOnMatch : 1;
|
unsigned SupportsAbortINOnMatch : 1;
|
||||||
unsigned Reserved : 7;
|
unsigned Reserved : 7;
|
||||||
} Device;
|
} Device;
|
||||||
|
|
||||||
uint8_t Reserved2[6];
|
uint8_t Reserved2[6];
|
||||||
uint8_t Reserved3[12];
|
uint8_t Reserved3[12];
|
||||||
} TMC_Capabilities_t;
|
} TMC_Capabilities_t;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
uint8_t LastMessageTransaction;
|
uint8_t LastMessageTransaction;
|
||||||
uint8_t TermChar;
|
uint8_t TermChar;
|
||||||
uint8_t Reserved[2];
|
uint8_t Reserved[2];
|
||||||
} TMC_DevOUTMessageHeader_t;
|
} TMC_DevOUTMessageHeader_t;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
uint8_t LastMessageTransaction;
|
uint8_t LastMessageTransaction;
|
||||||
uint8_t Reserved[3];
|
uint8_t Reserved[3];
|
||||||
} TMC_DevINMessageHeader_t;
|
} TMC_DevINMessageHeader_t;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
uint8_t MessageID;
|
uint8_t MessageID;
|
||||||
uint8_t Tag;
|
uint8_t Tag;
|
||||||
uint8_t InverseTag;
|
uint8_t InverseTag;
|
||||||
uint8_t Reserved;
|
uint8_t Reserved;
|
||||||
uint32_t TransferSize;
|
uint32_t TransferSize;
|
||||||
|
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
TMC_DevOUTMessageHeader_t DeviceOUT;
|
TMC_DevOUTMessageHeader_t DeviceOUT;
|
||||||
TMC_DevINMessageHeader_t DeviceIN;
|
TMC_DevINMessageHeader_t DeviceIN;
|
||||||
uint32_t VendorSpecific;
|
uint32_t VendorSpecific;
|
||||||
} MessageIDSpecific;
|
} MessageIDSpecific;
|
||||||
} TMC_MessageHeader_t;
|
} TMC_MessageHeader_t;
|
||||||
|
|
||||||
/* Function Prototypes: */
|
/* Function Prototypes: */
|
||||||
void SetupHardware(void);
|
void SetupHardware(void);
|
||||||
void TMC_Task(void);
|
void TMC_Task(void);
|
||||||
bool ReadTMCHeader(TMC_MessageHeader_t* const MessageHeader);
|
bool ReadTMCHeader(TMC_MessageHeader_t* const MessageHeader);
|
||||||
bool WriteTMCHeader(TMC_MessageHeader_t* const MessageHeader);
|
bool WriteTMCHeader(TMC_MessageHeader_t* const MessageHeader);
|
||||||
|
|
||||||
void EVENT_USB_Device_Connect(void);
|
void EVENT_USB_Device_Connect(void);
|
||||||
void EVENT_USB_Device_Disconnect(void);
|
void EVENT_USB_Device_Disconnect(void);
|
||||||
void EVENT_USB_Device_ConfigurationChanged(void);
|
void EVENT_USB_Device_ConfigurationChanged(void);
|
||||||
void EVENT_USB_Device_ControlRequest(void);
|
void EVENT_USB_Device_ControlRequest(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1,232 +1,232 @@
|
|||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2012.
|
Copyright (C) Dean Camera, 2012.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.lufa-lib.org
|
www.lufa-lib.org
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||||
|
|
||||||
Permission to use, copy, modify, distribute, and sell this
|
Permission to use, copy, modify, distribute, and sell this
|
||||||
software and its documentation for any purpose is hereby granted
|
software and its documentation for any purpose is hereby granted
|
||||||
without fee, provided that the above copyright notice appear in
|
without fee, provided that the above copyright notice appear in
|
||||||
all copies and that both that the copyright notice and this
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
software, including all implied warranties of merchantability
|
software, including all implied warranties of merchantability
|
||||||
and fitness. In no event shall the author be liable for any
|
and fitness. In no event shall the author be liable for any
|
||||||
special, indirect or consequential damages or any damages
|
special, indirect or consequential damages or any damages
|
||||||
whatsoever resulting from loss of use, data or profits, whether
|
whatsoever resulting from loss of use, data or profits, whether
|
||||||
in an action of contract, negligence or other tortious action,
|
in an action of contract, negligence or other tortious action,
|
||||||
arising out of or in connection with the use or performance of
|
arising out of or in connection with the use or performance of
|
||||||
this software.
|
this software.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \file
|
/** \file
|
||||||
*
|
*
|
||||||
* Main source file for the AndroidAccessoryHost demo. This file contains the main tasks of
|
* Main source file for the AndroidAccessoryHost demo. This file contains the main tasks of
|
||||||
* the demo and is responsible for the initial application hardware configuration.
|
* the demo and is responsible for the initial application hardware configuration.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "AndroidAccessoryHost.h"
|
#include "AndroidAccessoryHost.h"
|
||||||
|
|
||||||
/** LUFA Android Open Accessory Class driver interface configuration and state information. This
|
/** LUFA Android Open Accessory Class driver interface configuration and state information. This
|
||||||
* structure is passed to all Android Open Accessory Class driver functions, so that multiple
|
* structure is passed to all Android Open Accessory Class driver functions, so that multiple
|
||||||
* instances of the same class within a device can be differentiated from one another.
|
* instances of the same class within a device can be differentiated from one another.
|
||||||
*/
|
*/
|
||||||
USB_ClassInfo_AOA_Host_t AndroidDevice_AOA_Interface =
|
USB_ClassInfo_AOA_Host_t AndroidDevice_AOA_Interface =
|
||||||
{
|
{
|
||||||
.Config =
|
.Config =
|
||||||
{
|
{
|
||||||
.DataINPipe =
|
.DataINPipe =
|
||||||
{
|
{
|
||||||
.Address = (PIPE_DIR_IN | 1),
|
.Address = (PIPE_DIR_IN | 1),
|
||||||
.Banks = 1,
|
.Banks = 1,
|
||||||
},
|
},
|
||||||
.DataOUTPipe =
|
.DataOUTPipe =
|
||||||
{
|
{
|
||||||
.Address = (PIPE_DIR_OUT | 2),
|
.Address = (PIPE_DIR_OUT | 2),
|
||||||
.Banks = 1,
|
.Banks = 1,
|
||||||
},
|
},
|
||||||
.PropertyStrings =
|
.PropertyStrings =
|
||||||
{
|
{
|
||||||
[AOA_STRING_Manufacturer] = "Dean Camera",
|
[AOA_STRING_Manufacturer] = "Dean Camera",
|
||||||
[AOA_STRING_Model] = "LUFA Android Demo",
|
[AOA_STRING_Model] = "LUFA Android Demo",
|
||||||
[AOA_STRING_Description] = "LUFA Android Demo",
|
[AOA_STRING_Description] = "LUFA Android Demo",
|
||||||
[AOA_STRING_Version] = "1.0",
|
[AOA_STRING_Version] = "1.0",
|
||||||
[AOA_STRING_URI] = "http://www.lufa-lib.org",
|
[AOA_STRING_URI] = "http://www.lufa-lib.org",
|
||||||
[AOA_STRING_Serial] = "0000000012345678",
|
[AOA_STRING_Serial] = "0000000012345678",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/** Main program entry point. This routine configures the hardware required by the application, then
|
/** Main program entry point. This routine configures the hardware required by the application, then
|
||||||
* enters a loop to run the application tasks in sequence.
|
* enters a loop to run the application tasks in sequence.
|
||||||
*/
|
*/
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
SetupHardware();
|
SetupHardware();
|
||||||
|
|
||||||
puts_P(PSTR(ESC_FG_CYAN "Android Accessory Host Demo running.\r\n" ESC_FG_WHITE));
|
puts_P(PSTR(ESC_FG_CYAN "Android Accessory Host Demo running.\r\n" ESC_FG_WHITE));
|
||||||
|
|
||||||
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
|
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
|
||||||
sei();
|
sei();
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
AOAHost_Task();
|
AOAHost_Task();
|
||||||
|
|
||||||
AOA_Host_USBTask(&AndroidDevice_AOA_Interface);
|
AOA_Host_USBTask(&AndroidDevice_AOA_Interface);
|
||||||
USB_USBTask();
|
USB_USBTask();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Configures the board hardware and chip peripherals for the demo's functionality. */
|
/** Configures the board hardware and chip peripherals for the demo's functionality. */
|
||||||
void SetupHardware(void)
|
void SetupHardware(void)
|
||||||
{
|
{
|
||||||
/* Disable watchdog if enabled by bootloader/fuses */
|
/* Disable watchdog if enabled by bootloader/fuses */
|
||||||
MCUSR &= ~(1 << WDRF);
|
MCUSR &= ~(1 << WDRF);
|
||||||
wdt_disable();
|
wdt_disable();
|
||||||
|
|
||||||
/* Disable clock division */
|
/* Disable clock division */
|
||||||
clock_prescale_set(clock_div_1);
|
clock_prescale_set(clock_div_1);
|
||||||
|
|
||||||
/* Hardware Initialization */
|
/* Hardware Initialization */
|
||||||
Serial_Init(9600, false);
|
Serial_Init(9600, false);
|
||||||
LEDs_Init();
|
LEDs_Init();
|
||||||
USB_Init();
|
USB_Init();
|
||||||
|
|
||||||
/* Create a stdio stream for the serial port for stdin and stdout */
|
/* Create a stdio stream for the serial port for stdin and stdout */
|
||||||
Serial_CreateStream(NULL);
|
Serial_CreateStream(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Task to manage an enumerated USB Android Accessory device once connected, to print received data
|
/** Task to manage an enumerated USB Android Accessory device once connected, to print received data
|
||||||
* from the device to the serial port.
|
* from the device to the serial port.
|
||||||
*/
|
*/
|
||||||
void AOAHost_Task(void)
|
void AOAHost_Task(void)
|
||||||
{
|
{
|
||||||
if (USB_HostState != HOST_STATE_Configured)
|
if (USB_HostState != HOST_STATE_Configured)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (AOA_Host_BytesReceived(&AndroidDevice_AOA_Interface))
|
if (AOA_Host_BytesReceived(&AndroidDevice_AOA_Interface))
|
||||||
{
|
{
|
||||||
/* Echo received bytes from the attached device through the USART */
|
/* Echo received bytes from the attached device through the USART */
|
||||||
int16_t ReceivedByte = AOA_Host_ReceiveByte(&AndroidDevice_AOA_Interface);
|
int16_t ReceivedByte = AOA_Host_ReceiveByte(&AndroidDevice_AOA_Interface);
|
||||||
if (!(ReceivedByte < 0))
|
if (!(ReceivedByte < 0))
|
||||||
putchar(ReceivedByte);
|
putchar(ReceivedByte);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Event handler for the USB_DeviceAttached event. This indicates that a device has been attached to the host, and
|
/** Event handler for the USB_DeviceAttached event. This indicates that a device has been attached to the host, and
|
||||||
* starts the library USB task to begin the enumeration and USB management process.
|
* starts the library USB task to begin the enumeration and USB management process.
|
||||||
*/
|
*/
|
||||||
void EVENT_USB_Host_DeviceAttached(void)
|
void EVENT_USB_Host_DeviceAttached(void)
|
||||||
{
|
{
|
||||||
puts_P(PSTR("Device Attached.\r\n"));
|
puts_P(PSTR("Device Attached.\r\n"));
|
||||||
LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);
|
LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Event handler for the USB_DeviceUnattached event. This indicates that a device has been removed from the host, and
|
/** Event handler for the USB_DeviceUnattached event. This indicates that a device has been removed from the host, and
|
||||||
* stops the library USB task management process.
|
* stops the library USB task management process.
|
||||||
*/
|
*/
|
||||||
void EVENT_USB_Host_DeviceUnattached(void)
|
void EVENT_USB_Host_DeviceUnattached(void)
|
||||||
{
|
{
|
||||||
puts_P(PSTR("\r\nDevice Unattached.\r\n"));
|
puts_P(PSTR("\r\nDevice Unattached.\r\n"));
|
||||||
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
|
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Event handler for the USB_DeviceEnumerationComplete event. This indicates that a device has been successfully
|
/** Event handler for the USB_DeviceEnumerationComplete event. This indicates that a device has been successfully
|
||||||
* enumerated by the host and is now ready to be used by the application.
|
* enumerated by the host and is now ready to be used by the application.
|
||||||
*/
|
*/
|
||||||
void EVENT_USB_Host_DeviceEnumerationComplete(void)
|
void EVENT_USB_Host_DeviceEnumerationComplete(void)
|
||||||
{
|
{
|
||||||
LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);
|
LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);
|
||||||
|
|
||||||
USB_Descriptor_Device_t DeviceDescriptor;
|
USB_Descriptor_Device_t DeviceDescriptor;
|
||||||
|
|
||||||
if (USB_Host_GetDeviceDescriptor(&DeviceDescriptor) != HOST_SENDCONTROL_Successful)
|
if (USB_Host_GetDeviceDescriptor(&DeviceDescriptor) != HOST_SENDCONTROL_Successful)
|
||||||
{
|
{
|
||||||
puts_P(PSTR("Error Retrieving Device Descriptor.\r\n"));
|
puts_P(PSTR("Error Retrieving Device Descriptor.\r\n"));
|
||||||
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NeedModeSwitch;
|
bool NeedModeSwitch;
|
||||||
if (!(AOA_Host_ValidateAccessoryDevice(&AndroidDevice_AOA_Interface, &DeviceDescriptor, &NeedModeSwitch)))
|
if (!(AOA_Host_ValidateAccessoryDevice(&AndroidDevice_AOA_Interface, &DeviceDescriptor, &NeedModeSwitch)))
|
||||||
{
|
{
|
||||||
puts_P(PSTR("Not an Android device.\r\n"));
|
puts_P(PSTR("Not an Android device.\r\n"));
|
||||||
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NeedModeSwitch)
|
if (NeedModeSwitch)
|
||||||
{
|
{
|
||||||
puts_P(PSTR("Not in Accessory mode, switching...\r\n"));
|
puts_P(PSTR("Not in Accessory mode, switching...\r\n"));
|
||||||
AOA_Host_StartAccessoryMode(&AndroidDevice_AOA_Interface);
|
AOA_Host_StartAccessoryMode(&AndroidDevice_AOA_Interface);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t ConfigDescriptorSize;
|
uint16_t ConfigDescriptorSize;
|
||||||
uint8_t ConfigDescriptorData[512];
|
uint8_t ConfigDescriptorData[512];
|
||||||
|
|
||||||
if (USB_Host_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, ConfigDescriptorData,
|
if (USB_Host_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, ConfigDescriptorData,
|
||||||
sizeof(ConfigDescriptorData)) != HOST_GETCONFIG_Successful)
|
sizeof(ConfigDescriptorData)) != HOST_GETCONFIG_Successful)
|
||||||
{
|
{
|
||||||
puts_P(PSTR("Error Retrieving Configuration Descriptor.\r\n"));
|
puts_P(PSTR("Error Retrieving Configuration Descriptor.\r\n"));
|
||||||
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AOA_Host_ConfigurePipes(&AndroidDevice_AOA_Interface,
|
if (AOA_Host_ConfigurePipes(&AndroidDevice_AOA_Interface,
|
||||||
ConfigDescriptorSize, ConfigDescriptorData) != AOA_ENUMERROR_NoError)
|
ConfigDescriptorSize, ConfigDescriptorData) != AOA_ENUMERROR_NoError)
|
||||||
{
|
{
|
||||||
puts_P(PSTR("Attached Device Not a Valid Android Accessory Class Device.\r\n"));
|
puts_P(PSTR("Attached Device Not a Valid Android Accessory Class Device.\r\n"));
|
||||||
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful)
|
if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful)
|
||||||
{
|
{
|
||||||
puts_P(PSTR("Error Setting Device Configuration.\r\n"));
|
puts_P(PSTR("Error Setting Device Configuration.\r\n"));
|
||||||
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
puts_P(PSTR("Android Device Enumerated.\r\n"));
|
puts_P(PSTR("Android Device Enumerated.\r\n"));
|
||||||
LEDs_SetAllLEDs(LEDMASK_USB_READY);
|
LEDs_SetAllLEDs(LEDMASK_USB_READY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Event handler for the USB_HostError event. This indicates that a hardware error occurred while in host mode. */
|
/** Event handler for the USB_HostError event. This indicates that a hardware error occurred while in host mode. */
|
||||||
void EVENT_USB_Host_HostError(const uint8_t ErrorCode)
|
void EVENT_USB_Host_HostError(const uint8_t ErrorCode)
|
||||||
{
|
{
|
||||||
USB_Disable();
|
USB_Disable();
|
||||||
|
|
||||||
printf_P(PSTR(ESC_FG_RED "Host Mode Error\r\n"
|
printf_P(PSTR(ESC_FG_RED "Host Mode Error\r\n"
|
||||||
" -- Error Code %d\r\n" ESC_FG_WHITE), ErrorCode);
|
" -- Error Code %d\r\n" ESC_FG_WHITE), ErrorCode);
|
||||||
|
|
||||||
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
||||||
for(;;);
|
for(;;);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Event handler for the USB_DeviceEnumerationFailed event. This indicates that a problem occurred while
|
/** Event handler for the USB_DeviceEnumerationFailed event. This indicates that a problem occurred while
|
||||||
* enumerating an attached USB device.
|
* enumerating an attached USB device.
|
||||||
*/
|
*/
|
||||||
void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode,
|
void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode,
|
||||||
const uint8_t SubErrorCode)
|
const uint8_t SubErrorCode)
|
||||||
{
|
{
|
||||||
printf_P(PSTR(ESC_FG_RED "Dev Enum Error\r\n"
|
printf_P(PSTR(ESC_FG_RED "Dev Enum Error\r\n"
|
||||||
" -- Error Code %d\r\n"
|
" -- Error Code %d\r\n"
|
||||||
" -- Sub Error Code %d\r\n"
|
" -- Sub Error Code %d\r\n"
|
||||||
" -- In State %d\r\n" ESC_FG_WHITE), ErrorCode, SubErrorCode, USB_HostState);
|
" -- In State %d\r\n" ESC_FG_WHITE), ErrorCode, SubErrorCode, USB_HostState);
|
||||||
|
|
||||||
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,78 +1,78 @@
|
|||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2012.
|
Copyright (C) Dean Camera, 2012.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.lufa-lib.org
|
www.lufa-lib.org
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||||
|
|
||||||
Permission to use, copy, modify, distribute, and sell this
|
Permission to use, copy, modify, distribute, and sell this
|
||||||
software and its documentation for any purpose is hereby granted
|
software and its documentation for any purpose is hereby granted
|
||||||
without fee, provided that the above copyright notice appear in
|
without fee, provided that the above copyright notice appear in
|
||||||
all copies and that both that the copyright notice and this
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
software, including all implied warranties of merchantability
|
software, including all implied warranties of merchantability
|
||||||
and fitness. In no event shall the author be liable for any
|
and fitness. In no event shall the author be liable for any
|
||||||
special, indirect or consequential damages or any damages
|
special, indirect or consequential damages or any damages
|
||||||
whatsoever resulting from loss of use, data or profits, whether
|
whatsoever resulting from loss of use, data or profits, whether
|
||||||
in an action of contract, negligence or other tortious action,
|
in an action of contract, negligence or other tortious action,
|
||||||
arising out of or in connection with the use or performance of
|
arising out of or in connection with the use or performance of
|
||||||
this software.
|
this software.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \file
|
/** \file
|
||||||
*
|
*
|
||||||
* Header file for AndroidAccessoryHost.c.
|
* Header file for AndroidAccessoryHost.c.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _ANDROIDACCESSORY_HOST_H_
|
#ifndef _ANDROIDACCESSORY_HOST_H_
|
||||||
#define _ANDROIDACCESSORY_HOST_H_
|
#define _ANDROIDACCESSORY_HOST_H_
|
||||||
|
|
||||||
/* Includes: */
|
/* Includes: */
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
#include <avr/wdt.h>
|
#include <avr/wdt.h>
|
||||||
#include <avr/pgmspace.h>
|
#include <avr/pgmspace.h>
|
||||||
#include <avr/power.h>
|
#include <avr/power.h>
|
||||||
#include <avr/interrupt.h>
|
#include <avr/interrupt.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <LUFA/Drivers/Misc/TerminalCodes.h>
|
#include <LUFA/Drivers/Misc/TerminalCodes.h>
|
||||||
#include <LUFA/Drivers/Peripheral/Serial.h>
|
#include <LUFA/Drivers/Peripheral/Serial.h>
|
||||||
#include <LUFA/Drivers/Board/LEDs.h>
|
#include <LUFA/Drivers/Board/LEDs.h>
|
||||||
#include <LUFA/Drivers/USB/USB.h>
|
#include <LUFA/Drivers/USB/USB.h>
|
||||||
|
|
||||||
/* Macros: */
|
/* Macros: */
|
||||||
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
|
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
|
||||||
#define LEDMASK_USB_NOTREADY LEDS_LED1
|
#define LEDMASK_USB_NOTREADY LEDS_LED1
|
||||||
|
|
||||||
/** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */
|
/** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */
|
||||||
#define LEDMASK_USB_ENUMERATING (LEDS_LED2 | LEDS_LED3)
|
#define LEDMASK_USB_ENUMERATING (LEDS_LED2 | LEDS_LED3)
|
||||||
|
|
||||||
/** LED mask for the library LED driver, to indicate that the USB interface is ready. */
|
/** LED mask for the library LED driver, to indicate that the USB interface is ready. */
|
||||||
#define LEDMASK_USB_READY (LEDS_LED2 | LEDS_LED4)
|
#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. */
|
/** 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)
|
#define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3)
|
||||||
|
|
||||||
/* Function Prototypes: */
|
/* Function Prototypes: */
|
||||||
void SetupHardware(void);
|
void SetupHardware(void);
|
||||||
void AOAHost_Task(void);
|
void AOAHost_Task(void);
|
||||||
|
|
||||||
void EVENT_USB_Host_HostError(const uint8_t ErrorCode);
|
void EVENT_USB_Host_HostError(const uint8_t ErrorCode);
|
||||||
void EVENT_USB_Host_DeviceAttached(void);
|
void EVENT_USB_Host_DeviceAttached(void);
|
||||||
void EVENT_USB_Host_DeviceUnattached(void);
|
void EVENT_USB_Host_DeviceUnattached(void);
|
||||||
void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode,
|
void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode,
|
||||||
const uint8_t SubErrorCode);
|
const uint8_t SubErrorCode);
|
||||||
void EVENT_USB_Host_DeviceEnumerationComplete(void);
|
void EVENT_USB_Host_DeviceEnumerationComplete(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,70 +1,70 @@
|
|||||||
#
|
#
|
||||||
# LUFA Library
|
# LUFA Library
|
||||||
# Copyright (C) Dean Camera, 2012.
|
# Copyright (C) Dean Camera, 2012.
|
||||||
#
|
#
|
||||||
# dean [at] fourwalledcubicle [dot] com
|
# dean [at] fourwalledcubicle [dot] com
|
||||||
# www.lufa-lib.org
|
# www.lufa-lib.org
|
||||||
#
|
#
|
||||||
|
|
||||||
LUFA_BUILD_MODULES += HID
|
LUFA_BUILD_MODULES += HID
|
||||||
LUFA_BUILD_TARGETS += hid hid-teensy
|
LUFA_BUILD_TARGETS += hid hid-teensy
|
||||||
LUFA_BUILD_MANDATORY_VARS += MCU TARGET
|
LUFA_BUILD_MANDATORY_VARS += MCU TARGET
|
||||||
LUFA_BUILD_OPTIONAL_VARS +=
|
LUFA_BUILD_OPTIONAL_VARS +=
|
||||||
LUFA_BUILD_PROVIDED_VARS +=
|
LUFA_BUILD_PROVIDED_VARS +=
|
||||||
LUFA_BUILD_PROVIDED_MACROS +=
|
LUFA_BUILD_PROVIDED_MACROS +=
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# LUFA HID Bootloader Buildsystem Makefile Module.
|
# LUFA HID Bootloader Buildsystem Makefile Module.
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# DESCRIPTION:
|
# DESCRIPTION:
|
||||||
# Provides a set of targets to re-program a device currently running a HID
|
# Provides a set of targets to re-program a device currently running a HID
|
||||||
# class bootloader with a project's FLASH files.
|
# class bootloader with a project's FLASH files.
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# TARGETS:
|
# TARGETS:
|
||||||
#
|
#
|
||||||
# hid - Program FLASH into target via
|
# hid - Program FLASH into target via
|
||||||
# hid_bootloader_cli
|
# hid_bootloader_cli
|
||||||
# hid-teensy - Program FLASH into target via
|
# hid-teensy - Program FLASH into target via
|
||||||
# teensy_loader_cli
|
# teensy_loader_cli
|
||||||
#
|
#
|
||||||
# MANDATORY PARAMETERS:
|
# MANDATORY PARAMETERS:
|
||||||
#
|
#
|
||||||
# MCU - Microcontroller device model name
|
# MCU - Microcontroller device model name
|
||||||
# TARGET - Application name
|
# TARGET - Application name
|
||||||
#
|
#
|
||||||
# OPTIONAL PARAMETERS:
|
# OPTIONAL PARAMETERS:
|
||||||
#
|
#
|
||||||
# (None)
|
# (None)
|
||||||
#
|
#
|
||||||
# PROVIDED VARIABLES:
|
# PROVIDED VARIABLES:
|
||||||
#
|
#
|
||||||
# (None)
|
# (None)
|
||||||
#
|
#
|
||||||
# PROVIDED MACROS:
|
# PROVIDED MACROS:
|
||||||
#
|
#
|
||||||
# (None)
|
# (None)
|
||||||
#
|
#
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
ERROR_IF_UNSET ?= $(if $(filter undefined, $(origin $(strip $(1)))), $(error Makefile $(strip $(1)) value not set))
|
ERROR_IF_UNSET ?= $(if $(filter undefined, $(origin $(strip $(1)))), $(error Makefile $(strip $(1)) value not set))
|
||||||
ERROR_IF_EMPTY ?= $(if $(strip $($(strip $(1)))), , $(error Makefile $(strip $(1)) option cannot be blank))
|
ERROR_IF_EMPTY ?= $(if $(strip $($(strip $(1)))), , $(error Makefile $(strip $(1)) option cannot be blank))
|
||||||
ERROR_IF_NONBOOL ?= $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N))
|
ERROR_IF_NONBOOL ?= $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N))
|
||||||
|
|
||||||
# Sanity-check values of mandatory user-supplied variables
|
# Sanity-check values of mandatory user-supplied variables
|
||||||
$(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))
|
$(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))
|
||||||
$(call ERROR_IF_EMPTY, MCU)
|
$(call ERROR_IF_EMPTY, MCU)
|
||||||
$(call ERROR_IF_EMPTY, TARGET)
|
$(call ERROR_IF_EMPTY, TARGET)
|
||||||
|
|
||||||
# Output Messages
|
# Output Messages
|
||||||
MSG_HID_BOOTLOADER_CMD := ' [HID] :'
|
MSG_HID_BOOTLOADER_CMD := ' [HID] :'
|
||||||
|
|
||||||
hid: $(TARGET).hex $(MAKEFILE_LIST)
|
hid: $(TARGET).hex $(MAKEFILE_LIST)
|
||||||
@echo $(MSG_HID_BOOTLOADER_CMD) Programming FLASH with hid_bootloader_cli using \"$<\"
|
@echo $(MSG_HID_BOOTLOADER_CMD) Programming FLASH with hid_bootloader_cli using \"$<\"
|
||||||
hid_bootloader_cli -mmcu=$(MCU) -v $<
|
hid_bootloader_cli -mmcu=$(MCU) -v $<
|
||||||
|
|
||||||
hid-teensy: $(TARGET).hex $(MAKEFILE_LIST)
|
hid-teensy: $(TARGET).hex $(MAKEFILE_LIST)
|
||||||
@echo $(MSG_HID_BOOTLOADER_CMD) Programming FLASH with teensy_loader_cli using \"$<\"
|
@echo $(MSG_HID_BOOTLOADER_CMD) Programming FLASH with teensy_loader_cli using \"$<\"
|
||||||
teensy_loader_cli -mmcu=$(MCU) -v $<
|
teensy_loader_cli -mmcu=$(MCU) -v $<
|
||||||
|
|
||||||
# Phony build targets for this module
|
# Phony build targets for this module
|
||||||
.PHONY: hid hid-teensy
|
.PHONY: hid hid-teensy
|
||||||
|
@ -1,208 +1,208 @@
|
|||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2012.
|
Copyright (C) Dean Camera, 2012.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.lufa-lib.org
|
www.lufa-lib.org
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||||
|
|
||||||
Permission to use, copy, modify, distribute, and sell this
|
Permission to use, copy, modify, distribute, and sell this
|
||||||
software and its documentation for any purpose is hereby granted
|
software and its documentation for any purpose is hereby granted
|
||||||
without fee, provided that the above copyright notice appear in
|
without fee, provided that the above copyright notice appear in
|
||||||
all copies and that both that the copyright notice and this
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
software, including all implied warranties of merchantability
|
software, including all implied warranties of merchantability
|
||||||
and fitness. In no event shall the author be liable for any
|
and fitness. In no event shall the author be liable for any
|
||||||
special, indirect or consequential damages or any damages
|
special, indirect or consequential damages or any damages
|
||||||
whatsoever resulting from loss of use, data or profits, whether
|
whatsoever resulting from loss of use, data or profits, whether
|
||||||
in an action of contract, negligence or other tortious action,
|
in an action of contract, negligence or other tortious action,
|
||||||
arising out of or in connection with the use or performance of
|
arising out of or in connection with the use or performance of
|
||||||
this software.
|
this software.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \file
|
/** \file
|
||||||
* \brief Board specific Buttons driver header for the Micropendous series boards.
|
* \brief Board specific Buttons driver header for the Micropendous series boards.
|
||||||
* \copydetails Group_Buttons_MICROPENDOUS_32U2
|
* \copydetails Group_Buttons_MICROPENDOUS_32U2
|
||||||
*
|
*
|
||||||
* \note This file should not be included directly. It is automatically included as needed by the Buttons driver
|
* \note This file should not be included directly. It is automatically included as needed by the Buttons driver
|
||||||
* dispatch header located in LUFA/Drivers/Board/Buttons.h.
|
* dispatch header located in LUFA/Drivers/Board/Buttons.h.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \ingroup Group_Buttons
|
/** \ingroup Group_Buttons
|
||||||
* \defgroup Group_Buttons_MICROPENDOUS_A MICROPENDOUS_A
|
* \defgroup Group_Buttons_MICROPENDOUS_A MICROPENDOUS_A
|
||||||
* \brief Board specific Button driver header for the Micropendous A (https://code.google.com/p/micropendous/wiki/MicropendousA).
|
* \brief Board specific Button driver header for the Micropendous A (https://code.google.com/p/micropendous/wiki/MicropendousA).
|
||||||
*
|
*
|
||||||
* See \ref Group_Buttons_MICROPENDOUS_32U2 for more details.
|
* See \ref Group_Buttons_MICROPENDOUS_32U2 for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \ingroup Group_Buttons
|
/** \ingroup Group_Buttons
|
||||||
* \defgroup Group_Buttons_MICROPENDOUS_1 MICROPENDOUS_1
|
* \defgroup Group_Buttons_MICROPENDOUS_1 MICROPENDOUS_1
|
||||||
* \brief Board specific Button driver header for the Micropendous 1 (https://code.google.com/p/micropendous/wiki/Micropendous1).
|
* \brief Board specific Button driver header for the Micropendous 1 (https://code.google.com/p/micropendous/wiki/Micropendous1).
|
||||||
*
|
*
|
||||||
* See \ref Group_Buttons_MICROPENDOUS_32U2 for more details.
|
* See \ref Group_Buttons_MICROPENDOUS_32U2 for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \ingroup Group_Buttons
|
/** \ingroup Group_Buttons
|
||||||
* \defgroup Group_Buttons_MICROPENDOUS_2 MICROPENDOUS_2
|
* \defgroup Group_Buttons_MICROPENDOUS_2 MICROPENDOUS_2
|
||||||
* \brief Board specific Button driver header for the Micropendous 2 (https://code.google.com/p/micropendous/wiki/Micropendous2).
|
* \brief Board specific Button driver header for the Micropendous 2 (https://code.google.com/p/micropendous/wiki/Micropendous2).
|
||||||
*
|
*
|
||||||
* See \ref Group_Buttons_MICROPENDOUS_32U2 for more details.
|
* See \ref Group_Buttons_MICROPENDOUS_32U2 for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \ingroup Group_Buttons
|
/** \ingroup Group_Buttons
|
||||||
* \defgroup Group_Buttons_MICROPENDOUS_3 MICROPENDOUS_3
|
* \defgroup Group_Buttons_MICROPENDOUS_3 MICROPENDOUS_3
|
||||||
* \brief Board specific Button driver header for the Micropendous 3 (https://code.google.com/p/micropendous/wiki/Micropendous3).
|
* \brief Board specific Button driver header for the Micropendous 3 (https://code.google.com/p/micropendous/wiki/Micropendous3).
|
||||||
*
|
*
|
||||||
* See \ref Group_Buttons_MICROPENDOUS_32U2 for more details.
|
* See \ref Group_Buttons_MICROPENDOUS_32U2 for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \ingroup Group_Buttons
|
/** \ingroup Group_Buttons
|
||||||
* \defgroup Group_Buttons_MICROPENDOUS_4 MICROPENDOUS_4
|
* \defgroup Group_Buttons_MICROPENDOUS_4 MICROPENDOUS_4
|
||||||
* \brief Board specific Button driver header for the Micropendous 4 (https://code.google.com/p/micropendous/wiki/Micropendous4).
|
* \brief Board specific Button driver header for the Micropendous 4 (https://code.google.com/p/micropendous/wiki/Micropendous4).
|
||||||
*
|
*
|
||||||
* See \ref Group_Buttons_MICROPENDOUS_32U2 for more details.
|
* See \ref Group_Buttons_MICROPENDOUS_32U2 for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \ingroup Group_Buttons
|
/** \ingroup Group_Buttons
|
||||||
* \defgroup Group_Buttons_MICROPENDOUS_DIP MICROPENDOUS_DIP
|
* \defgroup Group_Buttons_MICROPENDOUS_DIP MICROPENDOUS_DIP
|
||||||
* \brief Board specific Button driver header for the Micropendous DIP (https://code.google.com/p/micropendous/wiki/MicropendousDIP).
|
* \brief Board specific Button driver header for the Micropendous DIP (https://code.google.com/p/micropendous/wiki/MicropendousDIP).
|
||||||
*
|
*
|
||||||
* See \ref Group_Buttons_MICROPENDOUS_32U2 for more details.
|
* See \ref Group_Buttons_MICROPENDOUS_32U2 for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \ingroup Group_Buttons
|
/** \ingroup Group_Buttons
|
||||||
* \defgroup Group_Buttons_MICROPENDOUS_REV1 MICROPENDOUS_REV1
|
* \defgroup Group_Buttons_MICROPENDOUS_REV1 MICROPENDOUS_REV1
|
||||||
* \brief Board specific Button driver header for the Micropendous Arduino-like Revision 1 (https://code.google.com/p/micropendous/wiki/Micropendous).
|
* \brief Board specific Button driver header for the Micropendous Arduino-like Revision 1 (https://code.google.com/p/micropendous/wiki/Micropendous).
|
||||||
*
|
*
|
||||||
* See \ref Group_Buttons_MICROPENDOUS_32U2 for more details.
|
* See \ref Group_Buttons_MICROPENDOUS_32U2 for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \ingroup Group_Buttons
|
/** \ingroup Group_Buttons
|
||||||
* \defgroup Group_Buttons_MICROPENDOUS_REV2 MICROPENDOUS_REV2
|
* \defgroup Group_Buttons_MICROPENDOUS_REV2 MICROPENDOUS_REV2
|
||||||
* \brief Board specific Button driver header for the Micropendous Arduino-like Revision 2 (https://code.google.com/p/micropendous/wiki/Micropendous).
|
* \brief Board specific Button driver header for the Micropendous Arduino-like Revision 2 (https://code.google.com/p/micropendous/wiki/Micropendous).
|
||||||
*
|
*
|
||||||
* See \ref Group_Buttons_MICROPENDOUS_32U2 for more details.
|
* See \ref Group_Buttons_MICROPENDOUS_32U2 for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \ingroup Group_Buttons
|
/** \ingroup Group_Buttons
|
||||||
* \defgroup Group_Buttons_MICROPENDOUS_32U2 MICROPENDOUS_32U2
|
* \defgroup Group_Buttons_MICROPENDOUS_32U2 MICROPENDOUS_32U2
|
||||||
* \brief Board specific Buttons driver header for the Micropendous 32U2.
|
* \brief Board specific Buttons driver header for the Micropendous 32U2.
|
||||||
*
|
*
|
||||||
* \note There are multiple supported Micropendous boards, compile with <code>BOARD = MICROPENDOUS_{VERSION}</code>.
|
* \note There are multiple supported Micropendous boards, compile with <code>BOARD = MICROPENDOUS_{VERSION}</code>.
|
||||||
*
|
*
|
||||||
* Board specific Buttons driver header for the Micropendous 32U2 (https://code.google.com/p/micropendous/wiki/Micropendous_32U2).
|
* Board specific Buttons driver header for the Micropendous 32U2 (https://code.google.com/p/micropendous/wiki/Micropendous_32U2).
|
||||||
*
|
*
|
||||||
* <b>BOARD_MICROPENDOUS_1 and BOARD_MICROPENDOUS_32U2</b>:
|
* <b>BOARD_MICROPENDOUS_1 and BOARD_MICROPENDOUS_32U2</b>:
|
||||||
* <table>
|
* <table>
|
||||||
* <tr><th>Name</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>
|
* <tr><th>Name</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>
|
||||||
* <tr><td>BUTTONS_BUTTON1</td><td>HWB Button</td><td>Low</td><td>PORTD.7</td></tr>
|
* <tr><td>BUTTONS_BUTTON1</td><td>HWB Button</td><td>Low</td><td>PORTD.7</td></tr>
|
||||||
* </table>
|
* </table>
|
||||||
*
|
*
|
||||||
* <b>Other Revisions</b>:
|
* <b>Other Revisions</b>:
|
||||||
* <table>
|
* <table>
|
||||||
* <tr><th>Name</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>
|
* <tr><th>Name</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>
|
||||||
* <tr><td>BUTTONS_BUTTON1</td><td>HWB Button</td><td>Low</td><td>PORTE.2</td></tr>
|
* <tr><td>BUTTONS_BUTTON1</td><td>HWB Button</td><td>Low</td><td>PORTE.2</td></tr>
|
||||||
* </table>
|
* </table>
|
||||||
*
|
*
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __BUTTONS_MICROPENDOUS_H__
|
#ifndef __BUTTONS_MICROPENDOUS_H__
|
||||||
#define __BUTTONS_MICROPENDOUS_H__
|
#define __BUTTONS_MICROPENDOUS_H__
|
||||||
|
|
||||||
/* Includes: */
|
/* Includes: */
|
||||||
#include "../../../../Common/Common.h"
|
#include "../../../../Common/Common.h"
|
||||||
|
|
||||||
/* Enable C linkage for C++ Compilers: */
|
/* Enable C linkage for C++ Compilers: */
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Preprocessor Checks: */
|
/* Preprocessor Checks: */
|
||||||
#if !defined(__INCLUDE_FROM_BUTTONS_H)
|
#if !defined(__INCLUDE_FROM_BUTTONS_H)
|
||||||
#error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead.
|
#error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Private Interface - For use in library only: */
|
/* Private Interface - For use in library only: */
|
||||||
#if !defined(__DOXYGEN__)
|
#if !defined(__DOXYGEN__)
|
||||||
#if (BOARD == BOARD_MICROPENDOUS_32U2)
|
#if (BOARD == BOARD_MICROPENDOUS_32U2)
|
||||||
#define _BOARD_BUTTON1_MASK (1 << 7)
|
#define _BOARD_BUTTON1_MASK (1 << 7)
|
||||||
#define _BOARD_BUTTON_PORTLETTER D
|
#define _BOARD_BUTTON_PORTLETTER D
|
||||||
#elif (BOARD == BOARD_MICROPENDOUS_A)
|
#elif (BOARD == BOARD_MICROPENDOUS_A)
|
||||||
#define _BOARD_BUTTON1_MASK (1 << 2)
|
#define _BOARD_BUTTON1_MASK (1 << 2)
|
||||||
#define _BOARD_BUTTON_PORTLETTER E
|
#define _BOARD_BUTTON_PORTLETTER E
|
||||||
#elif (BOARD == BOARD_MICROPENDOUS_1)
|
#elif (BOARD == BOARD_MICROPENDOUS_1)
|
||||||
#define _BOARD_BUTTON1_MASK (1 << 7)
|
#define _BOARD_BUTTON1_MASK (1 << 7)
|
||||||
#define _BOARD_BUTTON_PORTLETTER D
|
#define _BOARD_BUTTON_PORTLETTER D
|
||||||
#elif (BOARD == BOARD_MICROPENDOUS_2)
|
#elif (BOARD == BOARD_MICROPENDOUS_2)
|
||||||
#define _BOARD_BUTTON1_MASK (1 << 2)
|
#define _BOARD_BUTTON1_MASK (1 << 2)
|
||||||
#define _BOARD_BUTTON_PORTLETTER E
|
#define _BOARD_BUTTON_PORTLETTER E
|
||||||
#elif (BOARD == BOARD_MICROPENDOUS_3)
|
#elif (BOARD == BOARD_MICROPENDOUS_3)
|
||||||
#define _BOARD_BUTTON1_MASK (1 << 2)
|
#define _BOARD_BUTTON1_MASK (1 << 2)
|
||||||
#define _BOARD_BUTTON_PORTLETTER E
|
#define _BOARD_BUTTON_PORTLETTER E
|
||||||
#elif (BOARD == BOARD_MICROPENDOUS_4)
|
#elif (BOARD == BOARD_MICROPENDOUS_4)
|
||||||
#define _BOARD_BUTTON1_MASK (1 << 2)
|
#define _BOARD_BUTTON1_MASK (1 << 2)
|
||||||
#define _BOARD_BUTTON_PORTLETTER E
|
#define _BOARD_BUTTON_PORTLETTER E
|
||||||
#elif (BOARD == BOARD_MICROPENDOUS_DIP)
|
#elif (BOARD == BOARD_MICROPENDOUS_DIP)
|
||||||
#define _BOARD_BUTTON1_MASK (1 << 2)
|
#define _BOARD_BUTTON1_MASK (1 << 2)
|
||||||
#define _BOARD_BUTTON_PORTLETTER E
|
#define _BOARD_BUTTON_PORTLETTER E
|
||||||
#elif (BOARD == BOARD_MICROPENDOUS_REV1)
|
#elif (BOARD == BOARD_MICROPENDOUS_REV1)
|
||||||
#define _BOARD_BUTTON1_MASK (1 << 2)
|
#define _BOARD_BUTTON1_MASK (1 << 2)
|
||||||
#define _BOARD_BUTTON_PORTLETTER E
|
#define _BOARD_BUTTON_PORTLETTER E
|
||||||
#elif (BOARD == BOARD_MICROPENDOUS_REV2)
|
#elif (BOARD == BOARD_MICROPENDOUS_REV2)
|
||||||
#define _BOARD_BUTTON1_MASK (1 << 2)
|
#define _BOARD_BUTTON1_MASK (1 << 2)
|
||||||
#define _BOARD_BUTTON_PORTLETTER E
|
#define _BOARD_BUTTON_PORTLETTER E
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define _BOARD_BUTTON_CONCAT2(Reg, Letter) Reg ## Letter
|
#define _BOARD_BUTTON_CONCAT2(Reg, Letter) Reg ## Letter
|
||||||
#define _BOARD_BUTTON_CONCAT(Reg, Letter) _BOARD_BUTTON_CONCAT2(Reg, Letter)
|
#define _BOARD_BUTTON_CONCAT(Reg, Letter) _BOARD_BUTTON_CONCAT2(Reg, Letter)
|
||||||
|
|
||||||
#define _BOARD_BUTTON_PORT _BOARD_BUTTON_CONCAT(PORT, _BOARD_BUTTON_PORTLETTER)
|
#define _BOARD_BUTTON_PORT _BOARD_BUTTON_CONCAT(PORT, _BOARD_BUTTON_PORTLETTER)
|
||||||
#define _BOARD_BUTTON_PIN _BOARD_BUTTON_CONCAT(PIN, _BOARD_BUTTON_PORTLETTER)
|
#define _BOARD_BUTTON_PIN _BOARD_BUTTON_CONCAT(PIN, _BOARD_BUTTON_PORTLETTER)
|
||||||
#define _BOARD_BUTTON_DDR _BOARD_BUTTON_CONCAT(DDR, _BOARD_BUTTON_PORTLETTER)
|
#define _BOARD_BUTTON_DDR _BOARD_BUTTON_CONCAT(DDR, _BOARD_BUTTON_PORTLETTER)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Public Interface - May be used in end-application: */
|
/* Public Interface - May be used in end-application: */
|
||||||
/* Macros: */
|
/* Macros: */
|
||||||
/** Button mask for the first button on the board. */
|
/** Button mask for the first button on the board. */
|
||||||
#define BUTTONS_BUTTON1 _BOARD_BUTTON1_MASK
|
#define BUTTONS_BUTTON1 _BOARD_BUTTON1_MASK
|
||||||
|
|
||||||
/* Inline Functions: */
|
/* Inline Functions: */
|
||||||
#if !defined(__DOXYGEN__)
|
#if !defined(__DOXYGEN__)
|
||||||
static inline void Buttons_Init(void)
|
static inline void Buttons_Init(void)
|
||||||
{
|
{
|
||||||
_BOARD_BUTTON_DDR &= ~BUTTONS_BUTTON1;
|
_BOARD_BUTTON_DDR &= ~BUTTONS_BUTTON1;
|
||||||
_BOARD_BUTTON_PORT |= BUTTONS_BUTTON1;
|
_BOARD_BUTTON_PORT |= BUTTONS_BUTTON1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void Buttons_Disable(void)
|
static inline void Buttons_Disable(void)
|
||||||
{
|
{
|
||||||
_BOARD_BUTTON_DDR &= ~BUTTONS_BUTTON1;
|
_BOARD_BUTTON_DDR &= ~BUTTONS_BUTTON1;
|
||||||
_BOARD_BUTTON_PORT &= ~BUTTONS_BUTTON1;
|
_BOARD_BUTTON_PORT &= ~BUTTONS_BUTTON1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
|
static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
|
||||||
static inline uint8_t Buttons_GetStatus(void)
|
static inline uint8_t Buttons_GetStatus(void)
|
||||||
{
|
{
|
||||||
return ((_BOARD_BUTTON_PIN & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1);
|
return ((_BOARD_BUTTON_PIN & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Disable C linkage for C++ Compilers: */
|
/* Disable C linkage for C++ Compilers: */
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,113 +1,113 @@
|
|||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2012.
|
Copyright (C) Dean Camera, 2012.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.lufa-lib.org
|
www.lufa-lib.org
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||||
|
|
||||||
Permission to use, copy, modify, distribute, and sell this
|
Permission to use, copy, modify, distribute, and sell this
|
||||||
software and its documentation for any purpose is hereby granted
|
software and its documentation for any purpose is hereby granted
|
||||||
without fee, provided that the above copyright notice appear in
|
without fee, provided that the above copyright notice appear in
|
||||||
all copies and that both that the copyright notice and this
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
software, including all implied warranties of merchantability
|
software, including all implied warranties of merchantability
|
||||||
and fitness. In no event shall the author be liable for any
|
and fitness. In no event shall the author be liable for any
|
||||||
special, indirect or consequential damages or any damages
|
special, indirect or consequential damages or any damages
|
||||||
whatsoever resulting from loss of use, data or profits, whether
|
whatsoever resulting from loss of use, data or profits, whether
|
||||||
in an action of contract, negligence or other tortious action,
|
in an action of contract, negligence or other tortious action,
|
||||||
arising out of or in connection with the use or performance of
|
arising out of or in connection with the use or performance of
|
||||||
this software.
|
this software.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \file
|
/** \file
|
||||||
* \brief Board specific Buttons driver header for the Paranoid Studio USB2AX.
|
* \brief Board specific Buttons driver header for the Paranoid Studio USB2AX.
|
||||||
* \copydetails Group_Buttons_USB2AX
|
* \copydetails Group_Buttons_USB2AX
|
||||||
*
|
*
|
||||||
* \note This file should not be included directly. It is automatically included as needed by the Buttons driver
|
* \note This file should not be included directly. It is automatically included as needed by the Buttons driver
|
||||||
* dispatch header located in LUFA/Drivers/Board/Buttons.h.
|
* dispatch header located in LUFA/Drivers/Board/Buttons.h.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \ingroup Group_Buttons
|
/** \ingroup Group_Buttons
|
||||||
* \defgroup Group_Buttons_USB2AX_V3 USB2AX_V3
|
* \defgroup Group_Buttons_USB2AX_V3 USB2AX_V3
|
||||||
* \brief Board specific Button driver header for the Paranoid Studio USB2AX revision 3.
|
* \brief Board specific Button driver header for the Paranoid Studio USB2AX revision 3.
|
||||||
*
|
*
|
||||||
* See \ref Group_Buttons_USB2AX for more details.
|
* See \ref Group_Buttons_USB2AX for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \ingroup Group_Buttons
|
/** \ingroup Group_Buttons
|
||||||
* \defgroup Group_Buttons_USB2AX USB2AX
|
* \defgroup Group_Buttons_USB2AX USB2AX
|
||||||
* \brief Board specific Buttons driver header for the Paranoid Studio USB2AX.
|
* \brief Board specific Buttons driver header for the Paranoid Studio USB2AX.
|
||||||
*
|
*
|
||||||
* \note For version 3 USB2AX boards, compile with <code>BOARD = USB2AX_V3</code>.
|
* \note For version 3 USB2AX boards, compile with <code>BOARD = USB2AX_V3</code>.
|
||||||
*
|
*
|
||||||
* Board specific Buttons driver header for the Paranoid Studio USB2AX (http://paranoidstudio.assembla.com/wiki/show/paranoidstudio/USB2AX).
|
* Board specific Buttons driver header for the Paranoid Studio USB2AX (http://paranoidstudio.assembla.com/wiki/show/paranoidstudio/USB2AX).
|
||||||
*
|
*
|
||||||
* <table>
|
* <table>
|
||||||
* <tr><th>Name</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>
|
* <tr><th>Name</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>
|
||||||
* <tr><td>BUTTONS_BUTTON1</td><td>HWB Button</td><td>Low</td><td>PORTD.7</td></tr>
|
* <tr><td>BUTTONS_BUTTON1</td><td>HWB Button</td><td>Low</td><td>PORTD.7</td></tr>
|
||||||
* </table>
|
* </table>
|
||||||
*
|
*
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __BUTTONS_USB2AX_H__
|
#ifndef __BUTTONS_USB2AX_H__
|
||||||
#define __BUTTONS_USB2AX_H__
|
#define __BUTTONS_USB2AX_H__
|
||||||
|
|
||||||
/* Includes: */
|
/* Includes: */
|
||||||
#include "../../../../Common/Common.h"
|
#include "../../../../Common/Common.h"
|
||||||
|
|
||||||
/* Enable C linkage for C++ Compilers: */
|
/* Enable C linkage for C++ Compilers: */
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Preprocessor Checks: */
|
/* Preprocessor Checks: */
|
||||||
#if !defined(__INCLUDE_FROM_BUTTONS_H)
|
#if !defined(__INCLUDE_FROM_BUTTONS_H)
|
||||||
#error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead.
|
#error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Public Interface - May be used in end-application: */
|
/* Public Interface - May be used in end-application: */
|
||||||
/* Macros: */
|
/* Macros: */
|
||||||
/** Button mask for the first button on the board. */
|
/** Button mask for the first button on the board. */
|
||||||
#define BUTTONS_BUTTON1 (1 << 7)
|
#define BUTTONS_BUTTON1 (1 << 7)
|
||||||
|
|
||||||
/* Inline Functions: */
|
/* Inline Functions: */
|
||||||
#if !defined(__DOXYGEN__)
|
#if !defined(__DOXYGEN__)
|
||||||
static inline void Buttons_Init(void)
|
static inline void Buttons_Init(void)
|
||||||
{
|
{
|
||||||
DDRD &= ~BUTTONS_BUTTON1;
|
DDRD &= ~BUTTONS_BUTTON1;
|
||||||
PORTD |= BUTTONS_BUTTON1;
|
PORTD |= BUTTONS_BUTTON1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void Buttons_Disable(void)
|
static inline void Buttons_Disable(void)
|
||||||
{
|
{
|
||||||
DDRD &= ~BUTTONS_BUTTON1;
|
DDRD &= ~BUTTONS_BUTTON1;
|
||||||
PORTD &= ~BUTTONS_BUTTON1;
|
PORTD &= ~BUTTONS_BUTTON1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
|
static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
|
||||||
static inline uint8_t Buttons_GetStatus(void)
|
static inline uint8_t Buttons_GetStatus(void)
|
||||||
{
|
{
|
||||||
return ((PIND & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1);
|
return ((PIND & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Disable C linkage for C++ Compilers: */
|
/* Disable C linkage for C++ Compilers: */
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,196 +1,196 @@
|
|||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2012.
|
Copyright (C) Dean Camera, 2012.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.lufa-lib.org
|
www.lufa-lib.org
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||||
|
|
||||||
Permission to use, copy, modify, distribute, and sell this
|
Permission to use, copy, modify, distribute, and sell this
|
||||||
software and its documentation for any purpose is hereby granted
|
software and its documentation for any purpose is hereby granted
|
||||||
without fee, provided that the above copyright notice appear in
|
without fee, provided that the above copyright notice appear in
|
||||||
all copies and that both that the copyright notice and this
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
software, including all implied warranties of merchantability
|
software, including all implied warranties of merchantability
|
||||||
and fitness. In no event shall the author be liable for any
|
and fitness. In no event shall the author be liable for any
|
||||||
special, indirect or consequential damages or any damages
|
special, indirect or consequential damages or any damages
|
||||||
whatsoever resulting from loss of use, data or profits, whether
|
whatsoever resulting from loss of use, data or profits, whether
|
||||||
in an action of contract, negligence or other tortious action,
|
in an action of contract, negligence or other tortious action,
|
||||||
arising out of or in connection with the use or performance of
|
arising out of or in connection with the use or performance of
|
||||||
this software.
|
this software.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \file
|
/** \file
|
||||||
* \brief Board specific LED driver header for the Paranoid Studio USB2AX.
|
* \brief Board specific LED driver header for the Paranoid Studio USB2AX.
|
||||||
* \copydetails Group_LEDs_USB2AX
|
* \copydetails Group_LEDs_USB2AX
|
||||||
*
|
*
|
||||||
* \note This file should not be included directly. It is automatically included as needed by the LEDs driver
|
* \note This file should not be included directly. It is automatically included as needed by the LEDs driver
|
||||||
* dispatch header located in LUFA/Drivers/Board/LEDs.h.
|
* dispatch header located in LUFA/Drivers/Board/LEDs.h.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \ingroup Group_LEDs
|
/** \ingroup Group_LEDs
|
||||||
* \defgroup Group_LEDs_USB2AX_V3 USB2AX_V3
|
* \defgroup Group_LEDs_USB2AX_V3 USB2AX_V3
|
||||||
* \brief Board specific LED driver header for the Paranoid Studio USB2AX revision 3.
|
* \brief Board specific LED driver header for the Paranoid Studio USB2AX revision 3.
|
||||||
*
|
*
|
||||||
* See \ref Group_LEDs_USB2AX for more details.
|
* See \ref Group_LEDs_USB2AX for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \ingroup Group_LEDs
|
/** \ingroup Group_LEDs
|
||||||
* \defgroup Group_LEDs_USB2AX USB2AX
|
* \defgroup Group_LEDs_USB2AX USB2AX
|
||||||
* \brief Board specific LED driver header for the Paranoid Studio USB2AX.
|
* \brief Board specific LED driver header for the Paranoid Studio USB2AX.
|
||||||
*
|
*
|
||||||
* \note For version 3 USB2AX boards, compile with <code>BOARD = USB2AX_V3</code>.
|
* \note For version 3 USB2AX boards, compile with <code>BOARD = USB2AX_V3</code>.
|
||||||
*
|
*
|
||||||
* Board specific LED driver header for the Paranoid Studio USB2AX (http://paranoidstudio.assembla.com/wiki/show/paranoidstudio/USB2AX).
|
* Board specific LED driver header for the Paranoid Studio USB2AX (http://paranoidstudio.assembla.com/wiki/show/paranoidstudio/USB2AX).
|
||||||
*
|
*
|
||||||
* <b>USB2AX</b>:
|
* <b>USB2AX</b>:
|
||||||
* <table>
|
* <table>
|
||||||
* <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>
|
* <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>
|
||||||
* <tr><td>LEDS_LED1</td><td>Green</td><td>General Indicator</td><td>High</td><td>PORTC.6</td></tr>
|
* <tr><td>LEDS_LED1</td><td>Green</td><td>General Indicator</td><td>High</td><td>PORTC.6</td></tr>
|
||||||
* </table>
|
* </table>
|
||||||
*
|
*
|
||||||
* <b>USB2AX_V3</b>:
|
* <b>USB2AX_V3</b>:
|
||||||
* <table>
|
* <table>
|
||||||
* <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>
|
* <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>
|
||||||
* <tr><td>LEDS_LED1</td><td>Green</td><td>General Indicator</td><td>High</td><td>PORTD.1</td></tr>
|
* <tr><td>LEDS_LED1</td><td>Green</td><td>General Indicator</td><td>High</td><td>PORTD.1</td></tr>
|
||||||
* </table>
|
* </table>
|
||||||
*
|
*
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __LEDS_USB2AX_H__
|
#ifndef __LEDS_USB2AX_H__
|
||||||
#define __LEDS_USB2AX_H__
|
#define __LEDS_USB2AX_H__
|
||||||
|
|
||||||
/* Includes: */
|
/* Includes: */
|
||||||
#include "../../../../Common/Common.h"
|
#include "../../../../Common/Common.h"
|
||||||
|
|
||||||
/* Enable C linkage for C++ Compilers: */
|
/* Enable C linkage for C++ Compilers: */
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Preprocessor Checks: */
|
/* Preprocessor Checks: */
|
||||||
#if !defined(__INCLUDE_FROM_LEDS_H)
|
#if !defined(__INCLUDE_FROM_LEDS_H)
|
||||||
#error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.
|
#error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Private Interface - For use in library only: */
|
/* Private Interface - For use in library only: */
|
||||||
#if !defined(__DOXYGEN__)
|
#if !defined(__DOXYGEN__)
|
||||||
/* Macros: */
|
/* Macros: */
|
||||||
#if (BOARD == BOARD_USB2AX)
|
#if (BOARD == BOARD_USB2AX)
|
||||||
#define USB2AX_LEDS_LED1 (1 << 6)
|
#define USB2AX_LEDS_LED1 (1 << 6)
|
||||||
#else
|
#else
|
||||||
#define USB2AX_LEDS_LED1 (1 << 1)
|
#define USB2AX_LEDS_LED1 (1 << 1)
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Public Interface - May be used in end-application: */
|
/* Public Interface - May be used in end-application: */
|
||||||
/* Macros: */
|
/* Macros: */
|
||||||
/** LED mask for the first LED on the board. */
|
/** LED mask for the first LED on the board. */
|
||||||
#define LEDS_LED1 USB2AX_LEDS_LED1
|
#define LEDS_LED1 USB2AX_LEDS_LED1
|
||||||
|
|
||||||
/** LED mask for all the LEDs on the board. */
|
/** LED mask for all the LEDs on the board. */
|
||||||
#define LEDS_ALL_LEDS LEDS_LED1
|
#define LEDS_ALL_LEDS LEDS_LED1
|
||||||
|
|
||||||
/** LED mask for none of the board LEDs. */
|
/** LED mask for none of the board LEDs. */
|
||||||
#define LEDS_NO_LEDS 0
|
#define LEDS_NO_LEDS 0
|
||||||
|
|
||||||
/* Inline Functions: */
|
/* Inline Functions: */
|
||||||
#if !defined(__DOXYGEN__)
|
#if !defined(__DOXYGEN__)
|
||||||
static inline void LEDs_Init(void)
|
static inline void LEDs_Init(void)
|
||||||
{
|
{
|
||||||
#if (BOARD == BOARD_USB2AX)
|
#if (BOARD == BOARD_USB2AX)
|
||||||
DDRC |= LEDS_ALL_LEDS;
|
DDRC |= LEDS_ALL_LEDS;
|
||||||
PORTC &= ~LEDS_ALL_LEDS;
|
PORTC &= ~LEDS_ALL_LEDS;
|
||||||
#else
|
#else
|
||||||
DDRD |= LEDS_ALL_LEDS;
|
DDRD |= LEDS_ALL_LEDS;
|
||||||
PORTD &= ~LEDS_ALL_LEDS;
|
PORTD &= ~LEDS_ALL_LEDS;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void LEDs_Disable(void)
|
static inline void LEDs_Disable(void)
|
||||||
{
|
{
|
||||||
#if (BOARD == BOARD_USB2AX)
|
#if (BOARD == BOARD_USB2AX)
|
||||||
DDRC &= ~LEDS_ALL_LEDS;
|
DDRC &= ~LEDS_ALL_LEDS;
|
||||||
PORTC &= ~LEDS_ALL_LEDS;
|
PORTC &= ~LEDS_ALL_LEDS;
|
||||||
#else
|
#else
|
||||||
DDRD &= ~LEDS_ALL_LEDS;
|
DDRD &= ~LEDS_ALL_LEDS;
|
||||||
PORTD &= ~LEDS_ALL_LEDS;
|
PORTD &= ~LEDS_ALL_LEDS;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)
|
static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)
|
||||||
{
|
{
|
||||||
#if (BOARD == BOARD_USB2AX)
|
#if (BOARD == BOARD_USB2AX)
|
||||||
PORTC |= LEDMask;
|
PORTC |= LEDMask;
|
||||||
#else
|
#else
|
||||||
PORTD |= LEDMask;
|
PORTD |= LEDMask;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)
|
static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)
|
||||||
{
|
{
|
||||||
#if (BOARD == BOARD_USB2AX)
|
#if (BOARD == BOARD_USB2AX)
|
||||||
PORTC &= ~LEDMask;
|
PORTC &= ~LEDMask;
|
||||||
#else
|
#else
|
||||||
PORTD &= ~LEDMask;
|
PORTD &= ~LEDMask;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)
|
static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)
|
||||||
{
|
{
|
||||||
#if (BOARD == BOARD_USB2AX)
|
#if (BOARD == BOARD_USB2AX)
|
||||||
PORTC = ((PORTC & ~LEDS_ALL_LEDS) | LEDMask);
|
PORTC = ((PORTC & ~LEDS_ALL_LEDS) | LEDMask);
|
||||||
#else
|
#else
|
||||||
PORTD = ((PORTD & ~LEDS_ALL_LEDS) | LEDMask);
|
PORTD = ((PORTD & ~LEDS_ALL_LEDS) | LEDMask);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void LEDs_ChangeLEDs(const uint8_t LEDMask,
|
static inline void LEDs_ChangeLEDs(const uint8_t LEDMask,
|
||||||
const uint8_t ActiveMask)
|
const uint8_t ActiveMask)
|
||||||
{
|
{
|
||||||
#if (BOARD == BOARD_USB2AX)
|
#if (BOARD == BOARD_USB2AX)
|
||||||
PORTC = ((PORTC & ~LEDMask) | ActiveMask);
|
PORTC = ((PORTC & ~LEDMask) | ActiveMask);
|
||||||
#else
|
#else
|
||||||
PORTD = ((PORTD & ~LEDMask) | ActiveMask);
|
PORTD = ((PORTD & ~LEDMask) | ActiveMask);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)
|
static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)
|
||||||
{
|
{
|
||||||
#if (BOARD == BOARD_USB2AX)
|
#if (BOARD == BOARD_USB2AX)
|
||||||
PINC = LEDMask;
|
PINC = LEDMask;
|
||||||
#else
|
#else
|
||||||
PIND = LEDMask;
|
PIND = LEDMask;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;
|
static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;
|
||||||
static inline uint8_t LEDs_GetLEDs(void)
|
static inline uint8_t LEDs_GetLEDs(void)
|
||||||
{
|
{
|
||||||
#if (BOARD == BOARD_USB2AX)
|
#if (BOARD == BOARD_USB2AX)
|
||||||
return (PORTC & LEDS_ALL_LEDS);
|
return (PORTC & LEDS_ALL_LEDS);
|
||||||
#else
|
#else
|
||||||
return (PORTD & LEDS_ALL_LEDS);
|
return (PORTD & LEDS_ALL_LEDS);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Disable C linkage for C++ Compilers: */
|
/* Disable C linkage for C++ Compilers: */
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,76 +1,76 @@
|
|||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2012.
|
Copyright (C) Dean Camera, 2012.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.lufa-lib.org
|
www.lufa-lib.org
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||||
|
|
||||||
Permission to use, copy, modify, distribute, and sell this
|
Permission to use, copy, modify, distribute, and sell this
|
||||||
software and its documentation for any purpose is hereby granted
|
software and its documentation for any purpose is hereby granted
|
||||||
without fee, provided that the above copyright notice appear in
|
without fee, provided that the above copyright notice appear in
|
||||||
all copies and that both that the copyright notice and this
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
software, including all implied warranties of merchantability
|
software, including all implied warranties of merchantability
|
||||||
and fitness. In no event shall the author be liable for any
|
and fitness. In no event shall the author be liable for any
|
||||||
special, indirect or consequential damages or any damages
|
special, indirect or consequential damages or any damages
|
||||||
whatsoever resulting from loss of use, data or profits, whether
|
whatsoever resulting from loss of use, data or profits, whether
|
||||||
in an action of contract, negligence or other tortious action,
|
in an action of contract, negligence or other tortious action,
|
||||||
arising out of or in connection with the use or performance of
|
arising out of or in connection with the use or performance of
|
||||||
this software.
|
this software.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \file
|
/** \file
|
||||||
* \brief Master include file for the library USB Android Open Accessory Class driver.
|
* \brief Master include file for the library USB Android Open Accessory Class driver.
|
||||||
*
|
*
|
||||||
* Master include file for the library USB Android Open Accessory Class driver, for both host and device modes, where available.
|
* Master include file for the library USB Android Open Accessory Class driver, for both host and device modes, where available.
|
||||||
*
|
*
|
||||||
* This file should be included in all user projects making use of this optional class driver, instead of
|
* This file should be included in all user projects making use of this optional class driver, instead of
|
||||||
* including any headers in the USB/ClassDriver/Device, USB/ClassDriver/Host or USB/ClassDriver/Common subdirectories.
|
* including any headers in the USB/ClassDriver/Device, USB/ClassDriver/Host or USB/ClassDriver/Common subdirectories.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \ingroup Group_USBClassDrivers
|
/** \ingroup Group_USBClassDrivers
|
||||||
* \defgroup Group_USBClassAOA Android Open Accessory Class Driver
|
* \defgroup Group_USBClassAOA Android Open Accessory Class Driver
|
||||||
*
|
*
|
||||||
* \section Sec_Dependencies Module Source Dependencies
|
* \section Sec_Dependencies Module Source Dependencies
|
||||||
* The following files must be built with any user project that uses this module:
|
* The following files must be built with any user project that uses this module:
|
||||||
* - LUFA/Drivers/USB/Class/Host/AndroidAccessoryClassHost.c <i>(Makefile source module name: LUFA_SRC_USBCLASS)</i>
|
* - LUFA/Drivers/USB/Class/Host/AndroidAccessoryClassHost.c <i>(Makefile source module name: LUFA_SRC_USBCLASS)</i>
|
||||||
*
|
*
|
||||||
* \section Sec_ModDescription Module Description
|
* \section Sec_ModDescription Module Description
|
||||||
* Android Open Accessory Class Driver module. This module contains an internal implementation of the USB Android Open Accessory
|
* Android Open Accessory Class Driver module. This module contains an internal implementation of the USB Android Open Accessory
|
||||||
* Class, for Host USB mode. User applications can use this class driver instead of implementing the Android Open Accessory Class
|
* Class, for Host USB mode. User applications can use this class driver instead of implementing the Android Open Accessory Class
|
||||||
* manually via the low-level LUFA APIs.
|
* manually via the low-level LUFA APIs.
|
||||||
*
|
*
|
||||||
* This module is designed to simplify the user code by exposing only the required interface needed to interface with
|
* This module is designed to simplify the user code by exposing only the required interface needed to interface with
|
||||||
* Host using the USB Android Open Accessory Class.
|
* Host using the USB Android Open Accessory Class.
|
||||||
*
|
*
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _AOA_CLASS_H_
|
#ifndef _AOA_CLASS_H_
|
||||||
#define _AOA_CLASS_H_
|
#define _AOA_CLASS_H_
|
||||||
|
|
||||||
/* Macros: */
|
/* Macros: */
|
||||||
#define __INCLUDE_FROM_USB_DRIVER
|
#define __INCLUDE_FROM_USB_DRIVER
|
||||||
#define __INCLUDE_FROM_AOA_DRIVER
|
#define __INCLUDE_FROM_AOA_DRIVER
|
||||||
|
|
||||||
/* Includes: */
|
/* Includes: */
|
||||||
#include "../Core/USBMode.h"
|
#include "../Core/USBMode.h"
|
||||||
|
|
||||||
#if defined(USB_CAN_BE_HOST)
|
#if defined(USB_CAN_BE_HOST)
|
||||||
#include "Host/AndroidAccessoryClassHost.h"
|
#include "Host/AndroidAccessoryClassHost.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,128 +1,128 @@
|
|||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2012.
|
Copyright (C) Dean Camera, 2012.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.lufa-lib.org
|
www.lufa-lib.org
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||||
|
|
||||||
Permission to use, copy, modify, distribute, and sell this
|
Permission to use, copy, modify, distribute, and sell this
|
||||||
software and its documentation for any purpose is hereby granted
|
software and its documentation for any purpose is hereby granted
|
||||||
without fee, provided that the above copyright notice appear in
|
without fee, provided that the above copyright notice appear in
|
||||||
all copies and that both that the copyright notice and this
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
software, including all implied warranties of merchantability
|
software, including all implied warranties of merchantability
|
||||||
and fitness. In no event shall the author be liable for any
|
and fitness. In no event shall the author be liable for any
|
||||||
special, indirect or consequential damages or any damages
|
special, indirect or consequential damages or any damages
|
||||||
whatsoever resulting from loss of use, data or profits, whether
|
whatsoever resulting from loss of use, data or profits, whether
|
||||||
in an action of contract, negligence or other tortious action,
|
in an action of contract, negligence or other tortious action,
|
||||||
arising out of or in connection with the use or performance of
|
arising out of or in connection with the use or performance of
|
||||||
this software.
|
this software.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \file
|
/** \file
|
||||||
* \brief Common definitions and declarations for the library USB Android Open Accessory Class driver.
|
* \brief Common definitions and declarations for the library USB Android Open Accessory Class driver.
|
||||||
*
|
*
|
||||||
* Common definitions and declarations for the library USB Android Open Accessory Class driver.
|
* Common definitions and declarations for the library USB Android Open Accessory Class driver.
|
||||||
*
|
*
|
||||||
* \note This file should not be included directly. It is automatically included as needed by the USB module driver
|
* \note This file should not be included directly. It is automatically included as needed by the USB module driver
|
||||||
* dispatch header located in LUFA/Drivers/USB.h.
|
* dispatch header located in LUFA/Drivers/USB.h.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \ingroup Group_USBClassAOA
|
/** \ingroup Group_USBClassAOA
|
||||||
* \defgroup Group_USBClassAOACommon Common Class Definitions
|
* \defgroup Group_USBClassAOACommon Common Class Definitions
|
||||||
*
|
*
|
||||||
* \section Sec_ModDescription Module Description
|
* \section Sec_ModDescription Module Description
|
||||||
* Constants, Types and Enum definitions that are common to both Device and Host modes for the USB
|
* Constants, Types and Enum definitions that are common to both Device and Host modes for the USB
|
||||||
* Android Open Accessory Class.
|
* Android Open Accessory Class.
|
||||||
*
|
*
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _AOA_CLASS_COMMON_H_
|
#ifndef _AOA_CLASS_COMMON_H_
|
||||||
#define _AOA_CLASS_COMMON_H_
|
#define _AOA_CLASS_COMMON_H_
|
||||||
|
|
||||||
/* Includes: */
|
/* Includes: */
|
||||||
#include "../../Core/StdDescriptors.h"
|
#include "../../Core/StdDescriptors.h"
|
||||||
|
|
||||||
/* Enable C linkage for C++ Compilers: */
|
/* Enable C linkage for C++ Compilers: */
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Preprocessor Checks: */
|
/* Preprocessor Checks: */
|
||||||
#if !defined(__INCLUDE_FROM_AOA_DRIVER)
|
#if !defined(__INCLUDE_FROM_AOA_DRIVER)
|
||||||
#error Do not include this file directly. Include LUFA/Drivers/USB.h instead.
|
#error Do not include this file directly. Include LUFA/Drivers/USB.h instead.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Macros: */
|
/* Macros: */
|
||||||
/** Product ID value in a Device Descriptor to indicate an Android device in Open Accessory mode. */
|
/** Product ID value in a Device Descriptor to indicate an Android device in Open Accessory mode. */
|
||||||
#define ANDROID_ACCESSORY_PRODUCT_ID 0x2D00
|
#define ANDROID_ACCESSORY_PRODUCT_ID 0x2D00
|
||||||
|
|
||||||
/** Product ID value in a Device Descriptor to indicate an Android device in Open Accessory and Android Debug mode. */
|
/** Product ID value in a Device Descriptor to indicate an Android device in Open Accessory and Android Debug mode. */
|
||||||
#define ANDROID_ACCESSORY_ADB_PRODUCT_ID 0x2D01
|
#define ANDROID_ACCESSORY_ADB_PRODUCT_ID 0x2D01
|
||||||
|
|
||||||
/* Enums: */
|
/* Enums: */
|
||||||
/** Enum for possible Class, Subclass and Protocol values of device and interface descriptors relating to the
|
/** Enum for possible Class, Subclass and Protocol values of device and interface descriptors relating to the
|
||||||
* Android Open Accessory class.
|
* Android Open Accessory class.
|
||||||
*/
|
*/
|
||||||
enum AOA_Descriptor_ClassSubclassProtocol_t
|
enum AOA_Descriptor_ClassSubclassProtocol_t
|
||||||
{
|
{
|
||||||
AOA_CSCP_AOADataClass = 0xFF, /**< Descriptor Class value indicating that the device or interface
|
AOA_CSCP_AOADataClass = 0xFF, /**< Descriptor Class value indicating that the device or interface
|
||||||
* belongs to the AOA data class.
|
* belongs to the AOA data class.
|
||||||
*/
|
*/
|
||||||
AOA_CSCP_AOADataSubclass = 0xFF, /**< Descriptor Subclass value indicating that the device or interface
|
AOA_CSCP_AOADataSubclass = 0xFF, /**< Descriptor Subclass value indicating that the device or interface
|
||||||
* belongs to AOA data subclass.
|
* belongs to AOA data subclass.
|
||||||
*/
|
*/
|
||||||
AOA_CSCP_AOADataProtocol = 0x00, /**< Descriptor Protocol value indicating that the device or interface
|
AOA_CSCP_AOADataProtocol = 0x00, /**< Descriptor Protocol value indicating that the device or interface
|
||||||
* belongs to the AOA data class protocol.
|
* belongs to the AOA data class protocol.
|
||||||
*/
|
*/
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Enum for the Android Open Accessory class specific control requests that can be issued by the USB bus host. */
|
/** Enum for the Android Open Accessory class specific control requests that can be issued by the USB bus host. */
|
||||||
enum AOA_ClassRequests_t
|
enum AOA_ClassRequests_t
|
||||||
{
|
{
|
||||||
AOA_REQ_GetAccessoryProtocol = 0x33, /**< Android Open Accessory control request to retrieve the device's supported Accessory Protocol version. */
|
AOA_REQ_GetAccessoryProtocol = 0x33, /**< Android Open Accessory control request to retrieve the device's supported Accessory Protocol version. */
|
||||||
AOA_REQ_SendString = 0x34, /**< Android Open Accessory control request to set an accessory property string in the device. */
|
AOA_REQ_SendString = 0x34, /**< Android Open Accessory control request to set an accessory property string in the device. */
|
||||||
AOA_REQ_StartAccessoryMode = 0x35, /**< Android Open Accessory control request to switch the device into Accessory mode. */
|
AOA_REQ_StartAccessoryMode = 0x35, /**< Android Open Accessory control request to switch the device into Accessory mode. */
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Enum for the possible Android Open Accessory property string indexes. */
|
/** Enum for the possible Android Open Accessory property string indexes. */
|
||||||
enum AOA_Strings_t
|
enum AOA_Strings_t
|
||||||
{
|
{
|
||||||
AOA_STRING_Manufacturer = 0, /**< Index of the Manufacturer property string. */
|
AOA_STRING_Manufacturer = 0, /**< Index of the Manufacturer property string. */
|
||||||
AOA_STRING_Model = 1, /**< Index of the Model Name property string. */
|
AOA_STRING_Model = 1, /**< Index of the Model Name property string. */
|
||||||
AOA_STRING_Description = 2, /**< Index of the Description property string. */
|
AOA_STRING_Description = 2, /**< Index of the Description property string. */
|
||||||
AOA_STRING_Version = 3, /**< Index of the Version Number property string. */
|
AOA_STRING_Version = 3, /**< Index of the Version Number property string. */
|
||||||
AOA_STRING_URI = 4, /**< Index of the URI Information property string. */
|
AOA_STRING_URI = 4, /**< Index of the URI Information property string. */
|
||||||
AOA_STRING_Serial = 5, /**< Index of the Serial Number property string. */
|
AOA_STRING_Serial = 5, /**< Index of the Serial Number property string. */
|
||||||
|
|
||||||
#if !defined(__DOXYGEN__)
|
#if !defined(__DOXYGEN__)
|
||||||
AOA_STRING_TOTAL_STRINGS
|
AOA_STRING_TOTAL_STRINGS
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Enum for the possible Android Open Accessory protocol versions. */
|
/** Enum for the possible Android Open Accessory protocol versions. */
|
||||||
enum AOA_Protocols_t
|
enum AOA_Protocols_t
|
||||||
{
|
{
|
||||||
AOA_PROTOCOL_AccessoryV1 = 0x0001, /**< Android Open Accessory version 1. */
|
AOA_PROTOCOL_AccessoryV1 = 0x0001, /**< Android Open Accessory version 1. */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Disable C linkage for C++ Compilers: */
|
/* Disable C linkage for C++ Compilers: */
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,422 +1,422 @@
|
|||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2012.
|
Copyright (C) Dean Camera, 2012.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.lufa-lib.org
|
www.lufa-lib.org
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||||
|
|
||||||
Permission to use, copy, modify, distribute, and sell this
|
Permission to use, copy, modify, distribute, and sell this
|
||||||
software and its documentation for any purpose is hereby granted
|
software and its documentation for any purpose is hereby granted
|
||||||
without fee, provided that the above copyright notice appear in
|
without fee, provided that the above copyright notice appear in
|
||||||
all copies and that both that the copyright notice and this
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
software, including all implied warranties of merchantability
|
software, including all implied warranties of merchantability
|
||||||
and fitness. In no event shall the author be liable for any
|
and fitness. In no event shall the author be liable for any
|
||||||
special, indirect or consequential damages or any damages
|
special, indirect or consequential damages or any damages
|
||||||
whatsoever resulting from loss of use, data or profits, whether
|
whatsoever resulting from loss of use, data or profits, whether
|
||||||
in an action of contract, negligence or other tortious action,
|
in an action of contract, negligence or other tortious action,
|
||||||
arising out of or in connection with the use or performance of
|
arising out of or in connection with the use or performance of
|
||||||
this software.
|
this software.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define __INCLUDE_FROM_USB_DRIVER
|
#define __INCLUDE_FROM_USB_DRIVER
|
||||||
#include "../../Core/USBMode.h"
|
#include "../../Core/USBMode.h"
|
||||||
|
|
||||||
#if defined(USB_CAN_BE_HOST)
|
#if defined(USB_CAN_BE_HOST)
|
||||||
|
|
||||||
#define __INCLUDE_FROM_AOA_DRIVER
|
#define __INCLUDE_FROM_AOA_DRIVER
|
||||||
#define __INCLUDE_FROM_ANDROIDACCESSORY_HOST_C
|
#define __INCLUDE_FROM_ANDROIDACCESSORY_HOST_C
|
||||||
#include "AndroidAccessoryClassHost.h"
|
#include "AndroidAccessoryClassHost.h"
|
||||||
|
|
||||||
bool AOA_Host_ValidateAccessoryDevice(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo,
|
bool AOA_Host_ValidateAccessoryDevice(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo,
|
||||||
const USB_Descriptor_Device_t* const DeviceDescriptor,
|
const USB_Descriptor_Device_t* const DeviceDescriptor,
|
||||||
bool* const NeedModeSwitch)
|
bool* const NeedModeSwitch)
|
||||||
{
|
{
|
||||||
(void)AOAInterfaceInfo;
|
(void)AOAInterfaceInfo;
|
||||||
|
|
||||||
if (DeviceDescriptor->Header.Type != DTYPE_Device)
|
if (DeviceDescriptor->Header.Type != DTYPE_Device)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
*NeedModeSwitch = ((DeviceDescriptor->ProductID != ANDROID_ACCESSORY_PRODUCT_ID) &&
|
*NeedModeSwitch = ((DeviceDescriptor->ProductID != ANDROID_ACCESSORY_PRODUCT_ID) &&
|
||||||
(DeviceDescriptor->ProductID != ANDROID_ACCESSORY_ADB_PRODUCT_ID));
|
(DeviceDescriptor->ProductID != ANDROID_ACCESSORY_ADB_PRODUCT_ID));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t AOA_Host_ConfigurePipes(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo,
|
uint8_t AOA_Host_ConfigurePipes(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo,
|
||||||
uint16_t ConfigDescriptorSize,
|
uint16_t ConfigDescriptorSize,
|
||||||
void* ConfigDescriptorData)
|
void* ConfigDescriptorData)
|
||||||
{
|
{
|
||||||
USB_Descriptor_Endpoint_t* DataINEndpoint = NULL;
|
USB_Descriptor_Endpoint_t* DataINEndpoint = NULL;
|
||||||
USB_Descriptor_Endpoint_t* DataOUTEndpoint = NULL;
|
USB_Descriptor_Endpoint_t* DataOUTEndpoint = NULL;
|
||||||
USB_Descriptor_Interface_t* AOAInterface = NULL;
|
USB_Descriptor_Interface_t* AOAInterface = NULL;
|
||||||
|
|
||||||
memset(&AOAInterfaceInfo->State, 0x00, sizeof(AOAInterfaceInfo->State));
|
memset(&AOAInterfaceInfo->State, 0x00, sizeof(AOAInterfaceInfo->State));
|
||||||
|
|
||||||
if (DESCRIPTOR_TYPE(ConfigDescriptorData) != DTYPE_Configuration)
|
if (DESCRIPTOR_TYPE(ConfigDescriptorData) != DTYPE_Configuration)
|
||||||
return AOA_ENUMERROR_InvalidConfigDescriptor;
|
return AOA_ENUMERROR_InvalidConfigDescriptor;
|
||||||
|
|
||||||
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
|
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
|
||||||
DCOMP_AOA_Host_NextAndroidAccessoryInterface) != DESCRIPTOR_SEARCH_COMP_Found)
|
DCOMP_AOA_Host_NextAndroidAccessoryInterface) != DESCRIPTOR_SEARCH_COMP_Found)
|
||||||
{
|
{
|
||||||
return AOA_ENUMERROR_NoCompatibleInterfaceFound;
|
return AOA_ENUMERROR_NoCompatibleInterfaceFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
AOAInterface = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Interface_t);
|
AOAInterface = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Interface_t);
|
||||||
|
|
||||||
while (!(DataINEndpoint) || !(DataOUTEndpoint))
|
while (!(DataINEndpoint) || !(DataOUTEndpoint))
|
||||||
{
|
{
|
||||||
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
|
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
|
||||||
DCOMP_AOA_Host_NextInterfaceBulkEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)
|
DCOMP_AOA_Host_NextInterfaceBulkEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)
|
||||||
{
|
{
|
||||||
return AOA_ENUMERROR_NoCompatibleInterfaceFound;
|
return AOA_ENUMERROR_NoCompatibleInterfaceFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Endpoint_t);
|
USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Endpoint_t);
|
||||||
|
|
||||||
if ((EndpointData->EndpointAddress & ENDPOINT_DIR_MASK) == ENDPOINT_DIR_IN)
|
if ((EndpointData->EndpointAddress & ENDPOINT_DIR_MASK) == ENDPOINT_DIR_IN)
|
||||||
DataINEndpoint = EndpointData;
|
DataINEndpoint = EndpointData;
|
||||||
else
|
else
|
||||||
DataOUTEndpoint = EndpointData;
|
DataOUTEndpoint = EndpointData;
|
||||||
}
|
}
|
||||||
|
|
||||||
AOAInterfaceInfo->Config.DataINPipe.Size = le16_to_cpu(DataINEndpoint->EndpointSize);
|
AOAInterfaceInfo->Config.DataINPipe.Size = le16_to_cpu(DataINEndpoint->EndpointSize);
|
||||||
AOAInterfaceInfo->Config.DataINPipe.EndpointAddress = DataINEndpoint->EndpointAddress;
|
AOAInterfaceInfo->Config.DataINPipe.EndpointAddress = DataINEndpoint->EndpointAddress;
|
||||||
AOAInterfaceInfo->Config.DataINPipe.Type = EP_TYPE_BULK;
|
AOAInterfaceInfo->Config.DataINPipe.Type = EP_TYPE_BULK;
|
||||||
|
|
||||||
AOAInterfaceInfo->Config.DataOUTPipe.Size = le16_to_cpu(DataOUTEndpoint->EndpointSize);
|
AOAInterfaceInfo->Config.DataOUTPipe.Size = le16_to_cpu(DataOUTEndpoint->EndpointSize);
|
||||||
AOAInterfaceInfo->Config.DataOUTPipe.EndpointAddress = DataOUTEndpoint->EndpointAddress;
|
AOAInterfaceInfo->Config.DataOUTPipe.EndpointAddress = DataOUTEndpoint->EndpointAddress;
|
||||||
AOAInterfaceInfo->Config.DataOUTPipe.Type = EP_TYPE_BULK;
|
AOAInterfaceInfo->Config.DataOUTPipe.Type = EP_TYPE_BULK;
|
||||||
|
|
||||||
if (!(Pipe_ConfigurePipeTable(&AOAInterfaceInfo->Config.DataINPipe, 1)))
|
if (!(Pipe_ConfigurePipeTable(&AOAInterfaceInfo->Config.DataINPipe, 1)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!(Pipe_ConfigurePipeTable(&AOAInterfaceInfo->Config.DataOUTPipe, 1)))
|
if (!(Pipe_ConfigurePipeTable(&AOAInterfaceInfo->Config.DataOUTPipe, 1)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
AOAInterfaceInfo->State.IsActive = true;
|
AOAInterfaceInfo->State.IsActive = true;
|
||||||
AOAInterfaceInfo->State.InterfaceNumber = AOAInterface->InterfaceNumber;
|
AOAInterfaceInfo->State.InterfaceNumber = AOAInterface->InterfaceNumber;
|
||||||
|
|
||||||
return AOA_ENUMERROR_NoError;
|
return AOA_ENUMERROR_NoError;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t DCOMP_AOA_Host_NextAndroidAccessoryInterface(void* const CurrentDescriptor)
|
static uint8_t DCOMP_AOA_Host_NextAndroidAccessoryInterface(void* const CurrentDescriptor)
|
||||||
{
|
{
|
||||||
USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
|
USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
|
||||||
|
|
||||||
if (Header->Type == DTYPE_Interface)
|
if (Header->Type == DTYPE_Interface)
|
||||||
{
|
{
|
||||||
USB_Descriptor_Interface_t* Interface = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Interface_t);
|
USB_Descriptor_Interface_t* Interface = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Interface_t);
|
||||||
|
|
||||||
if ((Interface->Class == AOA_CSCP_AOADataClass) &&
|
if ((Interface->Class == AOA_CSCP_AOADataClass) &&
|
||||||
(Interface->SubClass == AOA_CSCP_AOADataSubclass) &&
|
(Interface->SubClass == AOA_CSCP_AOADataSubclass) &&
|
||||||
(Interface->Protocol == AOA_CSCP_AOADataProtocol))
|
(Interface->Protocol == AOA_CSCP_AOADataProtocol))
|
||||||
{
|
{
|
||||||
return DESCRIPTOR_SEARCH_Found;
|
return DESCRIPTOR_SEARCH_Found;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return DESCRIPTOR_SEARCH_NotFound;
|
return DESCRIPTOR_SEARCH_NotFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t DCOMP_AOA_Host_NextInterfaceBulkEndpoint(void* const CurrentDescriptor)
|
static uint8_t DCOMP_AOA_Host_NextInterfaceBulkEndpoint(void* const CurrentDescriptor)
|
||||||
{
|
{
|
||||||
USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
|
USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);
|
||||||
|
|
||||||
if (Header->Type == DTYPE_Endpoint)
|
if (Header->Type == DTYPE_Endpoint)
|
||||||
{
|
{
|
||||||
USB_Descriptor_Endpoint_t* Endpoint = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Endpoint_t);
|
USB_Descriptor_Endpoint_t* Endpoint = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Endpoint_t);
|
||||||
|
|
||||||
uint8_t EndpointType = (Endpoint->Attributes & EP_TYPE_MASK);
|
uint8_t EndpointType = (Endpoint->Attributes & EP_TYPE_MASK);
|
||||||
|
|
||||||
if ((EndpointType == EP_TYPE_BULK) && (!(Pipe_IsEndpointBound(Endpoint->EndpointAddress))))
|
if ((EndpointType == EP_TYPE_BULK) && (!(Pipe_IsEndpointBound(Endpoint->EndpointAddress))))
|
||||||
return DESCRIPTOR_SEARCH_Found;
|
return DESCRIPTOR_SEARCH_Found;
|
||||||
}
|
}
|
||||||
else if (Header->Type == DTYPE_Interface)
|
else if (Header->Type == DTYPE_Interface)
|
||||||
{
|
{
|
||||||
return DESCRIPTOR_SEARCH_Fail;
|
return DESCRIPTOR_SEARCH_Fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
return DESCRIPTOR_SEARCH_NotFound;
|
return DESCRIPTOR_SEARCH_NotFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AOA_Host_USBTask(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo)
|
void AOA_Host_USBTask(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo)
|
||||||
{
|
{
|
||||||
if ((USB_HostState != HOST_STATE_Configured) || !(AOAInterfaceInfo->State.IsActive))
|
if ((USB_HostState != HOST_STATE_Configured) || !(AOAInterfaceInfo->State.IsActive))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#if !defined(NO_CLASS_DRIVER_AUTOFLUSH)
|
#if !defined(NO_CLASS_DRIVER_AUTOFLUSH)
|
||||||
AOA_Host_Flush(AOAInterfaceInfo);
|
AOA_Host_Flush(AOAInterfaceInfo);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t AOA_Host_StartAccessoryMode(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo)
|
uint8_t AOA_Host_StartAccessoryMode(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo)
|
||||||
{
|
{
|
||||||
uint8_t ErrorCode;
|
uint8_t ErrorCode;
|
||||||
|
|
||||||
uint16_t AccessoryProtocol;
|
uint16_t AccessoryProtocol;
|
||||||
if ((ErrorCode = AOA_Host_GetAccessoryProtocol(&AccessoryProtocol)) != HOST_WAITERROR_Successful)
|
if ((ErrorCode = AOA_Host_GetAccessoryProtocol(&AccessoryProtocol)) != HOST_WAITERROR_Successful)
|
||||||
return ErrorCode;
|
return ErrorCode;
|
||||||
|
|
||||||
if (AccessoryProtocol != CPU_TO_LE16(AOA_PROTOCOL_AccessoryV1))
|
if (AccessoryProtocol != CPU_TO_LE16(AOA_PROTOCOL_AccessoryV1))
|
||||||
return AOA_ERROR_LOGICAL_CMD_FAILED;
|
return AOA_ERROR_LOGICAL_CMD_FAILED;
|
||||||
|
|
||||||
for (uint8_t PropertyIndex = 0; PropertyIndex < AOA_STRING_TOTAL_STRINGS; PropertyIndex++)
|
for (uint8_t PropertyIndex = 0; PropertyIndex < AOA_STRING_TOTAL_STRINGS; PropertyIndex++)
|
||||||
{
|
{
|
||||||
if ((ErrorCode = AOA_Host_SendPropertyString(AOAInterfaceInfo, PropertyIndex)) != HOST_WAITERROR_Successful)
|
if ((ErrorCode = AOA_Host_SendPropertyString(AOAInterfaceInfo, PropertyIndex)) != HOST_WAITERROR_Successful)
|
||||||
return ErrorCode;
|
return ErrorCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
USB_ControlRequest = (USB_Request_Header_t)
|
USB_ControlRequest = (USB_Request_Header_t)
|
||||||
{
|
{
|
||||||
.bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_VENDOR | REQREC_DEVICE),
|
.bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_VENDOR | REQREC_DEVICE),
|
||||||
.bRequest = AOA_REQ_StartAccessoryMode,
|
.bRequest = AOA_REQ_StartAccessoryMode,
|
||||||
.wValue = 0,
|
.wValue = 0,
|
||||||
.wIndex = 0,
|
.wIndex = 0,
|
||||||
.wLength = 0,
|
.wLength = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
Pipe_SelectPipe(PIPE_CONTROLPIPE);
|
Pipe_SelectPipe(PIPE_CONTROLPIPE);
|
||||||
return USB_Host_SendControlRequest(NULL);
|
return USB_Host_SendControlRequest(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t AOA_Host_GetAccessoryProtocol(uint16_t* const Protocol)
|
static uint8_t AOA_Host_GetAccessoryProtocol(uint16_t* const Protocol)
|
||||||
{
|
{
|
||||||
USB_ControlRequest = (USB_Request_Header_t)
|
USB_ControlRequest = (USB_Request_Header_t)
|
||||||
{
|
{
|
||||||
.bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_VENDOR | REQREC_DEVICE),
|
.bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_VENDOR | REQREC_DEVICE),
|
||||||
.bRequest = AOA_REQ_GetAccessoryProtocol,
|
.bRequest = AOA_REQ_GetAccessoryProtocol,
|
||||||
.wValue = 0,
|
.wValue = 0,
|
||||||
.wIndex = 0,
|
.wIndex = 0,
|
||||||
.wLength = sizeof(uint16_t),
|
.wLength = sizeof(uint16_t),
|
||||||
};
|
};
|
||||||
|
|
||||||
Pipe_SelectPipe(PIPE_CONTROLPIPE);
|
Pipe_SelectPipe(PIPE_CONTROLPIPE);
|
||||||
return USB_Host_SendControlRequest(Protocol);
|
return USB_Host_SendControlRequest(Protocol);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t AOA_Host_SendPropertyString(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo,
|
static uint8_t AOA_Host_SendPropertyString(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo,
|
||||||
const uint8_t StringIndex)
|
const uint8_t StringIndex)
|
||||||
{
|
{
|
||||||
const char* String = AOAInterfaceInfo->Config.PropertyStrings[StringIndex];
|
const char* String = AOAInterfaceInfo->Config.PropertyStrings[StringIndex];
|
||||||
|
|
||||||
if (String == NULL)
|
if (String == NULL)
|
||||||
String = "";
|
String = "";
|
||||||
|
|
||||||
USB_ControlRequest = (USB_Request_Header_t)
|
USB_ControlRequest = (USB_Request_Header_t)
|
||||||
{
|
{
|
||||||
.bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_VENDOR | REQREC_DEVICE),
|
.bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_VENDOR | REQREC_DEVICE),
|
||||||
.bRequest = AOA_REQ_SendString,
|
.bRequest = AOA_REQ_SendString,
|
||||||
.wValue = 0,
|
.wValue = 0,
|
||||||
.wIndex = StringIndex,
|
.wIndex = StringIndex,
|
||||||
.wLength = (strlen(String) + 1),
|
.wLength = (strlen(String) + 1),
|
||||||
};
|
};
|
||||||
|
|
||||||
Pipe_SelectPipe(PIPE_CONTROLPIPE);
|
Pipe_SelectPipe(PIPE_CONTROLPIPE);
|
||||||
return USB_Host_SendControlRequest((char*)String);
|
return USB_Host_SendControlRequest((char*)String);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t AOA_Host_SendData(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo,
|
uint8_t AOA_Host_SendData(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo,
|
||||||
const uint8_t* const Buffer,
|
const uint8_t* const Buffer,
|
||||||
const uint16_t Length)
|
const uint16_t Length)
|
||||||
{
|
{
|
||||||
if ((USB_HostState != HOST_STATE_Configured) || !(AOAInterfaceInfo->State.IsActive))
|
if ((USB_HostState != HOST_STATE_Configured) || !(AOAInterfaceInfo->State.IsActive))
|
||||||
return PIPE_READYWAIT_DeviceDisconnected;
|
return PIPE_READYWAIT_DeviceDisconnected;
|
||||||
|
|
||||||
uint8_t ErrorCode;
|
uint8_t ErrorCode;
|
||||||
|
|
||||||
Pipe_SelectPipe(AOAInterfaceInfo->Config.DataOUTPipe.Address);
|
Pipe_SelectPipe(AOAInterfaceInfo->Config.DataOUTPipe.Address);
|
||||||
|
|
||||||
Pipe_Unfreeze();
|
Pipe_Unfreeze();
|
||||||
ErrorCode = Pipe_Write_Stream_LE(Buffer, Length, NULL);
|
ErrorCode = Pipe_Write_Stream_LE(Buffer, Length, NULL);
|
||||||
Pipe_Freeze();
|
Pipe_Freeze();
|
||||||
|
|
||||||
return ErrorCode;
|
return ErrorCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t AOA_Host_SendString(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo,
|
uint8_t AOA_Host_SendString(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo,
|
||||||
const char* const String)
|
const char* const String)
|
||||||
{
|
{
|
||||||
if ((USB_HostState != HOST_STATE_Configured) || !(AOAInterfaceInfo->State.IsActive))
|
if ((USB_HostState != HOST_STATE_Configured) || !(AOAInterfaceInfo->State.IsActive))
|
||||||
return PIPE_READYWAIT_DeviceDisconnected;
|
return PIPE_READYWAIT_DeviceDisconnected;
|
||||||
|
|
||||||
uint8_t ErrorCode;
|
uint8_t ErrorCode;
|
||||||
|
|
||||||
Pipe_SelectPipe(AOAInterfaceInfo->Config.DataOUTPipe.Address);
|
Pipe_SelectPipe(AOAInterfaceInfo->Config.DataOUTPipe.Address);
|
||||||
|
|
||||||
Pipe_Unfreeze();
|
Pipe_Unfreeze();
|
||||||
ErrorCode = Pipe_Write_Stream_LE(String, strlen(String), NULL);
|
ErrorCode = Pipe_Write_Stream_LE(String, strlen(String), NULL);
|
||||||
Pipe_Freeze();
|
Pipe_Freeze();
|
||||||
|
|
||||||
return ErrorCode;
|
return ErrorCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t AOA_Host_SendByte(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo,
|
uint8_t AOA_Host_SendByte(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo,
|
||||||
const uint8_t Data)
|
const uint8_t Data)
|
||||||
{
|
{
|
||||||
if ((USB_HostState != HOST_STATE_Configured) || !(AOAInterfaceInfo->State.IsActive))
|
if ((USB_HostState != HOST_STATE_Configured) || !(AOAInterfaceInfo->State.IsActive))
|
||||||
return PIPE_READYWAIT_DeviceDisconnected;
|
return PIPE_READYWAIT_DeviceDisconnected;
|
||||||
|
|
||||||
uint8_t ErrorCode;
|
uint8_t ErrorCode;
|
||||||
|
|
||||||
Pipe_SelectPipe(AOAInterfaceInfo->Config.DataOUTPipe.Address);
|
Pipe_SelectPipe(AOAInterfaceInfo->Config.DataOUTPipe.Address);
|
||||||
Pipe_Unfreeze();
|
Pipe_Unfreeze();
|
||||||
|
|
||||||
if (!(Pipe_IsReadWriteAllowed()))
|
if (!(Pipe_IsReadWriteAllowed()))
|
||||||
{
|
{
|
||||||
Pipe_ClearOUT();
|
Pipe_ClearOUT();
|
||||||
|
|
||||||
if ((ErrorCode = Pipe_WaitUntilReady()) != PIPE_READYWAIT_NoError)
|
if ((ErrorCode = Pipe_WaitUntilReady()) != PIPE_READYWAIT_NoError)
|
||||||
return ErrorCode;
|
return ErrorCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
Pipe_Write_8(Data);
|
Pipe_Write_8(Data);
|
||||||
Pipe_Freeze();
|
Pipe_Freeze();
|
||||||
|
|
||||||
return PIPE_READYWAIT_NoError;
|
return PIPE_READYWAIT_NoError;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t AOA_Host_BytesReceived(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo)
|
uint16_t AOA_Host_BytesReceived(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo)
|
||||||
{
|
{
|
||||||
if ((USB_HostState != HOST_STATE_Configured) || !(AOAInterfaceInfo->State.IsActive))
|
if ((USB_HostState != HOST_STATE_Configured) || !(AOAInterfaceInfo->State.IsActive))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
Pipe_SelectPipe(AOAInterfaceInfo->Config.DataINPipe.Address);
|
Pipe_SelectPipe(AOAInterfaceInfo->Config.DataINPipe.Address);
|
||||||
Pipe_Unfreeze();
|
Pipe_Unfreeze();
|
||||||
|
|
||||||
if (Pipe_IsINReceived())
|
if (Pipe_IsINReceived())
|
||||||
{
|
{
|
||||||
if (!(Pipe_BytesInPipe()))
|
if (!(Pipe_BytesInPipe()))
|
||||||
{
|
{
|
||||||
Pipe_ClearIN();
|
Pipe_ClearIN();
|
||||||
Pipe_Freeze();
|
Pipe_Freeze();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Pipe_Freeze();
|
Pipe_Freeze();
|
||||||
return Pipe_BytesInPipe();
|
return Pipe_BytesInPipe();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Pipe_Freeze();
|
Pipe_Freeze();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t AOA_Host_ReceiveByte(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo)
|
int16_t AOA_Host_ReceiveByte(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo)
|
||||||
{
|
{
|
||||||
if ((USB_HostState != HOST_STATE_Configured) || !(AOAInterfaceInfo->State.IsActive))
|
if ((USB_HostState != HOST_STATE_Configured) || !(AOAInterfaceInfo->State.IsActive))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
int16_t ReceivedByte = -1;
|
int16_t ReceivedByte = -1;
|
||||||
|
|
||||||
Pipe_SelectPipe(AOAInterfaceInfo->Config.DataINPipe.Address);
|
Pipe_SelectPipe(AOAInterfaceInfo->Config.DataINPipe.Address);
|
||||||
Pipe_Unfreeze();
|
Pipe_Unfreeze();
|
||||||
|
|
||||||
if (Pipe_IsINReceived())
|
if (Pipe_IsINReceived())
|
||||||
{
|
{
|
||||||
if (Pipe_BytesInPipe())
|
if (Pipe_BytesInPipe())
|
||||||
ReceivedByte = Pipe_Read_8();
|
ReceivedByte = Pipe_Read_8();
|
||||||
|
|
||||||
if (!(Pipe_BytesInPipe()))
|
if (!(Pipe_BytesInPipe()))
|
||||||
Pipe_ClearIN();
|
Pipe_ClearIN();
|
||||||
}
|
}
|
||||||
|
|
||||||
Pipe_Freeze();
|
Pipe_Freeze();
|
||||||
|
|
||||||
return ReceivedByte;
|
return ReceivedByte;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t AOA_Host_Flush(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo)
|
uint8_t AOA_Host_Flush(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo)
|
||||||
{
|
{
|
||||||
if ((USB_HostState != HOST_STATE_Configured) || !(AOAInterfaceInfo->State.IsActive))
|
if ((USB_HostState != HOST_STATE_Configured) || !(AOAInterfaceInfo->State.IsActive))
|
||||||
return PIPE_READYWAIT_DeviceDisconnected;
|
return PIPE_READYWAIT_DeviceDisconnected;
|
||||||
|
|
||||||
uint8_t ErrorCode;
|
uint8_t ErrorCode;
|
||||||
|
|
||||||
Pipe_SelectPipe(AOAInterfaceInfo->Config.DataOUTPipe.Address);
|
Pipe_SelectPipe(AOAInterfaceInfo->Config.DataOUTPipe.Address);
|
||||||
Pipe_Unfreeze();
|
Pipe_Unfreeze();
|
||||||
|
|
||||||
if (!(Pipe_BytesInPipe()))
|
if (!(Pipe_BytesInPipe()))
|
||||||
return PIPE_READYWAIT_NoError;
|
return PIPE_READYWAIT_NoError;
|
||||||
|
|
||||||
bool BankFull = !(Pipe_IsReadWriteAllowed());
|
bool BankFull = !(Pipe_IsReadWriteAllowed());
|
||||||
|
|
||||||
Pipe_ClearOUT();
|
Pipe_ClearOUT();
|
||||||
|
|
||||||
if (BankFull)
|
if (BankFull)
|
||||||
{
|
{
|
||||||
if ((ErrorCode = Pipe_WaitUntilReady()) != PIPE_READYWAIT_NoError)
|
if ((ErrorCode = Pipe_WaitUntilReady()) != PIPE_READYWAIT_NoError)
|
||||||
return ErrorCode;
|
return ErrorCode;
|
||||||
|
|
||||||
Pipe_ClearOUT();
|
Pipe_ClearOUT();
|
||||||
}
|
}
|
||||||
|
|
||||||
Pipe_Freeze();
|
Pipe_Freeze();
|
||||||
|
|
||||||
return PIPE_READYWAIT_NoError;
|
return PIPE_READYWAIT_NoError;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(FDEV_SETUP_STREAM)
|
#if defined(FDEV_SETUP_STREAM)
|
||||||
void AOA_Host_CreateStream(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo,
|
void AOA_Host_CreateStream(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo,
|
||||||
FILE* const Stream)
|
FILE* const Stream)
|
||||||
{
|
{
|
||||||
*Stream = (FILE)FDEV_SETUP_STREAM(AOA_Host_putchar, AOA_Host_getchar, _FDEV_SETUP_RW);
|
*Stream = (FILE)FDEV_SETUP_STREAM(AOA_Host_putchar, AOA_Host_getchar, _FDEV_SETUP_RW);
|
||||||
fdev_set_udata(Stream, AOAInterfaceInfo);
|
fdev_set_udata(Stream, AOAInterfaceInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AOA_Host_CreateBlockingStream(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo,
|
void AOA_Host_CreateBlockingStream(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo,
|
||||||
FILE* const Stream)
|
FILE* const Stream)
|
||||||
{
|
{
|
||||||
*Stream = (FILE)FDEV_SETUP_STREAM(AOA_Host_putchar, AOA_Host_getchar_Blocking, _FDEV_SETUP_RW);
|
*Stream = (FILE)FDEV_SETUP_STREAM(AOA_Host_putchar, AOA_Host_getchar_Blocking, _FDEV_SETUP_RW);
|
||||||
fdev_set_udata(Stream, AOAInterfaceInfo);
|
fdev_set_udata(Stream, AOAInterfaceInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int AOA_Host_putchar(char c,
|
static int AOA_Host_putchar(char c,
|
||||||
FILE* Stream)
|
FILE* Stream)
|
||||||
{
|
{
|
||||||
return AOA_Host_SendByte((USB_ClassInfo_AOA_Host_t*)fdev_get_udata(Stream), c) ? _FDEV_ERR : 0;
|
return AOA_Host_SendByte((USB_ClassInfo_AOA_Host_t*)fdev_get_udata(Stream), c) ? _FDEV_ERR : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int AOA_Host_getchar(FILE* Stream)
|
static int AOA_Host_getchar(FILE* Stream)
|
||||||
{
|
{
|
||||||
int16_t ReceivedByte = AOA_Host_ReceiveByte((USB_ClassInfo_AOA_Host_t*)fdev_get_udata(Stream));
|
int16_t ReceivedByte = AOA_Host_ReceiveByte((USB_ClassInfo_AOA_Host_t*)fdev_get_udata(Stream));
|
||||||
|
|
||||||
if (ReceivedByte < 0)
|
if (ReceivedByte < 0)
|
||||||
return _FDEV_EOF;
|
return _FDEV_EOF;
|
||||||
|
|
||||||
return ReceivedByte;
|
return ReceivedByte;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int AOA_Host_getchar_Blocking(FILE* Stream)
|
static int AOA_Host_getchar_Blocking(FILE* Stream)
|
||||||
{
|
{
|
||||||
int16_t ReceivedByte;
|
int16_t ReceivedByte;
|
||||||
|
|
||||||
while ((ReceivedByte = AOA_Host_ReceiveByte((USB_ClassInfo_AOA_Host_t*)fdev_get_udata(Stream))) < 0)
|
while ((ReceivedByte = AOA_Host_ReceiveByte((USB_ClassInfo_AOA_Host_t*)fdev_get_udata(Stream))) < 0)
|
||||||
{
|
{
|
||||||
if (USB_HostState == HOST_STATE_Unattached)
|
if (USB_HostState == HOST_STATE_Unattached)
|
||||||
return _FDEV_EOF;
|
return _FDEV_EOF;
|
||||||
|
|
||||||
AOA_Host_USBTask((USB_ClassInfo_AOA_Host_t*)fdev_get_udata(Stream));
|
AOA_Host_USBTask((USB_ClassInfo_AOA_Host_t*)fdev_get_udata(Stream));
|
||||||
USB_USBTask();
|
USB_USBTask();
|
||||||
}
|
}
|
||||||
|
|
||||||
return ReceivedByte;
|
return ReceivedByte;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,314 +1,314 @@
|
|||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2012.
|
Copyright (C) Dean Camera, 2012.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.lufa-lib.org
|
www.lufa-lib.org
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||||
|
|
||||||
Permission to use, copy, modify, distribute, and sell this
|
Permission to use, copy, modify, distribute, and sell this
|
||||||
software and its documentation for any purpose is hereby granted
|
software and its documentation for any purpose is hereby granted
|
||||||
without fee, provided that the above copyright notice appear in
|
without fee, provided that the above copyright notice appear in
|
||||||
all copies and that both that the copyright notice and this
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
software, including all implied warranties of merchantability
|
software, including all implied warranties of merchantability
|
||||||
and fitness. In no event shall the author be liable for any
|
and fitness. In no event shall the author be liable for any
|
||||||
special, indirect or consequential damages or any damages
|
special, indirect or consequential damages or any damages
|
||||||
whatsoever resulting from loss of use, data or profits, whether
|
whatsoever resulting from loss of use, data or profits, whether
|
||||||
in an action of contract, negligence or other tortious action,
|
in an action of contract, negligence or other tortious action,
|
||||||
arising out of or in connection with the use or performance of
|
arising out of or in connection with the use or performance of
|
||||||
this software.
|
this software.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \file
|
/** \file
|
||||||
* \brief Host mode driver for the library USB Android Open Accessory Class driver.
|
* \brief Host mode driver for the library USB Android Open Accessory Class driver.
|
||||||
*
|
*
|
||||||
* Host mode driver for the library USB Android Open Accessory Class driver.
|
* Host mode driver for the library USB Android Open Accessory Class driver.
|
||||||
*
|
*
|
||||||
* \note This file should not be included directly. It is automatically included as needed by the USB module driver
|
* \note This file should not be included directly. It is automatically included as needed by the USB module driver
|
||||||
* dispatch header located in LUFA/Drivers/USB.h.
|
* dispatch header located in LUFA/Drivers/USB.h.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \ingroup Group_USBClassAOA
|
/** \ingroup Group_USBClassAOA
|
||||||
* \defgroup Group_USBClassAndroidAccessoryHost Android Open Accessory Class Host Mode Driver
|
* \defgroup Group_USBClassAndroidAccessoryHost Android Open Accessory Class Host Mode Driver
|
||||||
*
|
*
|
||||||
* \section Sec_Dependencies Module Source Dependencies
|
* \section Sec_Dependencies Module Source Dependencies
|
||||||
* The following files must be built with any user project that uses this module:
|
* The following files must be built with any user project that uses this module:
|
||||||
* - LUFA/Drivers/USB/Class/Host/AndroidAccessoryClassHost.c <i>(Makefile source module name: LUFA_SRC_USBCLASS)</i>
|
* - LUFA/Drivers/USB/Class/Host/AndroidAccessoryClassHost.c <i>(Makefile source module name: LUFA_SRC_USBCLASS)</i>
|
||||||
*
|
*
|
||||||
* \section Sec_ModDescription Module Description
|
* \section Sec_ModDescription Module Description
|
||||||
* Host Mode USB Class driver framework interface, for the Android Open Accessory USB Class driver.
|
* Host Mode USB Class driver framework interface, for the Android Open Accessory USB Class driver.
|
||||||
*
|
*
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __AOA_CLASS_HOST_H__
|
#ifndef __AOA_CLASS_HOST_H__
|
||||||
#define __AOA_CLASS_HOST_H__
|
#define __AOA_CLASS_HOST_H__
|
||||||
|
|
||||||
/* Includes: */
|
/* Includes: */
|
||||||
#include "../../USB.h"
|
#include "../../USB.h"
|
||||||
#include "../Common/AndroidAccessoryClassCommon.h"
|
#include "../Common/AndroidAccessoryClassCommon.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
/* Enable C linkage for C++ Compilers: */
|
/* Enable C linkage for C++ Compilers: */
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Preprocessor Checks: */
|
/* Preprocessor Checks: */
|
||||||
#if !defined(__INCLUDE_FROM_AOA_DRIVER)
|
#if !defined(__INCLUDE_FROM_AOA_DRIVER)
|
||||||
#error Do not include this file directly. Include LUFA/Drivers/USB.h instead.
|
#error Do not include this file directly. Include LUFA/Drivers/USB.h instead.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Public Interface - May be used in end-application: */
|
/* Public Interface - May be used in end-application: */
|
||||||
/* Macros: */
|
/* Macros: */
|
||||||
/** Error code for some Android Open Accessory Host functions, indicating a logical (and not hardware) error. */
|
/** Error code for some Android Open Accessory Host functions, indicating a logical (and not hardware) error. */
|
||||||
#define AOA_ERROR_LOGICAL_CMD_FAILED 0x80
|
#define AOA_ERROR_LOGICAL_CMD_FAILED 0x80
|
||||||
|
|
||||||
/* Type Defines: */
|
/* Type Defines: */
|
||||||
/** \brief Android Open Accessory Class Host Mode Configuration and State Structure.
|
/** \brief Android Open Accessory Class Host Mode Configuration and State Structure.
|
||||||
*
|
*
|
||||||
* Class state structure. An instance of this structure should be made within the user application,
|
* Class state structure. An instance of this structure should be made within the user application,
|
||||||
* and passed to each of the Android Open Accessory class driver functions as the \c AOAInterfaceInfo
|
* and passed to each of the Android Open Accessory class driver functions as the \c AOAInterfaceInfo
|
||||||
* parameter. This stores each Android Open Accessory interface's configuration and state information.
|
* parameter. This stores each Android Open Accessory interface's configuration and state information.
|
||||||
*/
|
*/
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
USB_Pipe_Table_t DataINPipe; /**< Data IN Pipe configuration table. */
|
USB_Pipe_Table_t DataINPipe; /**< Data IN Pipe configuration table. */
|
||||||
USB_Pipe_Table_t DataOUTPipe; /**< Data OUT Pipe configuration table. */
|
USB_Pipe_Table_t DataOUTPipe; /**< Data OUT Pipe configuration table. */
|
||||||
|
|
||||||
char* PropertyStrings[AOA_STRING_TOTAL_STRINGS]; /**< Android Accessory property strings, sent to identify the accessory when the
|
char* PropertyStrings[AOA_STRING_TOTAL_STRINGS]; /**< Android Accessory property strings, sent to identify the accessory when the
|
||||||
* Android device is switched into Open Accessory mode. */
|
* Android device is switched into Open Accessory mode. */
|
||||||
} Config; /**< Config data for the USB class interface within the device. All elements in this section
|
} Config; /**< Config data for the USB class interface within the device. All elements in this section
|
||||||
* <b>must</b> be set or the interface will fail to enumerate and operate correctly.
|
* <b>must</b> be set or the interface will fail to enumerate and operate correctly.
|
||||||
*/
|
*/
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
bool IsActive; /**< Indicates if the current interface instance is connected to an attached device, valid
|
bool IsActive; /**< Indicates if the current interface instance is connected to an attached device, valid
|
||||||
* after \ref AOA_Host_ConfigurePipes() is called and the Host state machine is in the
|
* after \ref AOA_Host_ConfigurePipes() is called and the Host state machine is in the
|
||||||
* Configured state.
|
* Configured state.
|
||||||
*/
|
*/
|
||||||
uint8_t InterfaceNumber; /**< Interface index of the AOA interface within the attached device. */
|
uint8_t InterfaceNumber; /**< Interface index of the AOA interface within the attached device. */
|
||||||
} State; /**< State data for the USB class interface within the device. All elements in this section
|
} State; /**< State data for the USB class interface within the device. All elements in this section
|
||||||
* <b>may</b> be set to initial values, but may also be ignored to default to sane values when
|
* <b>may</b> be set to initial values, but may also be ignored to default to sane values when
|
||||||
* the interface is enumerated.
|
* the interface is enumerated.
|
||||||
*/
|
*/
|
||||||
} USB_ClassInfo_AOA_Host_t;
|
} USB_ClassInfo_AOA_Host_t;
|
||||||
|
|
||||||
/* Enums: */
|
/* Enums: */
|
||||||
/** Enum for the possible error codes returned by the \ref AOA_Host_ConfigurePipes() function. */
|
/** Enum for the possible error codes returned by the \ref AOA_Host_ConfigurePipes() function. */
|
||||||
enum AOA_Host_EnumerationFailure_ErrorCodes_t
|
enum AOA_Host_EnumerationFailure_ErrorCodes_t
|
||||||
{
|
{
|
||||||
AOA_ENUMERROR_NoError = 0, /**< Configuration Descriptor was processed successfully. */
|
AOA_ENUMERROR_NoError = 0, /**< Configuration Descriptor was processed successfully. */
|
||||||
AOA_ENUMERROR_InvalidConfigDescriptor = 1, /**< The device returned an invalid Configuration Descriptor. */
|
AOA_ENUMERROR_InvalidConfigDescriptor = 1, /**< The device returned an invalid Configuration Descriptor. */
|
||||||
AOA_ENUMERROR_NoCompatibleInterfaceFound = 2, /**< A compatible Android Open Accessory interface was not found in the device's Configuration Descriptor. */
|
AOA_ENUMERROR_NoCompatibleInterfaceFound = 2, /**< A compatible Android Open Accessory interface was not found in the device's Configuration Descriptor. */
|
||||||
AOA_ENUMERROR_PipeConfigurationFailed = 3, /**< One or more pipes for the specified interface could not be configured correctly. */
|
AOA_ENUMERROR_PipeConfigurationFailed = 3, /**< One or more pipes for the specified interface could not be configured correctly. */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Function Prototypes: */
|
/* Function Prototypes: */
|
||||||
/** General management task for a given Android Open Accessory host class interface, required for the correct operation of the interface.
|
/** General management task for a given Android Open Accessory host class interface, required for the correct operation of the interface.
|
||||||
* This should be called frequently in the main program loop, before the master USB management task \ref USB_USBTask().
|
* This should be called frequently in the main program loop, before the master USB management task \ref USB_USBTask().
|
||||||
*
|
*
|
||||||
* \param[in,out] AOAInterfaceInfo Pointer to a structure containing an Android Open Accessory Class host configuration and state.
|
* \param[in,out] AOAInterfaceInfo Pointer to a structure containing an Android Open Accessory Class host configuration and state.
|
||||||
*/
|
*/
|
||||||
void AOA_Host_USBTask(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
|
void AOA_Host_USBTask(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** Validates a device descriptor, to check if the device is a valid Android device, and if it is currently in Android Open Accessory mode.
|
/** Validates a device descriptor, to check if the device is a valid Android device, and if it is currently in Android Open Accessory mode.
|
||||||
*
|
*
|
||||||
* \param[in,out] AOAInterfaceInfo Pointer to a structure containing an AOA Class host configuration and state.
|
* \param[in,out] AOAInterfaceInfo Pointer to a structure containing an AOA Class host configuration and state.
|
||||||
* \param[in] DeviceDescriptor Pointer a buffer containing the attached device's Device Descriptor.
|
* \param[in] DeviceDescriptor Pointer a buffer containing the attached device's Device Descriptor.
|
||||||
* \param[out] NeedModeSwitch Pointer to a boolean where the mode switch requirement of the attached device is to be stored.
|
* \param[out] NeedModeSwitch Pointer to a boolean where the mode switch requirement of the attached device is to be stored.
|
||||||
*
|
*
|
||||||
* \return Boolean \c true if the attached device is a valid Android device, \c false otherwise.
|
* \return Boolean \c true if the attached device is a valid Android device, \c false otherwise.
|
||||||
*/
|
*/
|
||||||
bool AOA_Host_ValidateAccessoryDevice(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo,
|
bool AOA_Host_ValidateAccessoryDevice(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo,
|
||||||
const USB_Descriptor_Device_t* const DeviceDescriptor,
|
const USB_Descriptor_Device_t* const DeviceDescriptor,
|
||||||
bool* const NeedModeSwitch) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2) ATTR_NON_NULL_PTR_ARG(3);
|
bool* const NeedModeSwitch) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2) ATTR_NON_NULL_PTR_ARG(3);
|
||||||
|
|
||||||
/** Host interface configuration routine, to configure a given Android Open Accessory host interface instance using the Configuration
|
/** Host interface configuration routine, to configure a given Android Open Accessory host interface instance using the Configuration
|
||||||
* Descriptor read from an attached USB device. This function automatically updates the given Android Open Accessory Host instance's
|
* Descriptor read from an attached USB device. This function automatically updates the given Android Open Accessory Host instance's
|
||||||
* state values and configures the pipes required to communicate with the interface if it is found within the device. This should be
|
* state values and configures the pipes required to communicate with the interface if it is found within the device. This should be
|
||||||
* called once after the stack has enumerated the attached device, while the host state machine is in the Addressed state.
|
* called once after the stack has enumerated the attached device, while the host state machine is in the Addressed state.
|
||||||
*
|
*
|
||||||
* \param[in,out] AOAInterfaceInfo Pointer to a structure containing an AOA Class host configuration and state.
|
* \param[in,out] AOAInterfaceInfo Pointer to a structure containing an AOA Class host configuration and state.
|
||||||
* \param[in] ConfigDescriptorSize Length of the attached device's Configuration Descriptor.
|
* \param[in] ConfigDescriptorSize Length of the attached device's Configuration Descriptor.
|
||||||
* \param[in] ConfigDescriptorData Pointer to a buffer containing the attached device's Configuration Descriptor.
|
* \param[in] ConfigDescriptorData Pointer to a buffer containing the attached device's Configuration Descriptor.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref AOA_Host_EnumerationFailure_ErrorCodes_t enum.
|
* \return A value from the \ref AOA_Host_EnumerationFailure_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t AOA_Host_ConfigurePipes(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo,
|
uint8_t AOA_Host_ConfigurePipes(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo,
|
||||||
uint16_t ConfigDescriptorSize,
|
uint16_t ConfigDescriptorSize,
|
||||||
void* ConfigDescriptorData) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(3);
|
void* ConfigDescriptorData) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(3);
|
||||||
|
|
||||||
/** Starts Accessory Mode in the attached Android device. This function will validate the device's Android Open Accessory protocol
|
/** Starts Accessory Mode in the attached Android device. This function will validate the device's Android Open Accessory protocol
|
||||||
* version, send the configured property strings, and request a switch to Android Open Accessory mode.
|
* version, send the configured property strings, and request a switch to Android Open Accessory mode.
|
||||||
*
|
*
|
||||||
* \param[in,out] AOAInterfaceInfo Pointer to a structure containing an AOA Class host configuration and state.
|
* \param[in,out] AOAInterfaceInfo Pointer to a structure containing an AOA Class host configuration and state.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref USB_Host_SendControlErrorCodes_t enum, or \ref AOA_ERROR_LOGICAL_CMD_FAILED if a logical error occurred..
|
* \return A value from the \ref USB_Host_SendControlErrorCodes_t enum, or \ref AOA_ERROR_LOGICAL_CMD_FAILED if a logical error occurred..
|
||||||
*/
|
*/
|
||||||
uint8_t AOA_Host_StartAccessoryMode(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
|
uint8_t AOA_Host_StartAccessoryMode(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** Sends a given data buffer to the attached USB device, if connected. If a device is not connected when the function is
|
/** Sends a given data buffer to the attached USB device, if connected. If a device is not connected when the function is
|
||||||
* called, the data will be discarded. Bytes will be queued for transmission to the device until either the pipe bank
|
* called, the data will be discarded. Bytes will be queued for transmission to the device until either the pipe bank
|
||||||
* becomes full, or the \ref AOA_Host_Flush() function is called to flush the pending data to the device. This allows for
|
* becomes full, or the \ref AOA_Host_Flush() function is called to flush the pending data to the device. This allows for
|
||||||
* multiple bytes to be packed into a single pipe packet, increasing data throughput.
|
* multiple bytes to be packed into a single pipe packet, increasing data throughput.
|
||||||
*
|
*
|
||||||
* \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the
|
* \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the
|
||||||
* call will fail.
|
* call will fail.
|
||||||
*
|
*
|
||||||
* \param[in,out] AOAInterfaceInfo Pointer to a structure containing a AOA Class host configuration and state.
|
* \param[in,out] AOAInterfaceInfo Pointer to a structure containing a AOA Class host configuration and state.
|
||||||
* \param[in] Buffer Pointer to a buffer containing the data to send to the device.
|
* \param[in] Buffer Pointer to a buffer containing the data to send to the device.
|
||||||
* \param[in] Length Length of the data to send to the device.
|
* \param[in] Length Length of the data to send to the device.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t AOA_Host_SendData(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo,
|
uint8_t AOA_Host_SendData(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo,
|
||||||
const uint8_t* const Buffer,
|
const uint8_t* const Buffer,
|
||||||
const uint16_t Length);
|
const uint16_t Length);
|
||||||
|
|
||||||
/** Sends a given null-terminated string to the attached USB device, if connected. If a device is not connected when the
|
/** Sends a given null-terminated string to the attached USB device, if connected. If a device is not connected when the
|
||||||
* function is called, the string is discarded. Bytes will be queued for transmission to the device until either the pipe
|
* function is called, the string is discarded. Bytes will be queued for transmission to the device until either the pipe
|
||||||
* bank becomes full, or the \ref AOA_Host_Flush() function is called to flush the pending data to the device. This allows
|
* bank becomes full, or the \ref AOA_Host_Flush() function is called to flush the pending data to the device. This allows
|
||||||
* for multiple bytes to be packed into a single pipe packet, increasing data throughput.
|
* for multiple bytes to be packed into a single pipe packet, increasing data throughput.
|
||||||
*
|
*
|
||||||
* \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the
|
* \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the
|
||||||
* call will fail.
|
* call will fail.
|
||||||
*
|
*
|
||||||
* \param[in,out] AOAInterfaceInfo Pointer to a structure containing a AOA Class host configuration and state.
|
* \param[in,out] AOAInterfaceInfo Pointer to a structure containing a AOA Class host configuration and state.
|
||||||
* \param[in] String Pointer to the null terminated string to send to the device.
|
* \param[in] String Pointer to the null terminated string to send to the device.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t AOA_Host_SendString(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo,
|
uint8_t AOA_Host_SendString(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo,
|
||||||
const char* const String) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);
|
const char* const String) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);
|
||||||
|
|
||||||
/** Sends a given byte to the attached USB device, if connected. If a device is not connected when the function is called, the
|
/** Sends a given byte to the attached USB device, if connected. If a device is not connected when the function is called, the
|
||||||
* byte is discarded. Bytes will be queued for transmission to the device until either the pipe bank becomes full, or the
|
* byte is discarded. Bytes will be queued for transmission to the device until either the pipe bank becomes full, or the
|
||||||
* \ref AOA_Host_Flush() function is called to flush the pending data to the host. This allows for multiple bytes to be
|
* \ref AOA_Host_Flush() function is called to flush the pending data to the host. This allows for multiple bytes to be
|
||||||
* packed into a single pipe packet, increasing data throughput.
|
* packed into a single pipe packet, increasing data throughput.
|
||||||
*
|
*
|
||||||
* \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the
|
* \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the
|
||||||
* call will fail.
|
* call will fail.
|
||||||
*
|
*
|
||||||
* \param[in,out] AOAInterfaceInfo Pointer to a structure containing a AOA Class host configuration and state.
|
* \param[in,out] AOAInterfaceInfo Pointer to a structure containing a AOA Class host configuration and state.
|
||||||
* \param[in] Data Byte of data to send to the device.
|
* \param[in] Data Byte of data to send to the device.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Pipe_WaitUntilReady_ErrorCodes_t enum.
|
* \return A value from the \ref Pipe_WaitUntilReady_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t AOA_Host_SendByte(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo,
|
uint8_t AOA_Host_SendByte(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo,
|
||||||
const uint8_t Data) ATTR_NON_NULL_PTR_ARG(1);
|
const uint8_t Data) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** Determines the number of bytes received by the AOA interface from the device, waiting to be read. This indicates the number
|
/** Determines the number of bytes received by the AOA interface from the device, waiting to be read. This indicates the number
|
||||||
* of bytes in the IN pipe bank only, and thus the number of calls to \ref AOA_Host_ReceiveByte() which are guaranteed to succeed
|
* of bytes in the IN pipe bank only, and thus the number of calls to \ref AOA_Host_ReceiveByte() which are guaranteed to succeed
|
||||||
* immediately. If multiple bytes are to be received, they should be buffered by the user application, as the pipe bank will not be
|
* immediately. If multiple bytes are to be received, they should be buffered by the user application, as the pipe bank will not be
|
||||||
* released back to the USB controller until all bytes are read.
|
* released back to the USB controller until all bytes are read.
|
||||||
*
|
*
|
||||||
* \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the
|
* \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the
|
||||||
* call will fail.
|
* call will fail.
|
||||||
*
|
*
|
||||||
* \param[in,out] AOAInterfaceInfo Pointer to a structure containing a AOA Class host configuration and state.
|
* \param[in,out] AOAInterfaceInfo Pointer to a structure containing a AOA Class host configuration and state.
|
||||||
*
|
*
|
||||||
* \return Total number of buffered bytes received from the device.
|
* \return Total number of buffered bytes received from the device.
|
||||||
*/
|
*/
|
||||||
uint16_t AOA_Host_BytesReceived(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t AOA_Host_BytesReceived(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** Reads a byte of data from the device. If no data is waiting to be read of if a USB device is not connected, the function
|
/** Reads a byte of data from the device. If no data is waiting to be read of if a USB device is not connected, the function
|
||||||
* returns a negative value. The \ref AOA_Host_BytesReceived() function may be queried in advance to determine how many bytes
|
* returns a negative value. The \ref AOA_Host_BytesReceived() function may be queried in advance to determine how many bytes
|
||||||
* are currently buffered in the AOA interface's data receive pipe.
|
* are currently buffered in the AOA interface's data receive pipe.
|
||||||
*
|
*
|
||||||
* \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the
|
* \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the
|
||||||
* call will fail.
|
* call will fail.
|
||||||
*
|
*
|
||||||
* \param[in,out] AOAInterfaceInfo Pointer to a structure containing a AOA Class host configuration and state.
|
* \param[in,out] AOAInterfaceInfo Pointer to a structure containing a AOA Class host configuration and state.
|
||||||
*
|
*
|
||||||
* \return Next received byte from the device, or a negative value if no data received.
|
* \return Next received byte from the device, or a negative value if no data received.
|
||||||
*/
|
*/
|
||||||
int16_t AOA_Host_ReceiveByte(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
|
int16_t AOA_Host_ReceiveByte(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** Flushes any data waiting to be sent, ensuring that the send buffer is cleared.
|
/** Flushes any data waiting to be sent, ensuring that the send buffer is cleared.
|
||||||
*
|
*
|
||||||
* \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the
|
* \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the
|
||||||
* call will fail.
|
* call will fail.
|
||||||
*
|
*
|
||||||
* \param[in,out] AOAInterfaceInfo Pointer to a structure containing a AOA Class host configuration and state.
|
* \param[in,out] AOAInterfaceInfo Pointer to a structure containing a AOA Class host configuration and state.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Pipe_WaitUntilReady_ErrorCodes_t enum.
|
* \return A value from the \ref Pipe_WaitUntilReady_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t AOA_Host_Flush(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
|
uint8_t AOA_Host_Flush(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** Creates a standard character stream for the given AOA Device instance so that it can be used with all the regular
|
/** Creates a standard character stream for the given AOA Device instance so that it can be used with all the regular
|
||||||
* functions in the standard \c <stdio.h> library that accept a \c FILE stream as a destination (e.g. \c fprintf). The created
|
* functions in the standard \c <stdio.h> library that accept a \c FILE stream as a destination (e.g. \c fprintf). The created
|
||||||
* stream is bidirectional and can be used for both input and output functions.
|
* stream is bidirectional and can be used for both input and output functions.
|
||||||
*
|
*
|
||||||
* Reading data from this stream is non-blocking, i.e. in most instances, complete strings cannot be read in by a single
|
* Reading data from this stream is non-blocking, i.e. in most instances, complete strings cannot be read in by a single
|
||||||
* fetch, as the endpoint will not be ready at some point in the transmission, aborting the transfer. However, this may
|
* fetch, as the endpoint will not be ready at some point in the transmission, aborting the transfer. However, this may
|
||||||
* be used when the read data is processed byte-per-bye (via \c getc()) or when the user application will implement its own
|
* be used when the read data is processed byte-per-bye (via \c getc()) or when the user application will implement its own
|
||||||
* line buffering.
|
* line buffering.
|
||||||
*
|
*
|
||||||
* \note The created stream can be given as \c stdout if desired to direct the standard output from all \c <stdio.h> functions
|
* \note The created stream can be given as \c stdout if desired to direct the standard output from all \c <stdio.h> functions
|
||||||
* to the given AOA interface.
|
* to the given AOA interface.
|
||||||
* \n\n
|
* \n\n
|
||||||
*
|
*
|
||||||
* \note This function is not available on all microcontroller architectures.
|
* \note This function is not available on all microcontroller architectures.
|
||||||
*
|
*
|
||||||
* \param[in,out] AOAInterfaceInfo Pointer to a structure containing a AOA Class configuration and state.
|
* \param[in,out] AOAInterfaceInfo Pointer to a structure containing a AOA Class configuration and state.
|
||||||
* \param[in,out] Stream Pointer to a FILE structure where the created stream should be placed.
|
* \param[in,out] Stream Pointer to a FILE structure where the created stream should be placed.
|
||||||
*/
|
*/
|
||||||
void AOA_Host_CreateStream(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo,
|
void AOA_Host_CreateStream(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo,
|
||||||
FILE* const Stream);
|
FILE* const Stream);
|
||||||
|
|
||||||
/** Identical to \ref AOA_Host_CreateStream(), except that reads are blocking until the calling stream function terminates
|
/** Identical to \ref AOA_Host_CreateStream(), except that reads are blocking until the calling stream function terminates
|
||||||
* the transfer. While blocking, the USB and AOA service tasks are called repeatedly to maintain USB communications.
|
* the transfer. While blocking, the USB and AOA service tasks are called repeatedly to maintain USB communications.
|
||||||
*
|
*
|
||||||
* \note This function is not available on all microcontroller architectures.
|
* \note This function is not available on all microcontroller architectures.
|
||||||
*
|
*
|
||||||
* \param[in,out] AOAInterfaceInfo Pointer to a structure containing a AOA Class configuration and state.
|
* \param[in,out] AOAInterfaceInfo Pointer to a structure containing a AOA Class configuration and state.
|
||||||
* \param[in,out] Stream Pointer to a FILE structure where the created stream should be placed.
|
* \param[in,out] Stream Pointer to a FILE structure where the created stream should be placed.
|
||||||
*/
|
*/
|
||||||
void AOA_Host_CreateBlockingStream(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo,
|
void AOA_Host_CreateBlockingStream(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo,
|
||||||
FILE* const Stream);
|
FILE* const Stream);
|
||||||
|
|
||||||
/* Private Interface - For use in library only: */
|
/* Private Interface - For use in library only: */
|
||||||
#if !defined(__DOXYGEN__)
|
#if !defined(__DOXYGEN__)
|
||||||
/* Function Prototypes: */
|
/* Function Prototypes: */
|
||||||
#if defined(__INCLUDE_FROM_ANDROIDACCESSORY_HOST_C)
|
#if defined(__INCLUDE_FROM_ANDROIDACCESSORY_HOST_C)
|
||||||
#if defined(FDEV_SETUP_STREAM)
|
#if defined(FDEV_SETUP_STREAM)
|
||||||
static int AOA_Host_putchar(char c,
|
static int AOA_Host_putchar(char c,
|
||||||
FILE* Stream) ATTR_NON_NULL_PTR_ARG(2);
|
FILE* Stream) ATTR_NON_NULL_PTR_ARG(2);
|
||||||
static int AOA_Host_getchar(FILE* Stream) ATTR_NON_NULL_PTR_ARG(1);
|
static int AOA_Host_getchar(FILE* Stream) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
static int AOA_Host_getchar_Blocking(FILE* Stream) ATTR_NON_NULL_PTR_ARG(1);
|
static int AOA_Host_getchar_Blocking(FILE* Stream) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static uint8_t AOA_Host_GetAccessoryProtocol(uint16_t* const Protocol) ATTR_NON_NULL_PTR_ARG(1);
|
static uint8_t AOA_Host_GetAccessoryProtocol(uint16_t* const Protocol) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
static uint8_t AOA_Host_SendPropertyString(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo,
|
static uint8_t AOA_Host_SendPropertyString(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo,
|
||||||
const uint8_t StringIndex) ATTR_NON_NULL_PTR_ARG(1);
|
const uint8_t StringIndex) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
static uint8_t DCOMP_AOA_Host_NextAndroidAccessoryInterface(void* const CurrentDescriptor)
|
static uint8_t DCOMP_AOA_Host_NextAndroidAccessoryInterface(void* const CurrentDescriptor)
|
||||||
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1);
|
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1);
|
||||||
static uint8_t DCOMP_AOA_Host_NextInterfaceBulkEndpoint(void* const CurrentDescriptor)
|
static uint8_t DCOMP_AOA_Host_NextInterfaceBulkEndpoint(void* const CurrentDescriptor)
|
||||||
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1);
|
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Disable C linkage for C++ Compilers: */
|
/* Disable C linkage for C++ Compilers: */
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,275 +1,275 @@
|
|||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2012.
|
Copyright (C) Dean Camera, 2012.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.lufa-lib.org
|
www.lufa-lib.org
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||||
|
|
||||||
Permission to use, copy, modify, distribute, and sell this
|
Permission to use, copy, modify, distribute, and sell this
|
||||||
software and its documentation for any purpose is hereby granted
|
software and its documentation for any purpose is hereby granted
|
||||||
without fee, provided that the above copyright notice appear in
|
without fee, provided that the above copyright notice appear in
|
||||||
all copies and that both that the copyright notice and this
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
software, including all implied warranties of merchantability
|
software, including all implied warranties of merchantability
|
||||||
and fitness. In no event shall the author be liable for any
|
and fitness. In no event shall the author be liable for any
|
||||||
special, indirect or consequential damages or any damages
|
special, indirect or consequential damages or any damages
|
||||||
whatsoever resulting from loss of use, data or profits, whether
|
whatsoever resulting from loss of use, data or profits, whether
|
||||||
in an action of contract, negligence or other tortious action,
|
in an action of contract, negligence or other tortious action,
|
||||||
arising out of or in connection with the use or performance of
|
arising out of or in connection with the use or performance of
|
||||||
this software.
|
this software.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../../../../Common/Common.h"
|
#include "../../../../Common/Common.h"
|
||||||
#if (ARCH == ARCH_AVR8)
|
#if (ARCH == ARCH_AVR8)
|
||||||
|
|
||||||
#define __INCLUDE_FROM_USB_DRIVER
|
#define __INCLUDE_FROM_USB_DRIVER
|
||||||
#include "../USBMode.h"
|
#include "../USBMode.h"
|
||||||
|
|
||||||
#if defined(USB_CAN_BE_DEVICE)
|
#if defined(USB_CAN_BE_DEVICE)
|
||||||
|
|
||||||
#include "EndpointStream_AVR8.h"
|
#include "EndpointStream_AVR8.h"
|
||||||
|
|
||||||
#if !defined(CONTROL_ONLY_DEVICE)
|
#if !defined(CONTROL_ONLY_DEVICE)
|
||||||
uint8_t Endpoint_Discard_Stream(uint16_t Length,
|
uint8_t Endpoint_Discard_Stream(uint16_t Length,
|
||||||
uint16_t* const BytesProcessed)
|
uint16_t* const BytesProcessed)
|
||||||
{
|
{
|
||||||
uint8_t ErrorCode;
|
uint8_t ErrorCode;
|
||||||
uint16_t BytesInTransfer = 0;
|
uint16_t BytesInTransfer = 0;
|
||||||
|
|
||||||
if ((ErrorCode = Endpoint_WaitUntilReady()))
|
if ((ErrorCode = Endpoint_WaitUntilReady()))
|
||||||
return ErrorCode;
|
return ErrorCode;
|
||||||
|
|
||||||
if (BytesProcessed != NULL)
|
if (BytesProcessed != NULL)
|
||||||
Length -= *BytesProcessed;
|
Length -= *BytesProcessed;
|
||||||
|
|
||||||
while (Length)
|
while (Length)
|
||||||
{
|
{
|
||||||
if (!(Endpoint_IsReadWriteAllowed()))
|
if (!(Endpoint_IsReadWriteAllowed()))
|
||||||
{
|
{
|
||||||
Endpoint_ClearOUT();
|
Endpoint_ClearOUT();
|
||||||
|
|
||||||
if (BytesProcessed != NULL)
|
if (BytesProcessed != NULL)
|
||||||
{
|
{
|
||||||
*BytesProcessed += BytesInTransfer;
|
*BytesProcessed += BytesInTransfer;
|
||||||
return ENDPOINT_RWSTREAM_IncompleteTransfer;
|
return ENDPOINT_RWSTREAM_IncompleteTransfer;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ErrorCode = Endpoint_WaitUntilReady()))
|
if ((ErrorCode = Endpoint_WaitUntilReady()))
|
||||||
return ErrorCode;
|
return ErrorCode;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Endpoint_Discard_8();
|
Endpoint_Discard_8();
|
||||||
|
|
||||||
Length--;
|
Length--;
|
||||||
BytesInTransfer++;
|
BytesInTransfer++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ENDPOINT_RWSTREAM_NoError;
|
return ENDPOINT_RWSTREAM_NoError;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t Endpoint_Null_Stream(uint16_t Length,
|
uint8_t Endpoint_Null_Stream(uint16_t Length,
|
||||||
uint16_t* const BytesProcessed)
|
uint16_t* const BytesProcessed)
|
||||||
{
|
{
|
||||||
uint8_t ErrorCode;
|
uint8_t ErrorCode;
|
||||||
uint16_t BytesInTransfer = 0;
|
uint16_t BytesInTransfer = 0;
|
||||||
|
|
||||||
if ((ErrorCode = Endpoint_WaitUntilReady()))
|
if ((ErrorCode = Endpoint_WaitUntilReady()))
|
||||||
return ErrorCode;
|
return ErrorCode;
|
||||||
|
|
||||||
if (BytesProcessed != NULL)
|
if (BytesProcessed != NULL)
|
||||||
Length -= *BytesProcessed;
|
Length -= *BytesProcessed;
|
||||||
|
|
||||||
while (Length)
|
while (Length)
|
||||||
{
|
{
|
||||||
if (!(Endpoint_IsReadWriteAllowed()))
|
if (!(Endpoint_IsReadWriteAllowed()))
|
||||||
{
|
{
|
||||||
Endpoint_ClearIN();
|
Endpoint_ClearIN();
|
||||||
|
|
||||||
if (BytesProcessed != NULL)
|
if (BytesProcessed != NULL)
|
||||||
{
|
{
|
||||||
*BytesProcessed += BytesInTransfer;
|
*BytesProcessed += BytesInTransfer;
|
||||||
return ENDPOINT_RWSTREAM_IncompleteTransfer;
|
return ENDPOINT_RWSTREAM_IncompleteTransfer;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ErrorCode = Endpoint_WaitUntilReady()))
|
if ((ErrorCode = Endpoint_WaitUntilReady()))
|
||||||
return ErrorCode;
|
return ErrorCode;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Endpoint_Write_8(0);
|
Endpoint_Write_8(0);
|
||||||
|
|
||||||
Length--;
|
Length--;
|
||||||
BytesInTransfer++;
|
BytesInTransfer++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ENDPOINT_RWSTREAM_NoError;
|
return ENDPOINT_RWSTREAM_NoError;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The following abuses the C preprocessor in order to copy-paste common code with slight alterations,
|
/* The following abuses the C preprocessor in order to copy-paste common code with slight alterations,
|
||||||
* so that the code needs to be written once. It is a crude form of templating to reduce code maintenance. */
|
* so that the code needs to be written once. It is a crude form of templating to reduce code maintenance. */
|
||||||
|
|
||||||
#define TEMPLATE_FUNC_NAME Endpoint_Write_Stream_LE
|
#define TEMPLATE_FUNC_NAME Endpoint_Write_Stream_LE
|
||||||
#define TEMPLATE_BUFFER_TYPE const void*
|
#define TEMPLATE_BUFFER_TYPE const void*
|
||||||
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()
|
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr)
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr)
|
||||||
#include "Template/Template_Endpoint_RW.c"
|
#include "Template/Template_Endpoint_RW.c"
|
||||||
|
|
||||||
#define TEMPLATE_FUNC_NAME Endpoint_Write_Stream_BE
|
#define TEMPLATE_FUNC_NAME Endpoint_Write_Stream_BE
|
||||||
#define TEMPLATE_BUFFER_TYPE const void*
|
#define TEMPLATE_BUFFER_TYPE const void*
|
||||||
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()
|
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr)
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr)
|
||||||
#include "Template/Template_Endpoint_RW.c"
|
#include "Template/Template_Endpoint_RW.c"
|
||||||
|
|
||||||
#define TEMPLATE_FUNC_NAME Endpoint_Read_Stream_LE
|
#define TEMPLATE_FUNC_NAME Endpoint_Read_Stream_LE
|
||||||
#define TEMPLATE_BUFFER_TYPE void*
|
#define TEMPLATE_BUFFER_TYPE void*
|
||||||
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT()
|
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT()
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8()
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8()
|
||||||
#include "Template/Template_Endpoint_RW.c"
|
#include "Template/Template_Endpoint_RW.c"
|
||||||
|
|
||||||
#define TEMPLATE_FUNC_NAME Endpoint_Read_Stream_BE
|
#define TEMPLATE_FUNC_NAME Endpoint_Read_Stream_BE
|
||||||
#define TEMPLATE_BUFFER_TYPE void*
|
#define TEMPLATE_BUFFER_TYPE void*
|
||||||
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT()
|
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT()
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8()
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8()
|
||||||
#include "Template/Template_Endpoint_RW.c"
|
#include "Template/Template_Endpoint_RW.c"
|
||||||
|
|
||||||
#if defined(ARCH_HAS_FLASH_ADDRESS_SPACE)
|
#if defined(ARCH_HAS_FLASH_ADDRESS_SPACE)
|
||||||
#define TEMPLATE_FUNC_NAME Endpoint_Write_PStream_LE
|
#define TEMPLATE_FUNC_NAME Endpoint_Write_PStream_LE
|
||||||
#define TEMPLATE_BUFFER_TYPE const void*
|
#define TEMPLATE_BUFFER_TYPE const void*
|
||||||
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()
|
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(pgm_read_byte(BufferPtr))
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(pgm_read_byte(BufferPtr))
|
||||||
#include "Template/Template_Endpoint_RW.c"
|
#include "Template/Template_Endpoint_RW.c"
|
||||||
|
|
||||||
#define TEMPLATE_FUNC_NAME Endpoint_Write_PStream_BE
|
#define TEMPLATE_FUNC_NAME Endpoint_Write_PStream_BE
|
||||||
#define TEMPLATE_BUFFER_TYPE const void*
|
#define TEMPLATE_BUFFER_TYPE const void*
|
||||||
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()
|
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(pgm_read_byte(BufferPtr))
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(pgm_read_byte(BufferPtr))
|
||||||
#include "Template/Template_Endpoint_RW.c"
|
#include "Template/Template_Endpoint_RW.c"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(ARCH_HAS_EEPROM_ADDRESS_SPACE)
|
#if defined(ARCH_HAS_EEPROM_ADDRESS_SPACE)
|
||||||
#define TEMPLATE_FUNC_NAME Endpoint_Write_EStream_LE
|
#define TEMPLATE_FUNC_NAME Endpoint_Write_EStream_LE
|
||||||
#define TEMPLATE_BUFFER_TYPE const void*
|
#define TEMPLATE_BUFFER_TYPE const void*
|
||||||
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()
|
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(eeprom_read_byte(BufferPtr))
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(eeprom_read_byte(BufferPtr))
|
||||||
#include "Template/Template_Endpoint_RW.c"
|
#include "Template/Template_Endpoint_RW.c"
|
||||||
|
|
||||||
#define TEMPLATE_FUNC_NAME Endpoint_Write_EStream_BE
|
#define TEMPLATE_FUNC_NAME Endpoint_Write_EStream_BE
|
||||||
#define TEMPLATE_BUFFER_TYPE const void*
|
#define TEMPLATE_BUFFER_TYPE const void*
|
||||||
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()
|
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(eeprom_read_byte(BufferPtr))
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(eeprom_read_byte(BufferPtr))
|
||||||
#include "Template/Template_Endpoint_RW.c"
|
#include "Template/Template_Endpoint_RW.c"
|
||||||
|
|
||||||
#define TEMPLATE_FUNC_NAME Endpoint_Read_EStream_LE
|
#define TEMPLATE_FUNC_NAME Endpoint_Read_EStream_LE
|
||||||
#define TEMPLATE_BUFFER_TYPE void*
|
#define TEMPLATE_BUFFER_TYPE void*
|
||||||
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT()
|
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT()
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Endpoint_Read_8())
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Endpoint_Read_8())
|
||||||
#include "Template/Template_Endpoint_RW.c"
|
#include "Template/Template_Endpoint_RW.c"
|
||||||
|
|
||||||
#define TEMPLATE_FUNC_NAME Endpoint_Read_EStream_BE
|
#define TEMPLATE_FUNC_NAME Endpoint_Read_EStream_BE
|
||||||
#define TEMPLATE_BUFFER_TYPE void*
|
#define TEMPLATE_BUFFER_TYPE void*
|
||||||
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT()
|
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT()
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Endpoint_Read_8())
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Endpoint_Read_8())
|
||||||
#include "Template/Template_Endpoint_RW.c"
|
#include "Template/Template_Endpoint_RW.c"
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_Stream_LE
|
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
|
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr)
|
|
||||||
#include "Template/Template_Endpoint_Control_W.c"
|
|
||||||
|
|
||||||
#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_Stream_BE
|
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
|
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr)
|
|
||||||
#include "Template/Template_Endpoint_Control_W.c"
|
|
||||||
|
|
||||||
#define TEMPLATE_FUNC_NAME Endpoint_Read_Control_Stream_LE
|
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
|
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8()
|
|
||||||
#include "Template/Template_Endpoint_Control_R.c"
|
|
||||||
|
|
||||||
#define TEMPLATE_FUNC_NAME Endpoint_Read_Control_Stream_BE
|
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
|
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8()
|
|
||||||
#include "Template/Template_Endpoint_Control_R.c"
|
|
||||||
|
|
||||||
#if defined(ARCH_HAS_FLASH_ADDRESS_SPACE)
|
|
||||||
#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_PStream_LE
|
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
|
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(pgm_read_byte(BufferPtr))
|
|
||||||
#include "Template/Template_Endpoint_Control_W.c"
|
|
||||||
|
|
||||||
#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_PStream_BE
|
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
|
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(pgm_read_byte(BufferPtr))
|
|
||||||
#include "Template/Template_Endpoint_Control_W.c"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(ARCH_HAS_EEPROM_ADDRESS_SPACE)
|
|
||||||
#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_EStream_LE
|
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
|
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(eeprom_read_byte(BufferPtr))
|
|
||||||
#include "Template/Template_Endpoint_Control_W.c"
|
|
||||||
|
|
||||||
#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_EStream_BE
|
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
|
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(eeprom_read_byte(BufferPtr))
|
|
||||||
#include "Template/Template_Endpoint_Control_W.c"
|
|
||||||
|
|
||||||
#define TEMPLATE_FUNC_NAME Endpoint_Read_Control_EStream_LE
|
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
|
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Endpoint_Read_8())
|
|
||||||
#include "Template/Template_Endpoint_Control_R.c"
|
|
||||||
|
|
||||||
#define TEMPLATE_FUNC_NAME Endpoint_Read_Control_EStream_BE
|
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
|
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Endpoint_Read_8())
|
|
||||||
#include "Template/Template_Endpoint_Control_R.c"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_Stream_LE
|
||||||
|
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
||||||
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
|
||||||
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr)
|
||||||
|
#include "Template/Template_Endpoint_Control_W.c"
|
||||||
|
|
||||||
|
#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_Stream_BE
|
||||||
|
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
||||||
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
|
||||||
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr)
|
||||||
|
#include "Template/Template_Endpoint_Control_W.c"
|
||||||
|
|
||||||
|
#define TEMPLATE_FUNC_NAME Endpoint_Read_Control_Stream_LE
|
||||||
|
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
||||||
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
|
||||||
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8()
|
||||||
|
#include "Template/Template_Endpoint_Control_R.c"
|
||||||
|
|
||||||
|
#define TEMPLATE_FUNC_NAME Endpoint_Read_Control_Stream_BE
|
||||||
|
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
||||||
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
|
||||||
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8()
|
||||||
|
#include "Template/Template_Endpoint_Control_R.c"
|
||||||
|
|
||||||
|
#if defined(ARCH_HAS_FLASH_ADDRESS_SPACE)
|
||||||
|
#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_PStream_LE
|
||||||
|
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
||||||
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
|
||||||
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(pgm_read_byte(BufferPtr))
|
||||||
|
#include "Template/Template_Endpoint_Control_W.c"
|
||||||
|
|
||||||
|
#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_PStream_BE
|
||||||
|
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
||||||
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
|
||||||
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(pgm_read_byte(BufferPtr))
|
||||||
|
#include "Template/Template_Endpoint_Control_W.c"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(ARCH_HAS_EEPROM_ADDRESS_SPACE)
|
||||||
|
#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_EStream_LE
|
||||||
|
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
||||||
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
|
||||||
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(eeprom_read_byte(BufferPtr))
|
||||||
|
#include "Template/Template_Endpoint_Control_W.c"
|
||||||
|
|
||||||
|
#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_EStream_BE
|
||||||
|
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
||||||
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
|
||||||
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(eeprom_read_byte(BufferPtr))
|
||||||
|
#include "Template/Template_Endpoint_Control_W.c"
|
||||||
|
|
||||||
|
#define TEMPLATE_FUNC_NAME Endpoint_Read_Control_EStream_LE
|
||||||
|
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
||||||
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
|
||||||
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Endpoint_Read_8())
|
||||||
|
#include "Template/Template_Endpoint_Control_R.c"
|
||||||
|
|
||||||
|
#define TEMPLATE_FUNC_NAME Endpoint_Read_Control_EStream_BE
|
||||||
|
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
||||||
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
|
||||||
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Endpoint_Read_8())
|
||||||
|
#include "Template/Template_Endpoint_Control_R.c"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@ -1,648 +1,648 @@
|
|||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2012.
|
Copyright (C) Dean Camera, 2012.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.lufa-lib.org
|
www.lufa-lib.org
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||||
|
|
||||||
Permission to use, copy, modify, distribute, and sell this
|
Permission to use, copy, modify, distribute, and sell this
|
||||||
software and its documentation for any purpose is hereby granted
|
software and its documentation for any purpose is hereby granted
|
||||||
without fee, provided that the above copyright notice appear in
|
without fee, provided that the above copyright notice appear in
|
||||||
all copies and that both that the copyright notice and this
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
software, including all implied warranties of merchantability
|
software, including all implied warranties of merchantability
|
||||||
and fitness. In no event shall the author be liable for any
|
and fitness. In no event shall the author be liable for any
|
||||||
special, indirect or consequential damages or any damages
|
special, indirect or consequential damages or any damages
|
||||||
whatsoever resulting from loss of use, data or profits, whether
|
whatsoever resulting from loss of use, data or profits, whether
|
||||||
in an action of contract, negligence or other tortious action,
|
in an action of contract, negligence or other tortious action,
|
||||||
arising out of or in connection with the use or performance of
|
arising out of or in connection with the use or performance of
|
||||||
this software.
|
this software.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \file
|
/** \file
|
||||||
* \brief Endpoint data stream transmission and reception management for the AVR8 microcontrollers.
|
* \brief Endpoint data stream transmission and reception management for the AVR8 microcontrollers.
|
||||||
* \copydetails Group_EndpointStreamRW_AVR8
|
* \copydetails Group_EndpointStreamRW_AVR8
|
||||||
*
|
*
|
||||||
* \note This file should not be included directly. It is automatically included as needed by the USB driver
|
* \note This file should not be included directly. It is automatically included as needed by the USB driver
|
||||||
* dispatch header located in LUFA/Drivers/USB/USB.h.
|
* dispatch header located in LUFA/Drivers/USB/USB.h.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \ingroup Group_EndpointStreamRW
|
/** \ingroup Group_EndpointStreamRW
|
||||||
* \defgroup Group_EndpointStreamRW_AVR8 Read/Write of Multi-Byte Streams (AVR8)
|
* \defgroup Group_EndpointStreamRW_AVR8 Read/Write of Multi-Byte Streams (AVR8)
|
||||||
* \brief Endpoint data stream transmission and reception management for the Atmel AVR8 architecture.
|
* \brief Endpoint data stream transmission and reception management for the Atmel AVR8 architecture.
|
||||||
*
|
*
|
||||||
* Functions, macros, variables, enums and types related to data reading and writing of data streams from
|
* Functions, macros, variables, enums and types related to data reading and writing of data streams from
|
||||||
* and to endpoints.
|
* and to endpoints.
|
||||||
*
|
*
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __ENDPOINT_STREAM_AVR8_H__
|
#ifndef __ENDPOINT_STREAM_AVR8_H__
|
||||||
#define __ENDPOINT_STREAM_AVR8_H__
|
#define __ENDPOINT_STREAM_AVR8_H__
|
||||||
|
|
||||||
/* Includes: */
|
/* Includes: */
|
||||||
#include "../../../../Common/Common.h"
|
#include "../../../../Common/Common.h"
|
||||||
#include "../USBMode.h"
|
#include "../USBMode.h"
|
||||||
#include "../USBTask.h"
|
#include "../USBTask.h"
|
||||||
|
|
||||||
/* Enable C linkage for C++ Compilers: */
|
/* Enable C linkage for C++ Compilers: */
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Preprocessor Checks: */
|
/* Preprocessor Checks: */
|
||||||
#if !defined(__INCLUDE_FROM_USB_DRIVER)
|
#if !defined(__INCLUDE_FROM_USB_DRIVER)
|
||||||
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
|
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Public Interface - May be used in end-application: */
|
/* Public Interface - May be used in end-application: */
|
||||||
/* Function Prototypes: */
|
/* Function Prototypes: */
|
||||||
/** \name Stream functions for null data */
|
/** \name Stream functions for null data */
|
||||||
//@{
|
//@{
|
||||||
|
|
||||||
/** Reads and discards the given number of bytes from the currently selected endpoint's bank,
|
/** Reads and discards the given number of bytes from the currently selected endpoint's bank,
|
||||||
* discarding fully read packets from the host as needed. The last packet is not automatically
|
* discarding fully read packets from the host as needed. The last packet is not automatically
|
||||||
* discarded once the remaining bytes has been read; the user is responsible for manually
|
* discarded once the remaining bytes has been read; the user is responsible for manually
|
||||||
* discarding the last packet from the host via the \ref Endpoint_ClearOUT() macro.
|
* discarding the last packet from the host via the \ref Endpoint_ClearOUT() macro.
|
||||||
*
|
*
|
||||||
* If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once,
|
* If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once,
|
||||||
* failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid
|
* failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid
|
||||||
* storage location, the transfer will instead be performed as a series of chunks. Each time
|
* storage location, the transfer will instead be performed as a series of chunks. Each time
|
||||||
* the endpoint bank becomes empty while there is still data to process (and after the current
|
* the endpoint bank becomes empty while there is still data to process (and after the current
|
||||||
* packet has been acknowledged) the BytesProcessed location will be updated with the total number
|
* packet has been acknowledged) the BytesProcessed location will be updated with the total number
|
||||||
* of bytes processed in the stream, and the function will exit with an error code of
|
* of bytes processed in the stream, and the function will exit with an error code of
|
||||||
* \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed
|
* \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed
|
||||||
* in the user code - to continue the transfer, call the function again with identical parameters
|
* in the user code - to continue the transfer, call the function again with identical parameters
|
||||||
* and it will resume until the BytesProcessed value reaches the total transfer length.
|
* and it will resume until the BytesProcessed value reaches the total transfer length.
|
||||||
*
|
*
|
||||||
* <b>Single Stream Transfer Example:</b>
|
* <b>Single Stream Transfer Example:</b>
|
||||||
* \code
|
* \code
|
||||||
* uint8_t ErrorCode;
|
* uint8_t ErrorCode;
|
||||||
*
|
*
|
||||||
* if ((ErrorCode = Endpoint_Discard_Stream(512, NULL)) != ENDPOINT_RWSTREAM_NoError)
|
* if ((ErrorCode = Endpoint_Discard_Stream(512, NULL)) != ENDPOINT_RWSTREAM_NoError)
|
||||||
* {
|
* {
|
||||||
* // Stream failed to complete - check ErrorCode here
|
* // Stream failed to complete - check ErrorCode here
|
||||||
* }
|
* }
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* <b>Partial Stream Transfers Example:</b>
|
* <b>Partial Stream Transfers Example:</b>
|
||||||
* \code
|
* \code
|
||||||
* uint8_t ErrorCode;
|
* uint8_t ErrorCode;
|
||||||
* uint16_t BytesProcessed;
|
* uint16_t BytesProcessed;
|
||||||
*
|
*
|
||||||
* BytesProcessed = 0;
|
* BytesProcessed = 0;
|
||||||
* while ((ErrorCode = Endpoint_Discard_Stream(512, &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer)
|
* while ((ErrorCode = Endpoint_Discard_Stream(512, &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer)
|
||||||
* {
|
* {
|
||||||
* // Stream not yet complete - do other actions here, abort if required
|
* // Stream not yet complete - do other actions here, abort if required
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* if (ErrorCode != ENDPOINT_RWSTREAM_NoError)
|
* if (ErrorCode != ENDPOINT_RWSTREAM_NoError)
|
||||||
* {
|
* {
|
||||||
* // Stream failed to complete - check ErrorCode here
|
* // Stream failed to complete - check ErrorCode here
|
||||||
* }
|
* }
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* \note This routine should not be used on CONTROL type endpoints.
|
* \note This routine should not be used on CONTROL type endpoints.
|
||||||
*
|
*
|
||||||
* \param[in] Length Number of bytes to discard via the currently selected endpoint.
|
* \param[in] Length Number of bytes to discard via the currently selected endpoint.
|
||||||
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
||||||
* transaction should be updated, \c NULL if the entire stream should be read at once.
|
* transaction should be updated, \c NULL if the entire stream should be read at once.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Endpoint_Discard_Stream(uint16_t Length,
|
uint8_t Endpoint_Discard_Stream(uint16_t Length,
|
||||||
uint16_t* const BytesProcessed);
|
uint16_t* const BytesProcessed);
|
||||||
|
|
||||||
/** Writes a given number of zeroed bytes to the currently selected endpoint's bank, sending
|
/** Writes a given number of zeroed bytes to the currently selected endpoint's bank, sending
|
||||||
* full packets to the host as needed. The last packet is not automatically sent once the
|
* full packets to the host as needed. The last packet is not automatically sent once the
|
||||||
* remaining bytes have been written; the user is responsible for manually sending the last
|
* remaining bytes have been written; the user is responsible for manually sending the last
|
||||||
* packet to the host via the \ref Endpoint_ClearIN() macro.
|
* packet to the host via the \ref Endpoint_ClearIN() macro.
|
||||||
*
|
*
|
||||||
* If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once,
|
* If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once,
|
||||||
* failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid
|
* failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid
|
||||||
* storage location, the transfer will instead be performed as a series of chunks. Each time
|
* storage location, the transfer will instead be performed as a series of chunks. Each time
|
||||||
* the endpoint bank becomes full while there is still data to process (and after the current
|
* the endpoint bank becomes full while there is still data to process (and after the current
|
||||||
* packet transmission has been initiated) the BytesProcessed location will be updated with the
|
* packet transmission has been initiated) the BytesProcessed location will be updated with the
|
||||||
* total number of bytes processed in the stream, and the function will exit with an error code of
|
* total number of bytes processed in the stream, and the function will exit with an error code of
|
||||||
* \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed
|
* \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed
|
||||||
* in the user code - to continue the transfer, call the function again with identical parameters
|
* in the user code - to continue the transfer, call the function again with identical parameters
|
||||||
* and it will resume until the BytesProcessed value reaches the total transfer length.
|
* and it will resume until the BytesProcessed value reaches the total transfer length.
|
||||||
*
|
*
|
||||||
* <b>Single Stream Transfer Example:</b>
|
* <b>Single Stream Transfer Example:</b>
|
||||||
* \code
|
* \code
|
||||||
* uint8_t ErrorCode;
|
* uint8_t ErrorCode;
|
||||||
*
|
*
|
||||||
* if ((ErrorCode = Endpoint_Null_Stream(512, NULL)) != ENDPOINT_RWSTREAM_NoError)
|
* if ((ErrorCode = Endpoint_Null_Stream(512, NULL)) != ENDPOINT_RWSTREAM_NoError)
|
||||||
* {
|
* {
|
||||||
* // Stream failed to complete - check ErrorCode here
|
* // Stream failed to complete - check ErrorCode here
|
||||||
* }
|
* }
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* <b>Partial Stream Transfers Example:</b>
|
* <b>Partial Stream Transfers Example:</b>
|
||||||
* \code
|
* \code
|
||||||
* uint8_t ErrorCode;
|
* uint8_t ErrorCode;
|
||||||
* uint16_t BytesProcessed;
|
* uint16_t BytesProcessed;
|
||||||
*
|
*
|
||||||
* BytesProcessed = 0;
|
* BytesProcessed = 0;
|
||||||
* while ((ErrorCode = Endpoint_Null_Stream(512, &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer)
|
* while ((ErrorCode = Endpoint_Null_Stream(512, &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer)
|
||||||
* {
|
* {
|
||||||
* // Stream not yet complete - do other actions here, abort if required
|
* // Stream not yet complete - do other actions here, abort if required
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* if (ErrorCode != ENDPOINT_RWSTREAM_NoError)
|
* if (ErrorCode != ENDPOINT_RWSTREAM_NoError)
|
||||||
* {
|
* {
|
||||||
* // Stream failed to complete - check ErrorCode here
|
* // Stream failed to complete - check ErrorCode here
|
||||||
* }
|
* }
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* \note This routine should not be used on CONTROL type endpoints.
|
* \note This routine should not be used on CONTROL type endpoints.
|
||||||
*
|
*
|
||||||
* \param[in] Length Number of zero bytes to send via the currently selected endpoint.
|
* \param[in] Length Number of zero bytes to send via the currently selected endpoint.
|
||||||
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
||||||
* transaction should be updated, \c NULL if the entire stream should be read at once.
|
* transaction should be updated, \c NULL if the entire stream should be read at once.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Endpoint_Null_Stream(uint16_t Length,
|
uint8_t Endpoint_Null_Stream(uint16_t Length,
|
||||||
uint16_t* const BytesProcessed);
|
uint16_t* const BytesProcessed);
|
||||||
|
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
/** \name Stream functions for RAM source/destination data */
|
/** \name Stream functions for RAM source/destination data */
|
||||||
//@{
|
//@{
|
||||||
|
|
||||||
/** Writes the given number of bytes to the endpoint from the given buffer in little endian,
|
/** Writes the given number of bytes to the endpoint from the given buffer in little endian,
|
||||||
* sending full packets to the host as needed. The last packet filled is not automatically sent;
|
* sending full packets to the host as needed. The last packet filled is not automatically sent;
|
||||||
* the user is responsible for manually sending the last written packet to the host via the
|
* the user is responsible for manually sending the last written packet to the host via the
|
||||||
* \ref Endpoint_ClearIN() macro.
|
* \ref Endpoint_ClearIN() macro.
|
||||||
*
|
*
|
||||||
* If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once,
|
* If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once,
|
||||||
* failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid
|
* failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid
|
||||||
* storage location, the transfer will instead be performed as a series of chunks. Each time
|
* storage location, the transfer will instead be performed as a series of chunks. Each time
|
||||||
* the endpoint bank becomes full while there is still data to process (and after the current
|
* the endpoint bank becomes full while there is still data to process (and after the current
|
||||||
* packet transmission has been initiated) the BytesProcessed location will be updated with the
|
* packet transmission has been initiated) the BytesProcessed location will be updated with the
|
||||||
* total number of bytes processed in the stream, and the function will exit with an error code of
|
* total number of bytes processed in the stream, and the function will exit with an error code of
|
||||||
* \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed
|
* \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed
|
||||||
* in the user code - to continue the transfer, call the function again with identical parameters
|
* in the user code - to continue the transfer, call the function again with identical parameters
|
||||||
* and it will resume until the BytesProcessed value reaches the total transfer length.
|
* and it will resume until the BytesProcessed value reaches the total transfer length.
|
||||||
*
|
*
|
||||||
* <b>Single Stream Transfer Example:</b>
|
* <b>Single Stream Transfer Example:</b>
|
||||||
* \code
|
* \code
|
||||||
* uint8_t DataStream[512];
|
* uint8_t DataStream[512];
|
||||||
* uint8_t ErrorCode;
|
* uint8_t ErrorCode;
|
||||||
*
|
*
|
||||||
* if ((ErrorCode = Endpoint_Write_Stream_LE(DataStream, sizeof(DataStream),
|
* if ((ErrorCode = Endpoint_Write_Stream_LE(DataStream, sizeof(DataStream),
|
||||||
* NULL)) != ENDPOINT_RWSTREAM_NoError)
|
* NULL)) != ENDPOINT_RWSTREAM_NoError)
|
||||||
* {
|
* {
|
||||||
* // Stream failed to complete - check ErrorCode here
|
* // Stream failed to complete - check ErrorCode here
|
||||||
* }
|
* }
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* <b>Partial Stream Transfers Example:</b>
|
* <b>Partial Stream Transfers Example:</b>
|
||||||
* \code
|
* \code
|
||||||
* uint8_t DataStream[512];
|
* uint8_t DataStream[512];
|
||||||
* uint8_t ErrorCode;
|
* uint8_t ErrorCode;
|
||||||
* uint16_t BytesProcessed;
|
* uint16_t BytesProcessed;
|
||||||
*
|
*
|
||||||
* BytesProcessed = 0;
|
* BytesProcessed = 0;
|
||||||
* while ((ErrorCode = Endpoint_Write_Stream_LE(DataStream, sizeof(DataStream),
|
* while ((ErrorCode = Endpoint_Write_Stream_LE(DataStream, sizeof(DataStream),
|
||||||
* &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer)
|
* &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer)
|
||||||
* {
|
* {
|
||||||
* // Stream not yet complete - do other actions here, abort if required
|
* // Stream not yet complete - do other actions here, abort if required
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* if (ErrorCode != ENDPOINT_RWSTREAM_NoError)
|
* if (ErrorCode != ENDPOINT_RWSTREAM_NoError)
|
||||||
* {
|
* {
|
||||||
* // Stream failed to complete - check ErrorCode here
|
* // Stream failed to complete - check ErrorCode here
|
||||||
* }
|
* }
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* \note This routine should not be used on CONTROL type endpoints.
|
* \note This routine should not be used on CONTROL type endpoints.
|
||||||
*
|
*
|
||||||
* \param[in] Buffer Pointer to the source data buffer to read from.
|
* \param[in] Buffer Pointer to the source data buffer to read from.
|
||||||
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
||||||
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
||||||
* transaction should be updated, \c NULL if the entire stream should be written at once.
|
* transaction should be updated, \c NULL if the entire stream should be written at once.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Endpoint_Write_Stream_LE(const void* const Buffer,
|
uint8_t Endpoint_Write_Stream_LE(const void* const Buffer,
|
||||||
uint16_t Length,
|
uint16_t Length,
|
||||||
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** Writes the given number of bytes to the endpoint from the given buffer in big endian,
|
/** Writes the given number of bytes to the endpoint from the given buffer in big endian,
|
||||||
* sending full packets to the host as needed. The last packet filled is not automatically sent;
|
* sending full packets to the host as needed. The last packet filled is not automatically sent;
|
||||||
* the user is responsible for manually sending the last written packet to the host via the
|
* the user is responsible for manually sending the last written packet to the host via the
|
||||||
* \ref Endpoint_ClearIN() macro.
|
* \ref Endpoint_ClearIN() macro.
|
||||||
*
|
*
|
||||||
* \note This routine should not be used on CONTROL type endpoints.
|
* \note This routine should not be used on CONTROL type endpoints.
|
||||||
*
|
*
|
||||||
* \param[in] Buffer Pointer to the source data buffer to read from.
|
* \param[in] Buffer Pointer to the source data buffer to read from.
|
||||||
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
||||||
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
||||||
* transaction should be updated, \c NULL if the entire stream should be written at once.
|
* transaction should be updated, \c NULL if the entire stream should be written at once.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Endpoint_Write_Stream_BE(const void* const Buffer,
|
uint8_t Endpoint_Write_Stream_BE(const void* const Buffer,
|
||||||
uint16_t Length,
|
uint16_t Length,
|
||||||
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** Reads the given number of bytes from the endpoint from the given buffer in little endian,
|
/** Reads the given number of bytes from the endpoint from the given buffer in little endian,
|
||||||
* discarding fully read packets from the host as needed. The last packet is not automatically
|
* discarding fully read packets from the host as needed. The last packet is not automatically
|
||||||
* discarded once the remaining bytes has been read; the user is responsible for manually
|
* discarded once the remaining bytes has been read; the user is responsible for manually
|
||||||
* discarding the last packet from the host via the \ref Endpoint_ClearOUT() macro.
|
* discarding the last packet from the host via the \ref Endpoint_ClearOUT() macro.
|
||||||
*
|
*
|
||||||
* If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once,
|
* If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once,
|
||||||
* failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid
|
* failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid
|
||||||
* storage location, the transfer will instead be performed as a series of chunks. Each time
|
* storage location, the transfer will instead be performed as a series of chunks. Each time
|
||||||
* the endpoint bank becomes empty while there is still data to process (and after the current
|
* the endpoint bank becomes empty while there is still data to process (and after the current
|
||||||
* packet has been acknowledged) the BytesProcessed location will be updated with the total number
|
* packet has been acknowledged) the BytesProcessed location will be updated with the total number
|
||||||
* of bytes processed in the stream, and the function will exit with an error code of
|
* of bytes processed in the stream, and the function will exit with an error code of
|
||||||
* \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed
|
* \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed
|
||||||
* in the user code - to continue the transfer, call the function again with identical parameters
|
* in the user code - to continue the transfer, call the function again with identical parameters
|
||||||
* and it will resume until the BytesProcessed value reaches the total transfer length.
|
* and it will resume until the BytesProcessed value reaches the total transfer length.
|
||||||
*
|
*
|
||||||
* <b>Single Stream Transfer Example:</b>
|
* <b>Single Stream Transfer Example:</b>
|
||||||
* \code
|
* \code
|
||||||
* uint8_t DataStream[512];
|
* uint8_t DataStream[512];
|
||||||
* uint8_t ErrorCode;
|
* uint8_t ErrorCode;
|
||||||
*
|
*
|
||||||
* if ((ErrorCode = Endpoint_Read_Stream_LE(DataStream, sizeof(DataStream),
|
* if ((ErrorCode = Endpoint_Read_Stream_LE(DataStream, sizeof(DataStream),
|
||||||
* NULL)) != ENDPOINT_RWSTREAM_NoError)
|
* NULL)) != ENDPOINT_RWSTREAM_NoError)
|
||||||
* {
|
* {
|
||||||
* // Stream failed to complete - check ErrorCode here
|
* // Stream failed to complete - check ErrorCode here
|
||||||
* }
|
* }
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* <b>Partial Stream Transfers Example:</b>
|
* <b>Partial Stream Transfers Example:</b>
|
||||||
* \code
|
* \code
|
||||||
* uint8_t DataStream[512];
|
* uint8_t DataStream[512];
|
||||||
* uint8_t ErrorCode;
|
* uint8_t ErrorCode;
|
||||||
* uint16_t BytesProcessed;
|
* uint16_t BytesProcessed;
|
||||||
*
|
*
|
||||||
* BytesProcessed = 0;
|
* BytesProcessed = 0;
|
||||||
* while ((ErrorCode = Endpoint_Read_Stream_LE(DataStream, sizeof(DataStream),
|
* while ((ErrorCode = Endpoint_Read_Stream_LE(DataStream, sizeof(DataStream),
|
||||||
* &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer)
|
* &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer)
|
||||||
* {
|
* {
|
||||||
* // Stream not yet complete - do other actions here, abort if required
|
* // Stream not yet complete - do other actions here, abort if required
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* if (ErrorCode != ENDPOINT_RWSTREAM_NoError)
|
* if (ErrorCode != ENDPOINT_RWSTREAM_NoError)
|
||||||
* {
|
* {
|
||||||
* // Stream failed to complete - check ErrorCode here
|
* // Stream failed to complete - check ErrorCode here
|
||||||
* }
|
* }
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* \note This routine should not be used on CONTROL type endpoints.
|
* \note This routine should not be used on CONTROL type endpoints.
|
||||||
*
|
*
|
||||||
* \param[out] Buffer Pointer to the destination data buffer to write to.
|
* \param[out] Buffer Pointer to the destination data buffer to write to.
|
||||||
* \param[in] Length Number of bytes to send via the currently selected endpoint.
|
* \param[in] Length Number of bytes to send via the currently selected endpoint.
|
||||||
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
||||||
* transaction should be updated, \c NULL if the entire stream should be read at once.
|
* transaction should be updated, \c NULL if the entire stream should be read at once.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Endpoint_Read_Stream_LE(void* const Buffer,
|
uint8_t Endpoint_Read_Stream_LE(void* const Buffer,
|
||||||
uint16_t Length,
|
uint16_t Length,
|
||||||
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** Reads the given number of bytes from the endpoint from the given buffer in big endian,
|
/** Reads the given number of bytes from the endpoint from the given buffer in big endian,
|
||||||
* discarding fully read packets from the host as needed. The last packet is not automatically
|
* discarding fully read packets from the host as needed. The last packet is not automatically
|
||||||
* discarded once the remaining bytes has been read; the user is responsible for manually
|
* discarded once the remaining bytes has been read; the user is responsible for manually
|
||||||
* discarding the last packet from the host via the \ref Endpoint_ClearOUT() macro.
|
* discarding the last packet from the host via the \ref Endpoint_ClearOUT() macro.
|
||||||
*
|
*
|
||||||
* \note This routine should not be used on CONTROL type endpoints.
|
* \note This routine should not be used on CONTROL type endpoints.
|
||||||
*
|
*
|
||||||
* \param[out] Buffer Pointer to the destination data buffer to write to.
|
* \param[out] Buffer Pointer to the destination data buffer to write to.
|
||||||
* \param[in] Length Number of bytes to send via the currently selected endpoint.
|
* \param[in] Length Number of bytes to send via the currently selected endpoint.
|
||||||
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
||||||
* transaction should be updated, \c NULL if the entire stream should be read at once.
|
* transaction should be updated, \c NULL if the entire stream should be read at once.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Endpoint_Read_Stream_BE(void* const Buffer,
|
uint8_t Endpoint_Read_Stream_BE(void* const Buffer,
|
||||||
uint16_t Length,
|
uint16_t Length,
|
||||||
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** Writes the given number of bytes to the CONTROL type endpoint from the given buffer in little endian,
|
/** Writes the given number of bytes to the CONTROL type endpoint from the given buffer in little endian,
|
||||||
* sending full packets to the host as needed. The host OUT acknowledgement is not automatically cleared
|
* sending full packets to the host as needed. The host OUT acknowledgement is not automatically cleared
|
||||||
* in both failure and success states; the user is responsible for manually clearing the setup OUT to
|
* in both failure and success states; the user is responsible for manually clearing the setup OUT to
|
||||||
* finalize the transfer via the \ref Endpoint_ClearOUT() macro.
|
* finalize the transfer via the \ref Endpoint_ClearOUT() macro.
|
||||||
*
|
*
|
||||||
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
|
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
|
||||||
* to clear the status stage when using this routine in a control transaction.
|
* to clear the status stage when using this routine in a control transaction.
|
||||||
* \n\n
|
* \n\n
|
||||||
*
|
*
|
||||||
* \note This routine should only be used on CONTROL type endpoints.
|
* \note This routine should only be used on CONTROL type endpoints.
|
||||||
*
|
*
|
||||||
* \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
|
* \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
|
||||||
* together; i.e. the entire stream data must be read or written at the one time.
|
* together; i.e. the entire stream data must be read or written at the one time.
|
||||||
*
|
*
|
||||||
* \param[in] Buffer Pointer to the source data buffer to read from.
|
* \param[in] Buffer Pointer to the source data buffer to read from.
|
||||||
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Endpoint_Write_Control_Stream_LE(const void* const Buffer,
|
uint8_t Endpoint_Write_Control_Stream_LE(const void* const Buffer,
|
||||||
uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** Writes the given number of bytes to the CONTROL type endpoint from the given buffer in big endian,
|
/** Writes the given number of bytes to the CONTROL type endpoint from the given buffer in big endian,
|
||||||
* sending full packets to the host as needed. The host OUT acknowledgement is not automatically cleared
|
* sending full packets to the host as needed. The host OUT acknowledgement is not automatically cleared
|
||||||
* in both failure and success states; the user is responsible for manually clearing the setup OUT to
|
* in both failure and success states; the user is responsible for manually clearing the setup OUT to
|
||||||
* finalize the transfer via the \ref Endpoint_ClearOUT() macro.
|
* finalize the transfer via the \ref Endpoint_ClearOUT() macro.
|
||||||
*
|
*
|
||||||
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
|
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
|
||||||
* to clear the status stage when using this routine in a control transaction.
|
* to clear the status stage when using this routine in a control transaction.
|
||||||
* \n\n
|
* \n\n
|
||||||
*
|
*
|
||||||
* \note This routine should only be used on CONTROL type endpoints.
|
* \note This routine should only be used on CONTROL type endpoints.
|
||||||
*
|
*
|
||||||
* \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
|
* \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
|
||||||
* together; i.e. the entire stream data must be read or written at the one time.
|
* together; i.e. the entire stream data must be read or written at the one time.
|
||||||
*
|
*
|
||||||
* \param[in] Buffer Pointer to the source data buffer to read from.
|
* \param[in] Buffer Pointer to the source data buffer to read from.
|
||||||
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Endpoint_Write_Control_Stream_BE(const void* const Buffer,
|
uint8_t Endpoint_Write_Control_Stream_BE(const void* const Buffer,
|
||||||
uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** Reads the given number of bytes from the CONTROL endpoint from the given buffer in little endian,
|
/** Reads the given number of bytes from the CONTROL endpoint from the given buffer in little endian,
|
||||||
* discarding fully read packets from the host as needed. The device IN acknowledgement is not
|
* discarding fully read packets from the host as needed. The device IN acknowledgement is not
|
||||||
* automatically sent after success or failure states; the user is responsible for manually sending the
|
* automatically sent after success or failure states; the user is responsible for manually sending the
|
||||||
* setup IN to finalize the transfer via the \ref Endpoint_ClearIN() macro.
|
* setup IN to finalize the transfer via the \ref Endpoint_ClearIN() macro.
|
||||||
*
|
*
|
||||||
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
|
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
|
||||||
* to clear the status stage when using this routine in a control transaction.
|
* to clear the status stage when using this routine in a control transaction.
|
||||||
* \n\n
|
* \n\n
|
||||||
*
|
*
|
||||||
* \note This routine should only be used on CONTROL type endpoints.
|
* \note This routine should only be used on CONTROL type endpoints.
|
||||||
*
|
*
|
||||||
* \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
|
* \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
|
||||||
* together; i.e. the entire stream data must be read or written at the one time.
|
* together; i.e. the entire stream data must be read or written at the one time.
|
||||||
*
|
*
|
||||||
* \param[out] Buffer Pointer to the destination data buffer to write to.
|
* \param[out] Buffer Pointer to the destination data buffer to write to.
|
||||||
* \param[in] Length Number of bytes to send via the currently selected endpoint.
|
* \param[in] Length Number of bytes to send via the currently selected endpoint.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Endpoint_Read_Control_Stream_LE(void* const Buffer,
|
uint8_t Endpoint_Read_Control_Stream_LE(void* const Buffer,
|
||||||
uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** Reads the given number of bytes from the CONTROL endpoint from the given buffer in big endian,
|
/** Reads the given number of bytes from the CONTROL endpoint from the given buffer in big endian,
|
||||||
* discarding fully read packets from the host as needed. The device IN acknowledgement is not
|
* discarding fully read packets from the host as needed. The device IN acknowledgement is not
|
||||||
* automatically sent after success or failure states; the user is responsible for manually sending the
|
* automatically sent after success or failure states; the user is responsible for manually sending the
|
||||||
* setup IN to finalize the transfer via the \ref Endpoint_ClearIN() macro.
|
* setup IN to finalize the transfer via the \ref Endpoint_ClearIN() macro.
|
||||||
*
|
*
|
||||||
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
|
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
|
||||||
* to clear the status stage when using this routine in a control transaction.
|
* to clear the status stage when using this routine in a control transaction.
|
||||||
* \n\n
|
* \n\n
|
||||||
*
|
*
|
||||||
* \note This routine should only be used on CONTROL type endpoints.
|
* \note This routine should only be used on CONTROL type endpoints.
|
||||||
*
|
*
|
||||||
* \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
|
* \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
|
||||||
* together; i.e. the entire stream data must be read or written at the one time.
|
* together; i.e. the entire stream data must be read or written at the one time.
|
||||||
*
|
*
|
||||||
* \param[out] Buffer Pointer to the destination data buffer to write to.
|
* \param[out] Buffer Pointer to the destination data buffer to write to.
|
||||||
* \param[in] Length Number of bytes to send via the currently selected endpoint.
|
* \param[in] Length Number of bytes to send via the currently selected endpoint.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Endpoint_Read_Control_Stream_BE(void* const Buffer,
|
uint8_t Endpoint_Read_Control_Stream_BE(void* const Buffer,
|
||||||
uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
/** \name Stream functions for EEPROM source/destination data */
|
/** \name Stream functions for EEPROM source/destination data */
|
||||||
//@{
|
//@{
|
||||||
|
|
||||||
/** EEPROM buffer source version of \ref Endpoint_Write_Stream_LE().
|
/** EEPROM buffer source version of \ref Endpoint_Write_Stream_LE().
|
||||||
*
|
*
|
||||||
* \param[in] Buffer Pointer to the source data buffer to read from.
|
* \param[in] Buffer Pointer to the source data buffer to read from.
|
||||||
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
||||||
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
||||||
* transaction should be updated, \c NULL if the entire stream should be written at once.
|
* transaction should be updated, \c NULL if the entire stream should be written at once.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Endpoint_Write_EStream_LE(const void* const Buffer,
|
uint8_t Endpoint_Write_EStream_LE(const void* const Buffer,
|
||||||
uint16_t Length,
|
uint16_t Length,
|
||||||
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** EEPROM buffer source version of \ref Endpoint_Write_Stream_BE().
|
/** EEPROM buffer source version of \ref Endpoint_Write_Stream_BE().
|
||||||
*
|
*
|
||||||
* \param[in] Buffer Pointer to the source data buffer to read from.
|
* \param[in] Buffer Pointer to the source data buffer to read from.
|
||||||
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
||||||
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
||||||
* transaction should be updated, \c NULL if the entire stream should be written at once.
|
* transaction should be updated, \c NULL if the entire stream should be written at once.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Endpoint_Write_EStream_BE(const void* const Buffer,
|
uint8_t Endpoint_Write_EStream_BE(const void* const Buffer,
|
||||||
uint16_t Length,
|
uint16_t Length,
|
||||||
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** EEPROM buffer destination version of \ref Endpoint_Read_Stream_LE().
|
/** EEPROM buffer destination version of \ref Endpoint_Read_Stream_LE().
|
||||||
*
|
*
|
||||||
* \param[out] Buffer Pointer to the destination data buffer to write to, located in EEPROM memory space.
|
* \param[out] Buffer Pointer to the destination data buffer to write to, located in EEPROM memory space.
|
||||||
* \param[in] Length Number of bytes to send via the currently selected endpoint.
|
* \param[in] Length Number of bytes to send via the currently selected endpoint.
|
||||||
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
||||||
* transaction should be updated, \c NULL if the entire stream should be read at once.
|
* transaction should be updated, \c NULL if the entire stream should be read at once.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Endpoint_Read_EStream_LE(void* const Buffer,
|
uint8_t Endpoint_Read_EStream_LE(void* const Buffer,
|
||||||
uint16_t Length,
|
uint16_t Length,
|
||||||
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** EEPROM buffer destination version of \ref Endpoint_Read_Stream_BE().
|
/** EEPROM buffer destination version of \ref Endpoint_Read_Stream_BE().
|
||||||
*
|
*
|
||||||
* \param[out] Buffer Pointer to the destination data buffer to write to, located in EEPROM memory space.
|
* \param[out] Buffer Pointer to the destination data buffer to write to, located in EEPROM memory space.
|
||||||
* \param[in] Length Number of bytes to send via the currently selected endpoint.
|
* \param[in] Length Number of bytes to send via the currently selected endpoint.
|
||||||
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
||||||
* transaction should be updated, \c NULL if the entire stream should be read at once.
|
* transaction should be updated, \c NULL if the entire stream should be read at once.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Endpoint_Read_EStream_BE(void* const Buffer,
|
uint8_t Endpoint_Read_EStream_BE(void* const Buffer,
|
||||||
uint16_t Length,
|
uint16_t Length,
|
||||||
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** EEPROM buffer source version of Endpoint_Write_Control_Stream_LE.
|
/** EEPROM buffer source version of Endpoint_Write_Control_Stream_LE.
|
||||||
*
|
*
|
||||||
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
|
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
|
||||||
* to clear the status stage when using this routine in a control transaction.
|
* to clear the status stage when using this routine in a control transaction.
|
||||||
* \n\n
|
* \n\n
|
||||||
*
|
*
|
||||||
* \note This routine should only be used on CONTROL type endpoints.
|
* \note This routine should only be used on CONTROL type endpoints.
|
||||||
* \n\n
|
* \n\n
|
||||||
*
|
*
|
||||||
* \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
|
* \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
|
||||||
* together; i.e. the entire stream data must be read or written at the one time.
|
* together; i.e. the entire stream data must be read or written at the one time.
|
||||||
*
|
*
|
||||||
* \param[in] Buffer Pointer to the source data buffer to read from.
|
* \param[in] Buffer Pointer to the source data buffer to read from.
|
||||||
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Endpoint_Write_Control_EStream_LE(const void* const Buffer,
|
uint8_t Endpoint_Write_Control_EStream_LE(const void* const Buffer,
|
||||||
uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** EEPROM buffer source version of \ref Endpoint_Write_Control_Stream_BE().
|
/** EEPROM buffer source version of \ref Endpoint_Write_Control_Stream_BE().
|
||||||
*
|
*
|
||||||
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
|
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
|
||||||
* to clear the status stage when using this routine in a control transaction.
|
* to clear the status stage when using this routine in a control transaction.
|
||||||
* \n\n
|
* \n\n
|
||||||
*
|
*
|
||||||
* \note This routine should only be used on CONTROL type endpoints.
|
* \note This routine should only be used on CONTROL type endpoints.
|
||||||
* \n\n
|
* \n\n
|
||||||
*
|
*
|
||||||
* \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
|
* \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
|
||||||
* together; i.e. the entire stream data must be read or written at the one time.
|
* together; i.e. the entire stream data must be read or written at the one time.
|
||||||
*
|
*
|
||||||
* \param[in] Buffer Pointer to the source data buffer to read from.
|
* \param[in] Buffer Pointer to the source data buffer to read from.
|
||||||
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Endpoint_Write_Control_EStream_BE(const void* const Buffer,
|
uint8_t Endpoint_Write_Control_EStream_BE(const void* const Buffer,
|
||||||
uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** EEPROM buffer source version of \ref Endpoint_Read_Control_Stream_LE().
|
/** EEPROM buffer source version of \ref Endpoint_Read_Control_Stream_LE().
|
||||||
*
|
*
|
||||||
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
|
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
|
||||||
* to clear the status stage when using this routine in a control transaction.
|
* to clear the status stage when using this routine in a control transaction.
|
||||||
* \n\n
|
* \n\n
|
||||||
*
|
*
|
||||||
* \note This routine should only be used on CONTROL type endpoints.
|
* \note This routine should only be used on CONTROL type endpoints.
|
||||||
* \n\n
|
* \n\n
|
||||||
*
|
*
|
||||||
* \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
|
* \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
|
||||||
* together; i.e. the entire stream data must be read or written at the one time.
|
* together; i.e. the entire stream data must be read or written at the one time.
|
||||||
*
|
*
|
||||||
* \param[out] Buffer Pointer to the destination data buffer to write to.
|
* \param[out] Buffer Pointer to the destination data buffer to write to.
|
||||||
* \param[in] Length Number of bytes to send via the currently selected endpoint.
|
* \param[in] Length Number of bytes to send via the currently selected endpoint.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Endpoint_Read_Control_EStream_LE(void* const Buffer,
|
uint8_t Endpoint_Read_Control_EStream_LE(void* const Buffer,
|
||||||
uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** EEPROM buffer source version of \ref Endpoint_Read_Control_Stream_BE().
|
/** EEPROM buffer source version of \ref Endpoint_Read_Control_Stream_BE().
|
||||||
*
|
*
|
||||||
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
|
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
|
||||||
* to clear the status stage when using this routine in a control transaction.
|
* to clear the status stage when using this routine in a control transaction.
|
||||||
* \n\n
|
* \n\n
|
||||||
*
|
*
|
||||||
* \note This routine should only be used on CONTROL type endpoints.
|
* \note This routine should only be used on CONTROL type endpoints.
|
||||||
* \n\n
|
* \n\n
|
||||||
*
|
*
|
||||||
* \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
|
* \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
|
||||||
* together; i.e. the entire stream data must be read or written at the one time.
|
* together; i.e. the entire stream data must be read or written at the one time.
|
||||||
*
|
*
|
||||||
* \param[out] Buffer Pointer to the destination data buffer to write to.
|
* \param[out] Buffer Pointer to the destination data buffer to write to.
|
||||||
* \param[in] Length Number of bytes to send via the currently selected endpoint.
|
* \param[in] Length Number of bytes to send via the currently selected endpoint.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Endpoint_Read_Control_EStream_BE(void* const Buffer,
|
uint8_t Endpoint_Read_Control_EStream_BE(void* const Buffer,
|
||||||
uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
/** \name Stream functions for PROGMEM source/destination data */
|
/** \name Stream functions for PROGMEM source/destination data */
|
||||||
//@{
|
//@{
|
||||||
|
|
||||||
/** FLASH buffer source version of \ref Endpoint_Write_Stream_LE().
|
/** FLASH buffer source version of \ref Endpoint_Write_Stream_LE().
|
||||||
*
|
*
|
||||||
* \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly.
|
* \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly.
|
||||||
*
|
*
|
||||||
* \param[in] Buffer Pointer to the source data buffer to read from.
|
* \param[in] Buffer Pointer to the source data buffer to read from.
|
||||||
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
||||||
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
||||||
* transaction should be updated, \c NULL if the entire stream should be written at once.
|
* transaction should be updated, \c NULL if the entire stream should be written at once.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Endpoint_Write_PStream_LE(const void* const Buffer,
|
uint8_t Endpoint_Write_PStream_LE(const void* const Buffer,
|
||||||
uint16_t Length,
|
uint16_t Length,
|
||||||
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** FLASH buffer source version of \ref Endpoint_Write_Stream_BE().
|
/** FLASH buffer source version of \ref Endpoint_Write_Stream_BE().
|
||||||
*
|
*
|
||||||
* \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly.
|
* \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly.
|
||||||
*
|
*
|
||||||
* \param[in] Buffer Pointer to the source data buffer to read from.
|
* \param[in] Buffer Pointer to the source data buffer to read from.
|
||||||
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
||||||
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
||||||
* transaction should be updated, \c NULL if the entire stream should be written at once.
|
* transaction should be updated, \c NULL if the entire stream should be written at once.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Endpoint_Write_PStream_BE(const void* const Buffer,
|
uint8_t Endpoint_Write_PStream_BE(const void* const Buffer,
|
||||||
uint16_t Length,
|
uint16_t Length,
|
||||||
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** FLASH buffer source version of \ref Endpoint_Write_Control_Stream_LE().
|
/** FLASH buffer source version of \ref Endpoint_Write_Control_Stream_LE().
|
||||||
*
|
*
|
||||||
* \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly.
|
* \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly.
|
||||||
*
|
*
|
||||||
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
|
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
|
||||||
* to clear the status stage when using this routine in a control transaction.
|
* to clear the status stage when using this routine in a control transaction.
|
||||||
* \n\n
|
* \n\n
|
||||||
*
|
*
|
||||||
* \note This routine should only be used on CONTROL type endpoints.
|
* \note This routine should only be used on CONTROL type endpoints.
|
||||||
* \n\n
|
* \n\n
|
||||||
*
|
*
|
||||||
* \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
|
* \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
|
||||||
* together; i.e. the entire stream data must be read or written at the one time.
|
* together; i.e. the entire stream data must be read or written at the one time.
|
||||||
*
|
*
|
||||||
* \param[in] Buffer Pointer to the source data buffer to read from.
|
* \param[in] Buffer Pointer to the source data buffer to read from.
|
||||||
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Endpoint_Write_Control_PStream_LE(const void* const Buffer,
|
uint8_t Endpoint_Write_Control_PStream_LE(const void* const Buffer,
|
||||||
uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** FLASH buffer source version of \ref Endpoint_Write_Control_Stream_BE().
|
/** FLASH buffer source version of \ref Endpoint_Write_Control_Stream_BE().
|
||||||
*
|
*
|
||||||
* \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly.
|
* \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly.
|
||||||
*
|
*
|
||||||
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
|
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
|
||||||
* to clear the status stage when using this routine in a control transaction.
|
* to clear the status stage when using this routine in a control transaction.
|
||||||
* \n\n
|
* \n\n
|
||||||
*
|
*
|
||||||
* \note This routine should only be used on CONTROL type endpoints.
|
* \note This routine should only be used on CONTROL type endpoints.
|
||||||
* \n\n
|
* \n\n
|
||||||
*
|
*
|
||||||
* \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
|
* \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
|
||||||
* together; i.e. the entire stream data must be read or written at the one time.
|
* together; i.e. the entire stream data must be read or written at the one time.
|
||||||
*
|
*
|
||||||
* \param[in] Buffer Pointer to the source data buffer to read from.
|
* \param[in] Buffer Pointer to the source data buffer to read from.
|
||||||
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Endpoint_Write_Control_PStream_BE(const void* const Buffer,
|
uint8_t Endpoint_Write_Control_PStream_BE(const void* const Buffer,
|
||||||
uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
/* Disable C linkage for C++ Compilers: */
|
/* Disable C linkage for C++ Compilers: */
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
@ -1,442 +1,442 @@
|
|||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2012.
|
Copyright (C) Dean Camera, 2012.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.lufa-lib.org
|
www.lufa-lib.org
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||||
|
|
||||||
Permission to use, copy, modify, distribute, and sell this
|
Permission to use, copy, modify, distribute, and sell this
|
||||||
software and its documentation for any purpose is hereby granted
|
software and its documentation for any purpose is hereby granted
|
||||||
without fee, provided that the above copyright notice appear in
|
without fee, provided that the above copyright notice appear in
|
||||||
all copies and that both that the copyright notice and this
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
software, including all implied warranties of merchantability
|
software, including all implied warranties of merchantability
|
||||||
and fitness. In no event shall the author be liable for any
|
and fitness. In no event shall the author be liable for any
|
||||||
special, indirect or consequential damages or any damages
|
special, indirect or consequential damages or any damages
|
||||||
whatsoever resulting from loss of use, data or profits, whether
|
whatsoever resulting from loss of use, data or profits, whether
|
||||||
in an action of contract, negligence or other tortious action,
|
in an action of contract, negligence or other tortious action,
|
||||||
arising out of or in connection with the use or performance of
|
arising out of or in connection with the use or performance of
|
||||||
this software.
|
this software.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \file
|
/** \file
|
||||||
* \brief Pipe data stream transmission and reception management for the AVR8 microcontrollers
|
* \brief Pipe data stream transmission and reception management for the AVR8 microcontrollers
|
||||||
* \copydetails Group_PipeStreamRW_AVR8
|
* \copydetails Group_PipeStreamRW_AVR8
|
||||||
*
|
*
|
||||||
* \note This file should not be included directly. It is automatically included as needed by the USB driver
|
* \note This file should not be included directly. It is automatically included as needed by the USB driver
|
||||||
* dispatch header located in LUFA/Drivers/USB/USB.h.
|
* dispatch header located in LUFA/Drivers/USB/USB.h.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \ingroup Group_PipeStreamRW
|
/** \ingroup Group_PipeStreamRW
|
||||||
* \defgroup Group_PipeStreamRW_AVR8 Read/Write of Multi-Byte Streams (AVR8)
|
* \defgroup Group_PipeStreamRW_AVR8 Read/Write of Multi-Byte Streams (AVR8)
|
||||||
* \brief Pipe data stream transmission and reception management for the Atmel AVR8 architecture.
|
* \brief Pipe data stream transmission and reception management for the Atmel AVR8 architecture.
|
||||||
*
|
*
|
||||||
* Functions, macros, variables, enums and types related to data reading and writing of data streams from
|
* Functions, macros, variables, enums and types related to data reading and writing of data streams from
|
||||||
* and to pipes.
|
* and to pipes.
|
||||||
*
|
*
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __PIPE_STREAM_AVR8_H__
|
#ifndef __PIPE_STREAM_AVR8_H__
|
||||||
#define __PIPE_STREAM_AVR8_H__
|
#define __PIPE_STREAM_AVR8_H__
|
||||||
|
|
||||||
/* Includes: */
|
/* Includes: */
|
||||||
#include "../../../../Common/Common.h"
|
#include "../../../../Common/Common.h"
|
||||||
#include "../USBMode.h"
|
#include "../USBMode.h"
|
||||||
#include "../USBTask.h"
|
#include "../USBTask.h"
|
||||||
|
|
||||||
/* Enable C linkage for C++ Compilers: */
|
/* Enable C linkage for C++ Compilers: */
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Preprocessor Checks: */
|
/* Preprocessor Checks: */
|
||||||
#if !defined(__INCLUDE_FROM_USB_DRIVER)
|
#if !defined(__INCLUDE_FROM_USB_DRIVER)
|
||||||
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
|
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Public Interface - May be used in end-application: */
|
/* Public Interface - May be used in end-application: */
|
||||||
/* Function Prototypes: */
|
/* Function Prototypes: */
|
||||||
/** \name Stream functions for null data */
|
/** \name Stream functions for null data */
|
||||||
//@{
|
//@{
|
||||||
|
|
||||||
/** Reads and discards the given number of bytes from the pipe, discarding fully read packets from the host
|
/** Reads and discards the given number of bytes from the pipe, discarding fully read packets from the host
|
||||||
* as needed. The last packet is not automatically discarded once the remaining bytes has been read; the
|
* as needed. The last packet is not automatically discarded once the remaining bytes has been read; the
|
||||||
* user is responsible for manually discarding the last packet from the device via the \ref Pipe_ClearIN() macro.
|
* user is responsible for manually discarding the last packet from the device via the \ref Pipe_ClearIN() macro.
|
||||||
*
|
*
|
||||||
* If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once, failing or
|
* If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once, failing or
|
||||||
* succeeding as a single unit. If the BytesProcessed parameter points to a valid storage location, the transfer
|
* succeeding as a single unit. If the BytesProcessed parameter points to a valid storage location, the transfer
|
||||||
* will instead be performed as a series of chunks. Each time the pipe bank becomes empty while there is still data
|
* will instead be performed as a series of chunks. Each time the pipe bank becomes empty while there is still data
|
||||||
* to process (and after the current packet has been acknowledged) the BytesProcessed location will be updated with
|
* to process (and after the current packet has been acknowledged) the BytesProcessed location will be updated with
|
||||||
* the total number of bytes processed in the stream, and the function will exit with an error code of
|
* the total number of bytes processed in the stream, and the function will exit with an error code of
|
||||||
* \ref PIPE_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed in the user code - to
|
* \ref PIPE_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed in the user code - to
|
||||||
* continue the transfer, call the function again with identical parameters and it will resume until the BytesProcessed
|
* continue the transfer, call the function again with identical parameters and it will resume until the BytesProcessed
|
||||||
* value reaches the total transfer length.
|
* value reaches the total transfer length.
|
||||||
*
|
*
|
||||||
* <b>Single Stream Transfer Example:</b>
|
* <b>Single Stream Transfer Example:</b>
|
||||||
* \code
|
* \code
|
||||||
* uint8_t ErrorCode;
|
* uint8_t ErrorCode;
|
||||||
*
|
*
|
||||||
* if ((ErrorCode = Pipe_Discard_Stream(512, NULL)) != PIPE_RWSTREAM_NoError)
|
* if ((ErrorCode = Pipe_Discard_Stream(512, NULL)) != PIPE_RWSTREAM_NoError)
|
||||||
* {
|
* {
|
||||||
* // Stream failed to complete - check ErrorCode here
|
* // Stream failed to complete - check ErrorCode here
|
||||||
* }
|
* }
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* <b>Partial Stream Transfers Example:</b>
|
* <b>Partial Stream Transfers Example:</b>
|
||||||
* \code
|
* \code
|
||||||
* uint8_t ErrorCode;
|
* uint8_t ErrorCode;
|
||||||
* uint16_t BytesProcessed;
|
* uint16_t BytesProcessed;
|
||||||
*
|
*
|
||||||
* BytesProcessed = 0;
|
* BytesProcessed = 0;
|
||||||
* while ((ErrorCode = Pipe_Discard_Stream(512, &BytesProcessed)) == PIPE_RWSTREAM_IncompleteTransfer)
|
* while ((ErrorCode = Pipe_Discard_Stream(512, &BytesProcessed)) == PIPE_RWSTREAM_IncompleteTransfer)
|
||||||
* {
|
* {
|
||||||
* // Stream not yet complete - do other actions here, abort if required
|
* // Stream not yet complete - do other actions here, abort if required
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* if (ErrorCode != PIPE_RWSTREAM_NoError)
|
* if (ErrorCode != PIPE_RWSTREAM_NoError)
|
||||||
* {
|
* {
|
||||||
* // Stream failed to complete - check ErrorCode here
|
* // Stream failed to complete - check ErrorCode here
|
||||||
* }
|
* }
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without
|
* \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without
|
||||||
* having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken().
|
* having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken().
|
||||||
*
|
*
|
||||||
* \param[in] Length Number of bytes to discard via the currently selected pipe.
|
* \param[in] Length Number of bytes to discard via the currently selected pipe.
|
||||||
* \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should
|
* \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should
|
||||||
* updated, \c NULL if the entire stream should be processed at once.
|
* updated, \c NULL if the entire stream should be processed at once.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Pipe_Discard_Stream(uint16_t Length,
|
uint8_t Pipe_Discard_Stream(uint16_t Length,
|
||||||
uint16_t* const BytesProcessed);
|
uint16_t* const BytesProcessed);
|
||||||
|
|
||||||
/** Writes a given number of zeroed bytes to the pipe, sending full pipe packets from the host to the device
|
/** Writes a given number of zeroed bytes to the pipe, sending full pipe packets from the host to the device
|
||||||
* as needed. The last packet is not automatically sent once the remaining bytes has been written; the
|
* as needed. The last packet is not automatically sent once the remaining bytes has been written; the
|
||||||
* user is responsible for manually discarding the last packet from the device via the \ref Pipe_ClearOUT() macro.
|
* user is responsible for manually discarding the last packet from the device via the \ref Pipe_ClearOUT() macro.
|
||||||
*
|
*
|
||||||
* If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once, failing or
|
* If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once, failing or
|
||||||
* succeeding as a single unit. If the BytesProcessed parameter points to a valid storage location, the transfer
|
* succeeding as a single unit. If the BytesProcessed parameter points to a valid storage location, the transfer
|
||||||
* will instead be performed as a series of chunks. Each time the pipe bank becomes full while there is still data
|
* will instead be performed as a series of chunks. Each time the pipe bank becomes full while there is still data
|
||||||
* to process (and after the current packet transmission has been initiated) the BytesProcessed location will be
|
* to process (and after the current packet transmission has been initiated) the BytesProcessed location will be
|
||||||
* updated with the total number of bytes processed in the stream, and the function will exit with an error code of
|
* updated with the total number of bytes processed in the stream, and the function will exit with an error code of
|
||||||
* \ref PIPE_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed in the user code - to
|
* \ref PIPE_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed in the user code - to
|
||||||
* continue the transfer, call the function again with identical parameters and it will resume until the BytesProcessed
|
* continue the transfer, call the function again with identical parameters and it will resume until the BytesProcessed
|
||||||
* value reaches the total transfer length.
|
* value reaches the total transfer length.
|
||||||
*
|
*
|
||||||
* <b>Single Stream Transfer Example:</b>
|
* <b>Single Stream Transfer Example:</b>
|
||||||
* \code
|
* \code
|
||||||
* uint8_t ErrorCode;
|
* uint8_t ErrorCode;
|
||||||
*
|
*
|
||||||
* if ((ErrorCode = Pipe_Null_Stream(512, NULL)) != PIPE_RWSTREAM_NoError)
|
* if ((ErrorCode = Pipe_Null_Stream(512, NULL)) != PIPE_RWSTREAM_NoError)
|
||||||
* {
|
* {
|
||||||
* // Stream failed to complete - check ErrorCode here
|
* // Stream failed to complete - check ErrorCode here
|
||||||
* }
|
* }
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* <b>Partial Stream Transfers Example:</b>
|
* <b>Partial Stream Transfers Example:</b>
|
||||||
* \code
|
* \code
|
||||||
* uint8_t ErrorCode;
|
* uint8_t ErrorCode;
|
||||||
* uint16_t BytesProcessed;
|
* uint16_t BytesProcessed;
|
||||||
*
|
*
|
||||||
* BytesProcessed = 0;
|
* BytesProcessed = 0;
|
||||||
* while ((ErrorCode = Pipe_Null_Stream(512, &BytesProcessed)) == PIPE_RWSTREAM_IncompleteTransfer)
|
* while ((ErrorCode = Pipe_Null_Stream(512, &BytesProcessed)) == PIPE_RWSTREAM_IncompleteTransfer)
|
||||||
* {
|
* {
|
||||||
* // Stream not yet complete - do other actions here, abort if required
|
* // Stream not yet complete - do other actions here, abort if required
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* if (ErrorCode != PIPE_RWSTREAM_NoError)
|
* if (ErrorCode != PIPE_RWSTREAM_NoError)
|
||||||
* {
|
* {
|
||||||
* // Stream failed to complete - check ErrorCode here
|
* // Stream failed to complete - check ErrorCode here
|
||||||
* }
|
* }
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without
|
* \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without
|
||||||
* having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken().
|
* having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken().
|
||||||
*
|
*
|
||||||
* \param[in] Length Number of zero bytes to write via the currently selected pipe.
|
* \param[in] Length Number of zero bytes to write via the currently selected pipe.
|
||||||
* \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should
|
* \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should
|
||||||
* updated, \c NULL if the entire stream should be processed at once.
|
* updated, \c NULL if the entire stream should be processed at once.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Pipe_Null_Stream(uint16_t Length,
|
uint8_t Pipe_Null_Stream(uint16_t Length,
|
||||||
uint16_t* const BytesProcessed);
|
uint16_t* const BytesProcessed);
|
||||||
|
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
/** \name Stream functions for RAM source/destination data */
|
/** \name Stream functions for RAM source/destination data */
|
||||||
//@{
|
//@{
|
||||||
|
|
||||||
/** Writes the given number of bytes to the pipe from the given buffer in little endian,
|
/** Writes the given number of bytes to the pipe from the given buffer in little endian,
|
||||||
* sending full packets to the device as needed. The last packet filled is not automatically sent;
|
* sending full packets to the device as needed. The last packet filled is not automatically sent;
|
||||||
* the user is responsible for manually sending the last written packet to the host via the
|
* the user is responsible for manually sending the last written packet to the host via the
|
||||||
* \ref Pipe_ClearOUT() macro. Between each USB packet, the given stream callback function is
|
* \ref Pipe_ClearOUT() macro. Between each USB packet, the given stream callback function is
|
||||||
* executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers.
|
* executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers.
|
||||||
*
|
*
|
||||||
* If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once,
|
* If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once,
|
||||||
* failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid
|
* failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid
|
||||||
* storage location, the transfer will instead be performed as a series of chunks. Each time
|
* storage location, the transfer will instead be performed as a series of chunks. Each time
|
||||||
* the pipe bank becomes full while there is still data to process (and after the current
|
* the pipe bank becomes full while there is still data to process (and after the current
|
||||||
* packet transmission has been initiated) the BytesProcessed location will be updated with the
|
* packet transmission has been initiated) the BytesProcessed location will be updated with the
|
||||||
* total number of bytes processed in the stream, and the function will exit with an error code of
|
* total number of bytes processed in the stream, and the function will exit with an error code of
|
||||||
* \ref PIPE_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed
|
* \ref PIPE_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed
|
||||||
* in the user code - to continue the transfer, call the function again with identical parameters
|
* in the user code - to continue the transfer, call the function again with identical parameters
|
||||||
* and it will resume until the BytesProcessed value reaches the total transfer length.
|
* and it will resume until the BytesProcessed value reaches the total transfer length.
|
||||||
*
|
*
|
||||||
* <b>Single Stream Transfer Example:</b>
|
* <b>Single Stream Transfer Example:</b>
|
||||||
* \code
|
* \code
|
||||||
* uint8_t DataStream[512];
|
* uint8_t DataStream[512];
|
||||||
* uint8_t ErrorCode;
|
* uint8_t ErrorCode;
|
||||||
*
|
*
|
||||||
* if ((ErrorCode = Pipe_Write_Stream_LE(DataStream, sizeof(DataStream),
|
* if ((ErrorCode = Pipe_Write_Stream_LE(DataStream, sizeof(DataStream),
|
||||||
* NULL)) != PIPE_RWSTREAM_NoError)
|
* NULL)) != PIPE_RWSTREAM_NoError)
|
||||||
* {
|
* {
|
||||||
* // Stream failed to complete - check ErrorCode here
|
* // Stream failed to complete - check ErrorCode here
|
||||||
* }
|
* }
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* <b>Partial Stream Transfers Example:</b>
|
* <b>Partial Stream Transfers Example:</b>
|
||||||
* \code
|
* \code
|
||||||
* uint8_t DataStream[512];
|
* uint8_t DataStream[512];
|
||||||
* uint8_t ErrorCode;
|
* uint8_t ErrorCode;
|
||||||
* uint16_t BytesProcessed;
|
* uint16_t BytesProcessed;
|
||||||
*
|
*
|
||||||
* BytesProcessed = 0;
|
* BytesProcessed = 0;
|
||||||
* while ((ErrorCode = Pipe_Write_Stream_LE(DataStream, sizeof(DataStream),
|
* while ((ErrorCode = Pipe_Write_Stream_LE(DataStream, sizeof(DataStream),
|
||||||
* &BytesProcessed)) == PIPE_RWSTREAM_IncompleteTransfer)
|
* &BytesProcessed)) == PIPE_RWSTREAM_IncompleteTransfer)
|
||||||
* {
|
* {
|
||||||
* // Stream not yet complete - do other actions here, abort if required
|
* // Stream not yet complete - do other actions here, abort if required
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* if (ErrorCode != PIPE_RWSTREAM_NoError)
|
* if (ErrorCode != PIPE_RWSTREAM_NoError)
|
||||||
* {
|
* {
|
||||||
* // Stream failed to complete - check ErrorCode here
|
* // Stream failed to complete - check ErrorCode here
|
||||||
* }
|
* }
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without
|
* \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without
|
||||||
* having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken().
|
* having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken().
|
||||||
*
|
*
|
||||||
* \param[in] Buffer Pointer to the source data buffer to read from.
|
* \param[in] Buffer Pointer to the source data buffer to read from.
|
||||||
* \param[in] Length Number of bytes to read for the currently selected pipe into the buffer.
|
* \param[in] Length Number of bytes to read for the currently selected pipe into the buffer.
|
||||||
* \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should
|
* \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should
|
||||||
* updated, \c NULL if the entire stream should be written at once.
|
* updated, \c NULL if the entire stream should be written at once.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Pipe_Write_Stream_LE(const void* const Buffer,
|
uint8_t Pipe_Write_Stream_LE(const void* const Buffer,
|
||||||
uint16_t Length,
|
uint16_t Length,
|
||||||
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** Writes the given number of bytes to the pipe from the given buffer in big endian,
|
/** Writes the given number of bytes to the pipe from the given buffer in big endian,
|
||||||
* sending full packets to the device as needed. The last packet filled is not automatically sent;
|
* sending full packets to the device as needed. The last packet filled is not automatically sent;
|
||||||
* the user is responsible for manually sending the last written packet to the host via the
|
* the user is responsible for manually sending the last written packet to the host via the
|
||||||
* \ref Pipe_ClearOUT() macro. Between each USB packet, the given stream callback function is
|
* \ref Pipe_ClearOUT() macro. Between each USB packet, the given stream callback function is
|
||||||
* executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers.
|
* executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers.
|
||||||
*
|
*
|
||||||
* \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without
|
* \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without
|
||||||
* having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken().
|
* having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken().
|
||||||
*
|
*
|
||||||
* \param[in] Buffer Pointer to the source data buffer to read from.
|
* \param[in] Buffer Pointer to the source data buffer to read from.
|
||||||
* \param[in] Length Number of bytes to read for the currently selected pipe into the buffer.
|
* \param[in] Length Number of bytes to read for the currently selected pipe into the buffer.
|
||||||
* \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should
|
* \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should
|
||||||
* updated, \c NULL if the entire stream should be written at once.
|
* updated, \c NULL if the entire stream should be written at once.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Pipe_Write_Stream_BE(const void* const Buffer,
|
uint8_t Pipe_Write_Stream_BE(const void* const Buffer,
|
||||||
uint16_t Length,
|
uint16_t Length,
|
||||||
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** Reads the given number of bytes from the pipe into the given buffer in little endian,
|
/** Reads the given number of bytes from the pipe into the given buffer in little endian,
|
||||||
* sending full packets to the device as needed. The last packet filled is not automatically sent;
|
* sending full packets to the device as needed. The last packet filled is not automatically sent;
|
||||||
* the user is responsible for manually sending the last written packet to the host via the
|
* the user is responsible for manually sending the last written packet to the host via the
|
||||||
* \ref Pipe_ClearIN() macro. Between each USB packet, the given stream callback function is
|
* \ref Pipe_ClearIN() macro. Between each USB packet, the given stream callback function is
|
||||||
* executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers.
|
* executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers.
|
||||||
*
|
*
|
||||||
* If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once,
|
* If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once,
|
||||||
* failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid
|
* failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid
|
||||||
* storage location, the transfer will instead be performed as a series of chunks. Each time
|
* storage location, the transfer will instead be performed as a series of chunks. Each time
|
||||||
* the pipe bank becomes empty while there is still data to process (and after the current
|
* the pipe bank becomes empty while there is still data to process (and after the current
|
||||||
* packet has been acknowledged) the BytesProcessed location will be updated with the total number
|
* packet has been acknowledged) the BytesProcessed location will be updated with the total number
|
||||||
* of bytes processed in the stream, and the function will exit with an error code of
|
* of bytes processed in the stream, and the function will exit with an error code of
|
||||||
* \ref PIPE_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed
|
* \ref PIPE_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed
|
||||||
* in the user code - to continue the transfer, call the function again with identical parameters
|
* in the user code - to continue the transfer, call the function again with identical parameters
|
||||||
* and it will resume until the BytesProcessed value reaches the total transfer length.
|
* and it will resume until the BytesProcessed value reaches the total transfer length.
|
||||||
*
|
*
|
||||||
* <b>Single Stream Transfer Example:</b>
|
* <b>Single Stream Transfer Example:</b>
|
||||||
* \code
|
* \code
|
||||||
* uint8_t DataStream[512];
|
* uint8_t DataStream[512];
|
||||||
* uint8_t ErrorCode;
|
* uint8_t ErrorCode;
|
||||||
*
|
*
|
||||||
* if ((ErrorCode = Pipe_Read_Stream_LE(DataStream, sizeof(DataStream),
|
* if ((ErrorCode = Pipe_Read_Stream_LE(DataStream, sizeof(DataStream),
|
||||||
* NULL)) != PIPE_RWSTREAM_NoError)
|
* NULL)) != PIPE_RWSTREAM_NoError)
|
||||||
* {
|
* {
|
||||||
* // Stream failed to complete - check ErrorCode here
|
* // Stream failed to complete - check ErrorCode here
|
||||||
* }
|
* }
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* <b>Partial Stream Transfers Example:</b>
|
* <b>Partial Stream Transfers Example:</b>
|
||||||
* \code
|
* \code
|
||||||
* uint8_t DataStream[512];
|
* uint8_t DataStream[512];
|
||||||
* uint8_t ErrorCode;
|
* uint8_t ErrorCode;
|
||||||
* uint16_t BytesProcessed;
|
* uint16_t BytesProcessed;
|
||||||
*
|
*
|
||||||
* BytesProcessed = 0;
|
* BytesProcessed = 0;
|
||||||
* while ((ErrorCode = Pipe_Read_Stream_LE(DataStream, sizeof(DataStream),
|
* while ((ErrorCode = Pipe_Read_Stream_LE(DataStream, sizeof(DataStream),
|
||||||
* &BytesProcessed)) == PIPE_RWSTREAM_IncompleteTransfer)
|
* &BytesProcessed)) == PIPE_RWSTREAM_IncompleteTransfer)
|
||||||
* {
|
* {
|
||||||
* // Stream not yet complete - do other actions here, abort if required
|
* // Stream not yet complete - do other actions here, abort if required
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* if (ErrorCode != PIPE_RWSTREAM_NoError)
|
* if (ErrorCode != PIPE_RWSTREAM_NoError)
|
||||||
* {
|
* {
|
||||||
* // Stream failed to complete - check ErrorCode here
|
* // Stream failed to complete - check ErrorCode here
|
||||||
* }
|
* }
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without
|
* \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without
|
||||||
* having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken().
|
* having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken().
|
||||||
*
|
*
|
||||||
* \param[out] Buffer Pointer to the source data buffer to write to.
|
* \param[out] Buffer Pointer to the source data buffer to write to.
|
||||||
* \param[in] Length Number of bytes to read for the currently selected pipe to read from.
|
* \param[in] Length Number of bytes to read for the currently selected pipe to read from.
|
||||||
* \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should
|
* \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should
|
||||||
* updated, \c NULL if the entire stream should be read at once.
|
* updated, \c NULL if the entire stream should be read at once.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Pipe_Read_Stream_LE(void* const Buffer,
|
uint8_t Pipe_Read_Stream_LE(void* const Buffer,
|
||||||
uint16_t Length,
|
uint16_t Length,
|
||||||
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** Reads the given number of bytes from the pipe into the given buffer in big endian,
|
/** Reads the given number of bytes from the pipe into the given buffer in big endian,
|
||||||
* sending full packets to the device as needed. The last packet filled is not automatically sent;
|
* sending full packets to the device as needed. The last packet filled is not automatically sent;
|
||||||
* the user is responsible for manually sending the last written packet to the host via the
|
* the user is responsible for manually sending the last written packet to the host via the
|
||||||
* \ref Pipe_ClearIN() macro. Between each USB packet, the given stream callback function is
|
* \ref Pipe_ClearIN() macro. Between each USB packet, the given stream callback function is
|
||||||
* executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers.
|
* executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers.
|
||||||
*
|
*
|
||||||
* \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without
|
* \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without
|
||||||
* having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken().
|
* having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken().
|
||||||
*
|
*
|
||||||
* \param[out] Buffer Pointer to the source data buffer to write to.
|
* \param[out] Buffer Pointer to the source data buffer to write to.
|
||||||
* \param[in] Length Number of bytes to read for the currently selected pipe to read from.
|
* \param[in] Length Number of bytes to read for the currently selected pipe to read from.
|
||||||
* \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should
|
* \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should
|
||||||
* updated, \c NULL if the entire stream should be read at once.
|
* updated, \c NULL if the entire stream should be read at once.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Pipe_Read_Stream_BE(void* const Buffer,
|
uint8_t Pipe_Read_Stream_BE(void* const Buffer,
|
||||||
uint16_t Length,
|
uint16_t Length,
|
||||||
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
/** \name Stream functions for EEPROM source/destination data */
|
/** \name Stream functions for EEPROM source/destination data */
|
||||||
//@{
|
//@{
|
||||||
|
|
||||||
/** EEPROM buffer source version of \ref Pipe_Write_Stream_LE().
|
/** EEPROM buffer source version of \ref Pipe_Write_Stream_LE().
|
||||||
*
|
*
|
||||||
* \param[in] Buffer Pointer to the source data buffer to read from.
|
* \param[in] Buffer Pointer to the source data buffer to read from.
|
||||||
* \param[in] Length Number of bytes to read for the currently selected pipe into the buffer.
|
* \param[in] Length Number of bytes to read for the currently selected pipe into the buffer.
|
||||||
* \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should
|
* \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should
|
||||||
* updated, \c NULL if the entire stream should be written at once.
|
* updated, \c NULL if the entire stream should be written at once.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Pipe_Write_EStream_LE(const void* const Buffer,
|
uint8_t Pipe_Write_EStream_LE(const void* const Buffer,
|
||||||
uint16_t Length,
|
uint16_t Length,
|
||||||
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** EEPROM buffer source version of \ref Pipe_Write_Stream_BE().
|
/** EEPROM buffer source version of \ref Pipe_Write_Stream_BE().
|
||||||
*
|
*
|
||||||
* \param[in] Buffer Pointer to the source data buffer to read from.
|
* \param[in] Buffer Pointer to the source data buffer to read from.
|
||||||
* \param[in] Length Number of bytes to read for the currently selected pipe into the buffer.
|
* \param[in] Length Number of bytes to read for the currently selected pipe into the buffer.
|
||||||
* \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should
|
* \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should
|
||||||
* updated, \c NULL if the entire stream should be written at once.
|
* updated, \c NULL if the entire stream should be written at once.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Pipe_Write_EStream_BE(const void* const Buffer,
|
uint8_t Pipe_Write_EStream_BE(const void* const Buffer,
|
||||||
uint16_t Length,
|
uint16_t Length,
|
||||||
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** EEPROM buffer source version of \ref Pipe_Read_Stream_LE().
|
/** EEPROM buffer source version of \ref Pipe_Read_Stream_LE().
|
||||||
*
|
*
|
||||||
* \param[out] Buffer Pointer to the source data buffer to write to.
|
* \param[out] Buffer Pointer to the source data buffer to write to.
|
||||||
* \param[in] Length Number of bytes to read for the currently selected pipe to read from.
|
* \param[in] Length Number of bytes to read for the currently selected pipe to read from.
|
||||||
* \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should
|
* \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should
|
||||||
* updated, \c NULL if the entire stream should be read at once.
|
* updated, \c NULL if the entire stream should be read at once.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Pipe_Read_EStream_LE(void* const Buffer,
|
uint8_t Pipe_Read_EStream_LE(void* const Buffer,
|
||||||
uint16_t Length,
|
uint16_t Length,
|
||||||
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** EEPROM buffer source version of \ref Pipe_Read_Stream_BE().
|
/** EEPROM buffer source version of \ref Pipe_Read_Stream_BE().
|
||||||
*
|
*
|
||||||
* \param[out] Buffer Pointer to the source data buffer to write to.
|
* \param[out] Buffer Pointer to the source data buffer to write to.
|
||||||
* \param[in] Length Number of bytes to read for the currently selected pipe to read from.
|
* \param[in] Length Number of bytes to read for the currently selected pipe to read from.
|
||||||
* \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should
|
* \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should
|
||||||
* updated, \c NULL if the entire stream should be read at once.
|
* updated, \c NULL if the entire stream should be read at once.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Pipe_Read_EStream_BE(void* const Buffer,
|
uint8_t Pipe_Read_EStream_BE(void* const Buffer,
|
||||||
uint16_t Length,
|
uint16_t Length,
|
||||||
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
/** \name Stream functions for PROGMEM source/destination data */
|
/** \name Stream functions for PROGMEM source/destination data */
|
||||||
//@{
|
//@{
|
||||||
|
|
||||||
/** FLASH buffer source version of \ref Pipe_Write_Stream_LE().
|
/** FLASH buffer source version of \ref Pipe_Write_Stream_LE().
|
||||||
*
|
*
|
||||||
* \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly.
|
* \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly.
|
||||||
*
|
*
|
||||||
* \param[in] Buffer Pointer to the source data buffer to read from.
|
* \param[in] Buffer Pointer to the source data buffer to read from.
|
||||||
* \param[in] Length Number of bytes to read for the currently selected pipe into the buffer.
|
* \param[in] Length Number of bytes to read for the currently selected pipe into the buffer.
|
||||||
* \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should
|
* \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should
|
||||||
* updated, \c NULL if the entire stream should be written at once.
|
* updated, \c NULL if the entire stream should be written at once.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Pipe_Write_PStream_LE(const void* const Buffer,
|
uint8_t Pipe_Write_PStream_LE(const void* const Buffer,
|
||||||
uint16_t Length,
|
uint16_t Length,
|
||||||
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** FLASH buffer source version of \ref Pipe_Write_Stream_BE().
|
/** FLASH buffer source version of \ref Pipe_Write_Stream_BE().
|
||||||
*
|
*
|
||||||
* \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly.
|
* \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly.
|
||||||
*
|
*
|
||||||
* \param[in] Buffer Pointer to the source data buffer to read from.
|
* \param[in] Buffer Pointer to the source data buffer to read from.
|
||||||
* \param[in] Length Number of bytes to read for the currently selected pipe into the buffer.
|
* \param[in] Length Number of bytes to read for the currently selected pipe into the buffer.
|
||||||
* \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should
|
* \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should
|
||||||
* updated, \c NULL if the entire stream should be written at once.
|
* updated, \c NULL if the entire stream should be written at once.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Pipe_Write_PStream_BE(const void* const Buffer,
|
uint8_t Pipe_Write_PStream_BE(const void* const Buffer,
|
||||||
uint16_t Length,
|
uint16_t Length,
|
||||||
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
/* Disable C linkage for C++ Compilers: */
|
/* Disable C linkage for C++ Compilers: */
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
@ -1,235 +1,235 @@
|
|||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2012.
|
Copyright (C) Dean Camera, 2012.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.lufa-lib.org
|
www.lufa-lib.org
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||||
|
|
||||||
Permission to use, copy, modify, distribute, and sell this
|
Permission to use, copy, modify, distribute, and sell this
|
||||||
software and its documentation for any purpose is hereby granted
|
software and its documentation for any purpose is hereby granted
|
||||||
without fee, provided that the above copyright notice appear in
|
without fee, provided that the above copyright notice appear in
|
||||||
all copies and that both that the copyright notice and this
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
software, including all implied warranties of merchantability
|
software, including all implied warranties of merchantability
|
||||||
and fitness. In no event shall the author be liable for any
|
and fitness. In no event shall the author be liable for any
|
||||||
special, indirect or consequential damages or any damages
|
special, indirect or consequential damages or any damages
|
||||||
whatsoever resulting from loss of use, data or profits, whether
|
whatsoever resulting from loss of use, data or profits, whether
|
||||||
in an action of contract, negligence or other tortious action,
|
in an action of contract, negligence or other tortious action,
|
||||||
arising out of or in connection with the use or performance of
|
arising out of or in connection with the use or performance of
|
||||||
this software.
|
this software.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../../../../Common/Common.h"
|
#include "../../../../Common/Common.h"
|
||||||
#if (ARCH == ARCH_UC3)
|
#if (ARCH == ARCH_UC3)
|
||||||
|
|
||||||
#define __INCLUDE_FROM_USB_DRIVER
|
#define __INCLUDE_FROM_USB_DRIVER
|
||||||
#include "../USBMode.h"
|
#include "../USBMode.h"
|
||||||
|
|
||||||
#if defined(USB_CAN_BE_DEVICE)
|
#if defined(USB_CAN_BE_DEVICE)
|
||||||
|
|
||||||
#include "EndpointStream_UC3.h"
|
#include "EndpointStream_UC3.h"
|
||||||
|
|
||||||
#if !defined(CONTROL_ONLY_DEVICE)
|
#if !defined(CONTROL_ONLY_DEVICE)
|
||||||
uint8_t Endpoint_Discard_Stream(uint16_t Length,
|
uint8_t Endpoint_Discard_Stream(uint16_t Length,
|
||||||
uint16_t* const BytesProcessed)
|
uint16_t* const BytesProcessed)
|
||||||
{
|
{
|
||||||
uint8_t ErrorCode;
|
uint8_t ErrorCode;
|
||||||
uint16_t BytesInTransfer = 0;
|
uint16_t BytesInTransfer = 0;
|
||||||
|
|
||||||
if ((ErrorCode = Endpoint_WaitUntilReady()))
|
if ((ErrorCode = Endpoint_WaitUntilReady()))
|
||||||
return ErrorCode;
|
return ErrorCode;
|
||||||
|
|
||||||
if (BytesProcessed != NULL)
|
if (BytesProcessed != NULL)
|
||||||
Length -= *BytesProcessed;
|
Length -= *BytesProcessed;
|
||||||
|
|
||||||
while (Length)
|
while (Length)
|
||||||
{
|
{
|
||||||
if (!(Endpoint_IsReadWriteAllowed()))
|
if (!(Endpoint_IsReadWriteAllowed()))
|
||||||
{
|
{
|
||||||
Endpoint_ClearOUT();
|
Endpoint_ClearOUT();
|
||||||
|
|
||||||
if (BytesProcessed != NULL)
|
if (BytesProcessed != NULL)
|
||||||
{
|
{
|
||||||
*BytesProcessed += BytesInTransfer;
|
*BytesProcessed += BytesInTransfer;
|
||||||
return ENDPOINT_RWSTREAM_IncompleteTransfer;
|
return ENDPOINT_RWSTREAM_IncompleteTransfer;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ErrorCode = Endpoint_WaitUntilReady()))
|
if ((ErrorCode = Endpoint_WaitUntilReady()))
|
||||||
return ErrorCode;
|
return ErrorCode;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Endpoint_Discard_8();
|
Endpoint_Discard_8();
|
||||||
|
|
||||||
Length--;
|
Length--;
|
||||||
BytesInTransfer++;
|
BytesInTransfer++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ENDPOINT_RWSTREAM_NoError;
|
return ENDPOINT_RWSTREAM_NoError;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t Endpoint_Null_Stream(uint16_t Length,
|
uint8_t Endpoint_Null_Stream(uint16_t Length,
|
||||||
uint16_t* const BytesProcessed)
|
uint16_t* const BytesProcessed)
|
||||||
{
|
{
|
||||||
uint8_t ErrorCode;
|
uint8_t ErrorCode;
|
||||||
uint16_t BytesInTransfer = 0;
|
uint16_t BytesInTransfer = 0;
|
||||||
|
|
||||||
if ((ErrorCode = Endpoint_WaitUntilReady()))
|
if ((ErrorCode = Endpoint_WaitUntilReady()))
|
||||||
return ErrorCode;
|
return ErrorCode;
|
||||||
|
|
||||||
if (BytesProcessed != NULL)
|
if (BytesProcessed != NULL)
|
||||||
Length -= *BytesProcessed;
|
Length -= *BytesProcessed;
|
||||||
|
|
||||||
while (Length)
|
while (Length)
|
||||||
{
|
{
|
||||||
if (!(Endpoint_IsReadWriteAllowed()))
|
if (!(Endpoint_IsReadWriteAllowed()))
|
||||||
{
|
{
|
||||||
Endpoint_ClearIN();
|
Endpoint_ClearIN();
|
||||||
|
|
||||||
if (BytesProcessed != NULL)
|
if (BytesProcessed != NULL)
|
||||||
{
|
{
|
||||||
*BytesProcessed += BytesInTransfer;
|
*BytesProcessed += BytesInTransfer;
|
||||||
return ENDPOINT_RWSTREAM_IncompleteTransfer;
|
return ENDPOINT_RWSTREAM_IncompleteTransfer;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ErrorCode = Endpoint_WaitUntilReady()))
|
if ((ErrorCode = Endpoint_WaitUntilReady()))
|
||||||
return ErrorCode;
|
return ErrorCode;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Endpoint_Write_8(0);
|
Endpoint_Write_8(0);
|
||||||
|
|
||||||
Length--;
|
Length--;
|
||||||
BytesInTransfer++;
|
BytesInTransfer++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ENDPOINT_RWSTREAM_NoError;
|
return ENDPOINT_RWSTREAM_NoError;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The following abuses the C preprocessor in order to copy-paste common code with slight alterations,
|
/* The following abuses the C preprocessor in order to copy-paste common code with slight alterations,
|
||||||
* so that the code needs to be written once. It is a crude form of templating to reduce code maintenance. */
|
* so that the code needs to be written once. It is a crude form of templating to reduce code maintenance. */
|
||||||
|
|
||||||
#define TEMPLATE_FUNC_NAME Endpoint_Write_Stream_LE
|
#define TEMPLATE_FUNC_NAME Endpoint_Write_Stream_LE
|
||||||
#define TEMPLATE_BUFFER_TYPE const void*
|
#define TEMPLATE_BUFFER_TYPE const void*
|
||||||
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()
|
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr)
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr)
|
||||||
#include "Template/Template_Endpoint_RW.c"
|
#include "Template/Template_Endpoint_RW.c"
|
||||||
|
|
||||||
#define TEMPLATE_FUNC_NAME Endpoint_Write_Stream_BE
|
#define TEMPLATE_FUNC_NAME Endpoint_Write_Stream_BE
|
||||||
#define TEMPLATE_BUFFER_TYPE const void*
|
#define TEMPLATE_BUFFER_TYPE const void*
|
||||||
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()
|
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr)
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr)
|
||||||
#include "Template/Template_Endpoint_RW.c"
|
#include "Template/Template_Endpoint_RW.c"
|
||||||
|
|
||||||
#define TEMPLATE_FUNC_NAME Endpoint_Read_Stream_LE
|
#define TEMPLATE_FUNC_NAME Endpoint_Read_Stream_LE
|
||||||
#define TEMPLATE_BUFFER_TYPE void*
|
#define TEMPLATE_BUFFER_TYPE void*
|
||||||
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT()
|
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT()
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8()
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8()
|
||||||
#include "Template/Template_Endpoint_RW.c"
|
#include "Template/Template_Endpoint_RW.c"
|
||||||
|
|
||||||
#define TEMPLATE_FUNC_NAME Endpoint_Read_Stream_BE
|
#define TEMPLATE_FUNC_NAME Endpoint_Read_Stream_BE
|
||||||
#define TEMPLATE_BUFFER_TYPE void*
|
#define TEMPLATE_BUFFER_TYPE void*
|
||||||
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT()
|
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT()
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8()
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8()
|
||||||
#include "Template/Template_Endpoint_RW.c"
|
#include "Template/Template_Endpoint_RW.c"
|
||||||
|
|
||||||
#if defined(ARCH_HAS_FLASH_ADDRESS_SPACE)
|
#if defined(ARCH_HAS_FLASH_ADDRESS_SPACE)
|
||||||
#define TEMPLATE_FUNC_NAME Endpoint_Write_PStream_LE
|
#define TEMPLATE_FUNC_NAME Endpoint_Write_PStream_LE
|
||||||
#define TEMPLATE_BUFFER_TYPE const void*
|
#define TEMPLATE_BUFFER_TYPE const void*
|
||||||
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()
|
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(pgm_read_byte(BufferPtr))
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(pgm_read_byte(BufferPtr))
|
||||||
#include "Template/Template_Endpoint_RW.c"
|
#include "Template/Template_Endpoint_RW.c"
|
||||||
|
|
||||||
#define TEMPLATE_FUNC_NAME Endpoint_Write_PStream_BE
|
#define TEMPLATE_FUNC_NAME Endpoint_Write_PStream_BE
|
||||||
#define TEMPLATE_BUFFER_TYPE const void*
|
#define TEMPLATE_BUFFER_TYPE const void*
|
||||||
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()
|
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(pgm_read_byte(BufferPtr))
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(pgm_read_byte(BufferPtr))
|
||||||
#include "Template/Template_Endpoint_RW.c"
|
#include "Template/Template_Endpoint_RW.c"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(ARCH_HAS_EEPROM_ADDRESS_SPACE)
|
#if defined(ARCH_HAS_EEPROM_ADDRESS_SPACE)
|
||||||
#define TEMPLATE_FUNC_NAME Endpoint_Write_EStream_LE
|
#define TEMPLATE_FUNC_NAME Endpoint_Write_EStream_LE
|
||||||
#define TEMPLATE_BUFFER_TYPE const void*
|
#define TEMPLATE_BUFFER_TYPE const void*
|
||||||
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()
|
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(eeprom_read_byte(BufferPtr))
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(eeprom_read_byte(BufferPtr))
|
||||||
#include "Template/Template_Endpoint_RW.c"
|
#include "Template/Template_Endpoint_RW.c"
|
||||||
|
|
||||||
#define TEMPLATE_FUNC_NAME Endpoint_Write_EStream_BE
|
#define TEMPLATE_FUNC_NAME Endpoint_Write_EStream_BE
|
||||||
#define TEMPLATE_BUFFER_TYPE const void*
|
#define TEMPLATE_BUFFER_TYPE const void*
|
||||||
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()
|
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(eeprom_read_byte(BufferPtr))
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(eeprom_read_byte(BufferPtr))
|
||||||
#include "Template/Template_Endpoint_RW.c"
|
#include "Template/Template_Endpoint_RW.c"
|
||||||
|
|
||||||
#define TEMPLATE_FUNC_NAME Endpoint_Read_EStream_LE
|
#define TEMPLATE_FUNC_NAME Endpoint_Read_EStream_LE
|
||||||
#define TEMPLATE_BUFFER_TYPE void*
|
#define TEMPLATE_BUFFER_TYPE void*
|
||||||
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT()
|
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT()
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Endpoint_Read_8())
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Endpoint_Read_8())
|
||||||
#include "Template/Template_Endpoint_RW.c"
|
#include "Template/Template_Endpoint_RW.c"
|
||||||
|
|
||||||
#define TEMPLATE_FUNC_NAME Endpoint_Read_EStream_BE
|
#define TEMPLATE_FUNC_NAME Endpoint_Read_EStream_BE
|
||||||
#define TEMPLATE_BUFFER_TYPE void*
|
#define TEMPLATE_BUFFER_TYPE void*
|
||||||
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT()
|
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT()
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Endpoint_Read_8())
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Endpoint_Read_8())
|
||||||
#include "Template/Template_Endpoint_RW.c"
|
#include "Template/Template_Endpoint_RW.c"
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_Stream_LE
|
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
|
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr)
|
|
||||||
#include "Template/Template_Endpoint_Control_W.c"
|
|
||||||
|
|
||||||
#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_Stream_BE
|
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
|
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr)
|
|
||||||
#include "Template/Template_Endpoint_Control_W.c"
|
|
||||||
|
|
||||||
#define TEMPLATE_FUNC_NAME Endpoint_Read_Control_Stream_LE
|
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
|
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8()
|
|
||||||
#include "Template/Template_Endpoint_Control_R.c"
|
|
||||||
|
|
||||||
#define TEMPLATE_FUNC_NAME Endpoint_Read_Control_Stream_BE
|
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
|
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8()
|
|
||||||
#include "Template/Template_Endpoint_Control_R.c"
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_Stream_LE
|
||||||
|
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
||||||
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
|
||||||
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr)
|
||||||
|
#include "Template/Template_Endpoint_Control_W.c"
|
||||||
|
|
||||||
|
#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_Stream_BE
|
||||||
|
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
||||||
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
|
||||||
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr)
|
||||||
|
#include "Template/Template_Endpoint_Control_W.c"
|
||||||
|
|
||||||
|
#define TEMPLATE_FUNC_NAME Endpoint_Read_Control_Stream_LE
|
||||||
|
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
||||||
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
|
||||||
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8()
|
||||||
|
#include "Template/Template_Endpoint_Control_R.c"
|
||||||
|
|
||||||
|
#define TEMPLATE_FUNC_NAME Endpoint_Read_Control_Stream_BE
|
||||||
|
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
||||||
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
|
||||||
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8()
|
||||||
|
#include "Template/Template_Endpoint_Control_R.c"
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@ -1,434 +1,434 @@
|
|||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2012.
|
Copyright (C) Dean Camera, 2012.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.lufa-lib.org
|
www.lufa-lib.org
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||||
|
|
||||||
Permission to use, copy, modify, distribute, and sell this
|
Permission to use, copy, modify, distribute, and sell this
|
||||||
software and its documentation for any purpose is hereby granted
|
software and its documentation for any purpose is hereby granted
|
||||||
without fee, provided that the above copyright notice appear in
|
without fee, provided that the above copyright notice appear in
|
||||||
all copies and that both that the copyright notice and this
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
software, including all implied warranties of merchantability
|
software, including all implied warranties of merchantability
|
||||||
and fitness. In no event shall the author be liable for any
|
and fitness. In no event shall the author be liable for any
|
||||||
special, indirect or consequential damages or any damages
|
special, indirect or consequential damages or any damages
|
||||||
whatsoever resulting from loss of use, data or profits, whether
|
whatsoever resulting from loss of use, data or profits, whether
|
||||||
in an action of contract, negligence or other tortious action,
|
in an action of contract, negligence or other tortious action,
|
||||||
arising out of or in connection with the use or performance of
|
arising out of or in connection with the use or performance of
|
||||||
this software.
|
this software.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \file
|
/** \file
|
||||||
* \brief Endpoint data stream transmission and reception management for the AVR32 UC3 microcontrollers.
|
* \brief Endpoint data stream transmission and reception management for the AVR32 UC3 microcontrollers.
|
||||||
* \copydetails Group_EndpointStreamRW_UC3
|
* \copydetails Group_EndpointStreamRW_UC3
|
||||||
*
|
*
|
||||||
* \note This file should not be included directly. It is automatically included as needed by the USB driver
|
* \note This file should not be included directly. It is automatically included as needed by the USB driver
|
||||||
* dispatch header located in LUFA/Drivers/USB/USB.h.
|
* dispatch header located in LUFA/Drivers/USB/USB.h.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \ingroup Group_EndpointStreamRW
|
/** \ingroup Group_EndpointStreamRW
|
||||||
* \defgroup Group_EndpointStreamRW_UC3 Read/Write of Multi-Byte Streams (UC3)
|
* \defgroup Group_EndpointStreamRW_UC3 Read/Write of Multi-Byte Streams (UC3)
|
||||||
* \brief Endpoint data stream transmission and reception management for the Atmel AVR32 UC3 architecture.
|
* \brief Endpoint data stream transmission and reception management for the Atmel AVR32 UC3 architecture.
|
||||||
*
|
*
|
||||||
* Functions, macros, variables, enums and types related to data reading and writing of data streams from
|
* Functions, macros, variables, enums and types related to data reading and writing of data streams from
|
||||||
* and to endpoints.
|
* and to endpoints.
|
||||||
*
|
*
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __ENDPOINT_STREAM_UC3_H__
|
#ifndef __ENDPOINT_STREAM_UC3_H__
|
||||||
#define __ENDPOINT_STREAM_UC3_H__
|
#define __ENDPOINT_STREAM_UC3_H__
|
||||||
|
|
||||||
/* Includes: */
|
/* Includes: */
|
||||||
#include "../../../../Common/Common.h"
|
#include "../../../../Common/Common.h"
|
||||||
#include "../USBMode.h"
|
#include "../USBMode.h"
|
||||||
#include "../USBTask.h"
|
#include "../USBTask.h"
|
||||||
|
|
||||||
/* Enable C linkage for C++ Compilers: */
|
/* Enable C linkage for C++ Compilers: */
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Preprocessor Checks: */
|
/* Preprocessor Checks: */
|
||||||
#if !defined(__INCLUDE_FROM_USB_DRIVER)
|
#if !defined(__INCLUDE_FROM_USB_DRIVER)
|
||||||
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
|
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Public Interface - May be used in end-application: */
|
/* Public Interface - May be used in end-application: */
|
||||||
/* Function Prototypes: */
|
/* Function Prototypes: */
|
||||||
/** \name Stream functions for null data */
|
/** \name Stream functions for null data */
|
||||||
//@{
|
//@{
|
||||||
|
|
||||||
/** Reads and discards the given number of bytes from the currently selected endpoint's bank,
|
/** Reads and discards the given number of bytes from the currently selected endpoint's bank,
|
||||||
* discarding fully read packets from the host as needed. The last packet is not automatically
|
* discarding fully read packets from the host as needed. The last packet is not automatically
|
||||||
* discarded once the remaining bytes has been read; the user is responsible for manually
|
* discarded once the remaining bytes has been read; the user is responsible for manually
|
||||||
* discarding the last packet from the host via the \ref Endpoint_ClearOUT() macro.
|
* discarding the last packet from the host via the \ref Endpoint_ClearOUT() macro.
|
||||||
*
|
*
|
||||||
* If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once,
|
* If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once,
|
||||||
* failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid
|
* failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid
|
||||||
* storage location, the transfer will instead be performed as a series of chunks. Each time
|
* storage location, the transfer will instead be performed as a series of chunks. Each time
|
||||||
* the endpoint bank becomes empty while there is still data to process (and after the current
|
* the endpoint bank becomes empty while there is still data to process (and after the current
|
||||||
* packet has been acknowledged) the BytesProcessed location will be updated with the total number
|
* packet has been acknowledged) the BytesProcessed location will be updated with the total number
|
||||||
* of bytes processed in the stream, and the function will exit with an error code of
|
* of bytes processed in the stream, and the function will exit with an error code of
|
||||||
* \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed
|
* \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed
|
||||||
* in the user code - to continue the transfer, call the function again with identical parameters
|
* in the user code - to continue the transfer, call the function again with identical parameters
|
||||||
* and it will resume until the BytesProcessed value reaches the total transfer length.
|
* and it will resume until the BytesProcessed value reaches the total transfer length.
|
||||||
*
|
*
|
||||||
* <b>Single Stream Transfer Example:</b>
|
* <b>Single Stream Transfer Example:</b>
|
||||||
* \code
|
* \code
|
||||||
* uint8_t ErrorCode;
|
* uint8_t ErrorCode;
|
||||||
*
|
*
|
||||||
* if ((ErrorCode = Endpoint_Discard_Stream(512, NULL)) != ENDPOINT_RWSTREAM_NoError)
|
* if ((ErrorCode = Endpoint_Discard_Stream(512, NULL)) != ENDPOINT_RWSTREAM_NoError)
|
||||||
* {
|
* {
|
||||||
* // Stream failed to complete - check ErrorCode here
|
* // Stream failed to complete - check ErrorCode here
|
||||||
* }
|
* }
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* <b>Partial Stream Transfers Example:</b>
|
* <b>Partial Stream Transfers Example:</b>
|
||||||
* \code
|
* \code
|
||||||
* uint8_t ErrorCode;
|
* uint8_t ErrorCode;
|
||||||
* uint16_t BytesProcessed;
|
* uint16_t BytesProcessed;
|
||||||
*
|
*
|
||||||
* BytesProcessed = 0;
|
* BytesProcessed = 0;
|
||||||
* while ((ErrorCode = Endpoint_Discard_Stream(512, &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer)
|
* while ((ErrorCode = Endpoint_Discard_Stream(512, &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer)
|
||||||
* {
|
* {
|
||||||
* // Stream not yet complete - do other actions here, abort if required
|
* // Stream not yet complete - do other actions here, abort if required
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* if (ErrorCode != ENDPOINT_RWSTREAM_NoError)
|
* if (ErrorCode != ENDPOINT_RWSTREAM_NoError)
|
||||||
* {
|
* {
|
||||||
* // Stream failed to complete - check ErrorCode here
|
* // Stream failed to complete - check ErrorCode here
|
||||||
* }
|
* }
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* \note This routine should not be used on CONTROL type endpoints.
|
* \note This routine should not be used on CONTROL type endpoints.
|
||||||
*
|
*
|
||||||
* \param[in] Length Number of bytes to discard via the currently selected endpoint.
|
* \param[in] Length Number of bytes to discard via the currently selected endpoint.
|
||||||
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
||||||
* transaction should be updated, \c NULL if the entire stream should be read at once.
|
* transaction should be updated, \c NULL if the entire stream should be read at once.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Endpoint_Discard_Stream(uint16_t Length,
|
uint8_t Endpoint_Discard_Stream(uint16_t Length,
|
||||||
uint16_t* const BytesProcessed);
|
uint16_t* const BytesProcessed);
|
||||||
|
|
||||||
/** Writes a given number of zeroed bytes to the currently selected endpoint's bank, sending
|
/** Writes a given number of zeroed bytes to the currently selected endpoint's bank, sending
|
||||||
* full packets to the host as needed. The last packet is not automatically sent once the
|
* full packets to the host as needed. The last packet is not automatically sent once the
|
||||||
* remaining bytes have been written; the user is responsible for manually sending the last
|
* remaining bytes have been written; the user is responsible for manually sending the last
|
||||||
* packet to the host via the \ref Endpoint_ClearIN() macro.
|
* packet to the host via the \ref Endpoint_ClearIN() macro.
|
||||||
*
|
*
|
||||||
* If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once,
|
* If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once,
|
||||||
* failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid
|
* failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid
|
||||||
* storage location, the transfer will instead be performed as a series of chunks. Each time
|
* storage location, the transfer will instead be performed as a series of chunks. Each time
|
||||||
* the endpoint bank becomes full while there is still data to process (and after the current
|
* the endpoint bank becomes full while there is still data to process (and after the current
|
||||||
* packet transmission has been initiated) the BytesProcessed location will be updated with the
|
* packet transmission has been initiated) the BytesProcessed location will be updated with the
|
||||||
* total number of bytes processed in the stream, and the function will exit with an error code of
|
* total number of bytes processed in the stream, and the function will exit with an error code of
|
||||||
* \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed
|
* \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed
|
||||||
* in the user code - to continue the transfer, call the function again with identical parameters
|
* in the user code - to continue the transfer, call the function again with identical parameters
|
||||||
* and it will resume until the BytesProcessed value reaches the total transfer length.
|
* and it will resume until the BytesProcessed value reaches the total transfer length.
|
||||||
*
|
*
|
||||||
* <b>Single Stream Transfer Example:</b>
|
* <b>Single Stream Transfer Example:</b>
|
||||||
* \code
|
* \code
|
||||||
* uint8_t ErrorCode;
|
* uint8_t ErrorCode;
|
||||||
*
|
*
|
||||||
* if ((ErrorCode = Endpoint_Null_Stream(512, NULL)) != ENDPOINT_RWSTREAM_NoError)
|
* if ((ErrorCode = Endpoint_Null_Stream(512, NULL)) != ENDPOINT_RWSTREAM_NoError)
|
||||||
* {
|
* {
|
||||||
* // Stream failed to complete - check ErrorCode here
|
* // Stream failed to complete - check ErrorCode here
|
||||||
* }
|
* }
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* <b>Partial Stream Transfers Example:</b>
|
* <b>Partial Stream Transfers Example:</b>
|
||||||
* \code
|
* \code
|
||||||
* uint8_t ErrorCode;
|
* uint8_t ErrorCode;
|
||||||
* uint16_t BytesProcessed;
|
* uint16_t BytesProcessed;
|
||||||
*
|
*
|
||||||
* BytesProcessed = 0;
|
* BytesProcessed = 0;
|
||||||
* while ((ErrorCode = Endpoint_Null_Stream(512, &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer)
|
* while ((ErrorCode = Endpoint_Null_Stream(512, &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer)
|
||||||
* {
|
* {
|
||||||
* // Stream not yet complete - do other actions here, abort if required
|
* // Stream not yet complete - do other actions here, abort if required
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* if (ErrorCode != ENDPOINT_RWSTREAM_NoError)
|
* if (ErrorCode != ENDPOINT_RWSTREAM_NoError)
|
||||||
* {
|
* {
|
||||||
* // Stream failed to complete - check ErrorCode here
|
* // Stream failed to complete - check ErrorCode here
|
||||||
* }
|
* }
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* \note This routine should not be used on CONTROL type endpoints.
|
* \note This routine should not be used on CONTROL type endpoints.
|
||||||
*
|
*
|
||||||
* \param[in] Length Number of zero bytes to send via the currently selected endpoint.
|
* \param[in] Length Number of zero bytes to send via the currently selected endpoint.
|
||||||
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
||||||
* transaction should be updated, \c NULL if the entire stream should be read at once.
|
* transaction should be updated, \c NULL if the entire stream should be read at once.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Endpoint_Null_Stream(uint16_t Length,
|
uint8_t Endpoint_Null_Stream(uint16_t Length,
|
||||||
uint16_t* const BytesProcessed);
|
uint16_t* const BytesProcessed);
|
||||||
|
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
/** \name Stream functions for RAM source/destination data */
|
/** \name Stream functions for RAM source/destination data */
|
||||||
//@{
|
//@{
|
||||||
|
|
||||||
/** Writes the given number of bytes to the endpoint from the given buffer in little endian,
|
/** Writes the given number of bytes to the endpoint from the given buffer in little endian,
|
||||||
* sending full packets to the host as needed. The last packet filled is not automatically sent;
|
* sending full packets to the host as needed. The last packet filled is not automatically sent;
|
||||||
* the user is responsible for manually sending the last written packet to the host via the
|
* the user is responsible for manually sending the last written packet to the host via the
|
||||||
* \ref Endpoint_ClearIN() macro.
|
* \ref Endpoint_ClearIN() macro.
|
||||||
*
|
*
|
||||||
* If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once,
|
* If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once,
|
||||||
* failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid
|
* failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid
|
||||||
* storage location, the transfer will instead be performed as a series of chunks. Each time
|
* storage location, the transfer will instead be performed as a series of chunks. Each time
|
||||||
* the endpoint bank becomes full while there is still data to process (and after the current
|
* the endpoint bank becomes full while there is still data to process (and after the current
|
||||||
* packet transmission has been initiated) the BytesProcessed location will be updated with the
|
* packet transmission has been initiated) the BytesProcessed location will be updated with the
|
||||||
* total number of bytes processed in the stream, and the function will exit with an error code of
|
* total number of bytes processed in the stream, and the function will exit with an error code of
|
||||||
* \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed
|
* \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed
|
||||||
* in the user code - to continue the transfer, call the function again with identical parameters
|
* in the user code - to continue the transfer, call the function again with identical parameters
|
||||||
* and it will resume until the BytesProcessed value reaches the total transfer length.
|
* and it will resume until the BytesProcessed value reaches the total transfer length.
|
||||||
*
|
*
|
||||||
* <b>Single Stream Transfer Example:</b>
|
* <b>Single Stream Transfer Example:</b>
|
||||||
* \code
|
* \code
|
||||||
* uint8_t DataStream[512];
|
* uint8_t DataStream[512];
|
||||||
* uint8_t ErrorCode;
|
* uint8_t ErrorCode;
|
||||||
*
|
*
|
||||||
* if ((ErrorCode = Endpoint_Write_Stream_LE(DataStream, sizeof(DataStream),
|
* if ((ErrorCode = Endpoint_Write_Stream_LE(DataStream, sizeof(DataStream),
|
||||||
* NULL)) != ENDPOINT_RWSTREAM_NoError)
|
* NULL)) != ENDPOINT_RWSTREAM_NoError)
|
||||||
* {
|
* {
|
||||||
* // Stream failed to complete - check ErrorCode here
|
* // Stream failed to complete - check ErrorCode here
|
||||||
* }
|
* }
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* <b>Partial Stream Transfers Example:</b>
|
* <b>Partial Stream Transfers Example:</b>
|
||||||
* \code
|
* \code
|
||||||
* uint8_t DataStream[512];
|
* uint8_t DataStream[512];
|
||||||
* uint8_t ErrorCode;
|
* uint8_t ErrorCode;
|
||||||
* uint16_t BytesProcessed;
|
* uint16_t BytesProcessed;
|
||||||
*
|
*
|
||||||
* BytesProcessed = 0;
|
* BytesProcessed = 0;
|
||||||
* while ((ErrorCode = Endpoint_Write_Stream_LE(DataStream, sizeof(DataStream),
|
* while ((ErrorCode = Endpoint_Write_Stream_LE(DataStream, sizeof(DataStream),
|
||||||
* &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer)
|
* &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer)
|
||||||
* {
|
* {
|
||||||
* // Stream not yet complete - do other actions here, abort if required
|
* // Stream not yet complete - do other actions here, abort if required
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* if (ErrorCode != ENDPOINT_RWSTREAM_NoError)
|
* if (ErrorCode != ENDPOINT_RWSTREAM_NoError)
|
||||||
* {
|
* {
|
||||||
* // Stream failed to complete - check ErrorCode here
|
* // Stream failed to complete - check ErrorCode here
|
||||||
* }
|
* }
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* \note This routine should not be used on CONTROL type endpoints.
|
* \note This routine should not be used on CONTROL type endpoints.
|
||||||
*
|
*
|
||||||
* \param[in] Buffer Pointer to the source data buffer to read from.
|
* \param[in] Buffer Pointer to the source data buffer to read from.
|
||||||
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
||||||
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
||||||
* transaction should be updated, \c NULL if the entire stream should be written at once.
|
* transaction should be updated, \c NULL if the entire stream should be written at once.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Endpoint_Write_Stream_LE(const void* const Buffer,
|
uint8_t Endpoint_Write_Stream_LE(const void* const Buffer,
|
||||||
uint16_t Length,
|
uint16_t Length,
|
||||||
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** Writes the given number of bytes to the endpoint from the given buffer in big endian,
|
/** Writes the given number of bytes to the endpoint from the given buffer in big endian,
|
||||||
* sending full packets to the host as needed. The last packet filled is not automatically sent;
|
* sending full packets to the host as needed. The last packet filled is not automatically sent;
|
||||||
* the user is responsible for manually sending the last written packet to the host via the
|
* the user is responsible for manually sending the last written packet to the host via the
|
||||||
* \ref Endpoint_ClearIN() macro.
|
* \ref Endpoint_ClearIN() macro.
|
||||||
*
|
*
|
||||||
* \note This routine should not be used on CONTROL type endpoints.
|
* \note This routine should not be used on CONTROL type endpoints.
|
||||||
*
|
*
|
||||||
* \param[in] Buffer Pointer to the source data buffer to read from.
|
* \param[in] Buffer Pointer to the source data buffer to read from.
|
||||||
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
||||||
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
||||||
* transaction should be updated, \c NULL if the entire stream should be written at once.
|
* transaction should be updated, \c NULL if the entire stream should be written at once.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Endpoint_Write_Stream_BE(const void* const Buffer,
|
uint8_t Endpoint_Write_Stream_BE(const void* const Buffer,
|
||||||
uint16_t Length,
|
uint16_t Length,
|
||||||
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** Reads the given number of bytes from the endpoint from the given buffer in little endian,
|
/** Reads the given number of bytes from the endpoint from the given buffer in little endian,
|
||||||
* discarding fully read packets from the host as needed. The last packet is not automatically
|
* discarding fully read packets from the host as needed. The last packet is not automatically
|
||||||
* discarded once the remaining bytes has been read; the user is responsible for manually
|
* discarded once the remaining bytes has been read; the user is responsible for manually
|
||||||
* discarding the last packet from the host via the \ref Endpoint_ClearOUT() macro.
|
* discarding the last packet from the host via the \ref Endpoint_ClearOUT() macro.
|
||||||
*
|
*
|
||||||
* If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once,
|
* If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once,
|
||||||
* failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid
|
* failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid
|
||||||
* storage location, the transfer will instead be performed as a series of chunks. Each time
|
* storage location, the transfer will instead be performed as a series of chunks. Each time
|
||||||
* the endpoint bank becomes empty while there is still data to process (and after the current
|
* the endpoint bank becomes empty while there is still data to process (and after the current
|
||||||
* packet has been acknowledged) the BytesProcessed location will be updated with the total number
|
* packet has been acknowledged) the BytesProcessed location will be updated with the total number
|
||||||
* of bytes processed in the stream, and the function will exit with an error code of
|
* of bytes processed in the stream, and the function will exit with an error code of
|
||||||
* \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed
|
* \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed
|
||||||
* in the user code - to continue the transfer, call the function again with identical parameters
|
* in the user code - to continue the transfer, call the function again with identical parameters
|
||||||
* and it will resume until the BytesProcessed value reaches the total transfer length.
|
* and it will resume until the BytesProcessed value reaches the total transfer length.
|
||||||
*
|
*
|
||||||
* <b>Single Stream Transfer Example:</b>
|
* <b>Single Stream Transfer Example:</b>
|
||||||
* \code
|
* \code
|
||||||
* uint8_t DataStream[512];
|
* uint8_t DataStream[512];
|
||||||
* uint8_t ErrorCode;
|
* uint8_t ErrorCode;
|
||||||
*
|
*
|
||||||
* if ((ErrorCode = Endpoint_Read_Stream_LE(DataStream, sizeof(DataStream),
|
* if ((ErrorCode = Endpoint_Read_Stream_LE(DataStream, sizeof(DataStream),
|
||||||
* NULL)) != ENDPOINT_RWSTREAM_NoError)
|
* NULL)) != ENDPOINT_RWSTREAM_NoError)
|
||||||
* {
|
* {
|
||||||
* // Stream failed to complete - check ErrorCode here
|
* // Stream failed to complete - check ErrorCode here
|
||||||
* }
|
* }
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* <b>Partial Stream Transfers Example:</b>
|
* <b>Partial Stream Transfers Example:</b>
|
||||||
* \code
|
* \code
|
||||||
* uint8_t DataStream[512];
|
* uint8_t DataStream[512];
|
||||||
* uint8_t ErrorCode;
|
* uint8_t ErrorCode;
|
||||||
* uint16_t BytesProcessed;
|
* uint16_t BytesProcessed;
|
||||||
*
|
*
|
||||||
* BytesProcessed = 0;
|
* BytesProcessed = 0;
|
||||||
* while ((ErrorCode = Endpoint_Read_Stream_LE(DataStream, sizeof(DataStream),
|
* while ((ErrorCode = Endpoint_Read_Stream_LE(DataStream, sizeof(DataStream),
|
||||||
* &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer)
|
* &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer)
|
||||||
* {
|
* {
|
||||||
* // Stream not yet complete - do other actions here, abort if required
|
* // Stream not yet complete - do other actions here, abort if required
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* if (ErrorCode != ENDPOINT_RWSTREAM_NoError)
|
* if (ErrorCode != ENDPOINT_RWSTREAM_NoError)
|
||||||
* {
|
* {
|
||||||
* // Stream failed to complete - check ErrorCode here
|
* // Stream failed to complete - check ErrorCode here
|
||||||
* }
|
* }
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* \note This routine should not be used on CONTROL type endpoints.
|
* \note This routine should not be used on CONTROL type endpoints.
|
||||||
*
|
*
|
||||||
* \param[out] Buffer Pointer to the destination data buffer to write to.
|
* \param[out] Buffer Pointer to the destination data buffer to write to.
|
||||||
* \param[in] Length Number of bytes to send via the currently selected endpoint.
|
* \param[in] Length Number of bytes to send via the currently selected endpoint.
|
||||||
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
||||||
* transaction should be updated, \c NULL if the entire stream should be read at once.
|
* transaction should be updated, \c NULL if the entire stream should be read at once.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Endpoint_Read_Stream_LE(void* const Buffer,
|
uint8_t Endpoint_Read_Stream_LE(void* const Buffer,
|
||||||
uint16_t Length,
|
uint16_t Length,
|
||||||
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** Reads the given number of bytes from the endpoint from the given buffer in big endian,
|
/** Reads the given number of bytes from the endpoint from the given buffer in big endian,
|
||||||
* discarding fully read packets from the host as needed. The last packet is not automatically
|
* discarding fully read packets from the host as needed. The last packet is not automatically
|
||||||
* discarded once the remaining bytes has been read; the user is responsible for manually
|
* discarded once the remaining bytes has been read; the user is responsible for manually
|
||||||
* discarding the last packet from the host via the \ref Endpoint_ClearOUT() macro.
|
* discarding the last packet from the host via the \ref Endpoint_ClearOUT() macro.
|
||||||
*
|
*
|
||||||
* \note This routine should not be used on CONTROL type endpoints.
|
* \note This routine should not be used on CONTROL type endpoints.
|
||||||
*
|
*
|
||||||
* \param[out] Buffer Pointer to the destination data buffer to write to.
|
* \param[out] Buffer Pointer to the destination data buffer to write to.
|
||||||
* \param[in] Length Number of bytes to send via the currently selected endpoint.
|
* \param[in] Length Number of bytes to send via the currently selected endpoint.
|
||||||
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
||||||
* transaction should be updated, \c NULL if the entire stream should be read at once.
|
* transaction should be updated, \c NULL if the entire stream should be read at once.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Endpoint_Read_Stream_BE(void* const Buffer,
|
uint8_t Endpoint_Read_Stream_BE(void* const Buffer,
|
||||||
uint16_t Length,
|
uint16_t Length,
|
||||||
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** Writes the given number of bytes to the CONTROL type endpoint from the given buffer in little endian,
|
/** Writes the given number of bytes to the CONTROL type endpoint from the given buffer in little endian,
|
||||||
* sending full packets to the host as needed. The host OUT acknowledgement is not automatically cleared
|
* sending full packets to the host as needed. The host OUT acknowledgement is not automatically cleared
|
||||||
* in both failure and success states; the user is responsible for manually clearing the setup OUT to
|
* in both failure and success states; the user is responsible for manually clearing the setup OUT to
|
||||||
* finalize the transfer via the \ref Endpoint_ClearOUT() macro.
|
* finalize the transfer via the \ref Endpoint_ClearOUT() macro.
|
||||||
*
|
*
|
||||||
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
|
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
|
||||||
* to clear the status stage when using this routine in a control transaction.
|
* to clear the status stage when using this routine in a control transaction.
|
||||||
* \n\n
|
* \n\n
|
||||||
*
|
*
|
||||||
* \note This routine should only be used on CONTROL type endpoints.
|
* \note This routine should only be used on CONTROL type endpoints.
|
||||||
*
|
*
|
||||||
* \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
|
* \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
|
||||||
* together; i.e. the entire stream data must be read or written at the one time.
|
* together; i.e. the entire stream data must be read or written at the one time.
|
||||||
*
|
*
|
||||||
* \param[in] Buffer Pointer to the source data buffer to read from.
|
* \param[in] Buffer Pointer to the source data buffer to read from.
|
||||||
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Endpoint_Write_Control_Stream_LE(const void* const Buffer,
|
uint8_t Endpoint_Write_Control_Stream_LE(const void* const Buffer,
|
||||||
uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** Writes the given number of bytes to the CONTROL type endpoint from the given buffer in big endian,
|
/** Writes the given number of bytes to the CONTROL type endpoint from the given buffer in big endian,
|
||||||
* sending full packets to the host as needed. The host OUT acknowledgement is not automatically cleared
|
* sending full packets to the host as needed. The host OUT acknowledgement is not automatically cleared
|
||||||
* in both failure and success states; the user is responsible for manually clearing the setup OUT to
|
* in both failure and success states; the user is responsible for manually clearing the setup OUT to
|
||||||
* finalize the transfer via the \ref Endpoint_ClearOUT() macro.
|
* finalize the transfer via the \ref Endpoint_ClearOUT() macro.
|
||||||
*
|
*
|
||||||
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
|
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
|
||||||
* to clear the status stage when using this routine in a control transaction.
|
* to clear the status stage when using this routine in a control transaction.
|
||||||
* \n\n
|
* \n\n
|
||||||
*
|
*
|
||||||
* \note This routine should only be used on CONTROL type endpoints.
|
* \note This routine should only be used on CONTROL type endpoints.
|
||||||
*
|
*
|
||||||
* \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
|
* \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
|
||||||
* together; i.e. the entire stream data must be read or written at the one time.
|
* together; i.e. the entire stream data must be read or written at the one time.
|
||||||
*
|
*
|
||||||
* \param[in] Buffer Pointer to the source data buffer to read from.
|
* \param[in] Buffer Pointer to the source data buffer to read from.
|
||||||
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Endpoint_Write_Control_Stream_BE(const void* const Buffer,
|
uint8_t Endpoint_Write_Control_Stream_BE(const void* const Buffer,
|
||||||
uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** Reads the given number of bytes from the CONTROL endpoint from the given buffer in little endian,
|
/** Reads the given number of bytes from the CONTROL endpoint from the given buffer in little endian,
|
||||||
* discarding fully read packets from the host as needed. The device IN acknowledgement is not
|
* discarding fully read packets from the host as needed. The device IN acknowledgement is not
|
||||||
* automatically sent after success or failure states; the user is responsible for manually sending the
|
* automatically sent after success or failure states; the user is responsible for manually sending the
|
||||||
* setup IN to finalize the transfer via the \ref Endpoint_ClearIN() macro.
|
* setup IN to finalize the transfer via the \ref Endpoint_ClearIN() macro.
|
||||||
*
|
*
|
||||||
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
|
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
|
||||||
* to clear the status stage when using this routine in a control transaction.
|
* to clear the status stage when using this routine in a control transaction.
|
||||||
* \n\n
|
* \n\n
|
||||||
*
|
*
|
||||||
* \note This routine should only be used on CONTROL type endpoints.
|
* \note This routine should only be used on CONTROL type endpoints.
|
||||||
*
|
*
|
||||||
* \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
|
* \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
|
||||||
* together; i.e. the entire stream data must be read or written at the one time.
|
* together; i.e. the entire stream data must be read or written at the one time.
|
||||||
*
|
*
|
||||||
* \param[out] Buffer Pointer to the destination data buffer to write to.
|
* \param[out] Buffer Pointer to the destination data buffer to write to.
|
||||||
* \param[in] Length Number of bytes to send via the currently selected endpoint.
|
* \param[in] Length Number of bytes to send via the currently selected endpoint.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Endpoint_Read_Control_Stream_LE(void* const Buffer,
|
uint8_t Endpoint_Read_Control_Stream_LE(void* const Buffer,
|
||||||
uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** Reads the given number of bytes from the CONTROL endpoint from the given buffer in big endian,
|
/** Reads the given number of bytes from the CONTROL endpoint from the given buffer in big endian,
|
||||||
* discarding fully read packets from the host as needed. The device IN acknowledgement is not
|
* discarding fully read packets from the host as needed. The device IN acknowledgement is not
|
||||||
* automatically sent after success or failure states; the user is responsible for manually sending the
|
* automatically sent after success or failure states; the user is responsible for manually sending the
|
||||||
* setup IN to finalize the transfer via the \ref Endpoint_ClearIN() macro.
|
* setup IN to finalize the transfer via the \ref Endpoint_ClearIN() macro.
|
||||||
*
|
*
|
||||||
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
|
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
|
||||||
* to clear the status stage when using this routine in a control transaction.
|
* to clear the status stage when using this routine in a control transaction.
|
||||||
* \n\n
|
* \n\n
|
||||||
*
|
*
|
||||||
* \note This routine should only be used on CONTROL type endpoints.
|
* \note This routine should only be used on CONTROL type endpoints.
|
||||||
*
|
*
|
||||||
* \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
|
* \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
|
||||||
* together; i.e. the entire stream data must be read or written at the one time.
|
* together; i.e. the entire stream data must be read or written at the one time.
|
||||||
*
|
*
|
||||||
* \param[out] Buffer Pointer to the destination data buffer to write to.
|
* \param[out] Buffer Pointer to the destination data buffer to write to.
|
||||||
* \param[in] Length Number of bytes to send via the currently selected endpoint.
|
* \param[in] Length Number of bytes to send via the currently selected endpoint.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Endpoint_Read_Control_Stream_BE(void* const Buffer,
|
uint8_t Endpoint_Read_Control_Stream_BE(void* const Buffer,
|
||||||
uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
/* Disable C linkage for C++ Compilers: */
|
/* Disable C linkage for C++ Compilers: */
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
@ -1,166 +1,166 @@
|
|||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2012.
|
Copyright (C) Dean Camera, 2012.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.lufa-lib.org
|
www.lufa-lib.org
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||||
|
|
||||||
Permission to use, copy, modify, distribute, and sell this
|
Permission to use, copy, modify, distribute, and sell this
|
||||||
software and its documentation for any purpose is hereby granted
|
software and its documentation for any purpose is hereby granted
|
||||||
without fee, provided that the above copyright notice appear in
|
without fee, provided that the above copyright notice appear in
|
||||||
all copies and that both that the copyright notice and this
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
software, including all implied warranties of merchantability
|
software, including all implied warranties of merchantability
|
||||||
and fitness. In no event shall the author be liable for any
|
and fitness. In no event shall the author be liable for any
|
||||||
special, indirect or consequential damages or any damages
|
special, indirect or consequential damages or any damages
|
||||||
whatsoever resulting from loss of use, data or profits, whether
|
whatsoever resulting from loss of use, data or profits, whether
|
||||||
in an action of contract, negligence or other tortious action,
|
in an action of contract, negligence or other tortious action,
|
||||||
arising out of or in connection with the use or performance of
|
arising out of or in connection with the use or performance of
|
||||||
this software.
|
this software.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../../../../Common/Common.h"
|
#include "../../../../Common/Common.h"
|
||||||
#if (ARCH == ARCH_UC3)
|
#if (ARCH == ARCH_UC3)
|
||||||
|
|
||||||
#define __INCLUDE_FROM_USB_DRIVER
|
#define __INCLUDE_FROM_USB_DRIVER
|
||||||
#include "../USBMode.h"
|
#include "../USBMode.h"
|
||||||
|
|
||||||
#if defined(USB_CAN_BE_HOST)
|
#if defined(USB_CAN_BE_HOST)
|
||||||
|
|
||||||
#include "PipeStream_UC3.h"
|
#include "PipeStream_UC3.h"
|
||||||
|
|
||||||
uint8_t Pipe_Discard_Stream(uint16_t Length,
|
uint8_t Pipe_Discard_Stream(uint16_t Length,
|
||||||
uint16_t* const BytesProcessed)
|
uint16_t* const BytesProcessed)
|
||||||
{
|
{
|
||||||
uint8_t ErrorCode;
|
uint8_t ErrorCode;
|
||||||
uint16_t BytesInTransfer = 0;
|
uint16_t BytesInTransfer = 0;
|
||||||
|
|
||||||
Pipe_SetPipeToken(PIPE_TOKEN_IN);
|
Pipe_SetPipeToken(PIPE_TOKEN_IN);
|
||||||
|
|
||||||
if ((ErrorCode = Pipe_WaitUntilReady()))
|
if ((ErrorCode = Pipe_WaitUntilReady()))
|
||||||
return ErrorCode;
|
return ErrorCode;
|
||||||
|
|
||||||
if (BytesProcessed != NULL)
|
if (BytesProcessed != NULL)
|
||||||
Length -= *BytesProcessed;
|
Length -= *BytesProcessed;
|
||||||
|
|
||||||
while (Length)
|
while (Length)
|
||||||
{
|
{
|
||||||
if (!(Pipe_IsReadWriteAllowed()))
|
if (!(Pipe_IsReadWriteAllowed()))
|
||||||
{
|
{
|
||||||
Pipe_ClearIN();
|
Pipe_ClearIN();
|
||||||
|
|
||||||
if (BytesProcessed != NULL)
|
if (BytesProcessed != NULL)
|
||||||
{
|
{
|
||||||
*BytesProcessed += BytesInTransfer;
|
*BytesProcessed += BytesInTransfer;
|
||||||
return PIPE_RWSTREAM_IncompleteTransfer;
|
return PIPE_RWSTREAM_IncompleteTransfer;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ErrorCode = Pipe_WaitUntilReady()))
|
if ((ErrorCode = Pipe_WaitUntilReady()))
|
||||||
return ErrorCode;
|
return ErrorCode;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Pipe_Discard_8();
|
Pipe_Discard_8();
|
||||||
|
|
||||||
Length--;
|
Length--;
|
||||||
BytesInTransfer++;
|
BytesInTransfer++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return PIPE_RWSTREAM_NoError;
|
return PIPE_RWSTREAM_NoError;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t Pipe_Null_Stream(uint16_t Length,
|
uint8_t Pipe_Null_Stream(uint16_t Length,
|
||||||
uint16_t* const BytesProcessed)
|
uint16_t* const BytesProcessed)
|
||||||
{
|
{
|
||||||
uint8_t ErrorCode;
|
uint8_t ErrorCode;
|
||||||
uint16_t BytesInTransfer = 0;
|
uint16_t BytesInTransfer = 0;
|
||||||
|
|
||||||
Pipe_SetPipeToken(PIPE_TOKEN_OUT);
|
Pipe_SetPipeToken(PIPE_TOKEN_OUT);
|
||||||
|
|
||||||
if ((ErrorCode = Pipe_WaitUntilReady()))
|
if ((ErrorCode = Pipe_WaitUntilReady()))
|
||||||
return ErrorCode;
|
return ErrorCode;
|
||||||
|
|
||||||
if (BytesProcessed != NULL)
|
if (BytesProcessed != NULL)
|
||||||
Length -= *BytesProcessed;
|
Length -= *BytesProcessed;
|
||||||
|
|
||||||
while (Length)
|
while (Length)
|
||||||
{
|
{
|
||||||
if (!(Pipe_IsReadWriteAllowed()))
|
if (!(Pipe_IsReadWriteAllowed()))
|
||||||
{
|
{
|
||||||
Pipe_ClearOUT();
|
Pipe_ClearOUT();
|
||||||
|
|
||||||
if (BytesProcessed != NULL)
|
if (BytesProcessed != NULL)
|
||||||
{
|
{
|
||||||
*BytesProcessed += BytesInTransfer;
|
*BytesProcessed += BytesInTransfer;
|
||||||
return PIPE_RWSTREAM_IncompleteTransfer;
|
return PIPE_RWSTREAM_IncompleteTransfer;
|
||||||
}
|
}
|
||||||
|
|
||||||
USB_USBTask();
|
USB_USBTask();
|
||||||
|
|
||||||
if ((ErrorCode = Pipe_WaitUntilReady()))
|
if ((ErrorCode = Pipe_WaitUntilReady()))
|
||||||
return ErrorCode;
|
return ErrorCode;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Pipe_Write_8(0);
|
Pipe_Write_8(0);
|
||||||
|
|
||||||
Length--;
|
Length--;
|
||||||
BytesInTransfer++;
|
BytesInTransfer++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return PIPE_RWSTREAM_NoError;
|
return PIPE_RWSTREAM_NoError;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The following abuses the C preprocessor in order to copy-paste common code with slight alterations,
|
/* The following abuses the C preprocessor in order to copy-paste common code with slight alterations,
|
||||||
* so that the code needs to be written once. It is a crude form of templating to reduce code maintenance. */
|
* so that the code needs to be written once. It is a crude form of templating to reduce code maintenance. */
|
||||||
|
|
||||||
#define TEMPLATE_FUNC_NAME Pipe_Write_Stream_LE
|
#define TEMPLATE_FUNC_NAME Pipe_Write_Stream_LE
|
||||||
#define TEMPLATE_BUFFER_TYPE const void*
|
#define TEMPLATE_BUFFER_TYPE const void*
|
||||||
#define TEMPLATE_TOKEN PIPE_TOKEN_OUT
|
#define TEMPLATE_TOKEN PIPE_TOKEN_OUT
|
||||||
#define TEMPLATE_CLEAR_PIPE() Pipe_ClearOUT()
|
#define TEMPLATE_CLEAR_PIPE() Pipe_ClearOUT()
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream += Amount
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream += Amount
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_8(*BufferPtr)
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_8(*BufferPtr)
|
||||||
#include "Template/Template_Pipe_RW.c"
|
#include "Template/Template_Pipe_RW.c"
|
||||||
|
|
||||||
#define TEMPLATE_FUNC_NAME Pipe_Write_Stream_BE
|
#define TEMPLATE_FUNC_NAME Pipe_Write_Stream_BE
|
||||||
#define TEMPLATE_BUFFER_TYPE const void*
|
#define TEMPLATE_BUFFER_TYPE const void*
|
||||||
#define TEMPLATE_TOKEN PIPE_TOKEN_OUT
|
#define TEMPLATE_TOKEN PIPE_TOKEN_OUT
|
||||||
#define TEMPLATE_CLEAR_PIPE() Pipe_ClearOUT()
|
#define TEMPLATE_CLEAR_PIPE() Pipe_ClearOUT()
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream -= Amount
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream -= Amount
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_8(*BufferPtr)
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_8(*BufferPtr)
|
||||||
#include "Template/Template_Pipe_RW.c"
|
#include "Template/Template_Pipe_RW.c"
|
||||||
|
|
||||||
#define TEMPLATE_FUNC_NAME Pipe_Read_Stream_LE
|
#define TEMPLATE_FUNC_NAME Pipe_Read_Stream_LE
|
||||||
#define TEMPLATE_BUFFER_TYPE void*
|
#define TEMPLATE_BUFFER_TYPE void*
|
||||||
#define TEMPLATE_TOKEN PIPE_TOKEN_IN
|
#define TEMPLATE_TOKEN PIPE_TOKEN_IN
|
||||||
#define TEMPLATE_CLEAR_PIPE() Pipe_ClearIN()
|
#define TEMPLATE_CLEAR_PIPE() Pipe_ClearIN()
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream += Amount
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream += Amount
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Pipe_Read_8()
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Pipe_Read_8()
|
||||||
#include "Template/Template_Pipe_RW.c"
|
#include "Template/Template_Pipe_RW.c"
|
||||||
|
|
||||||
#define TEMPLATE_FUNC_NAME Pipe_Read_Stream_BE
|
#define TEMPLATE_FUNC_NAME Pipe_Read_Stream_BE
|
||||||
#define TEMPLATE_BUFFER_TYPE void*
|
#define TEMPLATE_BUFFER_TYPE void*
|
||||||
#define TEMPLATE_TOKEN PIPE_TOKEN_IN
|
#define TEMPLATE_TOKEN PIPE_TOKEN_IN
|
||||||
#define TEMPLATE_CLEAR_PIPE() Pipe_ClearIN()
|
#define TEMPLATE_CLEAR_PIPE() Pipe_ClearIN()
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream -= Amount
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream -= Amount
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Pipe_Read_8()
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Pipe_Read_8()
|
||||||
#include "Template/Template_Pipe_RW.c"
|
#include "Template/Template_Pipe_RW.c"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,352 +1,352 @@
|
|||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2012.
|
Copyright (C) Dean Camera, 2012.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.lufa-lib.org
|
www.lufa-lib.org
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||||
|
|
||||||
Permission to use, copy, modify, distribute, and sell this
|
Permission to use, copy, modify, distribute, and sell this
|
||||||
software and its documentation for any purpose is hereby granted
|
software and its documentation for any purpose is hereby granted
|
||||||
without fee, provided that the above copyright notice appear in
|
without fee, provided that the above copyright notice appear in
|
||||||
all copies and that both that the copyright notice and this
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
software, including all implied warranties of merchantability
|
software, including all implied warranties of merchantability
|
||||||
and fitness. In no event shall the author be liable for any
|
and fitness. In no event shall the author be liable for any
|
||||||
special, indirect or consequential damages or any damages
|
special, indirect or consequential damages or any damages
|
||||||
whatsoever resulting from loss of use, data or profits, whether
|
whatsoever resulting from loss of use, data or profits, whether
|
||||||
in an action of contract, negligence or other tortious action,
|
in an action of contract, negligence or other tortious action,
|
||||||
arising out of or in connection with the use or performance of
|
arising out of or in connection with the use or performance of
|
||||||
this software.
|
this software.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \file
|
/** \file
|
||||||
* \brief Pipe data stream transmission and reception management for the AVR32 UC3 microcontrollers.
|
* \brief Pipe data stream transmission and reception management for the AVR32 UC3 microcontrollers.
|
||||||
* \copydetails Group_PipeStreamRW_UC3
|
* \copydetails Group_PipeStreamRW_UC3
|
||||||
*
|
*
|
||||||
* \note This file should not be included directly. It is automatically included as needed by the USB driver
|
* \note This file should not be included directly. It is automatically included as needed by the USB driver
|
||||||
* dispatch header located in LUFA/Drivers/USB/USB.h.
|
* dispatch header located in LUFA/Drivers/USB/USB.h.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \ingroup Group_PipeStreamRW
|
/** \ingroup Group_PipeStreamRW
|
||||||
* \defgroup Group_PipeStreamRW_UC3 Read/Write of Multi-Byte Streams (UC3)
|
* \defgroup Group_PipeStreamRW_UC3 Read/Write of Multi-Byte Streams (UC3)
|
||||||
* \brief Pipe data stream transmission and reception management for the Atmel AVR32 UC3 architecture.
|
* \brief Pipe data stream transmission and reception management for the Atmel AVR32 UC3 architecture.
|
||||||
*
|
*
|
||||||
* Functions, macros, variables, enums and types related to data reading and writing of data streams from
|
* Functions, macros, variables, enums and types related to data reading and writing of data streams from
|
||||||
* and to pipes.
|
* and to pipes.
|
||||||
*
|
*
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __PIPE_STREAM_UC3_H__
|
#ifndef __PIPE_STREAM_UC3_H__
|
||||||
#define __PIPE_STREAM_UC3_H__
|
#define __PIPE_STREAM_UC3_H__
|
||||||
|
|
||||||
/* Includes: */
|
/* Includes: */
|
||||||
#include "../../../../Common/Common.h"
|
#include "../../../../Common/Common.h"
|
||||||
#include "../USBMode.h"
|
#include "../USBMode.h"
|
||||||
#include "../USBTask.h"
|
#include "../USBTask.h"
|
||||||
|
|
||||||
/* Enable C linkage for C++ Compilers: */
|
/* Enable C linkage for C++ Compilers: */
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Preprocessor Checks: */
|
/* Preprocessor Checks: */
|
||||||
#if !defined(__INCLUDE_FROM_USB_DRIVER)
|
#if !defined(__INCLUDE_FROM_USB_DRIVER)
|
||||||
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
|
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Public Interface - May be used in end-application: */
|
/* Public Interface - May be used in end-application: */
|
||||||
/* Function Prototypes: */
|
/* Function Prototypes: */
|
||||||
/** \name Stream functions for null data */
|
/** \name Stream functions for null data */
|
||||||
//@{
|
//@{
|
||||||
|
|
||||||
/** Reads and discards the given number of bytes from the pipe, discarding fully read packets from the host
|
/** Reads and discards the given number of bytes from the pipe, discarding fully read packets from the host
|
||||||
* as needed. The last packet is not automatically discarded once the remaining bytes has been read; the
|
* as needed. The last packet is not automatically discarded once the remaining bytes has been read; the
|
||||||
* user is responsible for manually discarding the last packet from the device via the \ref Pipe_ClearIN() macro.
|
* user is responsible for manually discarding the last packet from the device via the \ref Pipe_ClearIN() macro.
|
||||||
*
|
*
|
||||||
* If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once, failing or
|
* If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once, failing or
|
||||||
* succeeding as a single unit. If the BytesProcessed parameter points to a valid storage location, the transfer
|
* succeeding as a single unit. If the BytesProcessed parameter points to a valid storage location, the transfer
|
||||||
* will instead be performed as a series of chunks. Each time the pipe bank becomes empty while there is still data
|
* will instead be performed as a series of chunks. Each time the pipe bank becomes empty while there is still data
|
||||||
* to process (and after the current packet has been acknowledged) the BytesProcessed location will be updated with
|
* to process (and after the current packet has been acknowledged) the BytesProcessed location will be updated with
|
||||||
* the total number of bytes processed in the stream, and the function will exit with an error code of
|
* the total number of bytes processed in the stream, and the function will exit with an error code of
|
||||||
* \ref PIPE_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed in the user code - to
|
* \ref PIPE_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed in the user code - to
|
||||||
* continue the transfer, call the function again with identical parameters and it will resume until the BytesProcessed
|
* continue the transfer, call the function again with identical parameters and it will resume until the BytesProcessed
|
||||||
* value reaches the total transfer length.
|
* value reaches the total transfer length.
|
||||||
*
|
*
|
||||||
* <b>Single Stream Transfer Example:</b>
|
* <b>Single Stream Transfer Example:</b>
|
||||||
* \code
|
* \code
|
||||||
* uint8_t ErrorCode;
|
* uint8_t ErrorCode;
|
||||||
*
|
*
|
||||||
* if ((ErrorCode = Pipe_Discard_Stream(512, NULL)) != PIPE_RWSTREAM_NoError)
|
* if ((ErrorCode = Pipe_Discard_Stream(512, NULL)) != PIPE_RWSTREAM_NoError)
|
||||||
* {
|
* {
|
||||||
* // Stream failed to complete - check ErrorCode here
|
* // Stream failed to complete - check ErrorCode here
|
||||||
* }
|
* }
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* <b>Partial Stream Transfers Example:</b>
|
* <b>Partial Stream Transfers Example:</b>
|
||||||
* \code
|
* \code
|
||||||
* uint8_t ErrorCode;
|
* uint8_t ErrorCode;
|
||||||
* uint16_t BytesProcessed;
|
* uint16_t BytesProcessed;
|
||||||
*
|
*
|
||||||
* BytesProcessed = 0;
|
* BytesProcessed = 0;
|
||||||
* while ((ErrorCode = Pipe_Discard_Stream(512, &BytesProcessed)) == PIPE_RWSTREAM_IncompleteTransfer)
|
* while ((ErrorCode = Pipe_Discard_Stream(512, &BytesProcessed)) == PIPE_RWSTREAM_IncompleteTransfer)
|
||||||
* {
|
* {
|
||||||
* // Stream not yet complete - do other actions here, abort if required
|
* // Stream not yet complete - do other actions here, abort if required
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* if (ErrorCode != PIPE_RWSTREAM_NoError)
|
* if (ErrorCode != PIPE_RWSTREAM_NoError)
|
||||||
* {
|
* {
|
||||||
* // Stream failed to complete - check ErrorCode here
|
* // Stream failed to complete - check ErrorCode here
|
||||||
* }
|
* }
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without
|
* \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without
|
||||||
* having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken().
|
* having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken().
|
||||||
*
|
*
|
||||||
* \param[in] Length Number of bytes to discard via the currently selected pipe.
|
* \param[in] Length Number of bytes to discard via the currently selected pipe.
|
||||||
* \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should
|
* \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should
|
||||||
* updated, \c NULL if the entire stream should be processed at once.
|
* updated, \c NULL if the entire stream should be processed at once.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Pipe_Discard_Stream(uint16_t Length,
|
uint8_t Pipe_Discard_Stream(uint16_t Length,
|
||||||
uint16_t* const BytesProcessed);
|
uint16_t* const BytesProcessed);
|
||||||
|
|
||||||
/** Writes a given number of zeroed bytes to the pipe, sending full pipe packets from the host to the device
|
/** Writes a given number of zeroed bytes to the pipe, sending full pipe packets from the host to the device
|
||||||
* as needed. The last packet is not automatically sent once the remaining bytes has been written; the
|
* as needed. The last packet is not automatically sent once the remaining bytes has been written; the
|
||||||
* user is responsible for manually discarding the last packet from the device via the \ref Pipe_ClearOUT() macro.
|
* user is responsible for manually discarding the last packet from the device via the \ref Pipe_ClearOUT() macro.
|
||||||
*
|
*
|
||||||
* If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once, failing or
|
* If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once, failing or
|
||||||
* succeeding as a single unit. If the BytesProcessed parameter points to a valid storage location, the transfer
|
* succeeding as a single unit. If the BytesProcessed parameter points to a valid storage location, the transfer
|
||||||
* will instead be performed as a series of chunks. Each time the pipe bank becomes full while there is still data
|
* will instead be performed as a series of chunks. Each time the pipe bank becomes full while there is still data
|
||||||
* to process (and after the current packet transmission has been initiated) the BytesProcessed location will be
|
* to process (and after the current packet transmission has been initiated) the BytesProcessed location will be
|
||||||
* updated with the total number of bytes processed in the stream, and the function will exit with an error code of
|
* updated with the total number of bytes processed in the stream, and the function will exit with an error code of
|
||||||
* \ref PIPE_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed in the user code - to
|
* \ref PIPE_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed in the user code - to
|
||||||
* continue the transfer, call the function again with identical parameters and it will resume until the BytesProcessed
|
* continue the transfer, call the function again with identical parameters and it will resume until the BytesProcessed
|
||||||
* value reaches the total transfer length.
|
* value reaches the total transfer length.
|
||||||
*
|
*
|
||||||
* <b>Single Stream Transfer Example:</b>
|
* <b>Single Stream Transfer Example:</b>
|
||||||
* \code
|
* \code
|
||||||
* uint8_t ErrorCode;
|
* uint8_t ErrorCode;
|
||||||
*
|
*
|
||||||
* if ((ErrorCode = Pipe_Null_Stream(512, NULL)) != PIPE_RWSTREAM_NoError)
|
* if ((ErrorCode = Pipe_Null_Stream(512, NULL)) != PIPE_RWSTREAM_NoError)
|
||||||
* {
|
* {
|
||||||
* // Stream failed to complete - check ErrorCode here
|
* // Stream failed to complete - check ErrorCode here
|
||||||
* }
|
* }
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* <b>Partial Stream Transfers Example:</b>
|
* <b>Partial Stream Transfers Example:</b>
|
||||||
* \code
|
* \code
|
||||||
* uint8_t ErrorCode;
|
* uint8_t ErrorCode;
|
||||||
* uint16_t BytesProcessed;
|
* uint16_t BytesProcessed;
|
||||||
*
|
*
|
||||||
* BytesProcessed = 0;
|
* BytesProcessed = 0;
|
||||||
* while ((ErrorCode = Pipe_Null_Stream(512, &BytesProcessed)) == PIPE_RWSTREAM_IncompleteTransfer)
|
* while ((ErrorCode = Pipe_Null_Stream(512, &BytesProcessed)) == PIPE_RWSTREAM_IncompleteTransfer)
|
||||||
* {
|
* {
|
||||||
* // Stream not yet complete - do other actions here, abort if required
|
* // Stream not yet complete - do other actions here, abort if required
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* if (ErrorCode != PIPE_RWSTREAM_NoError)
|
* if (ErrorCode != PIPE_RWSTREAM_NoError)
|
||||||
* {
|
* {
|
||||||
* // Stream failed to complete - check ErrorCode here
|
* // Stream failed to complete - check ErrorCode here
|
||||||
* }
|
* }
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without
|
* \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without
|
||||||
* having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken().
|
* having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken().
|
||||||
*
|
*
|
||||||
* \param[in] Length Number of zero bytes to write via the currently selected pipe.
|
* \param[in] Length Number of zero bytes to write via the currently selected pipe.
|
||||||
* \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should
|
* \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should
|
||||||
* updated, \c NULL if the entire stream should be processed at once.
|
* updated, \c NULL if the entire stream should be processed at once.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Pipe_Null_Stream(uint16_t Length,
|
uint8_t Pipe_Null_Stream(uint16_t Length,
|
||||||
uint16_t* const BytesProcessed);
|
uint16_t* const BytesProcessed);
|
||||||
|
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
/** \name Stream functions for RAM source/destination data */
|
/** \name Stream functions for RAM source/destination data */
|
||||||
//@{
|
//@{
|
||||||
|
|
||||||
/** Writes the given number of bytes to the pipe from the given buffer in little endian,
|
/** Writes the given number of bytes to the pipe from the given buffer in little endian,
|
||||||
* sending full packets to the device as needed. The last packet filled is not automatically sent;
|
* sending full packets to the device as needed. The last packet filled is not automatically sent;
|
||||||
* the user is responsible for manually sending the last written packet to the host via the
|
* the user is responsible for manually sending the last written packet to the host via the
|
||||||
* \ref Pipe_ClearOUT() macro. Between each USB packet, the given stream callback function is
|
* \ref Pipe_ClearOUT() macro. Between each USB packet, the given stream callback function is
|
||||||
* executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers.
|
* executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers.
|
||||||
*
|
*
|
||||||
* If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once,
|
* If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once,
|
||||||
* failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid
|
* failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid
|
||||||
* storage location, the transfer will instead be performed as a series of chunks. Each time
|
* storage location, the transfer will instead be performed as a series of chunks. Each time
|
||||||
* the pipe bank becomes full while there is still data to process (and after the current
|
* the pipe bank becomes full while there is still data to process (and after the current
|
||||||
* packet transmission has been initiated) the BytesProcessed location will be updated with the
|
* packet transmission has been initiated) the BytesProcessed location will be updated with the
|
||||||
* total number of bytes processed in the stream, and the function will exit with an error code of
|
* total number of bytes processed in the stream, and the function will exit with an error code of
|
||||||
* \ref PIPE_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed
|
* \ref PIPE_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed
|
||||||
* in the user code - to continue the transfer, call the function again with identical parameters
|
* in the user code - to continue the transfer, call the function again with identical parameters
|
||||||
* and it will resume until the BytesProcessed value reaches the total transfer length.
|
* and it will resume until the BytesProcessed value reaches the total transfer length.
|
||||||
*
|
*
|
||||||
* <b>Single Stream Transfer Example:</b>
|
* <b>Single Stream Transfer Example:</b>
|
||||||
* \code
|
* \code
|
||||||
* uint8_t DataStream[512];
|
* uint8_t DataStream[512];
|
||||||
* uint8_t ErrorCode;
|
* uint8_t ErrorCode;
|
||||||
*
|
*
|
||||||
* if ((ErrorCode = Pipe_Write_Stream_LE(DataStream, sizeof(DataStream),
|
* if ((ErrorCode = Pipe_Write_Stream_LE(DataStream, sizeof(DataStream),
|
||||||
* NULL)) != PIPE_RWSTREAM_NoError)
|
* NULL)) != PIPE_RWSTREAM_NoError)
|
||||||
* {
|
* {
|
||||||
* // Stream failed to complete - check ErrorCode here
|
* // Stream failed to complete - check ErrorCode here
|
||||||
* }
|
* }
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* <b>Partial Stream Transfers Example:</b>
|
* <b>Partial Stream Transfers Example:</b>
|
||||||
* \code
|
* \code
|
||||||
* uint8_t DataStream[512];
|
* uint8_t DataStream[512];
|
||||||
* uint8_t ErrorCode;
|
* uint8_t ErrorCode;
|
||||||
* uint16_t BytesProcessed;
|
* uint16_t BytesProcessed;
|
||||||
*
|
*
|
||||||
* BytesProcessed = 0;
|
* BytesProcessed = 0;
|
||||||
* while ((ErrorCode = Pipe_Write_Stream_LE(DataStream, sizeof(DataStream),
|
* while ((ErrorCode = Pipe_Write_Stream_LE(DataStream, sizeof(DataStream),
|
||||||
* &BytesProcessed)) == PIPE_RWSTREAM_IncompleteTransfer)
|
* &BytesProcessed)) == PIPE_RWSTREAM_IncompleteTransfer)
|
||||||
* {
|
* {
|
||||||
* // Stream not yet complete - do other actions here, abort if required
|
* // Stream not yet complete - do other actions here, abort if required
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* if (ErrorCode != PIPE_RWSTREAM_NoError)
|
* if (ErrorCode != PIPE_RWSTREAM_NoError)
|
||||||
* {
|
* {
|
||||||
* // Stream failed to complete - check ErrorCode here
|
* // Stream failed to complete - check ErrorCode here
|
||||||
* }
|
* }
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without
|
* \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without
|
||||||
* having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken().
|
* having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken().
|
||||||
*
|
*
|
||||||
* \param[in] Buffer Pointer to the source data buffer to read from.
|
* \param[in] Buffer Pointer to the source data buffer to read from.
|
||||||
* \param[in] Length Number of bytes to read for the currently selected pipe into the buffer.
|
* \param[in] Length Number of bytes to read for the currently selected pipe into the buffer.
|
||||||
* \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should
|
* \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should
|
||||||
* updated, \c NULL if the entire stream should be written at once.
|
* updated, \c NULL if the entire stream should be written at once.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Pipe_Write_Stream_LE(const void* const Buffer,
|
uint8_t Pipe_Write_Stream_LE(const void* const Buffer,
|
||||||
uint16_t Length,
|
uint16_t Length,
|
||||||
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** Writes the given number of bytes to the pipe from the given buffer in big endian,
|
/** Writes the given number of bytes to the pipe from the given buffer in big endian,
|
||||||
* sending full packets to the device as needed. The last packet filled is not automatically sent;
|
* sending full packets to the device as needed. The last packet filled is not automatically sent;
|
||||||
* the user is responsible for manually sending the last written packet to the host via the
|
* the user is responsible for manually sending the last written packet to the host via the
|
||||||
* \ref Pipe_ClearOUT() macro. Between each USB packet, the given stream callback function is
|
* \ref Pipe_ClearOUT() macro. Between each USB packet, the given stream callback function is
|
||||||
* executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers.
|
* executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers.
|
||||||
*
|
*
|
||||||
* \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without
|
* \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without
|
||||||
* having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken().
|
* having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken().
|
||||||
*
|
*
|
||||||
* \param[in] Buffer Pointer to the source data buffer to read from.
|
* \param[in] Buffer Pointer to the source data buffer to read from.
|
||||||
* \param[in] Length Number of bytes to read for the currently selected pipe into the buffer.
|
* \param[in] Length Number of bytes to read for the currently selected pipe into the buffer.
|
||||||
* \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should
|
* \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should
|
||||||
* updated, \c NULL if the entire stream should be written at once.
|
* updated, \c NULL if the entire stream should be written at once.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Pipe_Write_Stream_BE(const void* const Buffer,
|
uint8_t Pipe_Write_Stream_BE(const void* const Buffer,
|
||||||
uint16_t Length,
|
uint16_t Length,
|
||||||
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** Reads the given number of bytes from the pipe into the given buffer in little endian,
|
/** Reads the given number of bytes from the pipe into the given buffer in little endian,
|
||||||
* sending full packets to the device as needed. The last packet filled is not automatically sent;
|
* sending full packets to the device as needed. The last packet filled is not automatically sent;
|
||||||
* the user is responsible for manually sending the last written packet to the host via the
|
* the user is responsible for manually sending the last written packet to the host via the
|
||||||
* \ref Pipe_ClearIN() macro. Between each USB packet, the given stream callback function is
|
* \ref Pipe_ClearIN() macro. Between each USB packet, the given stream callback function is
|
||||||
* executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers.
|
* executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers.
|
||||||
*
|
*
|
||||||
* If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once,
|
* If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once,
|
||||||
* failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid
|
* failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid
|
||||||
* storage location, the transfer will instead be performed as a series of chunks. Each time
|
* storage location, the transfer will instead be performed as a series of chunks. Each time
|
||||||
* the pipe bank becomes empty while there is still data to process (and after the current
|
* the pipe bank becomes empty while there is still data to process (and after the current
|
||||||
* packet has been acknowledged) the BytesProcessed location will be updated with the total number
|
* packet has been acknowledged) the BytesProcessed location will be updated with the total number
|
||||||
* of bytes processed in the stream, and the function will exit with an error code of
|
* of bytes processed in the stream, and the function will exit with an error code of
|
||||||
* \ref PIPE_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed
|
* \ref PIPE_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed
|
||||||
* in the user code - to continue the transfer, call the function again with identical parameters
|
* in the user code - to continue the transfer, call the function again with identical parameters
|
||||||
* and it will resume until the BytesProcessed value reaches the total transfer length.
|
* and it will resume until the BytesProcessed value reaches the total transfer length.
|
||||||
*
|
*
|
||||||
* <b>Single Stream Transfer Example:</b>
|
* <b>Single Stream Transfer Example:</b>
|
||||||
* \code
|
* \code
|
||||||
* uint8_t DataStream[512];
|
* uint8_t DataStream[512];
|
||||||
* uint8_t ErrorCode;
|
* uint8_t ErrorCode;
|
||||||
*
|
*
|
||||||
* if ((ErrorCode = Pipe_Read_Stream_LE(DataStream, sizeof(DataStream),
|
* if ((ErrorCode = Pipe_Read_Stream_LE(DataStream, sizeof(DataStream),
|
||||||
* NULL)) != PIPE_RWSTREAM_NoError)
|
* NULL)) != PIPE_RWSTREAM_NoError)
|
||||||
* {
|
* {
|
||||||
* // Stream failed to complete - check ErrorCode here
|
* // Stream failed to complete - check ErrorCode here
|
||||||
* }
|
* }
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* <b>Partial Stream Transfers Example:</b>
|
* <b>Partial Stream Transfers Example:</b>
|
||||||
* \code
|
* \code
|
||||||
* uint8_t DataStream[512];
|
* uint8_t DataStream[512];
|
||||||
* uint8_t ErrorCode;
|
* uint8_t ErrorCode;
|
||||||
* uint16_t BytesProcessed;
|
* uint16_t BytesProcessed;
|
||||||
*
|
*
|
||||||
* BytesProcessed = 0;
|
* BytesProcessed = 0;
|
||||||
* while ((ErrorCode = Pipe_Read_Stream_LE(DataStream, sizeof(DataStream),
|
* while ((ErrorCode = Pipe_Read_Stream_LE(DataStream, sizeof(DataStream),
|
||||||
* &BytesProcessed)) == PIPE_RWSTREAM_IncompleteTransfer)
|
* &BytesProcessed)) == PIPE_RWSTREAM_IncompleteTransfer)
|
||||||
* {
|
* {
|
||||||
* // Stream not yet complete - do other actions here, abort if required
|
* // Stream not yet complete - do other actions here, abort if required
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* if (ErrorCode != PIPE_RWSTREAM_NoError)
|
* if (ErrorCode != PIPE_RWSTREAM_NoError)
|
||||||
* {
|
* {
|
||||||
* // Stream failed to complete - check ErrorCode here
|
* // Stream failed to complete - check ErrorCode here
|
||||||
* }
|
* }
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without
|
* \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without
|
||||||
* having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken().
|
* having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken().
|
||||||
*
|
*
|
||||||
* \param[out] Buffer Pointer to the source data buffer to write to.
|
* \param[out] Buffer Pointer to the source data buffer to write to.
|
||||||
* \param[in] Length Number of bytes to read for the currently selected pipe to read from.
|
* \param[in] Length Number of bytes to read for the currently selected pipe to read from.
|
||||||
* \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should
|
* \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should
|
||||||
* updated, \c NULL if the entire stream should be read at once.
|
* updated, \c NULL if the entire stream should be read at once.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Pipe_Read_Stream_LE(void* const Buffer,
|
uint8_t Pipe_Read_Stream_LE(void* const Buffer,
|
||||||
uint16_t Length,
|
uint16_t Length,
|
||||||
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** Reads the given number of bytes from the pipe into the given buffer in big endian,
|
/** Reads the given number of bytes from the pipe into the given buffer in big endian,
|
||||||
* sending full packets to the device as needed. The last packet filled is not automatically sent;
|
* sending full packets to the device as needed. The last packet filled is not automatically sent;
|
||||||
* the user is responsible for manually sending the last written packet to the host via the
|
* the user is responsible for manually sending the last written packet to the host via the
|
||||||
* \ref Pipe_ClearIN() macro. Between each USB packet, the given stream callback function is
|
* \ref Pipe_ClearIN() macro. Between each USB packet, the given stream callback function is
|
||||||
* executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers.
|
* executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers.
|
||||||
*
|
*
|
||||||
* \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without
|
* \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without
|
||||||
* having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken().
|
* having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken().
|
||||||
*
|
*
|
||||||
* \param[out] Buffer Pointer to the source data buffer to write to.
|
* \param[out] Buffer Pointer to the source data buffer to write to.
|
||||||
* \param[in] Length Number of bytes to read for the currently selected pipe to read from.
|
* \param[in] Length Number of bytes to read for the currently selected pipe to read from.
|
||||||
* \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should
|
* \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should
|
||||||
* updated, \c NULL if the entire stream should be read at once.
|
* updated, \c NULL if the entire stream should be read at once.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Pipe_Read_Stream_BE(void* const Buffer,
|
uint8_t Pipe_Read_Stream_BE(void* const Buffer,
|
||||||
uint16_t Length,
|
uint16_t Length,
|
||||||
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
/* Disable C linkage for C++ Compilers: */
|
/* Disable C linkage for C++ Compilers: */
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
@ -1,275 +1,275 @@
|
|||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2012.
|
Copyright (C) Dean Camera, 2012.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.lufa-lib.org
|
www.lufa-lib.org
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||||
|
|
||||||
Permission to use, copy, modify, distribute, and sell this
|
Permission to use, copy, modify, distribute, and sell this
|
||||||
software and its documentation for any purpose is hereby granted
|
software and its documentation for any purpose is hereby granted
|
||||||
without fee, provided that the above copyright notice appear in
|
without fee, provided that the above copyright notice appear in
|
||||||
all copies and that both that the copyright notice and this
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
software, including all implied warranties of merchantability
|
software, including all implied warranties of merchantability
|
||||||
and fitness. In no event shall the author be liable for any
|
and fitness. In no event shall the author be liable for any
|
||||||
special, indirect or consequential damages or any damages
|
special, indirect or consequential damages or any damages
|
||||||
whatsoever resulting from loss of use, data or profits, whether
|
whatsoever resulting from loss of use, data or profits, whether
|
||||||
in an action of contract, negligence or other tortious action,
|
in an action of contract, negligence or other tortious action,
|
||||||
arising out of or in connection with the use or performance of
|
arising out of or in connection with the use or performance of
|
||||||
this software.
|
this software.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../../../../Common/Common.h"
|
#include "../../../../Common/Common.h"
|
||||||
#if (ARCH == ARCH_XMEGA)
|
#if (ARCH == ARCH_XMEGA)
|
||||||
|
|
||||||
#define __INCLUDE_FROM_USB_DRIVER
|
#define __INCLUDE_FROM_USB_DRIVER
|
||||||
#include "../USBMode.h"
|
#include "../USBMode.h"
|
||||||
|
|
||||||
#if defined(USB_CAN_BE_DEVICE)
|
#if defined(USB_CAN_BE_DEVICE)
|
||||||
|
|
||||||
#include "EndpointStream_XMEGA.h"
|
#include "EndpointStream_XMEGA.h"
|
||||||
|
|
||||||
#if !defined(CONTROL_ONLY_DEVICE)
|
#if !defined(CONTROL_ONLY_DEVICE)
|
||||||
uint8_t Endpoint_Discard_Stream(uint16_t Length,
|
uint8_t Endpoint_Discard_Stream(uint16_t Length,
|
||||||
uint16_t* const BytesProcessed)
|
uint16_t* const BytesProcessed)
|
||||||
{
|
{
|
||||||
uint8_t ErrorCode;
|
uint8_t ErrorCode;
|
||||||
uint16_t BytesInTransfer = 0;
|
uint16_t BytesInTransfer = 0;
|
||||||
|
|
||||||
if ((ErrorCode = Endpoint_WaitUntilReady()))
|
if ((ErrorCode = Endpoint_WaitUntilReady()))
|
||||||
return ErrorCode;
|
return ErrorCode;
|
||||||
|
|
||||||
if (BytesProcessed != NULL)
|
if (BytesProcessed != NULL)
|
||||||
Length -= *BytesProcessed;
|
Length -= *BytesProcessed;
|
||||||
|
|
||||||
while (Length)
|
while (Length)
|
||||||
{
|
{
|
||||||
if (!(Endpoint_IsReadWriteAllowed()))
|
if (!(Endpoint_IsReadWriteAllowed()))
|
||||||
{
|
{
|
||||||
Endpoint_ClearOUT();
|
Endpoint_ClearOUT();
|
||||||
|
|
||||||
if (BytesProcessed != NULL)
|
if (BytesProcessed != NULL)
|
||||||
{
|
{
|
||||||
*BytesProcessed += BytesInTransfer;
|
*BytesProcessed += BytesInTransfer;
|
||||||
return ENDPOINT_RWSTREAM_IncompleteTransfer;
|
return ENDPOINT_RWSTREAM_IncompleteTransfer;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ErrorCode = Endpoint_WaitUntilReady()))
|
if ((ErrorCode = Endpoint_WaitUntilReady()))
|
||||||
return ErrorCode;
|
return ErrorCode;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Endpoint_Discard_8();
|
Endpoint_Discard_8();
|
||||||
|
|
||||||
Length--;
|
Length--;
|
||||||
BytesInTransfer++;
|
BytesInTransfer++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ENDPOINT_RWSTREAM_NoError;
|
return ENDPOINT_RWSTREAM_NoError;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t Endpoint_Null_Stream(uint16_t Length,
|
uint8_t Endpoint_Null_Stream(uint16_t Length,
|
||||||
uint16_t* const BytesProcessed)
|
uint16_t* const BytesProcessed)
|
||||||
{
|
{
|
||||||
uint8_t ErrorCode;
|
uint8_t ErrorCode;
|
||||||
uint16_t BytesInTransfer = 0;
|
uint16_t BytesInTransfer = 0;
|
||||||
|
|
||||||
if ((ErrorCode = Endpoint_WaitUntilReady()))
|
if ((ErrorCode = Endpoint_WaitUntilReady()))
|
||||||
return ErrorCode;
|
return ErrorCode;
|
||||||
|
|
||||||
if (BytesProcessed != NULL)
|
if (BytesProcessed != NULL)
|
||||||
Length -= *BytesProcessed;
|
Length -= *BytesProcessed;
|
||||||
|
|
||||||
while (Length)
|
while (Length)
|
||||||
{
|
{
|
||||||
if (!(Endpoint_IsReadWriteAllowed()))
|
if (!(Endpoint_IsReadWriteAllowed()))
|
||||||
{
|
{
|
||||||
Endpoint_ClearIN();
|
Endpoint_ClearIN();
|
||||||
|
|
||||||
if (BytesProcessed != NULL)
|
if (BytesProcessed != NULL)
|
||||||
{
|
{
|
||||||
*BytesProcessed += BytesInTransfer;
|
*BytesProcessed += BytesInTransfer;
|
||||||
return ENDPOINT_RWSTREAM_IncompleteTransfer;
|
return ENDPOINT_RWSTREAM_IncompleteTransfer;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ErrorCode = Endpoint_WaitUntilReady()))
|
if ((ErrorCode = Endpoint_WaitUntilReady()))
|
||||||
return ErrorCode;
|
return ErrorCode;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Endpoint_Write_8(0);
|
Endpoint_Write_8(0);
|
||||||
|
|
||||||
Length--;
|
Length--;
|
||||||
BytesInTransfer++;
|
BytesInTransfer++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ENDPOINT_RWSTREAM_NoError;
|
return ENDPOINT_RWSTREAM_NoError;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The following abuses the C preprocessor in order to copy-paste common code with slight alterations,
|
/* The following abuses the C preprocessor in order to copy-paste common code with slight alterations,
|
||||||
* so that the code needs to be written once. It is a crude form of templating to reduce code maintenance. */
|
* so that the code needs to be written once. It is a crude form of templating to reduce code maintenance. */
|
||||||
|
|
||||||
#define TEMPLATE_FUNC_NAME Endpoint_Write_Stream_LE
|
#define TEMPLATE_FUNC_NAME Endpoint_Write_Stream_LE
|
||||||
#define TEMPLATE_BUFFER_TYPE const void*
|
#define TEMPLATE_BUFFER_TYPE const void*
|
||||||
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()
|
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr)
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr)
|
||||||
#include "Template/Template_Endpoint_RW.c"
|
#include "Template/Template_Endpoint_RW.c"
|
||||||
|
|
||||||
#define TEMPLATE_FUNC_NAME Endpoint_Write_Stream_BE
|
#define TEMPLATE_FUNC_NAME Endpoint_Write_Stream_BE
|
||||||
#define TEMPLATE_BUFFER_TYPE const void*
|
#define TEMPLATE_BUFFER_TYPE const void*
|
||||||
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()
|
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr)
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr)
|
||||||
#include "Template/Template_Endpoint_RW.c"
|
#include "Template/Template_Endpoint_RW.c"
|
||||||
|
|
||||||
#define TEMPLATE_FUNC_NAME Endpoint_Read_Stream_LE
|
#define TEMPLATE_FUNC_NAME Endpoint_Read_Stream_LE
|
||||||
#define TEMPLATE_BUFFER_TYPE void*
|
#define TEMPLATE_BUFFER_TYPE void*
|
||||||
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT()
|
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT()
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8()
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8()
|
||||||
#include "Template/Template_Endpoint_RW.c"
|
#include "Template/Template_Endpoint_RW.c"
|
||||||
|
|
||||||
#define TEMPLATE_FUNC_NAME Endpoint_Read_Stream_BE
|
#define TEMPLATE_FUNC_NAME Endpoint_Read_Stream_BE
|
||||||
#define TEMPLATE_BUFFER_TYPE void*
|
#define TEMPLATE_BUFFER_TYPE void*
|
||||||
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT()
|
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT()
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8()
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8()
|
||||||
#include "Template/Template_Endpoint_RW.c"
|
#include "Template/Template_Endpoint_RW.c"
|
||||||
|
|
||||||
#if defined(ARCH_HAS_FLASH_ADDRESS_SPACE)
|
#if defined(ARCH_HAS_FLASH_ADDRESS_SPACE)
|
||||||
#define TEMPLATE_FUNC_NAME Endpoint_Write_PStream_LE
|
#define TEMPLATE_FUNC_NAME Endpoint_Write_PStream_LE
|
||||||
#define TEMPLATE_BUFFER_TYPE const void*
|
#define TEMPLATE_BUFFER_TYPE const void*
|
||||||
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()
|
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(pgm_read_byte(BufferPtr))
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(pgm_read_byte(BufferPtr))
|
||||||
#include "Template/Template_Endpoint_RW.c"
|
#include "Template/Template_Endpoint_RW.c"
|
||||||
|
|
||||||
#define TEMPLATE_FUNC_NAME Endpoint_Write_PStream_BE
|
#define TEMPLATE_FUNC_NAME Endpoint_Write_PStream_BE
|
||||||
#define TEMPLATE_BUFFER_TYPE const void*
|
#define TEMPLATE_BUFFER_TYPE const void*
|
||||||
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()
|
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(pgm_read_byte(BufferPtr))
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(pgm_read_byte(BufferPtr))
|
||||||
#include "Template/Template_Endpoint_RW.c"
|
#include "Template/Template_Endpoint_RW.c"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(ARCH_HAS_EEPROM_ADDRESS_SPACE)
|
#if defined(ARCH_HAS_EEPROM_ADDRESS_SPACE)
|
||||||
#define TEMPLATE_FUNC_NAME Endpoint_Write_EStream_LE
|
#define TEMPLATE_FUNC_NAME Endpoint_Write_EStream_LE
|
||||||
#define TEMPLATE_BUFFER_TYPE const void*
|
#define TEMPLATE_BUFFER_TYPE const void*
|
||||||
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()
|
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(eeprom_read_byte(BufferPtr))
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(eeprom_read_byte(BufferPtr))
|
||||||
#include "Template/Template_Endpoint_RW.c"
|
#include "Template/Template_Endpoint_RW.c"
|
||||||
|
|
||||||
#define TEMPLATE_FUNC_NAME Endpoint_Write_EStream_BE
|
#define TEMPLATE_FUNC_NAME Endpoint_Write_EStream_BE
|
||||||
#define TEMPLATE_BUFFER_TYPE const void*
|
#define TEMPLATE_BUFFER_TYPE const void*
|
||||||
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()
|
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(eeprom_read_byte(BufferPtr))
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(eeprom_read_byte(BufferPtr))
|
||||||
#include "Template/Template_Endpoint_RW.c"
|
#include "Template/Template_Endpoint_RW.c"
|
||||||
|
|
||||||
#define TEMPLATE_FUNC_NAME Endpoint_Read_EStream_LE
|
#define TEMPLATE_FUNC_NAME Endpoint_Read_EStream_LE
|
||||||
#define TEMPLATE_BUFFER_TYPE void*
|
#define TEMPLATE_BUFFER_TYPE void*
|
||||||
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT()
|
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT()
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Endpoint_Read_8())
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Endpoint_Read_8())
|
||||||
#include "Template/Template_Endpoint_RW.c"
|
#include "Template/Template_Endpoint_RW.c"
|
||||||
|
|
||||||
#define TEMPLATE_FUNC_NAME Endpoint_Read_EStream_BE
|
#define TEMPLATE_FUNC_NAME Endpoint_Read_EStream_BE
|
||||||
#define TEMPLATE_BUFFER_TYPE void*
|
#define TEMPLATE_BUFFER_TYPE void*
|
||||||
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT()
|
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT()
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Endpoint_Read_8())
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Endpoint_Read_8())
|
||||||
#include "Template/Template_Endpoint_RW.c"
|
#include "Template/Template_Endpoint_RW.c"
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_Stream_LE
|
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
|
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr)
|
|
||||||
#include "Template/Template_Endpoint_Control_W.c"
|
|
||||||
|
|
||||||
#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_Stream_BE
|
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
|
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr)
|
|
||||||
#include "Template/Template_Endpoint_Control_W.c"
|
|
||||||
|
|
||||||
#define TEMPLATE_FUNC_NAME Endpoint_Read_Control_Stream_LE
|
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
|
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8()
|
|
||||||
#include "Template/Template_Endpoint_Control_R.c"
|
|
||||||
|
|
||||||
#define TEMPLATE_FUNC_NAME Endpoint_Read_Control_Stream_BE
|
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
|
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8()
|
|
||||||
#include "Template/Template_Endpoint_Control_R.c"
|
|
||||||
|
|
||||||
#if defined(ARCH_HAS_FLASH_ADDRESS_SPACE)
|
|
||||||
#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_PStream_LE
|
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
|
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(pgm_read_byte(BufferPtr))
|
|
||||||
#include "Template/Template_Endpoint_Control_W.c"
|
|
||||||
|
|
||||||
#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_PStream_BE
|
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
|
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(pgm_read_byte(BufferPtr))
|
|
||||||
#include "Template/Template_Endpoint_Control_W.c"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(ARCH_HAS_EEPROM_ADDRESS_SPACE)
|
|
||||||
#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_EStream_LE
|
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
|
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(eeprom_read_byte(BufferPtr))
|
|
||||||
#include "Template/Template_Endpoint_Control_W.c"
|
|
||||||
|
|
||||||
#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_EStream_BE
|
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
|
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(eeprom_read_byte(BufferPtr))
|
|
||||||
#include "Template/Template_Endpoint_Control_W.c"
|
|
||||||
|
|
||||||
#define TEMPLATE_FUNC_NAME Endpoint_Read_Control_EStream_LE
|
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
|
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Endpoint_Read_8())
|
|
||||||
#include "Template/Template_Endpoint_Control_R.c"
|
|
||||||
|
|
||||||
#define TEMPLATE_FUNC_NAME Endpoint_Read_Control_EStream_BE
|
|
||||||
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
|
||||||
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
|
|
||||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Endpoint_Read_8())
|
|
||||||
#include "Template/Template_Endpoint_Control_R.c"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_Stream_LE
|
||||||
|
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
||||||
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
|
||||||
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr)
|
||||||
|
#include "Template/Template_Endpoint_Control_W.c"
|
||||||
|
|
||||||
|
#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_Stream_BE
|
||||||
|
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
||||||
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
|
||||||
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr)
|
||||||
|
#include "Template/Template_Endpoint_Control_W.c"
|
||||||
|
|
||||||
|
#define TEMPLATE_FUNC_NAME Endpoint_Read_Control_Stream_LE
|
||||||
|
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
||||||
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
|
||||||
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8()
|
||||||
|
#include "Template/Template_Endpoint_Control_R.c"
|
||||||
|
|
||||||
|
#define TEMPLATE_FUNC_NAME Endpoint_Read_Control_Stream_BE
|
||||||
|
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
||||||
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
|
||||||
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8()
|
||||||
|
#include "Template/Template_Endpoint_Control_R.c"
|
||||||
|
|
||||||
|
#if defined(ARCH_HAS_FLASH_ADDRESS_SPACE)
|
||||||
|
#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_PStream_LE
|
||||||
|
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
||||||
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
|
||||||
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(pgm_read_byte(BufferPtr))
|
||||||
|
#include "Template/Template_Endpoint_Control_W.c"
|
||||||
|
|
||||||
|
#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_PStream_BE
|
||||||
|
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
||||||
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
|
||||||
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(pgm_read_byte(BufferPtr))
|
||||||
|
#include "Template/Template_Endpoint_Control_W.c"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(ARCH_HAS_EEPROM_ADDRESS_SPACE)
|
||||||
|
#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_EStream_LE
|
||||||
|
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
||||||
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
|
||||||
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(eeprom_read_byte(BufferPtr))
|
||||||
|
#include "Template/Template_Endpoint_Control_W.c"
|
||||||
|
|
||||||
|
#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_EStream_BE
|
||||||
|
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
||||||
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
|
||||||
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(eeprom_read_byte(BufferPtr))
|
||||||
|
#include "Template/Template_Endpoint_Control_W.c"
|
||||||
|
|
||||||
|
#define TEMPLATE_FUNC_NAME Endpoint_Read_Control_EStream_LE
|
||||||
|
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
||||||
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
|
||||||
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Endpoint_Read_8())
|
||||||
|
#include "Template/Template_Endpoint_Control_R.c"
|
||||||
|
|
||||||
|
#define TEMPLATE_FUNC_NAME Endpoint_Read_Control_EStream_BE
|
||||||
|
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
||||||
|
#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
|
||||||
|
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Endpoint_Read_8())
|
||||||
|
#include "Template/Template_Endpoint_Control_R.c"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@ -1,648 +1,648 @@
|
|||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2012.
|
Copyright (C) Dean Camera, 2012.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.lufa-lib.org
|
www.lufa-lib.org
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||||
|
|
||||||
Permission to use, copy, modify, distribute, and sell this
|
Permission to use, copy, modify, distribute, and sell this
|
||||||
software and its documentation for any purpose is hereby granted
|
software and its documentation for any purpose is hereby granted
|
||||||
without fee, provided that the above copyright notice appear in
|
without fee, provided that the above copyright notice appear in
|
||||||
all copies and that both that the copyright notice and this
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
software, including all implied warranties of merchantability
|
software, including all implied warranties of merchantability
|
||||||
and fitness. In no event shall the author be liable for any
|
and fitness. In no event shall the author be liable for any
|
||||||
special, indirect or consequential damages or any damages
|
special, indirect or consequential damages or any damages
|
||||||
whatsoever resulting from loss of use, data or profits, whether
|
whatsoever resulting from loss of use, data or profits, whether
|
||||||
in an action of contract, negligence or other tortious action,
|
in an action of contract, negligence or other tortious action,
|
||||||
arising out of or in connection with the use or performance of
|
arising out of or in connection with the use or performance of
|
||||||
this software.
|
this software.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \file
|
/** \file
|
||||||
* \brief Endpoint data stream transmission and reception management for the AVR XMEGA microcontrollers.
|
* \brief Endpoint data stream transmission and reception management for the AVR XMEGA microcontrollers.
|
||||||
* \copydetails Group_EndpointStreamRW_XMEGA
|
* \copydetails Group_EndpointStreamRW_XMEGA
|
||||||
*
|
*
|
||||||
* \note This file should not be included directly. It is automatically included as needed by the USB driver
|
* \note This file should not be included directly. It is automatically included as needed by the USB driver
|
||||||
* dispatch header located in LUFA/Drivers/USB/USB.h.
|
* dispatch header located in LUFA/Drivers/USB/USB.h.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \ingroup Group_EndpointStreamRW
|
/** \ingroup Group_EndpointStreamRW
|
||||||
* \defgroup Group_EndpointStreamRW_XMEGA Read/Write of Multi-Byte Streams (XMEGA)
|
* \defgroup Group_EndpointStreamRW_XMEGA Read/Write of Multi-Byte Streams (XMEGA)
|
||||||
* \brief Endpoint data stream transmission and reception management for the Atmel AVR XMEGA architecture.
|
* \brief Endpoint data stream transmission and reception management for the Atmel AVR XMEGA architecture.
|
||||||
*
|
*
|
||||||
* Functions, macros, variables, enums and types related to data reading and writing of data streams from
|
* Functions, macros, variables, enums and types related to data reading and writing of data streams from
|
||||||
* and to endpoints.
|
* and to endpoints.
|
||||||
*
|
*
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __ENDPOINT_STREAM_XMEGA_H__
|
#ifndef __ENDPOINT_STREAM_XMEGA_H__
|
||||||
#define __ENDPOINT_STREAM_XMEGA_H__
|
#define __ENDPOINT_STREAM_XMEGA_H__
|
||||||
|
|
||||||
/* Includes: */
|
/* Includes: */
|
||||||
#include "../../../../Common/Common.h"
|
#include "../../../../Common/Common.h"
|
||||||
#include "../USBMode.h"
|
#include "../USBMode.h"
|
||||||
#include "../USBTask.h"
|
#include "../USBTask.h"
|
||||||
|
|
||||||
/* Enable C linkage for C++ Compilers: */
|
/* Enable C linkage for C++ Compilers: */
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Preprocessor Checks: */
|
/* Preprocessor Checks: */
|
||||||
#if !defined(__INCLUDE_FROM_USB_DRIVER)
|
#if !defined(__INCLUDE_FROM_USB_DRIVER)
|
||||||
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
|
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Public Interface - May be used in end-application: */
|
/* Public Interface - May be used in end-application: */
|
||||||
/* Function Prototypes: */
|
/* Function Prototypes: */
|
||||||
/** \name Stream functions for null data */
|
/** \name Stream functions for null data */
|
||||||
//@{
|
//@{
|
||||||
|
|
||||||
/** Reads and discards the given number of bytes from the currently selected endpoint's bank,
|
/** Reads and discards the given number of bytes from the currently selected endpoint's bank,
|
||||||
* discarding fully read packets from the host as needed. The last packet is not automatically
|
* discarding fully read packets from the host as needed. The last packet is not automatically
|
||||||
* discarded once the remaining bytes has been read; the user is responsible for manually
|
* discarded once the remaining bytes has been read; the user is responsible for manually
|
||||||
* discarding the last packet from the host via the \ref Endpoint_ClearOUT() macro.
|
* discarding the last packet from the host via the \ref Endpoint_ClearOUT() macro.
|
||||||
*
|
*
|
||||||
* If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once,
|
* If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once,
|
||||||
* failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid
|
* failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid
|
||||||
* storage location, the transfer will instead be performed as a series of chunks. Each time
|
* storage location, the transfer will instead be performed as a series of chunks. Each time
|
||||||
* the endpoint bank becomes empty while there is still data to process (and after the current
|
* the endpoint bank becomes empty while there is still data to process (and after the current
|
||||||
* packet has been acknowledged) the BytesProcessed location will be updated with the total number
|
* packet has been acknowledged) the BytesProcessed location will be updated with the total number
|
||||||
* of bytes processed in the stream, and the function will exit with an error code of
|
* of bytes processed in the stream, and the function will exit with an error code of
|
||||||
* \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed
|
* \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed
|
||||||
* in the user code - to continue the transfer, call the function again with identical parameters
|
* in the user code - to continue the transfer, call the function again with identical parameters
|
||||||
* and it will resume until the BytesProcessed value reaches the total transfer length.
|
* and it will resume until the BytesProcessed value reaches the total transfer length.
|
||||||
*
|
*
|
||||||
* <b>Single Stream Transfer Example:</b>
|
* <b>Single Stream Transfer Example:</b>
|
||||||
* \code
|
* \code
|
||||||
* uint8_t ErrorCode;
|
* uint8_t ErrorCode;
|
||||||
*
|
*
|
||||||
* if ((ErrorCode = Endpoint_Discard_Stream(512, NULL)) != ENDPOINT_RWSTREAM_NoError)
|
* if ((ErrorCode = Endpoint_Discard_Stream(512, NULL)) != ENDPOINT_RWSTREAM_NoError)
|
||||||
* {
|
* {
|
||||||
* // Stream failed to complete - check ErrorCode here
|
* // Stream failed to complete - check ErrorCode here
|
||||||
* }
|
* }
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* <b>Partial Stream Transfers Example:</b>
|
* <b>Partial Stream Transfers Example:</b>
|
||||||
* \code
|
* \code
|
||||||
* uint8_t ErrorCode;
|
* uint8_t ErrorCode;
|
||||||
* uint16_t BytesProcessed;
|
* uint16_t BytesProcessed;
|
||||||
*
|
*
|
||||||
* BytesProcessed = 0;
|
* BytesProcessed = 0;
|
||||||
* while ((ErrorCode = Endpoint_Discard_Stream(512, &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer)
|
* while ((ErrorCode = Endpoint_Discard_Stream(512, &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer)
|
||||||
* {
|
* {
|
||||||
* // Stream not yet complete - do other actions here, abort if required
|
* // Stream not yet complete - do other actions here, abort if required
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* if (ErrorCode != ENDPOINT_RWSTREAM_NoError)
|
* if (ErrorCode != ENDPOINT_RWSTREAM_NoError)
|
||||||
* {
|
* {
|
||||||
* // Stream failed to complete - check ErrorCode here
|
* // Stream failed to complete - check ErrorCode here
|
||||||
* }
|
* }
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* \note This routine should not be used on CONTROL type endpoints.
|
* \note This routine should not be used on CONTROL type endpoints.
|
||||||
*
|
*
|
||||||
* \param[in] Length Number of bytes to discard via the currently selected endpoint.
|
* \param[in] Length Number of bytes to discard via the currently selected endpoint.
|
||||||
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
||||||
* transaction should be updated, \c NULL if the entire stream should be read at once.
|
* transaction should be updated, \c NULL if the entire stream should be read at once.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Endpoint_Discard_Stream(uint16_t Length,
|
uint8_t Endpoint_Discard_Stream(uint16_t Length,
|
||||||
uint16_t* const BytesProcessed);
|
uint16_t* const BytesProcessed);
|
||||||
|
|
||||||
/** Writes a given number of zeroed bytes to the currently selected endpoint's bank, sending
|
/** Writes a given number of zeroed bytes to the currently selected endpoint's bank, sending
|
||||||
* full packets to the host as needed. The last packet is not automatically sent once the
|
* full packets to the host as needed. The last packet is not automatically sent once the
|
||||||
* remaining bytes have been written; the user is responsible for manually sending the last
|
* remaining bytes have been written; the user is responsible for manually sending the last
|
||||||
* packet to the host via the \ref Endpoint_ClearIN() macro.
|
* packet to the host via the \ref Endpoint_ClearIN() macro.
|
||||||
*
|
*
|
||||||
* If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once,
|
* If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once,
|
||||||
* failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid
|
* failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid
|
||||||
* storage location, the transfer will instead be performed as a series of chunks. Each time
|
* storage location, the transfer will instead be performed as a series of chunks. Each time
|
||||||
* the endpoint bank becomes full while there is still data to process (and after the current
|
* the endpoint bank becomes full while there is still data to process (and after the current
|
||||||
* packet transmission has been initiated) the BytesProcessed location will be updated with the
|
* packet transmission has been initiated) the BytesProcessed location will be updated with the
|
||||||
* total number of bytes processed in the stream, and the function will exit with an error code of
|
* total number of bytes processed in the stream, and the function will exit with an error code of
|
||||||
* \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed
|
* \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed
|
||||||
* in the user code - to continue the transfer, call the function again with identical parameters
|
* in the user code - to continue the transfer, call the function again with identical parameters
|
||||||
* and it will resume until the BytesProcessed value reaches the total transfer length.
|
* and it will resume until the BytesProcessed value reaches the total transfer length.
|
||||||
*
|
*
|
||||||
* <b>Single Stream Transfer Example:</b>
|
* <b>Single Stream Transfer Example:</b>
|
||||||
* \code
|
* \code
|
||||||
* uint8_t ErrorCode;
|
* uint8_t ErrorCode;
|
||||||
*
|
*
|
||||||
* if ((ErrorCode = Endpoint_Null_Stream(512, NULL)) != ENDPOINT_RWSTREAM_NoError)
|
* if ((ErrorCode = Endpoint_Null_Stream(512, NULL)) != ENDPOINT_RWSTREAM_NoError)
|
||||||
* {
|
* {
|
||||||
* // Stream failed to complete - check ErrorCode here
|
* // Stream failed to complete - check ErrorCode here
|
||||||
* }
|
* }
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* <b>Partial Stream Transfers Example:</b>
|
* <b>Partial Stream Transfers Example:</b>
|
||||||
* \code
|
* \code
|
||||||
* uint8_t ErrorCode;
|
* uint8_t ErrorCode;
|
||||||
* uint16_t BytesProcessed;
|
* uint16_t BytesProcessed;
|
||||||
*
|
*
|
||||||
* BytesProcessed = 0;
|
* BytesProcessed = 0;
|
||||||
* while ((ErrorCode = Endpoint_Null_Stream(512, &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer)
|
* while ((ErrorCode = Endpoint_Null_Stream(512, &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer)
|
||||||
* {
|
* {
|
||||||
* // Stream not yet complete - do other actions here, abort if required
|
* // Stream not yet complete - do other actions here, abort if required
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* if (ErrorCode != ENDPOINT_RWSTREAM_NoError)
|
* if (ErrorCode != ENDPOINT_RWSTREAM_NoError)
|
||||||
* {
|
* {
|
||||||
* // Stream failed to complete - check ErrorCode here
|
* // Stream failed to complete - check ErrorCode here
|
||||||
* }
|
* }
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* \note This routine should not be used on CONTROL type endpoints.
|
* \note This routine should not be used on CONTROL type endpoints.
|
||||||
*
|
*
|
||||||
* \param[in] Length Number of zero bytes to send via the currently selected endpoint.
|
* \param[in] Length Number of zero bytes to send via the currently selected endpoint.
|
||||||
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
||||||
* transaction should be updated, \c NULL if the entire stream should be read at once.
|
* transaction should be updated, \c NULL if the entire stream should be read at once.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Endpoint_Null_Stream(uint16_t Length,
|
uint8_t Endpoint_Null_Stream(uint16_t Length,
|
||||||
uint16_t* const BytesProcessed);
|
uint16_t* const BytesProcessed);
|
||||||
|
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
/** \name Stream functions for RAM source/destination data */
|
/** \name Stream functions for RAM source/destination data */
|
||||||
//@{
|
//@{
|
||||||
|
|
||||||
/** Writes the given number of bytes to the endpoint from the given buffer in little endian,
|
/** Writes the given number of bytes to the endpoint from the given buffer in little endian,
|
||||||
* sending full packets to the host as needed. The last packet filled is not automatically sent;
|
* sending full packets to the host as needed. The last packet filled is not automatically sent;
|
||||||
* the user is responsible for manually sending the last written packet to the host via the
|
* the user is responsible for manually sending the last written packet to the host via the
|
||||||
* \ref Endpoint_ClearIN() macro.
|
* \ref Endpoint_ClearIN() macro.
|
||||||
*
|
*
|
||||||
* If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once,
|
* If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once,
|
||||||
* failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid
|
* failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid
|
||||||
* storage location, the transfer will instead be performed as a series of chunks. Each time
|
* storage location, the transfer will instead be performed as a series of chunks. Each time
|
||||||
* the endpoint bank becomes full while there is still data to process (and after the current
|
* the endpoint bank becomes full while there is still data to process (and after the current
|
||||||
* packet transmission has been initiated) the BytesProcessed location will be updated with the
|
* packet transmission has been initiated) the BytesProcessed location will be updated with the
|
||||||
* total number of bytes processed in the stream, and the function will exit with an error code of
|
* total number of bytes processed in the stream, and the function will exit with an error code of
|
||||||
* \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed
|
* \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed
|
||||||
* in the user code - to continue the transfer, call the function again with identical parameters
|
* in the user code - to continue the transfer, call the function again with identical parameters
|
||||||
* and it will resume until the BytesProcessed value reaches the total transfer length.
|
* and it will resume until the BytesProcessed value reaches the total transfer length.
|
||||||
*
|
*
|
||||||
* <b>Single Stream Transfer Example:</b>
|
* <b>Single Stream Transfer Example:</b>
|
||||||
* \code
|
* \code
|
||||||
* uint8_t DataStream[512];
|
* uint8_t DataStream[512];
|
||||||
* uint8_t ErrorCode;
|
* uint8_t ErrorCode;
|
||||||
*
|
*
|
||||||
* if ((ErrorCode = Endpoint_Write_Stream_LE(DataStream, sizeof(DataStream),
|
* if ((ErrorCode = Endpoint_Write_Stream_LE(DataStream, sizeof(DataStream),
|
||||||
* NULL)) != ENDPOINT_RWSTREAM_NoError)
|
* NULL)) != ENDPOINT_RWSTREAM_NoError)
|
||||||
* {
|
* {
|
||||||
* // Stream failed to complete - check ErrorCode here
|
* // Stream failed to complete - check ErrorCode here
|
||||||
* }
|
* }
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* <b>Partial Stream Transfers Example:</b>
|
* <b>Partial Stream Transfers Example:</b>
|
||||||
* \code
|
* \code
|
||||||
* uint8_t DataStream[512];
|
* uint8_t DataStream[512];
|
||||||
* uint8_t ErrorCode;
|
* uint8_t ErrorCode;
|
||||||
* uint16_t BytesProcessed;
|
* uint16_t BytesProcessed;
|
||||||
*
|
*
|
||||||
* BytesProcessed = 0;
|
* BytesProcessed = 0;
|
||||||
* while ((ErrorCode = Endpoint_Write_Stream_LE(DataStream, sizeof(DataStream),
|
* while ((ErrorCode = Endpoint_Write_Stream_LE(DataStream, sizeof(DataStream),
|
||||||
* &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer)
|
* &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer)
|
||||||
* {
|
* {
|
||||||
* // Stream not yet complete - do other actions here, abort if required
|
* // Stream not yet complete - do other actions here, abort if required
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* if (ErrorCode != ENDPOINT_RWSTREAM_NoError)
|
* if (ErrorCode != ENDPOINT_RWSTREAM_NoError)
|
||||||
* {
|
* {
|
||||||
* // Stream failed to complete - check ErrorCode here
|
* // Stream failed to complete - check ErrorCode here
|
||||||
* }
|
* }
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* \note This routine should not be used on CONTROL type endpoints.
|
* \note This routine should not be used on CONTROL type endpoints.
|
||||||
*
|
*
|
||||||
* \param[in] Buffer Pointer to the source data buffer to read from.
|
* \param[in] Buffer Pointer to the source data buffer to read from.
|
||||||
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
||||||
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
||||||
* transaction should be updated, \c NULL if the entire stream should be written at once.
|
* transaction should be updated, \c NULL if the entire stream should be written at once.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Endpoint_Write_Stream_LE(const void* const Buffer,
|
uint8_t Endpoint_Write_Stream_LE(const void* const Buffer,
|
||||||
uint16_t Length,
|
uint16_t Length,
|
||||||
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** Writes the given number of bytes to the endpoint from the given buffer in big endian,
|
/** Writes the given number of bytes to the endpoint from the given buffer in big endian,
|
||||||
* sending full packets to the host as needed. The last packet filled is not automatically sent;
|
* sending full packets to the host as needed. The last packet filled is not automatically sent;
|
||||||
* the user is responsible for manually sending the last written packet to the host via the
|
* the user is responsible for manually sending the last written packet to the host via the
|
||||||
* \ref Endpoint_ClearIN() macro.
|
* \ref Endpoint_ClearIN() macro.
|
||||||
*
|
*
|
||||||
* \note This routine should not be used on CONTROL type endpoints.
|
* \note This routine should not be used on CONTROL type endpoints.
|
||||||
*
|
*
|
||||||
* \param[in] Buffer Pointer to the source data buffer to read from.
|
* \param[in] Buffer Pointer to the source data buffer to read from.
|
||||||
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
||||||
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
||||||
* transaction should be updated, \c NULL if the entire stream should be written at once.
|
* transaction should be updated, \c NULL if the entire stream should be written at once.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Endpoint_Write_Stream_BE(const void* const Buffer,
|
uint8_t Endpoint_Write_Stream_BE(const void* const Buffer,
|
||||||
uint16_t Length,
|
uint16_t Length,
|
||||||
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** Reads the given number of bytes from the endpoint from the given buffer in little endian,
|
/** Reads the given number of bytes from the endpoint from the given buffer in little endian,
|
||||||
* discarding fully read packets from the host as needed. The last packet is not automatically
|
* discarding fully read packets from the host as needed. The last packet is not automatically
|
||||||
* discarded once the remaining bytes has been read; the user is responsible for manually
|
* discarded once the remaining bytes has been read; the user is responsible for manually
|
||||||
* discarding the last packet from the host via the \ref Endpoint_ClearOUT() macro.
|
* discarding the last packet from the host via the \ref Endpoint_ClearOUT() macro.
|
||||||
*
|
*
|
||||||
* If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once,
|
* If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once,
|
||||||
* failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid
|
* failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid
|
||||||
* storage location, the transfer will instead be performed as a series of chunks. Each time
|
* storage location, the transfer will instead be performed as a series of chunks. Each time
|
||||||
* the endpoint bank becomes empty while there is still data to process (and after the current
|
* the endpoint bank becomes empty while there is still data to process (and after the current
|
||||||
* packet has been acknowledged) the BytesProcessed location will be updated with the total number
|
* packet has been acknowledged) the BytesProcessed location will be updated with the total number
|
||||||
* of bytes processed in the stream, and the function will exit with an error code of
|
* of bytes processed in the stream, and the function will exit with an error code of
|
||||||
* \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed
|
* \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed
|
||||||
* in the user code - to continue the transfer, call the function again with identical parameters
|
* in the user code - to continue the transfer, call the function again with identical parameters
|
||||||
* and it will resume until the BytesProcessed value reaches the total transfer length.
|
* and it will resume until the BytesProcessed value reaches the total transfer length.
|
||||||
*
|
*
|
||||||
* <b>Single Stream Transfer Example:</b>
|
* <b>Single Stream Transfer Example:</b>
|
||||||
* \code
|
* \code
|
||||||
* uint8_t DataStream[512];
|
* uint8_t DataStream[512];
|
||||||
* uint8_t ErrorCode;
|
* uint8_t ErrorCode;
|
||||||
*
|
*
|
||||||
* if ((ErrorCode = Endpoint_Read_Stream_LE(DataStream, sizeof(DataStream),
|
* if ((ErrorCode = Endpoint_Read_Stream_LE(DataStream, sizeof(DataStream),
|
||||||
* NULL)) != ENDPOINT_RWSTREAM_NoError)
|
* NULL)) != ENDPOINT_RWSTREAM_NoError)
|
||||||
* {
|
* {
|
||||||
* // Stream failed to complete - check ErrorCode here
|
* // Stream failed to complete - check ErrorCode here
|
||||||
* }
|
* }
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* <b>Partial Stream Transfers Example:</b>
|
* <b>Partial Stream Transfers Example:</b>
|
||||||
* \code
|
* \code
|
||||||
* uint8_t DataStream[512];
|
* uint8_t DataStream[512];
|
||||||
* uint8_t ErrorCode;
|
* uint8_t ErrorCode;
|
||||||
* uint16_t BytesProcessed;
|
* uint16_t BytesProcessed;
|
||||||
*
|
*
|
||||||
* BytesProcessed = 0;
|
* BytesProcessed = 0;
|
||||||
* while ((ErrorCode = Endpoint_Read_Stream_LE(DataStream, sizeof(DataStream),
|
* while ((ErrorCode = Endpoint_Read_Stream_LE(DataStream, sizeof(DataStream),
|
||||||
* &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer)
|
* &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer)
|
||||||
* {
|
* {
|
||||||
* // Stream not yet complete - do other actions here, abort if required
|
* // Stream not yet complete - do other actions here, abort if required
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* if (ErrorCode != ENDPOINT_RWSTREAM_NoError)
|
* if (ErrorCode != ENDPOINT_RWSTREAM_NoError)
|
||||||
* {
|
* {
|
||||||
* // Stream failed to complete - check ErrorCode here
|
* // Stream failed to complete - check ErrorCode here
|
||||||
* }
|
* }
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* \note This routine should not be used on CONTROL type endpoints.
|
* \note This routine should not be used on CONTROL type endpoints.
|
||||||
*
|
*
|
||||||
* \param[out] Buffer Pointer to the destination data buffer to write to.
|
* \param[out] Buffer Pointer to the destination data buffer to write to.
|
||||||
* \param[in] Length Number of bytes to send via the currently selected endpoint.
|
* \param[in] Length Number of bytes to send via the currently selected endpoint.
|
||||||
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
||||||
* transaction should be updated, \c NULL if the entire stream should be read at once.
|
* transaction should be updated, \c NULL if the entire stream should be read at once.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Endpoint_Read_Stream_LE(void* const Buffer,
|
uint8_t Endpoint_Read_Stream_LE(void* const Buffer,
|
||||||
uint16_t Length,
|
uint16_t Length,
|
||||||
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** Reads the given number of bytes from the endpoint from the given buffer in big endian,
|
/** Reads the given number of bytes from the endpoint from the given buffer in big endian,
|
||||||
* discarding fully read packets from the host as needed. The last packet is not automatically
|
* discarding fully read packets from the host as needed. The last packet is not automatically
|
||||||
* discarded once the remaining bytes has been read; the user is responsible for manually
|
* discarded once the remaining bytes has been read; the user is responsible for manually
|
||||||
* discarding the last packet from the host via the \ref Endpoint_ClearOUT() macro.
|
* discarding the last packet from the host via the \ref Endpoint_ClearOUT() macro.
|
||||||
*
|
*
|
||||||
* \note This routine should not be used on CONTROL type endpoints.
|
* \note This routine should not be used on CONTROL type endpoints.
|
||||||
*
|
*
|
||||||
* \param[out] Buffer Pointer to the destination data buffer to write to.
|
* \param[out] Buffer Pointer to the destination data buffer to write to.
|
||||||
* \param[in] Length Number of bytes to send via the currently selected endpoint.
|
* \param[in] Length Number of bytes to send via the currently selected endpoint.
|
||||||
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
||||||
* transaction should be updated, \c NULL if the entire stream should be read at once.
|
* transaction should be updated, \c NULL if the entire stream should be read at once.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Endpoint_Read_Stream_BE(void* const Buffer,
|
uint8_t Endpoint_Read_Stream_BE(void* const Buffer,
|
||||||
uint16_t Length,
|
uint16_t Length,
|
||||||
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** Writes the given number of bytes to the CONTROL type endpoint from the given buffer in little endian,
|
/** Writes the given number of bytes to the CONTROL type endpoint from the given buffer in little endian,
|
||||||
* sending full packets to the host as needed. The host OUT acknowledgement is not automatically cleared
|
* sending full packets to the host as needed. The host OUT acknowledgement is not automatically cleared
|
||||||
* in both failure and success states; the user is responsible for manually clearing the setup OUT to
|
* in both failure and success states; the user is responsible for manually clearing the setup OUT to
|
||||||
* finalize the transfer via the \ref Endpoint_ClearOUT() macro.
|
* finalize the transfer via the \ref Endpoint_ClearOUT() macro.
|
||||||
*
|
*
|
||||||
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
|
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
|
||||||
* to clear the status stage when using this routine in a control transaction.
|
* to clear the status stage when using this routine in a control transaction.
|
||||||
* \n\n
|
* \n\n
|
||||||
*
|
*
|
||||||
* \note This routine should only be used on CONTROL type endpoints.
|
* \note This routine should only be used on CONTROL type endpoints.
|
||||||
*
|
*
|
||||||
* \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
|
* \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
|
||||||
* together; i.e. the entire stream data must be read or written at the one time.
|
* together; i.e. the entire stream data must be read or written at the one time.
|
||||||
*
|
*
|
||||||
* \param[in] Buffer Pointer to the source data buffer to read from.
|
* \param[in] Buffer Pointer to the source data buffer to read from.
|
||||||
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Endpoint_Write_Control_Stream_LE(const void* const Buffer,
|
uint8_t Endpoint_Write_Control_Stream_LE(const void* const Buffer,
|
||||||
uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** Writes the given number of bytes to the CONTROL type endpoint from the given buffer in big endian,
|
/** Writes the given number of bytes to the CONTROL type endpoint from the given buffer in big endian,
|
||||||
* sending full packets to the host as needed. The host OUT acknowledgement is not automatically cleared
|
* sending full packets to the host as needed. The host OUT acknowledgement is not automatically cleared
|
||||||
* in both failure and success states; the user is responsible for manually clearing the setup OUT to
|
* in both failure and success states; the user is responsible for manually clearing the setup OUT to
|
||||||
* finalize the transfer via the \ref Endpoint_ClearOUT() macro.
|
* finalize the transfer via the \ref Endpoint_ClearOUT() macro.
|
||||||
*
|
*
|
||||||
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
|
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
|
||||||
* to clear the status stage when using this routine in a control transaction.
|
* to clear the status stage when using this routine in a control transaction.
|
||||||
* \n\n
|
* \n\n
|
||||||
*
|
*
|
||||||
* \note This routine should only be used on CONTROL type endpoints.
|
* \note This routine should only be used on CONTROL type endpoints.
|
||||||
*
|
*
|
||||||
* \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
|
* \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
|
||||||
* together; i.e. the entire stream data must be read or written at the one time.
|
* together; i.e. the entire stream data must be read or written at the one time.
|
||||||
*
|
*
|
||||||
* \param[in] Buffer Pointer to the source data buffer to read from.
|
* \param[in] Buffer Pointer to the source data buffer to read from.
|
||||||
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Endpoint_Write_Control_Stream_BE(const void* const Buffer,
|
uint8_t Endpoint_Write_Control_Stream_BE(const void* const Buffer,
|
||||||
uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** Reads the given number of bytes from the CONTROL endpoint from the given buffer in little endian,
|
/** Reads the given number of bytes from the CONTROL endpoint from the given buffer in little endian,
|
||||||
* discarding fully read packets from the host as needed. The device IN acknowledgement is not
|
* discarding fully read packets from the host as needed. The device IN acknowledgement is not
|
||||||
* automatically sent after success or failure states; the user is responsible for manually sending the
|
* automatically sent after success or failure states; the user is responsible for manually sending the
|
||||||
* setup IN to finalize the transfer via the \ref Endpoint_ClearIN() macro.
|
* setup IN to finalize the transfer via the \ref Endpoint_ClearIN() macro.
|
||||||
*
|
*
|
||||||
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
|
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
|
||||||
* to clear the status stage when using this routine in a control transaction.
|
* to clear the status stage when using this routine in a control transaction.
|
||||||
* \n\n
|
* \n\n
|
||||||
*
|
*
|
||||||
* \note This routine should only be used on CONTROL type endpoints.
|
* \note This routine should only be used on CONTROL type endpoints.
|
||||||
*
|
*
|
||||||
* \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
|
* \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
|
||||||
* together; i.e. the entire stream data must be read or written at the one time.
|
* together; i.e. the entire stream data must be read or written at the one time.
|
||||||
*
|
*
|
||||||
* \param[out] Buffer Pointer to the destination data buffer to write to.
|
* \param[out] Buffer Pointer to the destination data buffer to write to.
|
||||||
* \param[in] Length Number of bytes to send via the currently selected endpoint.
|
* \param[in] Length Number of bytes to send via the currently selected endpoint.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Endpoint_Read_Control_Stream_LE(void* const Buffer,
|
uint8_t Endpoint_Read_Control_Stream_LE(void* const Buffer,
|
||||||
uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** Reads the given number of bytes from the CONTROL endpoint from the given buffer in big endian,
|
/** Reads the given number of bytes from the CONTROL endpoint from the given buffer in big endian,
|
||||||
* discarding fully read packets from the host as needed. The device IN acknowledgement is not
|
* discarding fully read packets from the host as needed. The device IN acknowledgement is not
|
||||||
* automatically sent after success or failure states; the user is responsible for manually sending the
|
* automatically sent after success or failure states; the user is responsible for manually sending the
|
||||||
* setup IN to finalize the transfer via the \ref Endpoint_ClearIN() macro.
|
* setup IN to finalize the transfer via the \ref Endpoint_ClearIN() macro.
|
||||||
*
|
*
|
||||||
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
|
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
|
||||||
* to clear the status stage when using this routine in a control transaction.
|
* to clear the status stage when using this routine in a control transaction.
|
||||||
* \n\n
|
* \n\n
|
||||||
*
|
*
|
||||||
* \note This routine should only be used on CONTROL type endpoints.
|
* \note This routine should only be used on CONTROL type endpoints.
|
||||||
*
|
*
|
||||||
* \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
|
* \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
|
||||||
* together; i.e. the entire stream data must be read or written at the one time.
|
* together; i.e. the entire stream data must be read or written at the one time.
|
||||||
*
|
*
|
||||||
* \param[out] Buffer Pointer to the destination data buffer to write to.
|
* \param[out] Buffer Pointer to the destination data buffer to write to.
|
||||||
* \param[in] Length Number of bytes to send via the currently selected endpoint.
|
* \param[in] Length Number of bytes to send via the currently selected endpoint.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Endpoint_Read_Control_Stream_BE(void* const Buffer,
|
uint8_t Endpoint_Read_Control_Stream_BE(void* const Buffer,
|
||||||
uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
/** \name Stream functions for EEPROM source/destination data */
|
/** \name Stream functions for EEPROM source/destination data */
|
||||||
//@{
|
//@{
|
||||||
|
|
||||||
/** EEPROM buffer source version of \ref Endpoint_Write_Stream_LE().
|
/** EEPROM buffer source version of \ref Endpoint_Write_Stream_LE().
|
||||||
*
|
*
|
||||||
* \param[in] Buffer Pointer to the source data buffer to read from.
|
* \param[in] Buffer Pointer to the source data buffer to read from.
|
||||||
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
||||||
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
||||||
* transaction should be updated, \c NULL if the entire stream should be written at once.
|
* transaction should be updated, \c NULL if the entire stream should be written at once.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Endpoint_Write_EStream_LE(const void* const Buffer,
|
uint8_t Endpoint_Write_EStream_LE(const void* const Buffer,
|
||||||
uint16_t Length,
|
uint16_t Length,
|
||||||
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** EEPROM buffer source version of \ref Endpoint_Write_Stream_BE().
|
/** EEPROM buffer source version of \ref Endpoint_Write_Stream_BE().
|
||||||
*
|
*
|
||||||
* \param[in] Buffer Pointer to the source data buffer to read from.
|
* \param[in] Buffer Pointer to the source data buffer to read from.
|
||||||
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
||||||
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
||||||
* transaction should be updated, \c NULL if the entire stream should be written at once.
|
* transaction should be updated, \c NULL if the entire stream should be written at once.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Endpoint_Write_EStream_BE(const void* const Buffer,
|
uint8_t Endpoint_Write_EStream_BE(const void* const Buffer,
|
||||||
uint16_t Length,
|
uint16_t Length,
|
||||||
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** EEPROM buffer destination version of \ref Endpoint_Read_Stream_LE().
|
/** EEPROM buffer destination version of \ref Endpoint_Read_Stream_LE().
|
||||||
*
|
*
|
||||||
* \param[out] Buffer Pointer to the destination data buffer to write to, located in EEPROM memory space.
|
* \param[out] Buffer Pointer to the destination data buffer to write to, located in EEPROM memory space.
|
||||||
* \param[in] Length Number of bytes to send via the currently selected endpoint.
|
* \param[in] Length Number of bytes to send via the currently selected endpoint.
|
||||||
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
||||||
* transaction should be updated, \c NULL if the entire stream should be read at once.
|
* transaction should be updated, \c NULL if the entire stream should be read at once.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Endpoint_Read_EStream_LE(void* const Buffer,
|
uint8_t Endpoint_Read_EStream_LE(void* const Buffer,
|
||||||
uint16_t Length,
|
uint16_t Length,
|
||||||
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** EEPROM buffer destination version of \ref Endpoint_Read_Stream_BE().
|
/** EEPROM buffer destination version of \ref Endpoint_Read_Stream_BE().
|
||||||
*
|
*
|
||||||
* \param[out] Buffer Pointer to the destination data buffer to write to, located in EEPROM memory space.
|
* \param[out] Buffer Pointer to the destination data buffer to write to, located in EEPROM memory space.
|
||||||
* \param[in] Length Number of bytes to send via the currently selected endpoint.
|
* \param[in] Length Number of bytes to send via the currently selected endpoint.
|
||||||
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
||||||
* transaction should be updated, \c NULL if the entire stream should be read at once.
|
* transaction should be updated, \c NULL if the entire stream should be read at once.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Endpoint_Read_EStream_BE(void* const Buffer,
|
uint8_t Endpoint_Read_EStream_BE(void* const Buffer,
|
||||||
uint16_t Length,
|
uint16_t Length,
|
||||||
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** EEPROM buffer source version of Endpoint_Write_Control_Stream_LE.
|
/** EEPROM buffer source version of Endpoint_Write_Control_Stream_LE.
|
||||||
*
|
*
|
||||||
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
|
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
|
||||||
* to clear the status stage when using this routine in a control transaction.
|
* to clear the status stage when using this routine in a control transaction.
|
||||||
* \n\n
|
* \n\n
|
||||||
*
|
*
|
||||||
* \note This routine should only be used on CONTROL type endpoints.
|
* \note This routine should only be used on CONTROL type endpoints.
|
||||||
* \n\n
|
* \n\n
|
||||||
*
|
*
|
||||||
* \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
|
* \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
|
||||||
* together; i.e. the entire stream data must be read or written at the one time.
|
* together; i.e. the entire stream data must be read or written at the one time.
|
||||||
*
|
*
|
||||||
* \param[in] Buffer Pointer to the source data buffer to read from.
|
* \param[in] Buffer Pointer to the source data buffer to read from.
|
||||||
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Endpoint_Write_Control_EStream_LE(const void* const Buffer,
|
uint8_t Endpoint_Write_Control_EStream_LE(const void* const Buffer,
|
||||||
uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** EEPROM buffer source version of \ref Endpoint_Write_Control_Stream_BE().
|
/** EEPROM buffer source version of \ref Endpoint_Write_Control_Stream_BE().
|
||||||
*
|
*
|
||||||
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
|
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
|
||||||
* to clear the status stage when using this routine in a control transaction.
|
* to clear the status stage when using this routine in a control transaction.
|
||||||
* \n\n
|
* \n\n
|
||||||
*
|
*
|
||||||
* \note This routine should only be used on CONTROL type endpoints.
|
* \note This routine should only be used on CONTROL type endpoints.
|
||||||
* \n\n
|
* \n\n
|
||||||
*
|
*
|
||||||
* \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
|
* \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
|
||||||
* together; i.e. the entire stream data must be read or written at the one time.
|
* together; i.e. the entire stream data must be read or written at the one time.
|
||||||
*
|
*
|
||||||
* \param[in] Buffer Pointer to the source data buffer to read from.
|
* \param[in] Buffer Pointer to the source data buffer to read from.
|
||||||
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Endpoint_Write_Control_EStream_BE(const void* const Buffer,
|
uint8_t Endpoint_Write_Control_EStream_BE(const void* const Buffer,
|
||||||
uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** EEPROM buffer source version of \ref Endpoint_Read_Control_Stream_LE().
|
/** EEPROM buffer source version of \ref Endpoint_Read_Control_Stream_LE().
|
||||||
*
|
*
|
||||||
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
|
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
|
||||||
* to clear the status stage when using this routine in a control transaction.
|
* to clear the status stage when using this routine in a control transaction.
|
||||||
* \n\n
|
* \n\n
|
||||||
*
|
*
|
||||||
* \note This routine should only be used on CONTROL type endpoints.
|
* \note This routine should only be used on CONTROL type endpoints.
|
||||||
* \n\n
|
* \n\n
|
||||||
*
|
*
|
||||||
* \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
|
* \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
|
||||||
* together; i.e. the entire stream data must be read or written at the one time.
|
* together; i.e. the entire stream data must be read or written at the one time.
|
||||||
*
|
*
|
||||||
* \param[out] Buffer Pointer to the destination data buffer to write to.
|
* \param[out] Buffer Pointer to the destination data buffer to write to.
|
||||||
* \param[in] Length Number of bytes to send via the currently selected endpoint.
|
* \param[in] Length Number of bytes to send via the currently selected endpoint.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Endpoint_Read_Control_EStream_LE(void* const Buffer,
|
uint8_t Endpoint_Read_Control_EStream_LE(void* const Buffer,
|
||||||
uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** EEPROM buffer source version of \ref Endpoint_Read_Control_Stream_BE().
|
/** EEPROM buffer source version of \ref Endpoint_Read_Control_Stream_BE().
|
||||||
*
|
*
|
||||||
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
|
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
|
||||||
* to clear the status stage when using this routine in a control transaction.
|
* to clear the status stage when using this routine in a control transaction.
|
||||||
* \n\n
|
* \n\n
|
||||||
*
|
*
|
||||||
* \note This routine should only be used on CONTROL type endpoints.
|
* \note This routine should only be used on CONTROL type endpoints.
|
||||||
* \n\n
|
* \n\n
|
||||||
*
|
*
|
||||||
* \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
|
* \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
|
||||||
* together; i.e. the entire stream data must be read or written at the one time.
|
* together; i.e. the entire stream data must be read or written at the one time.
|
||||||
*
|
*
|
||||||
* \param[out] Buffer Pointer to the destination data buffer to write to.
|
* \param[out] Buffer Pointer to the destination data buffer to write to.
|
||||||
* \param[in] Length Number of bytes to send via the currently selected endpoint.
|
* \param[in] Length Number of bytes to send via the currently selected endpoint.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Endpoint_Read_Control_EStream_BE(void* const Buffer,
|
uint8_t Endpoint_Read_Control_EStream_BE(void* const Buffer,
|
||||||
uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
/** \name Stream functions for PROGMEM source/destination data */
|
/** \name Stream functions for PROGMEM source/destination data */
|
||||||
//@{
|
//@{
|
||||||
|
|
||||||
/** FLASH buffer source version of \ref Endpoint_Write_Stream_LE().
|
/** FLASH buffer source version of \ref Endpoint_Write_Stream_LE().
|
||||||
*
|
*
|
||||||
* \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly.
|
* \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly.
|
||||||
*
|
*
|
||||||
* \param[in] Buffer Pointer to the source data buffer to read from.
|
* \param[in] Buffer Pointer to the source data buffer to read from.
|
||||||
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
||||||
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
||||||
* transaction should be updated, \c NULL if the entire stream should be written at once.
|
* transaction should be updated, \c NULL if the entire stream should be written at once.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Endpoint_Write_PStream_LE(const void* const Buffer,
|
uint8_t Endpoint_Write_PStream_LE(const void* const Buffer,
|
||||||
uint16_t Length,
|
uint16_t Length,
|
||||||
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** FLASH buffer source version of \ref Endpoint_Write_Stream_BE().
|
/** FLASH buffer source version of \ref Endpoint_Write_Stream_BE().
|
||||||
*
|
*
|
||||||
* \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly.
|
* \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly.
|
||||||
*
|
*
|
||||||
* \param[in] Buffer Pointer to the source data buffer to read from.
|
* \param[in] Buffer Pointer to the source data buffer to read from.
|
||||||
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
||||||
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
* \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
|
||||||
* transaction should be updated, \c NULL if the entire stream should be written at once.
|
* transaction should be updated, \c NULL if the entire stream should be written at once.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Endpoint_Write_PStream_BE(const void* const Buffer,
|
uint8_t Endpoint_Write_PStream_BE(const void* const Buffer,
|
||||||
uint16_t Length,
|
uint16_t Length,
|
||||||
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** FLASH buffer source version of \ref Endpoint_Write_Control_Stream_LE().
|
/** FLASH buffer source version of \ref Endpoint_Write_Control_Stream_LE().
|
||||||
*
|
*
|
||||||
* \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly.
|
* \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly.
|
||||||
*
|
*
|
||||||
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
|
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
|
||||||
* to clear the status stage when using this routine in a control transaction.
|
* to clear the status stage when using this routine in a control transaction.
|
||||||
* \n\n
|
* \n\n
|
||||||
*
|
*
|
||||||
* \note This routine should only be used on CONTROL type endpoints.
|
* \note This routine should only be used on CONTROL type endpoints.
|
||||||
* \n\n
|
* \n\n
|
||||||
*
|
*
|
||||||
* \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
|
* \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
|
||||||
* together; i.e. the entire stream data must be read or written at the one time.
|
* together; i.e. the entire stream data must be read or written at the one time.
|
||||||
*
|
*
|
||||||
* \param[in] Buffer Pointer to the source data buffer to read from.
|
* \param[in] Buffer Pointer to the source data buffer to read from.
|
||||||
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Endpoint_Write_Control_PStream_LE(const void* const Buffer,
|
uint8_t Endpoint_Write_Control_PStream_LE(const void* const Buffer,
|
||||||
uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
|
|
||||||
/** FLASH buffer source version of \ref Endpoint_Write_Control_Stream_BE().
|
/** FLASH buffer source version of \ref Endpoint_Write_Control_Stream_BE().
|
||||||
*
|
*
|
||||||
* \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly.
|
* \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly.
|
||||||
*
|
*
|
||||||
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
|
* \note This function automatically clears the control transfer's status stage. Do not manually attempt
|
||||||
* to clear the status stage when using this routine in a control transaction.
|
* to clear the status stage when using this routine in a control transaction.
|
||||||
* \n\n
|
* \n\n
|
||||||
*
|
*
|
||||||
* \note This routine should only be used on CONTROL type endpoints.
|
* \note This routine should only be used on CONTROL type endpoints.
|
||||||
* \n\n
|
* \n\n
|
||||||
*
|
*
|
||||||
* \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
|
* \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
|
||||||
* together; i.e. the entire stream data must be read or written at the one time.
|
* together; i.e. the entire stream data must be read or written at the one time.
|
||||||
*
|
*
|
||||||
* \param[in] Buffer Pointer to the source data buffer to read from.
|
* \param[in] Buffer Pointer to the source data buffer to read from.
|
||||||
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
||||||
*
|
*
|
||||||
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t Endpoint_Write_Control_PStream_BE(const void* const Buffer,
|
uint8_t Endpoint_Write_Control_PStream_BE(const void* const Buffer,
|
||||||
uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
|
uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
/* Disable C linkage for C++ Compilers: */
|
/* Disable C linkage for C++ Compilers: */
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
Loading…
Reference in new issue