48#define TX_DATA_SIZE 64
50#define RX_DATA_SIZE 64
55void *
operator new(
size_t size);
57void *
operator new[](
size_t size);
59void operator delete(
void *ptr);
61void operator delete[](
void *ptr);
64__extension__
typedef int __guard __attribute__((mode(__DI__)));
98 uint16_t product_id = 0x2012, uint16_t product_release = 0x0001)
99 : USBCDC(vendor_id, product_id, product_release)
172 uint8_t *rbuf =
static_cast<uint8_t *
>(buf);
194 result = readEP_NB(
rxData_, &rxSize);
196 HASSERT(rxSize >= 0 && rxSize <= 255);
212 if (file->flags & O_NONBLOCK)
227 DIE(
"This serial driver does not support having multiple "
228 "threads execute blocking reads concurrently.");
252 const uint8_t *wbuf =
static_cast<const uint8_t *
>(buf);
279 if (file->flags & O_NONBLOCK)
294 DIE(
"This serial driver does not support having multiple "
295 "threads execute blocking writes concurrently.");
358void *
operator new(
size_t size)
363void *
operator new [](
size_t size)
364{
return malloc(size); }
void
365operator delete(
void *ptr)
noexcept(
true)
370void operator delete [](
void *ptr)
noexcept(
true)
373 return !*(
char *)(g);
void diewith(uint32_t pattern)
Sets a blinking pattern and never returns.
See OSMutexLock in os/OS.hxx.
Lightweight locking class for protecting small critical sections.
const char * name
device name
This class is an empty wrapper around MBed's USB CDC class.
void TxHelper()
Transmits txCount_ bytes from the txData_ buffer.
SyncNotifiable writeSync_
Helper object to block writer.
void disable() OVERRIDE
This will be called when reference count goes from non-zero to 0.
MbedAsyncUSBSerial(const char *name, uint16_t vendor_id=0x1f00, uint16_t product_id=0x2012, uint16_t product_release=0x0001)
Constructor.
bool has_rx_buffer_data() OVERRIDE
Called under a critical section.
SyncNotifiable readSync_
Helper object to block reader.
unsigned overrunCount_
How many times have we had to drop data to the floor due to buffer overrun.
bool EP2_OUT_callback() override
Callback when EP2_OUT is ready.
void flush_buffers() OVERRIDE
Instructs the device driver to drop all TX and RX queues.
uint8_t rxBegin_
First valid character in rxData.
uint8_t txCount_
number of valid characters in txData
static const int MAX_TX_PACKET_LENGTH
What's the maximum packet length for transmit.
uint8_t txData_[MAX_TX_PACKET_LENGTH]
packet assemby buffer from app to device
bool EP2_IN_callback() override
Callback when EP2_IN is ready.
uint8_t rxPending_
there is a packet in the USB block waiting
uint8_t txPending_
transmission currently pending
uint8_t rxEnd_
1 + Last valid character in rxData.
ssize_t write(File *file, const void *buf, size_t count) OVERRIDE
Write to a file or device.
bool has_tx_buffer_space() OVERRIDE
Called under a critical section.
ssize_t read(File *file, void *buf, size_t count) OVERRIDE
Read from a file or device.
uint8_t rxData_[MAX_RX_PACKET_LENGTH]
packet assemby buffer from device to app
void enable() OVERRIDE
This will be called once when reference-count goes from 0 to positive.
static const int MAX_RX_PACKET_LENGTH
What's the maximum packet length for receive.
OSMutex lock_
protects internal structures.
Node information for a device node in the filesystem that has support for nonblocking mode via Notifi...
Notifiable * readableNotify_
This will be notified if the device has data avilable for read.
Notifiable * writableNotify_
This will be notified if the device has buffer avilable for write.
An object that can schedule itself on an executor to run.
virtual void notify()=0
Generic callback.
Class to allow convenient locking and unlocking of mutexes in a C context.
A Notifiable for synchronously waiting for a notification.
void wait_for_notification()
Blocks the current thread until the notification is delivered.
#define OVERRIDE
Function attribute for virtual functions declaring that this funciton is overriding a funciton that s...
#define HASSERT(x)
Checks that the value of expression x is true, else terminates the current process.
#define DIE(MSG)
Unconditionally terminates the current process with a message.
int __cxa_guard_acquire(__guard *)
C++ operator (not sure why this is needed).
void __cxa_guard_abort(__guard *)
C++ operator (not sure why this is needed).
static Atomic critical_lock
Mutex for the USB-serial object.
void __cxa_pure_virtual(void)
C++ operator (not sure why this is needed).
MbedAsyncUSBSerial g_mbed_usb_serial("/dev/serUSB0")
Global object for the mbed usb serial.
void __cxa_guard_release(__guard *)
C++ operator (not sure why this is needed).
__extension__ typedef int __guard
not sure why this is needed.