Beispiel #1
0
/** Initialises the software UART, ready for data transmission and reception into the global ring buffers. */
void SoftUART_Init(void)
{
    /* Set TX pin to output high, enable RX pull-up */
    STXPORT |= (1 << STX);
    STXDDR  |= (1 << STX);
    SRXPORT |= (1 << SRX);

    /* Enable INT0 for the detection of incoming start bits that signal the start of a byte */
    EICRA  = (1 << ISC01);
    EIMSK  = (1 << INT0);

    /* Set the transmission and reception timer compare values for the default baud rate */
    SoftUART_SetBaud(9600);

    /* Setup reception timer compare ISR */
    TIMSK1 = (1 << ICIE1);

    /* Setup transmission timer compare ISR and start the timer */
    TIMSK3 = (1 << ICIE3);
    TCCR3B = ((1 << CS30) | (1 << WGM33) | (1 << WGM32));
}
Beispiel #2
0
/** Event handler for the CDC Class driver Line Encoding Changed event.
 *
 *  \param[in] CDCInterfaceInfo  Pointer to the CDC class interface configuration structure being referenced
 */
void EVENT_CDC_Device_LineEncodingChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo)
{
	/* Change the software UART's baud rate to match the new baud rate */
	SoftUART_SetBaud(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS);
}