Soft reset on DTR change
This commit is contained in:
@ -86,6 +86,7 @@ static U8 txdata[VCOM_FIFO_SIZE];
|
||||
static fifo_t txfifo;
|
||||
//static fifo_t rxfifo;
|
||||
|
||||
static UsbSerialLineStateCallback* usbSerialLineStateCallback = nullptr;
|
||||
static UsbSerialReadCallback* usbSerialReadCallback = nullptr;
|
||||
|
||||
// forward declaration of interrupt handler
|
||||
@ -299,10 +300,13 @@ static BOOL HandleClassRequest(TSetupPacket *pSetup, int *piLen, U8 **ppbData)
|
||||
break;
|
||||
|
||||
// set control line state
|
||||
case SET_CONTROL_LINE_STATE:
|
||||
// bit0 = DTR, bit = RTS
|
||||
|
||||
break;
|
||||
case SET_CONTROL_LINE_STATE: {
|
||||
bool dtr = (pSetup->wValue >> 0) & 1;
|
||||
bool rts = (pSetup->wValue >> 1) & 1;
|
||||
if (usbSerialLineStateCallback)
|
||||
usbSerialLineStateCallback(dtr, rts);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
return FALSE;
|
||||
@ -376,8 +380,9 @@ void enable_USB_interrupts(void);
|
||||
main
|
||||
====
|
||||
**************************************************************************/
|
||||
int usbSerialInit(UsbSerialReadCallback* usbSerialReadCallback)
|
||||
int usbSerialInit(UsbSerialLineStateCallback* usbSerialLineStateCallback, UsbSerialReadCallback* usbSerialReadCallback)
|
||||
{
|
||||
::usbSerialLineStateCallback = usbSerialLineStateCallback;
|
||||
::usbSerialReadCallback = usbSerialReadCallback;
|
||||
|
||||
// initialise stack
|
||||
|
@ -98,10 +98,13 @@ void VCOM_gets_echo(char *str); // gets string terminated in '\r' or '\n' and ec
|
||||
|
||||
#include "serial_fifo.h"
|
||||
|
||||
// Receives line state. Called by an interrupt.
|
||||
typedef void UsbSerialLineStateCallback(bool dtr, bool rts);
|
||||
|
||||
// Receives serial data. Called by an interrupt.
|
||||
typedef void UsbSerialReadCallback(const U8* data, unsigned len);
|
||||
|
||||
int usbSerialInit(UsbSerialReadCallback* usbSerialReadCallback); // run once in main b4 main loop starts.
|
||||
int usbSerialInit(UsbSerialLineStateCallback* usbSerialLineStateCallback, UsbSerialReadCallback* usbSerialReadCallback); // run once in main b4 main loop starts.
|
||||
|
||||
/*
|
||||
Writes one character to VCOM port
|
||||
|
Reference in New Issue
Block a user