diff --git a/demos/host/host_freertos/.cproject b/demos/host/host_freertos/.cproject
index fc4073bb..d22eea06 100644
--- a/demos/host/host_freertos/.cproject
+++ b/demos/host/host_freertos/.cproject
@@ -181,6 +181,7 @@
+
@@ -208,10 +209,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<TargetConfig>
<Properties property_0="" property_2="LPC18x7_43x7_2x512_BootA.cfx" property_3="NXP" property_4="LPC4357" property_count="5" version="60000"/>
-<infoList vendor="NXP">
-<info chip="LPC4357" flash_driver="LPC18x7_43x7_2x512_BootA.cfx" match_id="0x0" name="LPC4357" resetscript="LPC18LPC43InternalFLASHBootResetscript.scp" stub="crt_emu_lpc18_43_nxp">
-<chip>
-<name>LPC4357</name>
+<infoList vendor="NXP"><info chip="LPC4357" flash_driver="LPC18x7_43x7_2x512_BootA.cfx" match_id="0x0" name="LPC4357" resetscript="LPC18LPC43InternalFLASHBootResetscript.scp" stub="crt_emu_lpc18_43_nxp"><chip><name>LPC4357</name>
<family>LPC43xx</family>
<vendor>NXP (formerly Philips)</vendor>
<reset board="None" core="Real" sys="Real"/>
@@ -286,8 +284,7 @@
<peripheralInstance derived_from="SPI" determined="infoFile" id="SPI" location="0x40100000"/>
<peripheralInstance derived_from="SGPIO" determined="infoFile" id="SGPIO" location="0x40101000"/>
</chip>
-<processor>
-<name gcc_name="cortex-m4">Cortex-M4</name>
+<processor><name gcc_name="cortex-m4">Cortex-M4</name>
<family>Cortex-M</family>
</processor>
<link href="nxp_lpc43xx_peripheral.xme" show="embed" type="simple"/>
diff --git a/demos/host/src/cdc_serial_app.c b/demos/host/src/cdc_serial_app.c
index 589bb751..14f5bffc 100644
--- a/demos/host/src/cdc_serial_app.c
+++ b/demos/host/src/cdc_serial_app.c
@@ -50,13 +50,15 @@
// MACRO CONSTANT TYPEDEF
//--------------------------------------------------------------------+
OSAL_TASK_DEF(cdc_serial_app_task, 128, CDC_SERIAL_APP_TASK_PRIO);
-OSAL_QUEUE_DEF(queue_def, QUEUE_SERIAL_DEPTH, uint8_t);
+OSAL_SEM_DEF(serial_semaphore);
-static osal_queue_handle_t queue_hdl;
+static osal_semaphore_handle_t sem_hdl;
static uint8_t serial_in_buffer[32] TUSB_CFG_ATTR_USBRAM;
static uint8_t serial_out_buffer[32] TUSB_CFG_ATTR_USBRAM;
+static uint8_t received_bytes; // set by transfer complete callback
+
//--------------------------------------------------------------------+
// tinyusb Callbacks
//--------------------------------------------------------------------+
@@ -64,7 +66,12 @@ void tusbh_cdc_mounted_cb(uint8_t dev_addr)
{ // application set-up
printf("\na CDC device is mounted\n");
- osal_queue_flush(queue_hdl);
+ memclr_(serial_in_buffer, sizeof(serial_in_buffer));
+ memclr_(serial_out_buffer, sizeof(serial_out_buffer));
+ received_bytes = 0;
+
+ osal_semaphore_reset(sem_hdl);
+ tusbh_cdc_receive(dev_addr, serial_in_buffer, sizeof(serial_in_buffer), true); // schedule first transfer
}
void tusbh_cdc_unmounted_cb(uint8_t dev_addr)
@@ -79,13 +86,13 @@ void tusbh_cdc_xfer_isr(uint8_t dev_addr, tusb_event_t event, cdc_pipeid_t pipe_
switch(event)
{
case TUSB_EVENT_XFER_COMPLETE:
- for(uint32_t i=0; i TUSB_CFG_HOST_DEVICE_MAX)
+ { // there is no CDC device connected
+ osal_task_delay(1000);
+ }
+
OSAL_TASK_LOOP_END
}