![]() |
LPCOpen Platform
LPCOpen Platform for NXP LPC Microcontrollers
|
#include "../../../../Common/Common.h"
#include "../USBTask.h"
#include "HCD/HCD.h"
#include "../USBMemory.h"
#include <stdbool.h>
Go to the source code of this file.
Data Structures | |
struct | USB_Pipe_Data_t |
Macros | |
#define | PIPE_CONTROLPIPE_DEFAULT_SIZE 8 |
#define | PIPE_TOTAL_PIPES HCD_MAX_ENDPOINT |
#define | PIPE_MAX_SIZE 512 |
Pipe Error Flag Masks | |
#define | PIPE_ERRORFLAG_OVERFLOW (1 << 6) |
#define | PIPE_ERRORFLAG_UNDERFLOW (1 << 5) |
#define | PIPE_ERRORFLAG_CRC16 (1 << 4) |
#define | PIPE_ERRORFLAG_TIMEOUT (1 << 3) |
#define | PIPE_ERRORFLAG_PID (1 << 2) |
#define | PIPE_ERRORFLAG_DATAPID (1 << 1) |
#define | PIPE_ERRORFLAG_DATATGL (1 << 0) |
Pipe Token Masks | |
#define | PIPE_TOKEN_SETUP (0) |
#define | PIPE_TOKEN_IN (1) |
#define | PIPE_TOKEN_OUT (2) |
Pipe Bank Mode Masks | |
#define | PIPE_BANK_SINGLE (0 << 1) |
#define | PIPE_BANK_DOUBLE (1 << 1) |
Enumerations | |
enum | Pipe_WaitUntilReady_ErrorCodes_t { PIPE_READYWAIT_NoError = 0, PIPE_READYWAIT_PipeStalled = 1, PIPE_READYWAIT_DeviceDisconnected = 2, PIPE_READYWAIT_Timeout = 3 } |
Functions | |
static uint16_t | Pipe_BytesInPipe (const uint8_t corenum) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE |
Indicates the number of bytes currently stored in the current pipes's selected bank. | |
static uint8_t | Pipe_GetCurrentPipe (const uint8_t corenum) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE |
Returns the pipe address of the currently selected pipe. This is typically used to save the currently selected pipe number so that it can be restored after another pipe has been manipulated. | |
static void | Pipe_SelectPipe (const uint8_t corenum, const uint8_t PipeNumber) ATTR_ALWAYS_INLINE |
Selects the given pipe number. Any pipe operations which do not require the pipe number to be indicated will operate on the currently selected pipe. | |
static void | Pipe_ResetPipe (const uint8_t corenum, const uint8_t PipeNumber) ATTR_ALWAYS_INLINE |
Resets the desired pipe, including the pipe banks and flags. | |
static void | Pipe_EnablePipe (void) ATTR_ALWAYS_INLINE |
static void | Pipe_DisablePipe (void) ATTR_ALWAYS_INLINE |
static bool | Pipe_IsEnabled (void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE |
Determines if the currently selected pipe is enabled, but not necessarily configured. | |
static uint8_t | Pipe_GetPipeToken (const uint8_t corenum) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE |
Gets the current pipe token, indicating the pipe's data direction and type. | |
static void | Pipe_SetPipeToken (const uint8_t Token) ATTR_DEPRECATED ATTR_ALWAYS_INLINE |
Sets the token for the currently selected pipe to one of the tokens specified by the PIPE_TOKEN_* masks. This can be used on CONTROL type pipes, to allow for bidirectional transfer of data during control requests, or on regular pipes to allow for half-duplex bidirectional data transfer to devices which have two endpoints of opposite direction sharing the same endpoint address within the device. | |
static void | Pipe_SetInfiniteINRequests (void) ATTR_DEPRECATED ATTR_ALWAYS_INLINE |
static void | Pipe_SetFiniteINRequests (const uint8_t TotalINRequests) ATTR_DEPRECATED ATTR_ALWAYS_INLINE |
Configures the currently selected pipe to only allow the specified number of IN requests to be accepted by the pipe before it is automatically frozen. | |
static bool | Pipe_IsConfigured (const uint8_t corenum) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE |
Determines if the currently selected pipe is configured. | |
static uint8_t | Pipe_GetBoundEndpointAddress (const uint8_t corenum) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE |
Retrieves the endpoint address of the endpoint within the attached device that the currently selected pipe is bound to. | |
static void | Pipe_SetInterruptPeriod (const uint8_t Milliseconds) ATTR_ALWAYS_INLINE |
Sets the period between interrupts for an INTERRUPT type pipe to a specified number of milliseconds. | |
static uint8_t | Pipe_GetPipeInterrupts (void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE |
Returns a mask indicating which pipe's interrupt periods have elapsed, indicating that the pipe should be serviced. | |
static bool | Pipe_HasPipeInterrupted (const uint8_t PipeNumber) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE |
Determines if the specified pipe number has interrupted (valid only for INTERRUPT type pipes). | |
static void | Pipe_Unfreeze (void) ATTR_ALWAYS_INLINE |
static void | Pipe_Freeze (void) ATTR_ALWAYS_INLINE |
static bool | Pipe_IsFrozen (void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE |
Determines if the currently selected pipe is frozen, and not able to accept data. | |
static void | Pipe_ClearError (void) ATTR_ALWAYS_INLINE |
static bool | Pipe_IsError (void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE |
Determines if the master pipe error flag is set for the currently selected pipe, indicating that some sort of hardware error has occurred on the pipe. | |
static uint8_t | Pipe_GetErrorFlags (void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE |
Gets a mask of the hardware error flags which have occurred on the currently selected pipe. This value can then be masked against the PIPE_ERRORFLAG_* masks to determine what error has occurred. | |
static uint8_t | Pipe_GetBusyBanks (void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE |
Retrieves the number of busy banks in the currently selected pipe, which have been queued for transmission via the Pipe_ClearOUT() command, or are awaiting acknowledgement via the Pipe_ClearIN() command. | |
bool | Pipe_IsINReceived (const uint8_t corenum) ATTR_WARN_UNUSED_RESULT |
Determines if a packet has been received on the currently selected IN pipe from the attached device. | |
static bool | Pipe_IsOUTReady (const uint8_t corenum) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE |
Determines if the currently selected OUT pipe is ready to send an OUT packet to the attached device. | |
static bool | Pipe_IsReadWriteAllowed (const uint8_t corenum) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE |
Determines if the currently selected pipe may be read from (if data is waiting in the pipe bank and the pipe is an IN direction, or if the bank is not yet full if the pipe is an OUT direction). This function will return false if an error has occurred in the pipe, or if the pipe is an IN direction and no packet (or an empty packet) has been received, or if the pipe is an OUT direction and the pipe bank is full. | |
static bool | Pipe_IsSETUPSent (void) ATTR_DEPRECATED ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE |
Determines if no SETUP request is currently being sent to the attached device on the selected CONTROL type pipe. | |
static void | Pipe_ClearSETUP (void) ATTR_DEPRECATED ATTR_ALWAYS_INLINE |
static void | Pipe_ClearIN (const uint8_t corenum) ATTR_ALWAYS_INLINE |
static void | Pipe_ClearOUT (const uint8_t corenum) ATTR_ALWAYS_INLINE |
static bool | Pipe_IsNAKReceived (void) ATTR_DEPRECATED ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE |
Determines if the device sent a NAK (Negative Acknowledge) in response to the last sent packet on the currently selected pipe. This occurs when the host sends a packet to the device, but the device is not currently ready to handle the packet (i.e. its endpoint banks are full). Once a NAK has been received, it must be cleared using Pipe_ClearNAKReceived() before the previous (or any other) packet can be re-sent. | |
static void | Pipe_ClearNAKReceived (void) ATTR_DEPRECATED ATTR_ALWAYS_INLINE |
static bool | Pipe_IsStalled (const uint8_t corenum) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE |
Determines if the currently selected pipe has had the STALL condition set by the attached device. | |
static void | Pipe_ClearStall (const uint8_t corenum) ATTR_ALWAYS_INLINE |
static uint8_t | Pipe_Read_8 (const uint8_t corenum) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE |
Reads one byte from the currently selected pipe's bank, for OUT direction pipes. | |
static void | Pipe_Write_8 (const uint8_t corenum, const uint8_t Data) ATTR_ALWAYS_INLINE |
Writes one byte to the currently selected pipe's bank, for IN direction pipes. | |
static void | Pipe_Discard_8 (void) ATTR_ALWAYS_INLINE |
static uint16_t | Pipe_Read_16_LE (const uint8_t corenum) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE |
Reads two bytes from the currently selected pipe's bank in little endian format, for OUT direction pipes. | |
static uint16_t | Pipe_Read_16_BE (const uint8_t corenum) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE |
Reads two bytes from the currently selected pipe's bank in big endian format, for OUT direction pipes. | |
static void | Pipe_Write_16_LE (const uint8_t corenum, const uint16_t Data) ATTR_ALWAYS_INLINE |
Writes two bytes to the currently selected pipe's bank in little endian format, for IN direction pipes. | |
static void | Pipe_Write_16_BE (const uint8_t corenum, const uint16_t Data) ATTR_ALWAYS_INLINE |
Writes two bytes to the currently selected pipe's bank in big endian format, for IN direction pipes. | |
static void | Pipe_Discard_16 (void) ATTR_ALWAYS_INLINE |
static uint32_t | Pipe_Read_32_LE (const uint8_t corenum) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE |
Reads four bytes from the currently selected pipe's bank in little endian format, for OUT direction pipes. | |
static uint32_t | Pipe_Read_32_BE (const uint8_t corenum) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE |
Reads four bytes from the currently selected pipe's bank in big endian format, for OUT direction pipes. | |
static void | Pipe_Write_32_LE (const uint8_t corenum, const uint32_t Data) ATTR_ALWAYS_INLINE |
Writes four bytes to the currently selected pipe's bank in little endian format, for IN direction pipes. | |
static void | Pipe_Write_32_BE (const uint8_t corenum, const uint32_t Data) ATTR_ALWAYS_INLINE |
Writes four bytes to the currently selected pipe's bank in big endian format, for IN direction pipes. | |
static void | Pipe_Discard_32 (void) ATTR_ALWAYS_INLINE |
bool | Pipe_ConfigurePipe (const uint8_t corenum, const uint8_t Number, const uint8_t Type, const uint8_t Token, const uint8_t EndpointNumber, const uint16_t Size, const uint8_t Banks) |
Configures the specified pipe number with the given pipe type, token, target endpoint number in the attached device, bank size and banking mode. | |
void | Pipe_ClosePipe (const uint8_t corenum, uint8_t pipenum) |
uint8_t | Pipe_WaitUntilReady (const uint8_t corenum) |
Spin-loops until the currently selected non-control pipe is ready for the next packed of data to be read or written to it, aborting in the case of an error condition (such as a timeout or device disconnect). | |
bool | Pipe_IsEndpointBound (const uint8_t EndpointAddress) ATTR_WARN_UNUSED_RESULT |
Determines if a pipe has been bound to the given device endpoint address. If a pipe which is bound to the given endpoint is found, it is automatically selected. | |
Variables | |
uint8_t | hostselected |
HCD_USB_SPEED | hostportspeed [] |
uint8_t | pipeselected [MAX_USB_CORE] |
USB_Pipe_Data_t | PipeInfo [MAX_USB_CORE][PIPE_TOTAL_PIPES] |