Commit cf241143 authored by Dean Camera's avatar Dean Camera

Removed Pipe_ClearErrorFlags(), pipe error flags are now automatically cleared...

Removed Pipe_ClearErrorFlags(), pipe error flags are now automatically cleared when Pipe_ClearError() is called.

More UC3B architecture porting.
parent 66c38cd9
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -410,10 +410,11 @@
return ((UPCONX & (1 << PFREEZE)) ? true : false);
}
/** Clears the master pipe error flag. */
/** Clears the error flags for the currently selected pipe. */
static inline void Pipe_ClearError(void) ATTR_ALWAYS_INLINE;
static inline void Pipe_ClearError(void)
{
UPERRX = 0;
UPINTX &= ~(1 << PERRI);
}
......@@ -430,15 +431,6 @@
return ((UPINTX & (1 << PERRI)) ? true : false);
}
/** Clears all the currently selected pipe's hardware error flags, but does not clear the master error
* flag for the pipe.
*/
static inline void Pipe_ClearErrorFlags(void) ATTR_ALWAYS_INLINE;
static inline void Pipe_ClearErrorFlags(void)
{
UPERRX = 0;
}
/** Gets a mask of the hardware error flags which have occurred on the currently selected pipe. This
* value can then be masked against the \c PIPE_ERRORFLAG_* masks to determine what error has occurred.
*
......
......@@ -38,11 +38,11 @@
uint8_t USB_Host_SendControlRequest(void* const BufferPtr)
{
uint8_t* HeaderStream = (uint8_t*)&USB_ControlRequest;
uint8_t* DataStream = (uint8_t*)BufferPtr;
bool BusSuspended = USB_Host_IsBusSuspended();
uint8_t ReturnStatus = HOST_SENDCONTROL_Successful;
uint16_t DataLen = USB_ControlRequest.wLength;
uint8_t* HeaderStream = (uint8_t*)&USB_ControlRequest;
uint8_t* DataStream = (uint8_t*)BufferPtr;
bool BusSuspended = USB_Host_IsBusSuspended();
uint8_t ReturnStatus = HOST_SENDCONTROL_Successful;
uint16_t DataLen = USB_ControlRequest.wLength;
USB_Host_ResumeBus();
......@@ -50,7 +50,7 @@ uint8_t USB_Host_SendControlRequest(void* const BufferPtr)
goto End_Of_Control_Send;
Pipe_SetPipeToken(PIPE_TOKEN_SETUP);
Pipe_ClearErrorFlags();
Pipe_ClearError();
Pipe_Unfreeze();
......
......@@ -55,8 +55,6 @@
#if (ARCH == ARCH_AVR8)
#include "AVR8/OTG_AVR8.h"
#elif (ARCH == ARCH_UC3B)
#include "UC3B/OTG_UC3B.h"
#endif
/* Preprocessor Checks: */
......
This diff is collapsed.
......@@ -245,7 +245,7 @@
*/
static inline uint16_t USB_Host_GetFrameNumber(void)
{
return UHFNUM;
return AVR32_USBB_UHFNUM;
}
#if !defined(NO_SOF_EVENTS)
......@@ -282,7 +282,7 @@
static inline void USB_Host_ResetBus(void) ATTR_ALWAYS_INLINE;
static inline void USB_Host_ResetBus(void)
{
UHCON |= (1 << RESET);
AVR32_USBB_UHCON.reset = true;
}
/** Determines if a previously issued bus reset (via the \ref USB_Host_ResetBus() macro) has
......@@ -293,7 +293,7 @@
static inline bool USB_Host_IsBusResetComplete(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
static inline bool USB_Host_IsBusResetComplete(void)
{
return ((UHCON & (1 << RESET)) ? false : true);
return AVR32_USBB_UHCON.reset;
}
/** Resumes USB communications with an attached and enumerated device, by resuming the transmission
......@@ -303,7 +303,7 @@
static inline void USB_Host_ResumeBus(void) ATTR_ALWAYS_INLINE;
static inline void USB_Host_ResumeBus(void)
{
UHCON |= (1 << SOFEN);
AVR32_USBB_UHCON.sofe = true;
}
/** Suspends the USB bus, preventing any communications from occurring between the host and attached
......@@ -313,7 +313,7 @@
static inline void USB_Host_SuspendBus(void) ATTR_ALWAYS_INLINE;
static inline void USB_Host_SuspendBus(void)
{
UHCON &= ~(1 << SOFEN);
AVR32_USBB_UHCON.sofe = false;
}
/** Determines if the USB bus has been suspended via the use of the \ref USB_Host_SuspendBus() macro,
......@@ -325,7 +325,7 @@
static inline bool USB_Host_IsBusSuspended(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
static inline bool USB_Host_IsBusSuspended(void)
{
return ((UHCON & (1 << SOFEN)) ? false : true);
return AVR32_USBB_UHCON.sofe;
}
/** Determines if the attached device is currently enumerated in Full Speed mode (12Mb/s), or
......@@ -336,7 +336,7 @@
static inline bool USB_Host_IsDeviceFullSpeed(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
static inline bool USB_Host_IsDeviceFullSpeed(void)
{
return ((USBSTA & (1 << SPEED)) ? true : false);
return (AVR32_USBB_USBSTA.speed == AVR32_USBB_SPEED_FULL);
}
/** Determines if the attached device is currently issuing a Remote Wakeup request, requesting
......@@ -347,14 +347,14 @@
static inline bool USB_Host_IsRemoteWakeupSent(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
static inline bool USB_Host_IsRemoteWakeupSent(void)
{
return ((UHINT & (1 << RXRSMI)) ? true : false);
return AVR32_USBB_UHINT.rxrsmi;
}
/** Clears the flag indicating that a Remote Wakeup request has been issued by an attached device. */
static inline void USB_Host_ClearRemoteWakeupSent(void) ATTR_ALWAYS_INLINE;
static inline void USB_Host_ClearRemoteWakeupSent(void)
{
UHINT &= ~(1 << RXRSMI);
AVR32_USBB_UHINTCLR.rxrsmic = true;
}
/** Accepts a Remote Wakeup request from an attached device. This must be issued in response to
......@@ -364,7 +364,7 @@
static inline void USB_Host_ResumeFromWakeupRequest(void) ATTR_ALWAYS_INLINE;
static inline void USB_Host_ResumeFromWakeupRequest(void)
{
UHCON |= (1 << RESUME);
AVR32_USBB_UHCON.resume = true;
}
/** Determines if a resume from Remote Wakeup request is currently being sent to an attached
......@@ -375,7 +375,7 @@
static inline bool USB_Host_IsResumeFromWakeupRequestSent(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
static inline bool USB_Host_IsResumeFromWakeupRequestSent(void)
{
return ((UHCON & (1 << RESUME)) ? false : true);
return AVR32_USBB_UHCON.resume;
}
/* Function Prototypes: */
......@@ -438,59 +438,63 @@
static inline void USB_Host_HostMode_On(void) ATTR_ALWAYS_INLINE;
static inline void USB_Host_HostMode_On(void)
{
USBCON |= (1 << HOST);
// Not required for UC3B
}
static inline void USB_Host_HostMode_Off(void) ATTR_ALWAYS_INLINE;
static inline void USB_Host_HostMode_Off(void)
{
USBCON &= ~(1 << HOST);
// Not required for UC3B
}
static inline void USB_Host_VBUS_Auto_Enable(void) ATTR_ALWAYS_INLINE;
static inline void USB_Host_VBUS_Auto_Enable(void)
{
OTGCON &= ~(1 << VBUSHWC);
UHWCON |= (1 << UVCONE);
AVR32_USBB_USBCON.vbushwc = false;
}
static inline void USB_Host_VBUS_Manual_Enable(void) ATTR_ALWAYS_INLINE;
static inline void USB_Host_VBUS_Manual_Enable(void)
{
OTGCON |= (1 << VBUSHWC);
UHWCON &= ~(1 << UVCONE);
DDRE |= (1 << 7);
AVR32_USBB_USBCON.vbushwc = true;
// TODO: Manual VBUS pin output setup
}
static inline void USB_Host_VBUS_Auto_On(void) ATTR_ALWAYS_INLINE;
static inline void USB_Host_VBUS_Auto_On(void)
{
OTGCON |= (1 << VBUSREQ);
AVR32_USBB_USBSTASET.vbusreqs = true;
}
static inline void USB_Host_VBUS_Manual_On(void) ATTR_ALWAYS_INLINE;
static inline void USB_Host_VBUS_Manual_On(void)
{
PORTE |= (1 << 7);
// TODO: Manual VBUS pin output on
}
static inline void USB_Host_VBUS_Auto_Off(void) ATTR_ALWAYS_INLINE;
static inline void USB_Host_VBUS_Auto_Off(void)
{
OTGCON |= (1 << VBUSRQC);
AVR32_USBB_USBSTACLR.vbusreqc = true;
}
static inline void USB_Host_VBUS_Manual_Off(void) ATTR_ALWAYS_INLINE;
static inline void USB_Host_VBUS_Manual_Off(void)
{
PORTE &= ~(1 << 7);
// TODO: Manual VBUS pin output off
}
static inline void USB_Host_SetDeviceAddress(const uint8_t Address) ATTR_ALWAYS_INLINE;
static inline void USB_Host_SetDeviceAddress(const uint8_t Address)
{
UHADDR = (Address & 0x7F);
AVR32_USBB_UHADDR1.uhaddrp0 = Address;
AVR32_USBB_UHADDR1.uhaddrp1 = Address;
AVR32_USBB_UHADDR1.uhaddrp2 = Address;
AVR32_USBB_UHADDR1.uhaddrp3 = Address;
AVR32_USBB_UHADDR2.uhaddrp4 = Address;
AVR32_USBB_UHADDR2.uhaddrp5 = Address;
AVR32_USBB_UHADDR2.uhaddrp6 = Address;
}
/* Enums: */
......
/*
LUFA Library
Copyright (C) Dean Camera, 2011.
dean [at] fourwalledcubicle [dot] com
www.lufa-lib.org
*/
/*
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Permission to use, copy, modify, distribute, and sell this
software and its documentation for any purpose is hereby granted
without fee, provided that the above copyright notice appear in
all copies and that both that the copyright notice and this
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
software, including all implied warranties of merchantability
and fitness. In no event shall the author be liable for any
special, indirect or consequential damages or any damages
whatsoever resulting from loss of use, data or profits, whether
in an action of contract, negligence or other tortious action,
arising out of or in connection with the use or performance of
this software.
*/
/** \file
* \brief USB OTG definitions for the AVR32 UC3B microcontrollers.
* \copydetails Group_OTG_UC3B
*
* \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.
*/
/** \ingroup Group_OTG
* \defgroup Group_OTG_UC3B USB On The Go (OTG) Management (UC3B)
* \brief USB OTG definitions for the AVR32 UC3B microcontrollers.
*
* Architecture specific USB OTG definitions for the Atmel 32-bit AVR UC3B microcontrollers.
*
* @{
*/
#ifndef __USBOTG_UC3B_H__
#define __USBOTG_UC3B_H__
/* Includes: */
#include "../../../../Common/Common.h"
/* Preprocessor Checks: */
#if !defined(__INCLUDE_FROM_USB_DRIVER)
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
#endif
/* Public Interface - May be used in end-application: */
/* Macros: */
/** Mask for the VBUS pulsing method of SRP, supported by some OTG devices.
*
* \see \ref USB_OTG_Device_InitiateSRP().
*/
#define USB_OTG_SRP_VBUS (1 << SRPSEL)
/** Mask for the Data + pulsing method of SRP, supported by some OTG devices.
*
* \see \ref USB_OTG_Device_InitiateSRP().
*/
#define USB_OTG_STP_DATA 0
/* Inline Functions: */
/** Initiate a Host Negotiation Protocol request. This indicates to the other connected device
* that the device wishes to change device/host roles.
*/
static inline void USB_OTG_Device_RequestHNP(void) ATTR_ALWAYS_INLINE;
static inline void USB_OTG_Device_RequestHNP(void)
{
OTGCON |= (1 << HNPREQ);
}
/** Cancel a Host Negotiation Protocol request. This stops a pending HNP request to the other
* connected device.
*/
static inline void USB_OTG_Device_CancelHNPRequest(void) ATTR_ALWAYS_INLINE;
static inline void USB_OTG_Device_CancelHNPRequest(void)
{
OTGCON &= ~(1 << HNPREQ);
}
/** Determines if the device is currently sending a HNP to an attached host.
*
* \return Boolean \c true if currently sending a HNP to the other connected device, \c false otherwise
*/
static inline bool USB_OTG_Device_IsSendingHNP(void) ATTR_ALWAYS_INLINE;
static inline bool USB_OTG_Device_IsSendingHNP(void)
{
return ((OTGCON & (1 << HNPREQ)) ? true : false);
}
/** Initiates a Session Request Protocol request. Most OTG devices turn off VBUS when the USB
* interface is not in use, to conserve power. Sending a SRP to a USB OTG device running in
* host mode indicates that VBUS should be applied and a session started.
*
* There are two different methods of sending a SRP - either pulses on the VBUS line, or by
* pulsing the Data + line via the internal pull-up resistor.
*
* \param[in] SRPTypeMask Mask indicating the type of SRP to use, either \ref USB_OTG_SRP_VBUS or
* \ref USB_OTG_STP_DATA.
*/
static inline void USB_OTG_Device_InitiateSRP(const uint8_t SRPTypeMask) ATTR_ALWAYS_INLINE;
static inline void USB_OTG_Device_InitiateSRP(const uint8_t SRPTypeMask)
{
OTGCON = ((OTGCON & ~(1 << SRPSEL)) | (SRPTypeMask | (1 << SRPREQ)));
}
/** Accepts a HNP from a connected device, indicating that both devices should exchange
* device/host roles.
*/
static inline void USB_OTG_Host_AcceptHNP(void) ATTR_ALWAYS_INLINE;
static inline void USB_OTG_Host_AcceptHNP(void)
{
OTGCON |= (1 << HNPREQ);
}
/** Rejects a HNP from a connected device, indicating that both devices should remain in their
* current device/host roles.
*/
static inline void USB_OTG_Host_RejectHNP(void) ATTR_ALWAYS_INLINE;
static inline void USB_OTG_Host_RejectHNP(void)
{
OTGCON &= ~(1 << HNPREQ);
}
/** Indicates if the connected device is not currently sending a HNP request.
*
* \return Boolean \c true if a HNP is currently being issued by the connected device, \c false otherwise.
*/
static inline bool USB_OTG_Host_IsHNPReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
static inline bool USB_OTG_Host_IsHNPReceived(void)
{
return ((OTGCON & (1 << HNPREQ)) ? true : false);
}
#endif
/** @} */
......@@ -36,6 +36,7 @@
#include "../Pipe.h"
uint8_t USB_ControlPipeSize = PIPE_CONTROLPIPE_DEFAULT_SIZE;
uint8_t USB_SelectedPipe = PIPE_CONTROLPIPE;
bool Pipe_ConfigurePipe(const uint8_t Number,
const uint8_t Type,
......@@ -44,70 +45,19 @@ bool Pipe_ConfigurePipe(const uint8_t Number,
const uint16_t Size,
const uint8_t Banks)
{
#if defined(ORDERED_EP_CONFIG)
Pipe_SelectPipe(Number);
Pipe_EnablePipe();
UPCFG1X = 0;
UPCFG0X = ((Type << EPTYPE0) | Token | ((EndpointNumber & PIPE_EPNUM_MASK) << PEPNUM0));
UPCFG1X = ((1 << ALLOC) | Banks | Pipe_BytesToEPSizeMask(Size));
*((uint32_t*)AVR32_USBB_UPCFG0)[USB_SelectedPipe] = 0;
*((uint32_t*)AVR32_USBB_UPCFG0)[USB_SelectedPipe] = (AVR32_USBB_ALLOC_MASK |
((uint32_t)Type << AVR32_USBB_PTYPE_OFFSET) |
((uint32_t)Token << AVR32_USBB_PTOKEN_OFFSET) |
((uint32_t)Banks << AVR32_USBB_PBK_OFFSET) |
((EndpointNumber & PIPE_EPNUM_MASK) << AVR32_USBB_PEPNUM_OFFSET));
Pipe_SetInfiniteINRequests();
return Pipe_IsConfigured();
#else
for (uint8_t PNum = Number; PNum < PIPE_TOTAL_PIPES; PNum++)
{
uint8_t UPCFG0XTemp;
uint8_t UPCFG1XTemp;
uint8_t UPCFG2XTemp;
uint8_t UPCONXTemp;
uint8_t UPINRQXTemp;
uint8_t UPIENXTemp;
Pipe_SelectPipe(PNum);
if (PNum == Number)
{
UPCFG0XTemp = ((Type << EPTYPE0) | Token | ((EndpointNumber & PIPE_EPNUM_MASK) << PEPNUM0));
UPCFG1XTemp = ((1 << ALLOC) | Banks | Pipe_BytesToEPSizeMask(Size));
UPCFG2XTemp = 0;
UPCONXTemp = ((1 << PEN) | (1 << INMODE));
UPINRQXTemp = 0;
UPIENXTemp = 0;
}
else
{
UPCFG0XTemp = UPCFG0X;
UPCFG1XTemp = UPCFG1X;
UPCFG2XTemp = UPCFG2X;
UPCONXTemp = UPCONX;
UPINRQXTemp = UPINRQX;
UPIENXTemp = UPIENX;
}
if (!(UPCFG1XTemp & (1 << ALLOC)))
continue;
Pipe_DisablePipe();
UPCFG1X &= (1 << ALLOC);
Pipe_EnablePipe();
UPCFG0X = UPCFG0XTemp;
UPCFG1X = UPCFG1XTemp;
UPCFG2X = UPCFG2XTemp;
UPCONX = UPCONXTemp;
UPINRQX = UPINRQXTemp;
UPIENX = UPIENXTemp;
if (!(Pipe_IsConfigured()))
return false;
}
Pipe_SelectPipe(Number);
return true;
#endif
}
void Pipe_ClearPipes(void)
......@@ -117,9 +67,7 @@ void Pipe_ClearPipes(void)
for (uint8_t PNum = 0; PNum < PIPE_TOTAL_PIPES; PNum++)
{
Pipe_SelectPipe(PNum);
UPIENX = 0;
UPINTX = 0;
UPCFG1X = 0;
*((uint32_t*)AVR32_USBB_UPCFG0)[USB_SelectedPipe] = 0;
Pipe_DisablePipe();
}
}
......
This diff is collapsed.
......@@ -55,6 +55,7 @@
* added new versions of the *_SendString() routines that expect a null terminated string instead
* - Renamed all driver termination *_ShutDown() functions to the more logical name *_Disable()
* - Reduced latency for executing the Start-Of-Frame events (if enabled in the user application)
* - Removed Pipe_ClearErrorFlags(), pipe error flags are now automatically cleared when Pipe_ClearError() is called
* - Library Applications:
* - Changed the XPLAINBridge software UART to use the regular timer CTC mode instead of the alternative CTC mode
* via the Input Capture register, to reduce user confusion
......
......@@ -51,9 +51,6 @@ volatile struct
uint8_t PingPongLEDPulse; /**< Milliseconds remaining for enumeration Tx/Rx ping-pong LED pulse */
} PulseMSRemaining;
/** Previous state of the virtual DTR control line from the host */
bool PreviousDTRState = false;
/** Milliseconds remaining until the receive buffer is flushed to the USB host */
uint8_t FlushPeriodRemaining = RECEIVE_BUFFER_FLUSH_MS;
......@@ -286,7 +283,8 @@ ISR(USART1_RX_vect, ISR_BLOCK)
*/
void EVENT_CDC_Device_ControLineStateChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo)
{
bool CurrentDTRState = (CDCInterfaceInfo->State.ControlLineStates.HostToDevice & CDC_CONTROL_LINE_OUT_DTR);
static bool PreviousDTRState = false;
bool CurrentDTRState = (CDCInterfaceInfo->State.ControlLineStates.HostToDevice & CDC_CONTROL_LINE_OUT_DTR);
/* Check if the DTR line has been asserted - if so, start the target AVR's reset pulse */
if (!(PreviousDTRState) && CurrentDTRState)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment