SLAA457B September 2013 – October 2018 MSP430F5500 , MSP430F5501 , MSP430F5502 , MSP430F5503 , MSP430F5504 , MSP430F5505 , MSP430F5506 , MSP430F5507 , MSP430F5508 , MSP430F5509 , MSP430F5510 , MSP430F5513 , MSP430F5514 , MSP430F5515 , MSP430F5517 , MSP430F5519 , MSP430F5521 , MSP430F5522 , MSP430F5524 , MSP430F5525 , MSP430F5526 , MSP430F5527 , MSP430F5528 , MSP430F5529 , MSP430F5630 , MSP430F5631 , MSP430F5632 , MSP430F5633 , MSP430F5634 , MSP430F5635 , MSP430F5636 , MSP430F5637 , MSP430F5638 , MSP430F5658 , MSP430F5659 , MSP430F6630 , MSP430F6631 , MSP430F6632 , MSP430F6633 , MSP430F6634 , MSP430F6635 , MSP430F6636 , MSP430F6637 , MSP430F6638 , MSP430F6658 , MSP430F6659 , MSP430FG6425 , MSP430FG6426 , MSP430FG6625 , MSP430FG6626
The API is the foundation of the MSP430 USB Developers Package. It supports three of the most common USB device classes:
These classes provide a good selection for general-purpose use. See Section 5.1 for a discussion of how to choose your interface.
Features of the API include:
CDC and HID-Datapipe provide the developer a simple data exchange interface. As a brief example of this interface, a simple application follows.
VOID main(VOID)
{
// Init clocks, power, ports
WDT_A_hold(WDT_A_BASE);
PMM_setVCore(PMM_BASE, PMM_CORE_LEVEL_2);
initPorts();
initClocks(8000000); // CPU frequency, in Hz
initTimer(); // Set up one-second intervals to wake from LPM0
USB_setup(TRUE,TRUE); // USB API call; initializes USB and connects to the host
__enable_interrupt();
while (1)
{
__bis_SR_register(LPM0_bits + GIE); // Enter LPM0 sleep
if (cdcSendDataInBackground(helloWorldStr, 12, CDC0_INTFNUM, 1000))
{
handleFailedSend(); // Might fail if cable is disconnected, bus is
// busy, or host has become unresponsive
}
}
}
This application wakes up once per second (using a timer interrupt, not shown) and sends a string over USB to a virtual COM port on the host.
To send data over a CDC interface (to a virtual COM port), you can simply build the interface with the Descriptor Tool, prepare your data, and call the API construct function cdcSendDataInBackground(), which accepts these parameters:
This is only one simple example; much more is possible with the USB API. See the MSP430 USB API Programmer's Guide and examples in the MSP430 USB Developers Package for more information.