Instructions

User Experience Software
www.ti.com
3.6.5.4 Configuring Ports
In the function initPorts(), all of the I/Os are configured to drive out-low. Later, in bcUartInit(), the USCI_A1
module's UART pins will be configured for the backchannel UART.
The purpose of initPorts() is to eliminate floating inputs. These are a source of unexpected power draw, so
it is a good practice to either drive all I/Os out or make sure any inputs are being pulled high or low from
the outside. If you drive an I/O out, make sure this does not negatively affect some other component on
the board.
3.6.5.5 Initializing the Backchannel UART
bcUartInit() initializes the backchannel UART. See Section 3.6.4 for more information about configuring
the backchannel UART library.
3.6.5.6 Configuring USB
USB_setup() is called next. This initializes the USB API and enables all of the USB events. It then checks
to see if a USB host is already attached, which it determines by the presence of 5 V on the VBUS pin. If
attached, it pulls the D+ signal high, telling the host it is there. The host responds by enumerating the
device.
Finally, global interrupts are enabled, and execution enters the main loop.
3.6.6 Code Description: Main Loop
The following code sample shows the main loop.
while(1)
{
// Receive backchannel UART bytes, send over USB
rxByteCount = bcUartReceiveBytesInBuffer(buf_bcuartToUsb);
if(rxByteCount)
{
cdcSendDataInBackground(buf_bcuartToUsb, rxByteCount, CDC0_INTFNUM, 1000);
//hidSendDataInBackground(buf_bcuartToUsb, rxByteCount, HID0_INTFNUM, 1000);
}
// Receive USB bytes, send over backchannel UART
rxByteCount = cdcReceiveDataInBuffer(buf_usbToBcuart,
sizeof(buf_usbToBcuart),
CDC0_INTFNUM);
/*rxByteCount = hidReceiveDataInBuffer(buf_usbToBcuart,
sizeof(buf_usbToBcuart),
HID0_INTFNUM); */
if(rxByteCount)
{
bcUartSend(buf_usbToBcuart, rxByteCount);
}
}
The main loop does the following actions for both the backchannel UART and USB CDC interface:
Copies data from their respective input buffers.
If any data was present, retransmits the data over the other interface.
When data arrives at the USCI_A1 backchannel UART, it is immediately copied to the receive buffer,
bcUartRcvBuf. Then, because this main loop never sleeps, it frequently checks if any bytes are waiting in
the receive buffer using bcUartReceiveBytesInBuffer(). If bytes are waiting, the bytes are copied into
buf_bcuartToUsb. Then cdcSendDataInBackground() sends them over the application's CDC interface to
the host PC.
The same happens in the other direction. When data arrives over the USB CDC interface, the USB
hardware module places them into the USB endpoint buffers. The main loop calls
cdcReceiveDataInBuffer(), which checks if any bytes have been received; if so, they are copied into
buf_usbtoBcuart. Then, bcUartSend() sends them over the backchannel UART.
46
MSP430F5529 LaunchPad™ Development Tool (MSP
EXP430F5529LP) SLAU533ASeptember 2013Revised January 2014
Submit Documentation Feedback
Copyright © 2013–2014, Texas Instruments Incorporated