diff options
Diffstat (limited to 'Demos')
-rw-r--r-- | Demos/Device/ClassDriver/MassStorage/Lib/DataflashManager.c | 28 | ||||
-rw-r--r-- | Demos/Device/ClassDriver/MassStorage/MassStorage.h | 2 | ||||
-rw-r--r-- | Demos/Device/LowLevel/CDC/CDC.c | 20 | ||||
-rw-r--r-- | Demos/Device/LowLevel/DualCDC/DualCDC.c | 12 | ||||
-rw-r--r-- | Demos/Device/LowLevel/MassStorage/Lib/DataflashManager.c | 28 | ||||
-rw-r--r-- | Demos/Device/LowLevel/MassStorage/MassStorage.h | 2 | ||||
-rw-r--r-- | Demos/Device/LowLevel/USBtoSerial/USBtoSerial.c | 12 |
7 files changed, 27 insertions, 77 deletions
diff --git a/Demos/Device/ClassDriver/MassStorage/Lib/DataflashManager.c b/Demos/Device/ClassDriver/MassStorage/Lib/DataflashManager.c index 5f12d02b4..3858d3873 100644 --- a/Demos/Device/ClassDriver/MassStorage/Lib/DataflashManager.c +++ b/Demos/Device/ClassDriver/MassStorage/Lib/DataflashManager.c @@ -69,11 +69,8 @@ void DataflashManager_WriteBlocks(USB_ClassInfo_MS_Device_t* MSInterfaceInfo, co Dataflash_SendAddressBytes(0, CurrDFPageByte);
/* Wait until endpoint is ready before continuing */
- while (!(Endpoint_IsReadWriteAllowed()))
- {
- if (USB_DeviceState == DEVICE_STATE_Unattached)
- return;
- }
+ if (Endpoint_WaitUntilReady())
+ return;
while (TotalBlocks)
{
@@ -89,11 +86,8 @@ void DataflashManager_WriteBlocks(USB_ClassInfo_MS_Device_t* MSInterfaceInfo, co Endpoint_ClearOUT();
/* Wait until the host has sent another packet */
- while (!(Endpoint_IsReadWriteAllowed()))
- {
- if (USB_DeviceState == DEVICE_STATE_Unattached)
- return;
- }
+ if (Endpoint_WaitUntilReady())
+ return;
}
/* Check if end of dataflash page reached */
@@ -205,11 +199,8 @@ void DataflashManager_ReadBlocks(USB_ClassInfo_MS_Device_t* MSInterfaceInfo, con Dataflash_SendByte(0x00);
/* Wait until endpoint is ready before continuing */
- while (!(Endpoint_IsReadWriteAllowed()))
- {
- if (USB_DeviceState == DEVICE_STATE_Unattached)
- return;
- }
+ if (Endpoint_WaitUntilReady())
+ return;
while (TotalBlocks)
{
@@ -225,11 +216,8 @@ void DataflashManager_ReadBlocks(USB_ClassInfo_MS_Device_t* MSInterfaceInfo, con Endpoint_ClearIN();
/* Wait until the endpoint is ready for more data */
- while (!(Endpoint_IsReadWriteAllowed()))
- {
- if (USB_DeviceState == DEVICE_STATE_Unattached)
- return;
- }
+ if (Endpoint_WaitUntilReady())
+ return;
}
/* Check if end of dataflash page reached */
diff --git a/Demos/Device/ClassDriver/MassStorage/MassStorage.h b/Demos/Device/ClassDriver/MassStorage/MassStorage.h index e6b2bf99f..930e8f4cb 100644 --- a/Demos/Device/ClassDriver/MassStorage/MassStorage.h +++ b/Demos/Device/ClassDriver/MassStorage/MassStorage.h @@ -70,7 +70,7 @@ #define LEDMASK_USB_BUSY (LEDS_LED2)
/** Total number of logical drives within the device - must be non-zero. */
- #define TOTAL_LUNS 2
+ #define TOTAL_LUNS 1
/** Blocks in each LUN, calculated from the total capacity divided by the total number of Logical Units in the device. */
#define LUN_MEDIA_BLOCKS (VIRTUAL_MEMORY_BLOCKS / TOTAL_LUNS)
diff --git a/Demos/Device/LowLevel/CDC/CDC.c b/Demos/Device/LowLevel/CDC/CDC.c index 9ee744ea0..12cd8c40f 100644 --- a/Demos/Device/LowLevel/CDC/CDC.c +++ b/Demos/Device/LowLevel/CDC/CDC.c @@ -62,11 +62,8 @@ static int CDC_putchar(char c, FILE *stream) if (!(LineEncoding.BaudRateBPS))
return -1;
- while (!(Endpoint_IsReadWriteAllowed()))
- {
- if (USB_DeviceState != DEVICE_STATE_Configured)
- return -1;
- }
+ if (Endpoint_WaitUntilReady())
+ return -1;
Endpoint_Write_Byte(c);
Endpoint_ClearIN();
@@ -85,11 +82,8 @@ static int CDC_getchar(FILE *stream) for (;;)
{
- while (!(Endpoint_IsReadWriteAllowed()))
- {
- if (USB_DeviceState != DEVICE_STATE_Configured)
- return -1;
- }
+ if (Endpoint_WaitUntilReady())
+ return -1;
if (!(Endpoint_BytesInEndpoint()))
{
@@ -327,11 +321,7 @@ void CDC_Task(void) if (IsFull)
{
/* Wait until the endpoint is ready for another packet */
- while (!(Endpoint_IsINReady()))
- {
- if (USB_DeviceState == DEVICE_STATE_Unattached)
- return;
- }
+ Endpoint_WaitUntilReady();
/* Send an empty packet to ensure that the host does not buffer data sent to it */
Endpoint_ClearIN();
diff --git a/Demos/Device/LowLevel/DualCDC/DualCDC.c b/Demos/Device/LowLevel/DualCDC/DualCDC.c index c49a1ad85..7a84c8dcd 100644 --- a/Demos/Device/LowLevel/DualCDC/DualCDC.c +++ b/Demos/Device/LowLevel/DualCDC/DualCDC.c @@ -274,11 +274,7 @@ void CDC1_Task(void) Endpoint_ClearIN();
/* Wait until the endpoint is ready for another packet */
- while (!(Endpoint_IsINReady()))
- {
- if (USB_DeviceState == DEVICE_STATE_Unattached)
- return;
- }
+ Endpoint_WaitUntilReady();
/* Send an empty packet to ensure that the host does not buffer data sent to it */
Endpoint_ClearIN();
@@ -329,11 +325,7 @@ void CDC2_Task(void) Endpoint_ClearIN();
/* Wait until the endpoint is ready for the next packet */
- while (!(Endpoint_IsINReady()))
- {
- if (USB_DeviceState == DEVICE_STATE_Unattached)
- return;
- }
+ Endpoint_WaitUntilReady();
/* Send an empty packet to prevent host buffering */
Endpoint_ClearIN();
diff --git a/Demos/Device/LowLevel/MassStorage/Lib/DataflashManager.c b/Demos/Device/LowLevel/MassStorage/Lib/DataflashManager.c index 2bd03c98d..9cd0279d6 100644 --- a/Demos/Device/LowLevel/MassStorage/Lib/DataflashManager.c +++ b/Demos/Device/LowLevel/MassStorage/Lib/DataflashManager.c @@ -68,11 +68,8 @@ void DataflashManager_WriteBlocks(const uint32_t BlockAddress, uint16_t TotalBlo Dataflash_SendAddressBytes(0, CurrDFPageByte);
/* Wait until endpoint is ready before continuing */
- while (!(Endpoint_IsReadWriteAllowed()))
- {
- if (USB_DeviceState == DEVICE_STATE_Unattached)
- return;
- }
+ if (Endpoint_WaitUntilReady())
+ return;
while (TotalBlocks)
{
@@ -88,11 +85,8 @@ void DataflashManager_WriteBlocks(const uint32_t BlockAddress, uint16_t TotalBlo Endpoint_ClearOUT();
/* Wait until the host has sent another packet */
- while (!(Endpoint_IsReadWriteAllowed()))
- {
- if (USB_DeviceState == DEVICE_STATE_Unattached)
- return;
- }
+ if (Endpoint_WaitUntilReady())
+ return;
}
/* Check if end of dataflash page reached */
@@ -203,11 +197,8 @@ void DataflashManager_ReadBlocks(const uint32_t BlockAddress, uint16_t TotalBloc Dataflash_SendByte(0x00);
/* Wait until endpoint is ready before continuing */
- while (!(Endpoint_IsReadWriteAllowed()))
- {
- if (USB_DeviceState == DEVICE_STATE_Unattached)
- return;
- }
+ if (Endpoint_WaitUntilReady())
+ return;
while (TotalBlocks)
{
@@ -223,11 +214,8 @@ void DataflashManager_ReadBlocks(const uint32_t BlockAddress, uint16_t TotalBloc Endpoint_ClearIN();
/* Wait until the endpoint is ready for more data */
- while (!(Endpoint_IsReadWriteAllowed()))
- {
- if (USB_DeviceState == DEVICE_STATE_Unattached)
- return;
- }
+ if (Endpoint_WaitUntilReady())
+ return;
}
/* Check if end of dataflash page reached */
diff --git a/Demos/Device/LowLevel/MassStorage/MassStorage.h b/Demos/Device/LowLevel/MassStorage/MassStorage.h index 868daf09a..65407c8c1 100644 --- a/Demos/Device/LowLevel/MassStorage/MassStorage.h +++ b/Demos/Device/LowLevel/MassStorage/MassStorage.h @@ -64,7 +64,7 @@ /** Total number of Logical Units (drives) in the device. The total device capacity is shared equally between
* each drive - this can be set to any positive non-zero amount.
*/
- #define TOTAL_LUNS 2
+ #define TOTAL_LUNS 1
/** Blocks in each LUN, calculated from the total capacity divided by the total number of Logical Units in the device. */
#define LUN_MEDIA_BLOCKS (VIRTUAL_MEMORY_BLOCKS / TOTAL_LUNS)
diff --git a/Demos/Device/LowLevel/USBtoSerial/USBtoSerial.c b/Demos/Device/LowLevel/USBtoSerial/USBtoSerial.c index bb1b4da2d..736c0af10 100644 --- a/Demos/Device/LowLevel/USBtoSerial/USBtoSerial.c +++ b/Demos/Device/LowLevel/USBtoSerial/USBtoSerial.c @@ -263,11 +263,7 @@ void CDC_Task(void) if ((Tx_Buffer.Elements) && LineEncoding.BaudRateBPS)
{
/* Wait until Serial Tx Endpoint Ready for Read/Write */
- while (!(Endpoint_IsReadWriteAllowed()))
- {
- if (USB_DeviceState == DEVICE_STATE_Unattached)
- return;
- }
+ Endpoint_WaitUntilReady();
/* Write the bytes from the buffer to the endpoint while space is available */
while (Tx_Buffer.Elements && Endpoint_IsReadWriteAllowed())
@@ -287,11 +283,7 @@ void CDC_Task(void) if (IsFull && !(Tx_Buffer.Elements))
{
/* Wait until Serial Tx Endpoint Ready for Read/Write */
- while (!(Endpoint_IsReadWriteAllowed()))
- {
- if (USB_DeviceState == DEVICE_STATE_Unattached)
- return;
- }
+ Endpoint_WaitUntilReady();
/* Send an empty packet to terminate the transfer */
Endpoint_ClearIN();
|