X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/73d9fafc0fe42741ad8f609dd4762e2bc14cbd01..4f74075fad7f1e7a35d04ff534d9d6a57d2b97fc:/LUFA/Drivers/USB/LowLevel/Pipe.c diff --git a/LUFA/Drivers/USB/LowLevel/Pipe.c b/LUFA/Drivers/USB/LowLevel/Pipe.c index 18fbc19b5..fd8f81bc6 100644 --- a/LUFA/Drivers/USB/LowLevel/Pipe.c +++ b/LUFA/Drivers/USB/LowLevel/Pipe.c @@ -70,6 +70,22 @@ void Pipe_ClearPipes(void) } } +bool Pipe_IsEndpointBound(const uint8_t EndpointAddress) +{ + uint8_t PrevPipeNumber = Pipe_GetCurrentPipe(); + + for (uint8_t PNum = 0; PNum < PIPE_TOTAL_PIPES; PNum++) + { + Pipe_SelectPipe(PNum); + + if (Pipe_IsConfigured() && (Pipe_BoundEndpointNumber() == (EndpointAddress & PIPE_EPNUM_MASK))) + return true; + } + + Pipe_SelectPipe(PrevPipeNumber); + return false; +} + uint8_t Pipe_WaitUntilReady(void) { #if (USB_STREAM_TIMEOUT_MS < 0xFF) @@ -77,7 +93,7 @@ uint8_t Pipe_WaitUntilReady(void) #else uint16_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS; #endif - + for (;;) { if (Pipe_GetPipeToken() == PIPE_TOKEN_IN) @@ -93,7 +109,7 @@ uint8_t Pipe_WaitUntilReady(void) if (Pipe_IsStalled()) return PIPE_READYWAIT_PipeStalled; - else if (!(USB_IsConnected)) + else if (USB_HostState == HOST_STATE_Unattached) return PIPE_READYWAIT_DeviceDisconnected; if (USB_INT_HasOccurred(USB_INT_HSOFI)) @@ -114,7 +130,7 @@ uint8_t Pipe_Discard_Stream(uint16_t Length { uint8_t ErrorCode; - Pipe_SetToken(PIPE_TOKEN_IN); + Pipe_SetPipeToken(PIPE_TOKEN_IN); if ((ErrorCode = Pipe_WaitUntilReady())) return ErrorCode; @@ -184,63 +200,83 @@ uint8_t Pipe_Discard_Stream(uint16_t Length } #define TEMPLATE_FUNC_NAME Pipe_Write_Stream_LE +#define TEMPLATE_BUFFER_TYPE const void* +#define TEMPLATE_TOKEN PIPE_TOKEN_OUT #define TEMPLATE_CLEAR_PIPE() Pipe_ClearOUT() #define TEMPLATE_BUFFER_OFFSET(Length) 0 -#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_Byte(*(BufferPtr++)) +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_Byte(*((uint8_t*)BufferPtr++)) #include "Template/Template_Pipe_RW.c" #define TEMPLATE_FUNC_NAME Pipe_Write_PStream_LE +#define TEMPLATE_BUFFER_TYPE const void* +#define TEMPLATE_TOKEN PIPE_TOKEN_OUT #define TEMPLATE_CLEAR_PIPE() Pipe_ClearOUT() #define TEMPLATE_BUFFER_OFFSET(Length) 0 -#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_Byte(pgm_read_byte(BufferPtr++)) +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_Byte(pgm_read_byte((uint8_t*)BufferPtr++)) #include "Template/Template_Pipe_RW.c" #define TEMPLATE_FUNC_NAME Pipe_Write_EStream_LE +#define TEMPLATE_BUFFER_TYPE const void* +#define TEMPLATE_TOKEN PIPE_TOKEN_OUT #define TEMPLATE_CLEAR_PIPE() Pipe_ClearOUT() #define TEMPLATE_BUFFER_OFFSET(Length) 0 -#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_Byte(eeprom_read_byte(BufferPtr++)) +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_Byte(eeprom_read_byte((uint8_t*)BufferPtr++)) #include "Template/Template_Pipe_RW.c" #define TEMPLATE_FUNC_NAME Pipe_Write_Stream_BE +#define TEMPLATE_BUFFER_TYPE const void* +#define TEMPLATE_TOKEN PIPE_TOKEN_OUT #define TEMPLATE_CLEAR_PIPE() Pipe_ClearOUT() #define TEMPLATE_BUFFER_OFFSET(Length) Length - 1 -#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_Byte(*(BufferPtr--)) +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_Byte(*((uint8_t*)BufferPtr--)) #include "Template/Template_Pipe_RW.c" #define TEMPLATE_FUNC_NAME Pipe_Write_PStream_BE +#define TEMPLATE_BUFFER_TYPE const void* +#define TEMPLATE_TOKEN PIPE_TOKEN_OUT #define TEMPLATE_CLEAR_PIPE() Pipe_ClearOUT() #define TEMPLATE_BUFFER_OFFSET(Length) Length - 1 -#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_Byte(pgm_read_byte(BufferPtr--)) +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_Byte(pgm_read_byte((uint8_t*)BufferPtr--)) #include "Template/Template_Pipe_RW.c" #define TEMPLATE_FUNC_NAME Pipe_Write_EStream_BE +#define TEMPLATE_BUFFER_TYPE const void* +#define TEMPLATE_TOKEN PIPE_TOKEN_OUT #define TEMPLATE_CLEAR_PIPE() Pipe_ClearOUT() #define TEMPLATE_BUFFER_OFFSET(Length) Length - 1 -#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_Byte(eeprom_read_byte(BufferPtr--)) +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_Byte(eeprom_read_byte((uint8_t*)BufferPtr--)) #include "Template/Template_Pipe_RW.c" #define TEMPLATE_FUNC_NAME Pipe_Read_Stream_LE +#define TEMPLATE_BUFFER_TYPE void* +#define TEMPLATE_TOKEN PIPE_TOKEN_IN #define TEMPLATE_CLEAR_PIPE() Pipe_ClearIN() #define TEMPLATE_BUFFER_OFFSET(Length) 0 -#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *(BufferPtr++) = Pipe_Read_Byte() +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *((uint8_t*)BufferPtr++) = Pipe_Read_Byte() #include "Template/Template_Pipe_RW.c" #define TEMPLATE_FUNC_NAME Pipe_Read_EStream_LE +#define TEMPLATE_BUFFER_TYPE void* +#define TEMPLATE_TOKEN PIPE_TOKEN_IN #define TEMPLATE_CLEAR_PIPE() Pipe_ClearIN() #define TEMPLATE_BUFFER_OFFSET(Length) 0 -#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_write_byte(BufferPtr++, Pipe_Read_Byte()) +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_write_byte((uint8_t*)BufferPtr++, Pipe_Read_Byte()) #include "Template/Template_Pipe_RW.c" #define TEMPLATE_FUNC_NAME Pipe_Read_Stream_BE +#define TEMPLATE_BUFFER_TYPE void* +#define TEMPLATE_TOKEN PIPE_TOKEN_IN #define TEMPLATE_CLEAR_PIPE() Pipe_ClearIN() #define TEMPLATE_BUFFER_OFFSET(Length) Length - 1 -#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *(BufferPtr--) = Pipe_Read_Byte() +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *((uint8_t*)BufferPtr--) = Pipe_Read_Byte() #include "Template/Template_Pipe_RW.c" #define TEMPLATE_FUNC_NAME Pipe_Read_EStream_BE +#define TEMPLATE_BUFFER_TYPE void* +#define TEMPLATE_TOKEN PIPE_TOKEN_IN #define TEMPLATE_CLEAR_PIPE() Pipe_ClearIN() #define TEMPLATE_BUFFER_OFFSET(Length) Length - 1 -#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_write_byte(BufferPtr--, Pipe_Read_Byte()) +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_write_byte((uint8_t*)BufferPtr--, Pipe_Read_Byte()) #include "Template/Template_Pipe_RW.c" #endif