Skip to content

CDC-ACM fixes #546

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions cores/arduino/CDCSerialClass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include "wiring_digital.h"
#include "variant.h"

#define CDCACM_FIXED_DELAY 120

extern void CDCSerial_Handler(void);
extern void serialEventRun1(void) __attribute__((weak));
Expand Down Expand Up @@ -133,7 +132,7 @@ void CDCSerialClass::flush( void )

size_t CDCSerialClass::write( const uint8_t uc_data )
{
uint32_t retries = 2;
uint32_t retries = 1;

if (!_shared_data->device_open || !_shared_data->host_open)
return(0);
Expand All @@ -145,11 +144,12 @@ size_t CDCSerialClass::write( const uint8_t uc_data )
// current location of the tail), we're about to overflow the buffer
// and so we don't write the character or advance the head.
if (i != _tx_buffer->tail) {
_tx_buffer->lock = 1;
_tx_buffer->data[_tx_buffer->head] = uc_data;
_tx_buffer->head = i;

// Just use a fixed delay to make it compatible with the CODK-M based firmware
delayMicroseconds(CDCACM_FIXED_DELAY);
_tx_buffer->lock = 0;
// Just use a fixed delay to make it compatible with the CODK-M based firmware
delayMicroseconds(_writeDelayUsec);
break;
}
} while (retries--);
Expand Down
7 changes: 4 additions & 3 deletions system/libarc32_arduino101/framework/include/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,12 @@
struct cdc_ring_buffer
{
/** Ring buffer data */
uint8_t data[CDCACM_BUFFER_SIZE];
volatile uint8_t data[CDCACM_BUFFER_SIZE];
/** Ring buffer head pointer, modified by producer */
int head;
volatile int head;
/** Ring buffer head pointer, modified by consumer */
int tail;
volatile int tail;
volatile uint8_t lock;
};

struct cdc_acm_shared_data {
Expand Down