sync
This commit is contained in:
@@ -37,7 +37,6 @@ static void cdc_acm_irq_cb(const struct device *dev, void *user_data)
|
||||
|
||||
bool usb_wait_for_data(k_timeout_t timeout)
|
||||
{
|
||||
/* Wartet auf das Signal aus der ISR */
|
||||
return (k_sem_take(&usb_rx_sem, timeout) == 0);
|
||||
}
|
||||
|
||||
@@ -71,23 +70,27 @@ void usb_write_char(uint8_t c)
|
||||
|
||||
void usb_write_buffer(const uint8_t *buf, size_t len)
|
||||
{
|
||||
if (!device_is_ready(cdc_dev)) {
|
||||
if (!device_is_ready(cdc_dev))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
size_t written;
|
||||
while (len > 0) {
|
||||
while (len > 0)
|
||||
{
|
||||
written = uart_fifo_fill(cdc_dev, buf, len);
|
||||
|
||||
|
||||
len -= written;
|
||||
buf += written;
|
||||
|
||||
if (len > 0) {
|
||||
/* Der FIFO ist voll, aber wir haben noch Daten.
|
||||
* 1. TX-Interrupt aktivieren (meldet sich, wenn wieder Platz ist)
|
||||
* 2. Thread schlafen legen, bis die ISR die Semaphore gibt */
|
||||
if (len > 0)
|
||||
{
|
||||
uart_irq_tx_enable(cdc_dev);
|
||||
k_sem_take(&usb_tx_sem, K_FOREVER);
|
||||
if (k_sem_take(&usb_tx_sem, K_MSEC(100)) != 0)
|
||||
{
|
||||
LOG_WRN("USB TX timeout - consumer not reading?");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user