BSP430  20141115
Board Support Package for MSP430 microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
bootstrap/console/main.c
/* We're going to use LEDs so we need the interface. */
/* We want to know the nominal clock speed so we can delay the
* appropriate interval. */
#include <bsp430/clock.h>
/* We require console support as verified by <bsp430/platform.h> */
#ifndef BSP430_CONSOLE
#error No console UART PERIPH handle has been defined
#endif /* BSP430_CONSOLE */
void main ()
{
int rv;
#if (APP_VERBOSE - 0)
#endif /* APP_VERBOSE */
/* Initialize platform. */
/* Turn on the first LED */
/* Configure the console to use the default UART handle */
/* assert(0 == rv); */
#if (APP_VERBOSE - 0)
console = hBSP430console();
#endif /* APP_VERBOSE */
/* Indicate we made it this far. */
if (0 > rv) {
/* Failed to configure the UART HAL */
} else {
unsigned int counter = 0;
/* Now blink and display a counter value every nominal half
* second. The blink proves that the loop is running even if
* nothing's coming out the serial port. On each iteration,
* attempt to read a character and display it if one is
* present. */
while (1) {
int rc;
#if (BSP430_CONSOLE_RX_BUFFER_SIZE - 0) || (BSP430_CONSOLE_TX_BUFFER_SIZE - 0)
/* If we're using interrupt-driven transmission or reception, we'd
* better enable interrupts. */
#endif /* BSP430_CONSOLE_RX_BUFFER_SIZE */
#if (BSP430_CONSOLE_RX_BUFFER_SIZE - 0) || (BSP430_CONSOLE_TX_BUFFER_SIZE - 0)
#endif /* BSP430_CONSOLE_RX_BUFFER_SIZE */
while (0 <= ((rc = cgetchar()))) {
cputtext(" rx char ");
cputu(rc, 10);
cputtext(" '");
cputchar(rc);
cputtext("'");
}
cputtext("\nctr ");
cputu(counter, 10);
#if (APP_VERBOSE - 0)
cputtext("; tx ");
cputul(console->num_tx, 10);
cputtext("; rx ");
cputul(console->num_rx, 10);
cputtext("; stat 0x");
#if (configBSP430_SERIAL_USE_USCI - 0)
cputu(console->hpl.usci->stat, 16);
#endif
#if (configBSP430_SERIAL_USE_USCI5 - 0)
cputu(console->hpl.usci5->stat, 16);
#endif
#if (configBSP430_SERIAL_USE_EUSCI - 0)
cputu(console->hpl.euscia->statw, 16);
#endif
#endif /* APP_VERBOSE */
++counter;
}
}
}