Skip to content

Instantly share code, notes, and snippets.

@govorox
Last active September 26, 2017 08:29
Show Gist options
  • Save govorox/8c8b9f0a3778ef2fb87b725ecacc3f81 to your computer and use it in GitHub Desktop.
Save govorox/8c8b9f0a3778ef2fb87b725ecacc3f81 to your computer and use it in GitHub Desktop.
Microchip Harmony fix - USB CDC console issue with escape sequence handling (ArrowUp, ArrowDn, etc)
...
/*******************************************************
* USB CDC Device Events - Application Event Handler
*******************************************************/
USB_DEVICE_CDC_EVENT_RESPONSE USBDeviceCDCEventHandler
(
USB_DEVICE_CDC_INDEX index ,
USB_DEVICE_CDC_EVENT event ,
void* pData,
uintptr_t userData
)
{
...
case USB_DEVICE_CDC_EVENT_READ_COMPLETE:
//*pCdcReadBuff = tmpReadBuffer;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// FIX
// handle the packets
// of size > 1 correctly
//
{
USB_DEVICE_CDC_EVENT_DATA_READ_COMPLETE* pRC =
(USB_DEVICE_CDC_EVENT_DATA_READ_COMPLETE*)pData;
struct QPkt pkt = rdQElements[rdQueue.tailPos];
*((uint32_t*)pkt.data.buf) = tmpReadBuffer;
pkt.sz = pRC->length % 4;
tmpReadBuffer = 0;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* This means that the host has sent some data*/
consUsbDataObject->isReadComplete = true;
break;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment