|
|
@ -50,6 +50,12 @@ CDC_Line_Coding_t LineCoding = { .BaudRateBPS = 9600,
|
|
|
|
.ParityType = Parity_None,
|
|
|
|
.ParityType = Parity_None,
|
|
|
|
.DataBits = 8 };
|
|
|
|
.DataBits = 8 };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Indicates if the host has set the device line encoding. Until the line encoding is set by the host, the device should
|
|
|
|
|
|
|
|
* not attempt to send any bytes.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool LineEncodingSet = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
#if 0
|
|
|
|
/* NOTE: Here you can set up a standard stream using the created virtual serial port, so that the standard stream functions in
|
|
|
|
/* NOTE: Here you can set up a standard stream using the created virtual serial port, so that the standard stream functions in
|
|
|
|
* <stdio.h> can be used on the virtual serial port (e.g. fprintf(&USBSerial, "Test"); to print a string).
|
|
|
|
* <stdio.h> can be used on the virtual serial port (e.g. fprintf(&USBSerial, "Test"); to print a string).
|
|
|
@ -59,6 +65,9 @@ static int CDC_putchar(char c, FILE *stream)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Endpoint_SelectEndpoint(CDC_TX_EPNUM);
|
|
|
|
Endpoint_SelectEndpoint(CDC_TX_EPNUM);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!(LineEncodingSet))
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
|
|
while (!(Endpoint_IsReadWriteAllowed()))
|
|
|
|
while (!(Endpoint_IsReadWriteAllowed()))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (USB_DeviceState != DEVICE_STATE_Configured)
|
|
|
|
if (USB_DeviceState != DEVICE_STATE_Configured)
|
|
|
@ -75,6 +84,9 @@ static int CDC_getchar(FILE *stream)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int c;
|
|
|
|
int c;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!(LineEncodingSet))
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
|
|
Endpoint_SelectEndpoint(CDC_RX_EPNUM);
|
|
|
|
Endpoint_SelectEndpoint(CDC_RX_EPNUM);
|
|
|
|
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
for (;;)
|
|
|
@ -217,6 +229,9 @@ void EVENT_USB_UnhandledControlPacket(void)
|
|
|
|
/* Read the line coding data in from the host into the global struct */
|
|
|
|
/* Read the line coding data in from the host into the global struct */
|
|
|
|
Endpoint_Read_Control_Stream_LE(LineCodingData, sizeof(CDC_Line_Coding_t));
|
|
|
|
Endpoint_Read_Control_Stream_LE(LineCodingData, sizeof(CDC_Line_Coding_t));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Indicate that the line encoding has been set, and the device may now send data */
|
|
|
|
|
|
|
|
LineEncodingSet = true;
|
|
|
|
|
|
|
|
|
|
|
|
/* Finalize the stream transfer to clear the last packet from the host */
|
|
|
|
/* Finalize the stream transfer to clear the last packet from the host */
|
|
|
|
Endpoint_ClearIN();
|
|
|
|
Endpoint_ClearIN();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -299,7 +314,7 @@ void CDC_Task(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ActionSent = false;
|
|
|
|
ActionSent = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (ActionSent == false)
|
|
|
|
else if ((ActionSent == false) && LineEncodingSet)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ActionSent = true;
|
|
|
|
ActionSent = true;
|
|
|
|
|
|
|
|
|
|
|
|