Exemplo n.º 1
0
int main()
{
	// Set the clocking to run directly from the crystal.
	SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ);

	//Initialize peripherals
	InitializeDisplay();
	InitializeTimers();
	InitializeADC();
	InitializeInterrupts();

	//Main program loop
	unsigned long avgADCValue = 0;
	while(1)
	{
		if(BufOneReadyToRead)
		{
			avgADCValue = GetAvgOfBuf(1);
			usnprintf(str, 25, "Buf1: %5u", avgADCValue);
			RIT128x96x4StringDraw(str, 0, 0, 15);
			BufOneReadyToRead = 0;
		}
		else if(BufTwoReadyToRead)
		{
			avgADCValue = GetAvgOfBuf(2);
			usnprintf(str, 25, "Buf2: %5u", avgADCValue);
			RIT128x96x4StringDraw(str, 0, 10, 15);
			BufTwoReadyToRead = 0;
		}
	}
}
Exemplo n.º 2
0
//*****************************************************************************
//
// Report to the user the amount of free space and used space in the data
// storage area.
//
//*****************************************************************************
void
FlashStoreReport(void)
{
    unsigned long ulAddr;
    unsigned long ulFreeBlocks = 0;
    unsigned long ulUsedBlocks = 0;
    static char cBufFree[16];
    static char cBufUsed[16];

    //
    // Loop through each block of the storage area and count how many blocks
    // are free and non-free.
    //
    for(ulAddr = FLASH_STORE_START_ADDR; ulAddr < FLASH_STORE_END_ADDR;
        ulAddr += 0x400)
    {
        if(IsBlockFree(ulAddr))
        {
            ulFreeBlocks++;
        }
        else
        {
            ulUsedBlocks++;
        }
    }

    //
    // Report the result to the user via a status display screen.
    //
    usnprintf(cBufFree, sizeof(cBufFree), "FREE: %3uK", ulFreeBlocks);
    usnprintf(cBufUsed, sizeof(cBufUsed), "USED: %3uK", ulUsedBlocks);
    SetStatusText("FREE FLASH", cBufFree, cBufUsed, "PRESS <");
}
Exemplo n.º 3
0
void main () {
	 SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | 
	                SYSCTL_XTAL_8MHZ);

	// NOTE: actual clock speed is pll / 2/ div = 400M / 2/ 10
//	SysCtlClockSet(SYSCTL_SYSDIV_10 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ); 

 initializeGlobalData(); // initialize global data
#if DEBUG
 RIT128x96x4Init(1000000);
#endif

#if DEBUG
	char num[30];
	usnprintf(num, 30, "begin CommandTest");
	RIT128x96x4StringDraw(num, 0, 0, 15);
#endif

	strncpy(global.commandStr, "M A", COMMAND_LENGTH - 1);	// this is the test command

	commandTask.runTaskFunction(commandTask.taskDataPtr);
	
#if DEBUG
	usnprintf(num, 30, global.responseStr);
	RIT128x96x4StringDraw(num, 0, 70, 7);
	usnprintf(num, 30, "done %d %d", global.measurementSelection, global.responseReady);
	RIT128x96x4StringDraw(num, 0, 80, 15);
#endif
}
Exemplo n.º 4
0
void io_get_status(char * pcBuf, int iBufLen)
{
    if (reflow_get_instance()->active) {
        usnprintf(pcBuf, iBufLen, "on");
    } else {
        usnprintf(pcBuf, iBufLen, "off");
    }
}
Exemplo n.º 5
0
//*****************************************************************************
//
// The main loop of the application.  This implementation is specific to the
// EK-LM4F232 board and merely displays the current timer count value and the
// number of interrupts taken.  It contains nothing directly relevant to the
// timer configuration or operation.
//
//*****************************************************************************
void
MainLoopRun(void)
{
    uint32_t ui32Count, ui32LastCount;

    //
    // Set up for the main loop.
    //
    ui32LastCount = 10;

    //
    // Loop forever while the timer runs.
    //
    while(1)
    {
        //
        // Get the current timer count.
        //
        ui32Count = ROM_TimerValueGet(TIMER4_BASE, TIMER_A);

        //
        // Has it changed?
        //
        if(ui32Count != ui32LastCount)
        {
            //
            // Yes - update the display.
            //
            usnprintf(g_pcPrintBuff, PRINT_BUFF_SIZE, "%d ", ui32Count);
            GrStringDraw(&g_sContext, g_pcPrintBuff, -1, 80, 26, true);

            //
            // Remember the new count value.
            //
            ui32LastCount = ui32Count;
        }

        //
        // Has there been an interrupt since last we checked?
        //
        if(HWREGBITW(&g_ui32Flags, 0))
        {
            //
            // Clear the bit.
            //
            HWREGBITW(&g_ui32Flags, 0) = 0;

            //
            // Update the interrupt count.
            //
            usnprintf(g_pcPrintBuff, PRINT_BUFF_SIZE, "%d ", g_ui32IntCount);
            GrStringDraw(&g_sContext, g_pcPrintBuff, -1, 80, 36, true);
        }
    }
}
//*****************************************************************************
//
// This function will encode the sensor data into a JSON format string.
//
// \param pcBuf is a pointer to a buffer where the JSON string is stored.
// \param ui32BufSize is the size of the buffer pointer to by pcBuf.
//
// \return the number of bytes written to pcBuf as indicated by usnprintf.
//
//*****************************************************************************
uint32_t
ISL29023DataEncodeJSON(char *pcBuf, uint32_t ui32BufSize)
{
    uint32_t ui32SpaceUsed;
    char pcVisibleBuf[12];
    char pcInfraredBuf[12];

    //
    // Convert the floating point members of the struct into strings.
    //
    uftostr(pcVisibleBuf, 12, 3, g_sISL29023Data.fVisible);
    uftostr(pcInfraredBuf, 12, 3, g_sISL29023Data.fInfrared);

    //
    // Merge the strings into the buffer in JSON format.
    //
    ui32SpaceUsed = usnprintf(pcBuf, ui32BufSize, "{\"sISL29023Data_t\":{"
                              "\"bActive\":%d,\"fVisible\":%s,"
                              "\"fInfrared\":%s,\"ui8Range\":%d}}",
                              g_sISL29023Data.bActive, pcVisibleBuf,
                              pcInfraredBuf, g_sISL29023Data.ui8Range);

    //
    // Return size of string created.
    //
    return ui32SpaceUsed;

}
Exemplo n.º 7
0
//*****************************************************************************
//
// Return PWM state
//
//*****************************************************************************
void
io_get_pwmstate(char * pcBuf, int iBufLen)
{
    //
    // Get the state of the PWM1
    //
    if(HWREG(PWM_BASE + PWM_O_ENABLE) & PWM_OUT_1_BIT)
    {
        usnprintf(pcBuf, iBufLen, "ON");
    }
    else
    {
        usnprintf(pcBuf, iBufLen, "OFF");
    }

}
Exemplo n.º 8
0
//*****************************************************************************
//
// Return LED state
//
//*****************************************************************************
void
io_get_ledstate(char * pcBuf, int iBufLen)
{
    //
    // Get the state of the LED
    //
    if(ROM_GPIOPinRead(LED_PORT_BASE, LED_PIN))
    {
        usnprintf(pcBuf, iBufLen, "ON");
    }
    else
    {
        usnprintf(pcBuf, iBufLen, "OFF");
    }

}
Exemplo n.º 9
0
/* This function prints out some module stats
*/
int cmd_stats(int argc, char *argv[]) {
	struct uart_info *uart_config;
	struct crc_info *crc_config;
	struct relay_info *relay_config;
	char buf[3];
	
	for(size_t i = MODULE1; i <= MODULE4; i++)	{
		if(module_exists(i))	{
			switch	(module_profile_id(i)) {
				case PROFILE_UART: {
					uart_config = get_uart_profile(i);
					cmd_print("\r\nmodule id: %d base: %X port: %d rcv: %d sent: %d err: %d lost: %d buf: %d profile: ", i, uart_config->base, uart_config->port,uart_config->recv, uart_config->sent, uart_config->err, uart_config->lost,uart_config->buf_size * UART_QUEUE_SIZE);
					usnprintf((char *)&buf, 3, "%d",i+1);
					argc=2;
					argv[1]=(char *)&buf;
					read_uartmode(argc,argv);
					break;}
					case PROFILE_CRC: {
						crc_config = get_crc_profile(i);
						cmd_print("\r\nmodule id: %d profile: %s crc: %X crc2: %X", i, "crc error", crc_config->crc,crc_config->crc2);
						
						break;}
					case PROFILE_RELAY: {
						relay_config = get_relay_profile(i);
						cmd_print("\r\nmodule id: %d profile: %s start_value: %d negation: %d convert: %d", i, "relay", relay_config->start_value, relay_config->negation, relay_config->convert);
						break;
					}
			};
		} else {
			cmd_print("\r\nmodule id: %d not available", i);
		}
	}
	return(0);
}
Exemplo n.º 10
0
//*****************************************************************************
//
// Initialize the offscreen buffers and the menu structure.  This should be
// called before using the application menus.
// The parameter is a function pointer to a callback function whenever the
// menu widget activates or deactivates a child widget.
//
//*****************************************************************************
void
MenuInit(void (*pfnActive)(tWidget *, tSlideMenuItem *, bool))
{
    uint32_t ui32Idx;

    //
    // Initialize two offscreen displays and assign the palette.  These
    // buffers are used by the slide menu widget and other parts of the
    // application to allow for animation effects.
    //
    GrOffScreen4BPPInit(&g_sOffscreenDisplayA, g_pui8OffscreenBufA, 96, 64);
    GrOffScreen4BPPPaletteSet(&g_sOffscreenDisplayA, g_pui32Palette, 0,
                              NUM_PALETTE_ENTRIES);
    GrOffScreen4BPPInit(&g_sOffscreenDisplayB, g_pui8OffscreenBufB, 96, 64);
    GrOffScreen4BPPPaletteSet(&g_sOffscreenDisplayB, g_pui32Palette, 0,
                              NUM_PALETTE_ENTRIES);

    //
    // Initialize each of the text fields with a "blank" indication.
    //
    for(ui32Idx = 0; ui32Idx < NUM_LOG_ITEMS; ui32Idx++)
    {
        usnprintf(g_pcTextFields[ui32Idx], TEXT_FIELD_LENGTH, "----");
    }

    //
    // Set the slide menu widget callback function.
    //
    SlideMenuActiveCallbackSet(&g_sMenuWidget, pfnActive);
}
Exemplo n.º 11
0
//*****************************************************************************
//
// Return LED state
//
//*****************************************************************************
void
io_get_ledstate(char * pcBuf, int iBufLen)
{
    //
    // Get the state of the LED
    //
    if(GPIOPinRead(GPIO_PORTF_BASE, GPIO_PIN_0))
    {
        usnprintf(pcBuf, iBufLen, "ON");
    }
    else
    {
        usnprintf(pcBuf, iBufLen, "OFF");
    }

}
Exemplo n.º 12
0
void TimerAIntHandler(void) {
  minor_cycle_ctr++;
  
#if DEBUG
  char num[30];
  usnprintf(num, 30, "minor_cycle_ctr =  %d  ", minor_cycle_ctr);
  RIT128x96x4StringDraw(num, 0, 80, 15);
#endif
  
  TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
}
Exemplo n.º 13
0
void Handler2() {
	TimerIntClear(TIMER1_BASE, TIMER_TIMA_TIMEOUT);
	ADCProcessorTrigger(ADC_BASE, 0);
	while (!ADCIntStatus(ADC_BASE, 0, false));
	ADCSequenceDataGet(ADC_BASE, 0, &ADC_resultValue);


	pwm = ((double) 400 / 1024) * ADC_resultValue;
	usnprintf(buffer, BUFFSIZE, "ADC : %d\n", (int)ADC_resultValue);
	UARTPrint0((unsigned char *) buffer);

}
Exemplo n.º 14
0
void io_get_power(char * pcBuf, int iBufLen, char * heater, int size)
{
    uint8_t h_index = atoi(heater);
    uint8_t power = 0;

    if (h_index < 2)
    {
        power = triac_map[h_index].duty_cycle;
    }

    usnprintf(pcBuf, iBufLen, "%d", power);
}
Exemplo n.º 15
0
//*****************************************************************************
//
// This function allows dynamic text fields to be updated.
//
//*****************************************************************************
void
MenuUpdateText(uint32_t ui32TextID, const char *pcText)
{
    //
    // If the text field ID is valid, then update the string for that text
    // field.  The next time the associated widget is painted, the new text
    // will be shown.
    //
    if(ui32TextID < NUM_TEXT_ITEMS)
    {
        usnprintf(g_pcTextFields[ui32TextID], TEXT_FIELD_LENGTH, "%s", pcText);
    }
}
Exemplo n.º 16
0
BYTE js_is_connected(int dev) {
	uTCHAR path_dev[30];
	int fd;

	usnprintf(path_dev, usizeof(path_dev), uL("" JS_DEV_PATH "%d"), dev);

	if ((fd = uopen(path_dev, O_RDONLY | O_NONBLOCK)) < 0) {
		return (EXIT_ERROR);
	}

	close(fd);
	return (EXIT_OK);
}
Exemplo n.º 17
0
//*****************************************************************************
//
// Report to the user the amount of free space and used space in the data
// storage area.
//
//*****************************************************************************
void
FlashStoreReport(void)
{
    uint32_t ui32Addr, ui32FreeBlocks, ui32UsedBlocks = 0;
    static char pcBufFree[16], pcBufUsed[16];

    //
    // Initialize locals.
    //
    ui32FreeBlocks = 0;
    ui32UsedBlocks = 0;

    //
    // Loop through each block of the storage area and count how many blocks
    // are free and non-free.
    //
    for(ui32Addr = FLASH_STORE_START_ADDR; ui32Addr < FLASH_STORE_END_ADDR;
        ui32Addr += 0x400)
    {
        if(IsBlockFree(ui32Addr))
        {
            ui32FreeBlocks++;
        }
        else
        {
            ui32UsedBlocks++;
        }
    }

    //
    // Report the result to the user via a status display screen.
    //
    usnprintf(pcBufFree, sizeof(pcBufFree), "FREE: %3uK", ui32FreeBlocks);
    usnprintf(pcBufUsed, sizeof(pcBufUsed), "USED: %3uK", ui32UsedBlocks);
    SetStatusText("FREE FLASH", pcBufFree, pcBufUsed, "PRESS <");
}
Exemplo n.º 18
0
void js_init(void) {
	BYTE i;

	for (i = PORT1; i < PORT_MAX; i++) {
		memset(&js[i], 0x00, sizeof(_js));

		if (port[i].joy_id == name_to_jsn(uL("NULL"))) {
			continue;
		}

		usnprintf(js[i].dev, usizeof(js[i].dev), uL("" JS_DEV_PATH "%d"), port[i].joy_id);
		js[i].input_decode_event = input_decode_event[i];
		js_open(&js[i]);
	}
}
Exemplo n.º 19
0
//*****************************************************************************
//
// Encodes a string for use within an HTML tag, escaping non alphanumeric
// characters.
//
// \param pcDecoded is a pointer to a null terminated ASCII string.
// \param pcEncoded is a pointer to a storage for the encoded string.
// \param ulLen is the number of bytes of storage pointed to by pcEncoded.
//
// This function encodes a string, adding escapes in place of any special,
// non-alphanumeric characters.  If the encoded string is too long for the
// provided output buffer, the output will be truncated.
//
// \return Returns the number of characters written to the output buffer
// not including the terminating NULL.
//
//*****************************************************************************
unsigned long
EncodeFormString(const char *pcDecoded, char *pcEncoded,
                 unsigned long ulLen)
{
    unsigned long ulLoop;
    unsigned long ulCount;

    //
    // Make sure we were not passed a tiny buffer.
    //
    if(ulLen <= 1)
    {
        return(0);
    }

    //
    // Initialize our output character counter.
    //
    ulCount = 0;

    //
    // Step through each character of the input until we run out of data or
    // space to put our output in.
    //
    for(ulLoop = 0; pcDecoded[ulLoop] && (ulCount < (ulLen - 1)); ulLoop++)
    {
        switch(pcDecoded[ulLoop])
        {
            //
            // Pass most characters without modification.
            //
            default:
            {
                pcEncoded[ulCount++] = pcDecoded[ulLoop];
                break;
            }

            case '\'':
            {
                ulCount += usnprintf(&pcEncoded[ulCount], (ulLen - ulCount),
                                     "&#39;");
                break;
            }
        }
    }

    return(ulCount);
}
Exemplo n.º 20
0
//*****************************************************************************
//
//! Maps a path string containing mount point names to a path suitable for
//! use in calls to the FatFs APIs.
//!
//! \param pcPath points to a string containing a path in the namespace
//! defined by the mount information passed to fs_init().
//! \param pcMapped points to a buffer into which the mapped path string will
//! be written.
//! \param iLen is the size, in bytes, of the buffer pointed to by pcMapped.
//!
//! This function may be used by applications which want to make use of FatFs
//! functions which are not directly mapped by the fswrapper layer.  A path
//! in the namespace defined by the mount points passed to function fs_init()
//! is translated to an equivalent path in the FatFs namespace and this may
//! then be used in a direct call to functions such as f_opendir() or
//! f_getfree().
//!
//! \return Returns \b true on success or \b false if fs_init() has not
//! been called, if the path provided maps to an internal file system image
//! rather than a FatFs logical drive or if the buffer pointed to by
//! \e pcMapped is too small to fit the output string.
//
//*****************************************************************************
bool
fs_map_path(const char *pcPath, char *pcMapped, int iLen)
{
    char *pcFSFilename;
    uint32_t ui32MountIndex;
    int iCount;

    //
    // If no mount points have been defined, return an error.
    //
    if(!g_psMountPoints)
    {
        return(false);
    }

    //
    // Find which mount point we need to use to satisfy this file open request.
    //
    ui32MountIndex = fs_find_mount_index(pcPath, &pcFSFilename);

    //
    // If we got a bad mount index or the index returned represents a mount
    // point that is not in the FAT file system, return an error.
    //
    if((ui32MountIndex == BAD_MOUNT_INDEX) ||
       (g_psMountPoints[ui32MountIndex].pui8FSImage))
    {
        //
        // We can't map the mount index so return an error.
        //
        return(false);
    }

    //
    // Now we can generate the FatFs namespace path string.
    //
    iCount = usnprintf(pcMapped, iLen, "%d:%s",
                       g_psMountPoints[ui32MountIndex].ui32DriveNum,
                       pcFSFilename);

    //
    // Tell the user how we got on.  The count returned by usnprintf is the
    // number of characters that should have been written, excluding the
    // terminating NULL so we use this to check for overflow of the output
    // buffer.
    //
    return((iLen >= (iCount + 1)) ? true : false);
}
Exemplo n.º 21
0
uTCHAR *js_name_device(int dev) {
	static uTCHAR name[128];
	uTCHAR path_dev[30];
	int fd;

	umemset(name, 0x00, usizeof(name));

	usnprintf(path_dev, usizeof(path_dev), uL("" JS_DEV_PATH "%d"), dev);
	fd = uopen(path_dev, O_RDONLY | O_NONBLOCK);

	if (uioctl(fd, JSIOCGNAME(sizeof(name)), name) < 0) {
		ustrncpy(name, uL("Not connected"), usizeof(name));
	}

	close(fd);

	return((uTCHAR *) name);
}
Exemplo n.º 22
0
//*****************************************************************************
//
// Create a file name for the file to be saved on the memory stick.
// This function uses an incrementing numerical search scheme to determine
// an available file name.  It tries opening file names in succession until
// it finds a file that does not yet exist.
// The file name will be of the form LOGnnnn.CSV.
// The caller supplies storage for the file name through the pcFilename
// parameter.
// The function will return 0 if successful and non-zero if a file name could
// not be found.
//
//*****************************************************************************
static int32_t
CreateFileName(char *pcFilename, uint32_t ui32Len)
{
    FRESULT iFResult;
    uint32_t ui32FileNum = 0;

    //
    // Enter loop to search for available file name
    //
    do
    {
        //
        // Prepare a numerical based file name and attempt to open it
        //
        usnprintf(pcFilename, ui32Len, "LOG%04d.CSV", ui32FileNum);
        iFResult = f_open(&g_sFileObject, pcFilename, FA_OPEN_EXISTING);

        //
        // If file does not exist, then we have found a useable file name
        //
        if(iFResult == FR_NO_FILE)
        {
            //
            // Return to caller, indicating that a file name has been found.
            //
            return(0);
        }

        //
        // Otherwise, advance to the next number in the file name sequence.
        //
        ui32FileNum++;

    } while(ui32FileNum < 1000);

    //
    // If we reach this point, it means that no useable file name was found
    // after attempting 10000 file names.
    //
    return(1);
}
Exemplo n.º 23
0
//*****************************************************************************
//
// Update the countdown text on the display prior to starting a new game.
//
//*****************************************************************************
void
UpdateCountdown(unsigned long ulCountdown)
{
    short sX, sY;
    char pcCountdown[4];

    //
    // Determine the position for the countdown text.
    //
    sX = GAME_AREA_LEFT + (GAME_AREA_WIDTH / 2);
    sY = GAME_AREA_TOP + 70;

    //
    // Render the countdown string.
    //
    usnprintf(pcCountdown, 4, " %d ", ulCountdown);

    //
    // Display it on the screen.
    //
    CenteredStringWithShadow(g_pFontCmss32b, pcCountdown, sX, sY, true);
}
Exemplo n.º 24
0
static void
get_tag_insert(struct http_state *hs)
{
  int loop;

  if(g_pfnSSIHandler && g_ppcTags && g_iNumTags) {

    /* Find this tag in the list we have been provided. */
    for(loop = 0; loop < g_iNumTags; loop++)
    {
#if USER_PROVIDES_ZERO_COPY_STATIC_TAGS
        if(strcmp(hs->tag_name, g_ppcTags[loop].pcCGIName) == 0) {
          hs->tag_insert_len = g_pfnSSIHandler(loop, 0, NULL, NULL,
        		  &(hs->tag_insert));
          return;
        }
#else
        if(strcmp(hs->tag_name, g_ppcTags[loop]) == 0) {
          hs->tag_insert_len = g_pfnSSIHandler(loop, hs->tag_insert,
                                             MAX_TAG_INSERT_LEN);
          return;
        }
#endif
    }
  }

  /* If we drop out, we were asked to serve a page which contains tags that
   * we don't have a handler for. Merely echo back the tags with an error
   * marker.
   */
#if USER_PROVIDES_ZERO_COPY_STATIC_TAGS
  hs->tag_insert = "<b>***UNKNOWN TAG***</b>";
#else
  usnprintf(hs->tag_insert, (MAX_TAG_INSERT_LEN + 1),
           "<b>***UNKNOWN TAG %s***</b>", hs->tag_name);
#endif
  hs->tag_insert_len = strlen(hs->tag_insert);
}
Exemplo n.º 25
0
//*****************************************************************************
//
// Update the high score if necessary then repaint the display to show the
// "Game Over" information.
//
//*****************************************************************************
void
GameOver(int iLastScore)
{
    //
    // See if the high score needs to be updated.
    //
    g_bNewHighScore = (iLastScore > g_iHighScore) ? true : false;
    g_iHighScore = g_bNewHighScore ? iLastScore : g_iHighScore;

    //
    // Update the score if necessary.
    //
    if (iLastScore != g_iCurScore)
    {
        usnprintf(g_pcScore, MAX_SCORE_LEN, "  %d  ", iLastScore);
        WidgetPaint((tWidget *)&g_sScore);
        g_iCurScore = iLastScore;
    }

    //
    // Update the display.
    //
    WidgetPaint((tWidget *)&g_sStoppedCanvas);
}
Exemplo n.º 26
0
//*****************************************************************************
//
// This is the main application entry function.
//
//*****************************************************************************
int
main(void)
{
    uint_fast32_t ui32TxCount;
    uint_fast32_t ui32RxCount;
    tRectangle sRect;
    char pcBuffer[16];

    //
    // Enable lazy stacking for interrupt handlers.  This allows floating-point
    // instructions to be used within interrupt handlers, but at the expense of
    // extra stack usage.
    //
    ROM_FPULazyStackingEnable();

    //
    // Set the clocking to run from the PLL at 50MHz
    //
    ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
                       SYSCTL_XTAL_16MHZ);

#ifdef DEBUG
    //
    // Configure the UART for debug output.
    //
    ConfigureUART();
#endif

    //
    // Not configured initially.
    //
    g_bUSBConfigured = false;

    //
    // Initialize the display driver.
    //
    CFAL96x64x16Init();

    //
    // Initialize the graphics context.
    //
    GrContextInit(&g_sContext, &g_sCFAL96x64x16);

    //
    // Fill the top part of the screen with blue to create the banner.
    //
    sRect.i16XMin = 0;
    sRect.i16YMin = 0;
    sRect.i16XMax = GrContextDpyWidthGet(&g_sContext) - 1;
    sRect.i16YMax = 9;
    GrContextForegroundSet(&g_sContext, ClrDarkBlue);
    GrRectFill(&g_sContext, &sRect);

    //
    // Change foreground for white text.
    //
    GrContextForegroundSet(&g_sContext, ClrWhite);

    //
    // Put the application name in the middle of the banner.
    //
    GrContextFontSet(&g_sContext, g_psFontFixed6x8);
    GrStringDrawCentered(&g_sContext, "usb-dev-bulk", -1,
                         GrContextDpyWidthGet(&g_sContext) / 2, 4, 0);

    //
    // Show the various static text elements on the color STN display.
    //
    GrStringDraw(&g_sContext, "Tx bytes:", -1, 0, 32, false);
    GrStringDraw(&g_sContext, "Rx bytes:", -1, 0, 42, false);

    //
    // Enable the GPIO peripheral used for USB, and configure the USB
    // pins.
    //
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOL);
    ROM_GPIOPinTypeUSBAnalog(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1);
    ROM_GPIOPinTypeUSBAnalog(GPIO_PORTL_BASE, GPIO_PIN_6 | GPIO_PIN_7);

    //
    // Enable the system tick.
    //
    ROM_SysTickPeriodSet(ROM_SysCtlClockGet() / SYSTICKS_PER_SECOND);
    ROM_SysTickIntEnable();
    ROM_SysTickEnable();

    //
    // Show the application name on the display and UART output.
    //
    DEBUG_PRINT("\nTiva C Series USB bulk device example\n");
    DEBUG_PRINT("---------------------------------\n\n");

    //
    // Tell the user what we are up to.
    //
    DisplayStatus(&g_sContext, "Configuring USB");

    //
    // Initialize the transmit and receive buffers.
    //
    USBBufferInit(&g_sTxBuffer);
    USBBufferInit(&g_sRxBuffer);

    //
    // Pass our device information to the USB library and place the device
    // on the bus.
    //
    USBDBulkInit(0, &g_sBulkDevice);

    //
    // Wait for initial configuration to complete.
    //
    DisplayStatus(&g_sContext, "Waiting for host");

    //
    // Clear our local byte counters.
    //
    ui32RxCount = 0;
    ui32TxCount = 0;

    //
    // Main application loop.
    //
    while(1)
    {

        //
        // Have we been asked to update the status display?
        //
        if(g_ui32Flags & COMMAND_STATUS_UPDATE)
        {
            //
            // Clear the command flag
            //
            g_ui32Flags &= ~COMMAND_STATUS_UPDATE;
            DisplayStatus(&g_sContext, g_pcStatus);
        }

        //
        // Has there been any transmit traffic since we last checked?
        //
        if(ui32TxCount != g_ui32TxCount)
        {
            //
            // Take a snapshot of the latest transmit count.
            //
            ui32TxCount = g_ui32TxCount;

            //
            // Update the display of bytes transmitted by the UART.
            //
            usnprintf(pcBuffer, 16, " %d ", ui32TxCount);
            GrStringDraw(&g_sContext, pcBuffer, -1, 48, 32, true);
        }

        //
        // Has there been any receive traffic since we last checked?
        //
        if(ui32RxCount != g_ui32RxCount)
        {
            //
            // Take a snapshot of the latest receive count.
            //
            ui32RxCount = g_ui32RxCount;

            //
            // Update the display of bytes received by the UART.
            //
            usnprintf(pcBuffer, 16, " %d ", ui32RxCount);
            GrStringDraw(&g_sContext, pcBuffer, -1, 48, 42, true);
        }
    }
}
Exemplo n.º 27
0
//*****************************************************************************
//
// This is the main application entry function.
//
//*****************************************************************************
int
main(void)
{
    uint32_t ui32TxCount;
    uint32_t ui32RxCount;
    tRectangle sRect;
    char pcBuffer[16];
    uint32_t ui32Fullness;

    //
    // Enable lazy stacking for interrupt handlers.  This allows floating-point
    // instructions to be used within interrupt handlers, but at the expense of
    // extra stack usage.
    //
    ROM_FPULazyStackingEnable();

    //
    // Set the clocking to run from the PLL at 50MHz
    //
    ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
                       SYSCTL_XTAL_16MHZ);

    //
    // Configure the required pins for USB operation.
    //
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
    ROM_GPIOPinConfigure(GPIO_PG4_USB0EPEN);
    ROM_GPIOPinTypeUSBDigital(GPIO_PORTG_BASE, GPIO_PIN_4);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOL);
    ROM_GPIOPinTypeUSBAnalog(GPIO_PORTL_BASE, GPIO_PIN_6 | GPIO_PIN_7);
    ROM_GPIOPinTypeUSBAnalog(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1);

    //
    // Erratum workaround for silicon revision A1.  VBUS must have pull-down.
    //
    if(CLASS_IS_BLIZZARD && REVISION_IS_A1)
    {
        HWREG(GPIO_PORTB_BASE + GPIO_O_PDR) |= GPIO_PIN_1;
    }

    //
    // Not configured initially.
    //
    g_bUSBConfigured = false;

    //
    // Initialize the display driver.
    //
    CFAL96x64x16Init();

    //
    // Initialize the graphics context.
    //
    GrContextInit(&g_sContext, &g_sCFAL96x64x16);

    //
    // Fill the top 15 rows of the screen with blue to create the banner.
    //
    sRect.i16XMin = 0;
    sRect.i16YMin = 0;
    sRect.i16XMax = GrContextDpyWidthGet(&g_sContext) - 1;
    sRect.i16YMax = 9;
    GrContextForegroundSet(&g_sContext, ClrDarkBlue);
    GrRectFill(&g_sContext, &sRect);

    //
    // Put a white box around the banner.
    //
    GrContextForegroundSet(&g_sContext, ClrWhite);
    GrRectDraw(&g_sContext, &sRect);

    //
    // Put the application name in the middle of the banner.
    //
    GrContextFontSet(&g_sContext, g_psFontFixed6x8);
    GrStringDrawCentered(&g_sContext, "usb-dev-serial", -1,
                         GrContextDpyWidthGet(&g_sContext) / 2, 4, 0);

    //
    // Show the various static text elements on the color STN display.
    //
    GrStringDraw(&g_sContext, "Tx #",-1, 0, 12, false);
    GrStringDraw(&g_sContext, "Tx buf", -1, 0, 22, false);
    GrStringDraw(&g_sContext, "Rx #", -1, 0, 32, false);
    GrStringDraw(&g_sContext, "Rx buf", -1, 0, 42, false);
    DrawBufferMeter(&g_sContext, 40, 22);
    DrawBufferMeter(&g_sContext, 40, 42);

    //
    // Enable the UART that we will be redirecting.
    //
    ROM_SysCtlPeripheralEnable(USB_UART_PERIPH);

    //
    // Enable and configure the UART RX and TX pins
    //
    ROM_SysCtlPeripheralEnable(TX_GPIO_PERIPH);
    ROM_SysCtlPeripheralEnable(RX_GPIO_PERIPH);
    ROM_GPIOPinTypeUART(TX_GPIO_BASE, TX_GPIO_PIN);
    ROM_GPIOPinTypeUART(RX_GPIO_BASE, RX_GPIO_PIN);

    //
    // TODO: Add code to configure handshake GPIOs if required.
    //

    //
    // Set the default UART configuration.
    //
    ROM_UARTConfigSetExpClk(USB_UART_BASE, ROM_SysCtlClockGet(),
                            DEFAULT_BIT_RATE, DEFAULT_UART_CONFIG);
    ROM_UARTFIFOLevelSet(USB_UART_BASE, UART_FIFO_TX4_8, UART_FIFO_RX4_8);

    //
    // Configure and enable UART interrupts.
    //
    ROM_UARTIntClear(USB_UART_BASE, ROM_UARTIntStatus(USB_UART_BASE, false));
    ROM_UARTIntEnable(USB_UART_BASE, (UART_INT_OE | UART_INT_BE | UART_INT_PE |
                      UART_INT_FE | UART_INT_RT | UART_INT_TX | UART_INT_RX));

    //
    // Enable the system tick.
    //
    ROM_SysTickPeriodSet(ROM_SysCtlClockGet() / SYSTICKS_PER_SECOND);
    ROM_SysTickIntEnable();
    ROM_SysTickEnable();

    //
    // Tell the user what we are up to.
    //
    DisplayStatus(&g_sContext, " Configuring... ");

    //
    // Initialize the transmit and receive buffers.
    //
    USBBufferInit(&g_sTxBuffer);
    USBBufferInit(&g_sRxBuffer);

    //
    // Set the USB stack mode to Device mode with VBUS monitoring.
    //
    USBStackModeSet(0, eUSBModeDevice, 0);

    //
    // Pass our device information to the USB library and place the device
    // on the bus.
    //
    USBDCDCInit(0, &g_sCDCDevice);

    //
    // Wait for initial configuration to complete.
    //
    DisplayStatus(&g_sContext, "Waiting for host");

    //
    // Clear our local byte counters.
    //
    ui32RxCount = 0;
    ui32TxCount = 0;

    //
    // Enable interrupts now that the application is ready to start.
    //
    ROM_IntEnable(USB_UART_INT);

    //
    // Main application loop.
    //
    while(1)
    {

        //
        // Have we been asked to update the status display?
        //
        if(g_ui32Flags & COMMAND_STATUS_UPDATE)
        {
            //
            // Clear the command flag
            //
            ROM_IntMasterDisable();
            g_ui32Flags &= ~COMMAND_STATUS_UPDATE;
            ROM_IntMasterEnable();

            DisplayStatus(&g_sContext, g_pcStatus);
        }

        //
        // Has there been any transmit traffic since we last checked?
        //
        if(ui32TxCount != g_ui32UARTTxCount)
        {
            //
            // Take a snapshot of the latest transmit count.
            //
            ui32TxCount = g_ui32UARTTxCount;

            //
            // Update the display of bytes transmitted by the UART.
            //
            usnprintf(pcBuffer, 16, "%d ", ui32TxCount);
            GrStringDraw(&g_sContext, pcBuffer, -1, 40, 12, true);

            //
            // Update the RX buffer fullness. Remember that the buffers are
            // named relative to the USB whereas the status display is from
            // the UART's perspective. The USB's receive buffer is the UART's
            // transmit buffer.
            //
            ui32Fullness = ((USBBufferDataAvailable(&g_sRxBuffer) * 100) /
                          UART_BUFFER_SIZE);

            UpdateBufferMeter(&g_sContext, ui32Fullness, 40, 22);
        }

        //
        // Has there been any receive traffic since we last checked?
        //
        if(ui32RxCount != g_ui32UARTRxCount)
        {
            //
            // Take a snapshot of the latest receive count.
            //
            ui32RxCount = g_ui32UARTRxCount;

            //
            // Update the display of bytes received by the UART.
            //
            usnprintf(pcBuffer, 16, "%d ", ui32RxCount);
            GrStringDraw(&g_sContext, pcBuffer, -1, 40, 32, true);

            //
            // Update the TX buffer fullness. Remember that the buffers are
            // named relative to the USB whereas the status display is from
            // the UART's perspective. The USB's transmit buffer is the UART's
            // receive buffer.
            //
            ui32Fullness = ((USBBufferDataAvailable(&g_sTxBuffer) * 100) /
                          UART_BUFFER_SIZE);

            UpdateBufferMeter(&g_sContext, ui32Fullness, 40, 42);
        }
    }
}
//*****************************************************************************
//
// This is the main application entry function.
//
//*****************************************************************************
int
main(void)
{
    uint32_t ui32TxCount, ui32RxCount, ui32Fullness, ui32SysClock, ui32PLLRate;
    tRectangle sRect;
    char pcBuffer[16];
#ifdef USE_ULPI
    uint32_t ui32Setting;
#endif

    //
    // Set the system clock to run at 120MHz from the PLL.
    //
    ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
                                           SYSCTL_OSC_MAIN | SYSCTL_USE_PLL |
                                           SYSCTL_CFG_VCO_480), 120000000);

    //
    // Configure the device pins.
    //
    PinoutSet();

#ifdef USE_ULPI
    //
    // Switch the USB ULPI Pins over.
    //
    USBULPIPinoutSet();

    //
    // Enable USB ULPI with high speed support.
    //
    ui32Setting = USBLIB_FEATURE_ULPI_HS;
    USBOTGFeatureSet(0, USBLIB_FEATURE_USBULPI, &ui32Setting);

    //
    // Setting the PLL frequency to zero tells the USB library to use the
    // external USB clock.
    //
    ui32PLLRate = 0;
#else
    //
    // Save the PLL rate used by this application.
    //
    ui32PLLRate = 480000000;
#endif

    //
    // Enable the system tick.
    //
    ROM_SysTickPeriodSet(ui32SysClock / TICKS_PER_SECOND);
    ROM_SysTickIntEnable();
    ROM_SysTickEnable();

    //
    // Not configured initially.
    //
    g_ui32Flags = 0;

    //
    // Initialize the display driver.
    //
    Kentec320x240x16_SSD2119Init(ui32SysClock);

    //
    // Initialize the graphics context.
    //
    GrContextInit(&g_sContext, &g_sKentec320x240x16_SSD2119);

    //
    // Draw the application frame.
    //
    FrameDraw(&g_sContext, "usb-dev-serial");

    //
    // Fill the top 15 rows of the screen with blue to create the banner.
    //
    sRect.i16XMin = 0;
    sRect.i16YMin = 0;
    sRect.i16XMax = GrContextDpyWidthGet(&g_sContext) - 1;
    sRect.i16YMax = 23;
    GrContextForegroundSet(&g_sContext, ClrDarkBlue);
    GrRectFill(&g_sContext, &sRect);

    //
    // Put a white box around the banner.
    //
    GrContextForegroundSet(&g_sContext, ClrWhite);
    GrRectDraw(&g_sContext, &sRect);

    //
    // Show the various static text elements on the color STN display.
    //
    GrContextFontSet(&g_sContext, TEXT_FONT);
    GrStringDraw(&g_sContext, "Tx bytes:", -1, 8, 80, false);
    GrStringDraw(&g_sContext, "Tx buffer:", -1, 8, 105, false);
    GrStringDraw(&g_sContext, "Rx bytes:", -1, 8, 160, false);
    GrStringDraw(&g_sContext, "Rx buffer:", -1, 8, 185, false);
    DrawBufferMeter(&g_sContext, 150, 105);
    DrawBufferMeter(&g_sContext, 150, 185);

    //
    // Enable the UART that we will be redirecting.
    //
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);

    //
    // Change the UART clock to the 16 MHz PIOSC.
    //
    UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC);

    //
    // Set the default UART configuration.
    //
    ROM_UARTConfigSetExpClk(UART0_BASE, UART_CLOCK,
                            DEFAULT_BIT_RATE, DEFAULT_UART_CONFIG);
    ROM_UARTFIFOLevelSet(UART0_BASE, UART_FIFO_TX4_8, UART_FIFO_RX4_8);

    //
    // Configure and enable UART interrupts.
    //
    ROM_UARTIntClear(UART0_BASE, ROM_UARTIntStatus(UART0_BASE, false));
    ROM_UARTIntEnable(UART0_BASE, (UART_INT_OE | UART_INT_BE | UART_INT_PE |
                      UART_INT_FE | UART_INT_RT | UART_INT_TX | UART_INT_RX));

    //
    // Tell the user what we are up to.
    //
    DisplayStatus(&g_sContext, " Configuring USB... ");

    //
    // Initialize the transmit and receive buffers.
    //
    USBBufferInit(&g_sTxBuffer);
    USBBufferInit(&g_sRxBuffer);

    //
    // Set the USB stack mode to Device mode with VBUS monitoring.
    //
    USBStackModeSet(0, eUSBModeDevice, 0);

    //
    // Tell the USB library the CPU clock and the PLL frequency.  This is a
    // new requirement for TM4C129 devices.
    //
    USBDCDFeatureSet(0, USBLIB_FEATURE_CPUCLK, &ui32SysClock);
    USBDCDFeatureSet(0, USBLIB_FEATURE_USBPLL, &ui32PLLRate);

    //
    // Pass our device information to the USB library and place the device
    // on the bus.
    //
    USBDCDCInit(0, (tUSBDCDCDevice *)&g_sCDCDevice);

    //
    // Wait for initial configuration to complete.
    //
    DisplayStatus(&g_sContext, " Waiting for host... ");

    //
    // Clear our local byte counters.
    //
    ui32RxCount = 0;
    ui32TxCount = 0;
    g_ui32UARTTxCount = 0;
    g_ui32UARTRxCount = 0;
#ifdef DEBUG
    g_ui32UARTRxErrors = 0;
#endif

    //
    // Enable interrupts now that the application is ready to start.
    //
    ROM_IntEnable(INT_UART0);

    //
    // Main application loop.
    //
    while(1)
    {
        //
        // Have we been asked to update the status display?
        //
        if(HWREGBITW(&g_ui32Flags, FLAG_STATUS_UPDATE))
        {
            //
            // Clear the command flag
            //
            HWREGBITW(&g_ui32Flags, FLAG_STATUS_UPDATE) = 0;

            DisplayStatus(&g_sContext, g_pcStatus);
        }

        //
        // Has there been any transmit traffic since we last checked?
        //
        if(ui32TxCount != g_ui32UARTTxCount)
        {
            //
            // Take a snapshot of the latest transmit count.
            //
            ui32TxCount = g_ui32UARTTxCount;

            //
            // Update the display of bytes transmitted by the UART.
            //
            usnprintf(pcBuffer, 16, "%d ", ui32TxCount);
            GrStringDraw(&g_sContext, pcBuffer, -1, 150, 80, true);

            //
            // Update the RX buffer fullness. Remember that the buffers are
            // named relative to the USB whereas the status display is from
            // the UART's perspective. The USB's receive buffer is the UART's
            // transmit buffer.
            //
            ui32Fullness = ((USBBufferDataAvailable(&g_sRxBuffer) * 100) /
                          UART_BUFFER_SIZE);

            UpdateBufferMeter(&g_sContext, ui32Fullness, 150, 105);
        }

        //
        // Has there been any receive traffic since we last checked?
        //
        if(ui32RxCount != g_ui32UARTRxCount)
        {
            //
            // Take a snapshot of the latest receive count.
            //
            ui32RxCount = g_ui32UARTRxCount;

            //
            // Update the display of bytes received by the UART.
            //
            usnprintf(pcBuffer, 16, "%d ", ui32RxCount);
            GrStringDraw(&g_sContext, pcBuffer, -1, 150, 160, true);

            //
            // Update the TX buffer fullness. Remember that the buffers are
            // named relative to the USB whereas the status display is from
            // the UART's perspective. The USB's transmit buffer is the UART's
            // receive buffer.
            //
            ui32Fullness = ((USBBufferDataAvailable(&g_sTxBuffer) * 100) /
                          UART_BUFFER_SIZE);

            UpdateBufferMeter(&g_sContext, ui32Fullness, 150, 185);
        }
    }
}
Exemplo n.º 29
0
//*****************************************************************************
//
// Get the current animation speed as an ASCII string.
//
//*****************************************************************************
void
io_get_animation_speed_string(char *pcBuf, int iBufLen)
{
    usnprintf(pcBuf, iBufLen, "%d%%", g_ulAnimSpeed);
}
Exemplo n.º 30
0
//*****************************************************************************
//
// This is the main application entry function.
//
//*****************************************************************************
int
main(void)
{
    unsigned long ulTxCount;
    unsigned long ulRxCount;
    tRectangle sRect;
    char pcBuffer[16];

    //
    // Set the clocking to run from the PLL at 50MHz
    //
    ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
                       SYSCTL_XTAL_8MHZ);

#ifdef DEBUG
    //
    // Configure the relevant pins such that UART0 owns them.
    //
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);

    //
    // Open UART0 for debug output.
    //
    UARTStdioInit(0);
#endif

    //
    // Not configured initially.
    //
    g_bUSBConfigured = false;

    //
    // Initialize the display driver.
    //
    Formike128x128x16Init();

    //
    // Turn on the backlight.
    //
    Formike128x128x16BacklightOn();

    //
    // Initialize the graphics context.
    //
    GrContextInit(&g_sContext, &g_sFormike128x128x16);

    //
    // Fill the top 15 rows of the screen with blue to create the banner.
    //
    sRect.sXMin = 0;
    sRect.sYMin = 0;
    sRect.sXMax = GrContextDpyWidthGet(&g_sContext) - 1;
    sRect.sYMax = 14;
    GrContextForegroundSet(&g_sContext, ClrDarkBlue);
    GrRectFill(&g_sContext, &sRect);

    //
    // Put a white box around the banner.
    //
    GrContextForegroundSet(&g_sContext, ClrWhite);
    GrRectDraw(&g_sContext, &sRect);

    //
    // Put the application name in the middle of the banner.
    //
    GrContextFontSet(&g_sContext, g_pFontFixed6x8);
    GrStringDrawCentered(&g_sContext, "usb_dev_bulk", -1,
                         GrContextDpyWidthGet(&g_sContext) / 2, 7, 0);

    //
    // Show the various static text elements on the color STN display.
    //
    GrContextFontSet(&g_sContext, TEXT_FONT);
    GrStringDraw(&g_sContext, "Tx bytes:", -1, 8, 70, false);
    GrStringDraw(&g_sContext, "Rx bytes:", -1, 8, 90, false);

    //
    // Configure the USB mux on the board to put us in device mode.  We pull
    // the relevant pin high to do this.
    //
    ROM_SysCtlPeripheralEnable(USB_MUX_GPIO_PERIPH);
    ROM_GPIOPinTypeGPIOOutput(USB_MUX_GPIO_BASE, USB_MUX_GPIO_PIN);
    ROM_GPIOPinWrite(USB_MUX_GPIO_BASE, USB_MUX_GPIO_PIN, USB_MUX_SEL_DEVICE);

    //
    // Enable the system tick.
    //
    ROM_SysTickPeriodSet(SysCtlClockGet() / SYSTICKS_PER_SECOND);
    ROM_SysTickIntEnable();
    ROM_SysTickEnable();

    //
    // Show the application name on the display and UART output.
    //
    DEBUG_PRINT("\nStellaris USB bulk device example\n");
    DEBUG_PRINT("---------------------------------\n\n");

    //
    // Tell the user what we are up to.
    //
    DisplayStatus(&g_sContext, "Configuring USB...");

    //
    // Initialize the transmit and receive buffers.
    //
    USBBufferInit((tUSBBuffer *)&g_sTxBuffer);
    USBBufferInit((tUSBBuffer *)&g_sRxBuffer);

    //
    // Pass our device information to the USB library and place the device
    // on the bus.
    //
    USBDBulkInit(0, (tUSBDBulkDevice *)&g_sBulkDevice);

    //
    // Wait for initial configuration to complete.
    //
    DisplayStatus(&g_sContext, "Waiting for host...");

    //
    // Clear our local byte counters.
    //
    ulRxCount = 0;
    ulTxCount = 0;

    //
    // Main application loop.
    //
    while(1)
    {

        //
        // Have we been asked to update the status display?
        //
        if(g_ulFlags & COMMAND_STATUS_UPDATE)
        {
            //
            // Clear the command flag
            //
            g_ulFlags &= ~COMMAND_STATUS_UPDATE;
            DisplayStatus(&g_sContext, g_pcStatus);
        }

        //
        // Has there been any transmit traffic since we last checked?
        //
        if(ulTxCount != g_ulTxCount)
        {
            //
            // Take a snapshot of the latest transmit count.
            //
            ulTxCount = g_ulTxCount;

            //
            // Update the display of bytes transmitted by the UART.
            //
            usnprintf(pcBuffer, 16, "%d", ulTxCount);
            GrStringDraw(&g_sContext, pcBuffer, -1, 70, 70, true);
        }

        //
        // Has there been any receive traffic since we last checked?
        //
        if(ulRxCount != g_ulRxCount)
        {
            //
            // Take a snapshot of the latest receive count.
            //
            ulRxCount = g_ulRxCount;

            //
            // Update the display of bytes received by the UART.
            //
            usnprintf(pcBuffer, 16, "%d", ulRxCount);
            GrStringDraw(&g_sContext, pcBuffer, -1, 70, 90, true);
        }
    }
}