aboutsummaryrefslogtreecommitdiff
path: root/example-cdc/sample.c
diff options
context:
space:
mode:
authorNIIBE Yutaka <gniibe@fsij.org>2016-04-07 14:44:58 +0900
committerNIIBE Yutaka <gniibe@fsij.org>2016-04-07 14:52:39 +0900
commit92e17d3bdf2371031967f949659edb91b72fb63f (patch)
tree741147d6b21e019d77e2a095ea53f034717f0b3e /example-cdc/sample.c
parent674c19c495feb6cba9d87515a2ae9daed84e754f (diff)
USB stack for STM32F103 improvement
Diffstat (limited to 'example-cdc/sample.c')
-rw-r--r--example-cdc/sample.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/example-cdc/sample.c b/example-cdc/sample.c
index 4e61980..7a6b99f 100644
--- a/example-cdc/sample.c
+++ b/example-cdc/sample.c
@@ -129,6 +129,7 @@ main (int argc, const char *argv[])
{
struct stream *st;
uint8_t count;
+ extern uint32_t bDeviceState;
(void)argc;
(void)argv;
@@ -153,11 +154,14 @@ main (int argc, const char *argv[])
chopstx_cond_signal (&cnd1);
chopstx_mutex_unlock (&mtx);
- count= 0;
+ u = 1;
+ while (bDeviceState != CONFIGURED)
+ chopstx_usec_wait (500*1000);
+
+ count = 0;
while (1)
{
uint8_t s[64];
- u = 1;
if (stream_wait_connection (st) < 0)
{
@@ -165,6 +169,11 @@ main (int argc, const char *argv[])
continue;
}
+ chopstx_usec_wait (500*1000);
+
+ /* Send ZLP at the beginning. */
+ stream_send (st, s, 0);
+
memcpy (s, "xx: Hello, World with Chopstx!\r\n\000", 32);
s[0] = hexchar (count >> 4);
s[1] = hexchar (count & 0x0f);
@@ -180,8 +189,11 @@ main (int argc, const char *argv[])
if (size < 0)
break;
- if (stream_send (st, s, size) < 0)
- break;
+ if (size >= 0)
+ {
+ if (stream_send (st, s, size) < 0)
+ break;
+ }
u ^= 1;
}