Merge pull request #7090 from jorisa/usbserial-write-nonblocking

Add non-blocking write function for USBCDC
pull/7224/head
Cruz Monrreal 2018-06-14 10:20:26 -05:00 committed by GitHub
commit baf563709a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View File

@ -127,6 +127,10 @@ bool USBCDC::send(uint8_t * buffer, uint32_t size) {
return USBDevice::write(EPBULK_IN, buffer, size, MAX_CDC_REPORT_SIZE); return USBDevice::write(EPBULK_IN, buffer, size, MAX_CDC_REPORT_SIZE);
} }
bool USBCDC::send_NB(uint8_t * buffer, uint32_t size) {
return USBDevice::writeNB(EPBULK_IN, buffer, size, MAX_CDC_REPORT_SIZE);
}
bool USBCDC::readEP(uint8_t * buffer, uint32_t * size) { bool USBCDC::readEP(uint8_t * buffer, uint32_t * size) {
if (!USBDevice::readEP(EPBULK_OUT, buffer, size, MAX_CDC_REPORT_SIZE)) if (!USBDevice::readEP(EPBULK_OUT, buffer, size, MAX_CDC_REPORT_SIZE))
return false; return false;

View File

@ -70,7 +70,7 @@ protected:
virtual const uint8_t * configurationDesc(); virtual const uint8_t * configurationDesc();
/* /*
* Send a buffer * Send a buffer. Warning: blocking
* *
* @param endpoint endpoint which will be sent the buffer * @param endpoint endpoint which will be sent the buffer
* @param buffer buffer to be sent * @param buffer buffer to be sent
@ -79,6 +79,16 @@ protected:
*/ */
bool send(uint8_t * buffer, uint32_t size); bool send(uint8_t * buffer, uint32_t size);
/*
* Send a buffer. Warning: non blocking
*
* @param endpoint endpoint which will be sent the buffer
* @param buffer buffer to be sent
* @param size length of the buffer
* @returns true if successful
*/
bool send_NB(uint8_t * buffer, uint32_t size);
/* /*
* Read a buffer from a certain endpoint. Warning: blocking * Read a buffer from a certain endpoint. Warning: blocking
* *