void confSys(){ // // Set the clocking to run at 40 MHz from the PLL. // ROM_SysCtlClockSet(SYSCTL_SYSDIV_5 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN); //Ponermos el reloj principal a 40 MHz (200 Mhz del Pll dividido por 5) // Get the system clock speed. g_ulSystemClock = SysCtlClockGet(); //Habilita el clock gating de los perifericos durante el bajo consumo --> perifericos que se desee activos en modo Sleep // deben habilitarse con SysCtlPeripheralSleepEnable ROM_SysCtlPeripheralClockGating(true); // Inicializa el subsistema de medida del uso de CPU (mide el tiempo que la CPU no esta dormida) // Para eso utiliza un timer, que aqui hemos puesto que sea el TIMER3 (ultimo parametro que se pasa a la funcion) // (y por tanto este no se deberia utilizar para otra cosa). CPUUsageInit(g_ulSystemClock, configTICK_RATE_HZ/10, 3); }
//***************************************************************************** // // This example demonstrates how to use the uDMA controller to transfer data // between memory buffers and to and from a peripheral, in this case a UART. // The uDMA controller is configured to repeatedly transfer a block of data // from one memory buffer to another. It is also set up to repeatedly copy a // block of data from a buffer to the UART output. The UART data is looped // back so the same data is received, and the uDMA controlled is configured to // continuously receive the UART data using ping-pong buffers. // // The processor is put to sleep when it is not doing anything, and this allows // collection of CPU usage data to see how much CPU is being used while the // data transfers are ongoing. // //***************************************************************************** int main(void) { static unsigned long ulPrevSeconds; static unsigned long ulPrevXferCount; static unsigned long ulPrevUARTCount = 0; static char cStrBuf[40]; tRectangle sRect; unsigned long ulCenterX; unsigned long ulXfersCompleted; unsigned long ulBytesTransferred; // // Set the clocking to run from the PLL at 50 MHz. // ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); // // Set the device pinout appropriately for this board. // PinoutSet(); // // Enable peripherals to operate when CPU is in sleep. // ROM_SysCtlPeripheralClockGating(true); // // Initialize the display driver. // Kitronix320x240x16_SSD2119Init(); // // Initialize the graphics context and find the middle X coordinate. // GrContextInit(&g_sContext, &g_sKitronix320x240x16_SSD2119); // // Get the center X coordinate of the screen, since it is used a lot. // ulCenterX = GrContextDpyWidthGet(&g_sContext) / 2; // // 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 = 23; 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_pFontCm20); GrStringDrawCentered(&g_sContext, "udma-demo", -1, ulCenterX, 11, 0); // // Show the clock frequency on the display. // GrContextFontSet(&g_sContext, g_pFontCmss18b); usnprintf(cStrBuf, sizeof(cStrBuf), "Stellaris @ %u MHz", SysCtlClockGet() / 1000000); GrStringDrawCentered(&g_sContext, cStrBuf, -1, ulCenterX, 40, 0); // // Show static text and field labels on the display. // GrStringDrawCentered(&g_sContext, "uDMA Mem Transfers", -1, ulCenterX, 62, 0); GrStringDrawCentered(&g_sContext, "uDMA UART Transfers", -1, ulCenterX, 84, 0); // // Configure SysTick to occur 100 times per second, to use as a time // reference. Enable SysTick to generate interrupts. // ROM_SysTickPeriodSet(ROM_SysCtlClockGet() / SYSTICKS_PER_SECOND); ROM_SysTickIntEnable(); ROM_SysTickEnable(); // // Initialize the CPU usage measurement routine. // CPUUsageInit(SysCtlClockGet(), SYSTICKS_PER_SECOND, 2); // // Enable the uDMA controller at the system level. Enable it to continue // to run while the processor is in sleep. // ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UDMA); ROM_SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_UDMA); // // Enable the uDMA controller error interrupt. This interrupt will occur // if there is a bus error during a transfer. // ROM_IntEnable(INT_UDMAERR); // // Enable the uDMA controller. // ROM_uDMAEnable(); // // Point at the control table to use for channel control structures. // ROM_uDMAControlBaseSet(ucControlTable); // // Initialize the uDMA memory to memory transfers. // InitSWTransfer(); // // Initialize the uDMA UART transfers. // InitUART0Transfer(); // // Remember the current SysTick seconds count. // ulPrevSeconds = g_ulSeconds; // // Remember the current count of memory buffer transfers. // ulPrevXferCount = g_ulMemXferCount; // // Loop until the button is pressed. The processor is put to sleep // in this loop so that CPU utilization can be measured. // while(1) { // // Check to see if one second has elapsed. If so, the make some // updates. // if(g_ulSeconds != ulPrevSeconds) { // // Print a message to the display showing the CPU usage percent. // The fractional part of the percent value is ignored. // usnprintf(cStrBuf, sizeof(cStrBuf), "CPU utilization %2u%%", g_ulCPUUsage >> 16); GrStringDrawCentered(&g_sContext, cStrBuf, -1, ulCenterX, 160, 1); // // Tell the user how many seconds we have to go before ending. // usnprintf(cStrBuf, sizeof(cStrBuf), " Test ends in %d seconds ", 10 - g_ulSeconds); GrStringDrawCentered(&g_sContext, cStrBuf, -1, ulCenterX, 120, 1); // // Remember the new seconds count. // ulPrevSeconds = g_ulSeconds; // // Calculate how many memory transfers have occurred since the last // second. // ulXfersCompleted = g_ulMemXferCount - ulPrevXferCount; // // Remember the new transfer count. // ulPrevXferCount = g_ulMemXferCount; // // Compute how many bytes were transferred in the memory transfer // since the last second. // ulBytesTransferred = ulXfersCompleted * MEM_BUFFER_SIZE * 4; // // Print a message to the display showing the memory transfer rate. // usnprintf(cStrBuf, sizeof(cStrBuf), " %8u Bytes/Sec ", ulBytesTransferred); GrStringDrawCentered(&g_sContext, cStrBuf, -1, ulCenterX, 182, 1); // // Calculate how many UART transfers have occurred since the last // second. // ulXfersCompleted = (g_ulRxBufACount + g_ulRxBufBCount - ulPrevUARTCount); // // Remember the new UART transfer count. // ulPrevUARTCount = g_ulRxBufACount + g_ulRxBufBCount; // // Compute how many bytes were transferred by the UART. The number // of bytes received is multiplied by 2 so that the TX bytes // transferred are also accounted for. // ulBytesTransferred = ulXfersCompleted * UART_RXBUF_SIZE * 2; // // Print a message to the display showing the UART transfer rate. // usnprintf(cStrBuf, sizeof(cStrBuf), " %8u Bytes/Sec ", ulBytesTransferred); GrStringDrawCentered(&g_sContext, cStrBuf, -1, ulCenterX, 204, 1); } // // Put the processor to sleep if there is nothing to do. This allows // the CPU usage routine to measure the number of free CPU cycles. // If the processor is sleeping a lot, it can be hard to connect to // the target with the debugger. // SysCtlSleep(); // // See if we have run long enough and exit the loop if so. // if(g_ulSeconds >= 10) { break; } }
//***************************************************************************** // // This example demonstrates how to use the uDMA controller to transfer data // between memory buffers and to and from a peripheral, in this case a UART. // The uDMA controller is configured to repeatedly transfer a block of data // from one memory buffer to another. It is also set up to repeatedly copy a // block of data from a buffer to the UART output. The UART data is looped // back so the same data is received, and the uDMA controlled is configured to // continuously receive the UART data using ping-pong buffers. // // The processor is put to sleep when it is not doing anything, and this allows // collection of CPU usage data to see how much CPU is being used while the // data transfers are ongoing. // //***************************************************************************** int main(void) { static uint32_t ui32PrevSeconds; static uint32_t ui32PrevXferCount; static uint32_t ui32PrevUARTCount = 0; uint32_t ui32XfersCompleted; uint32_t ui32BytesTransferred; // // 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 50 MHz. // ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); // // Enable peripherals to operate when CPU is in sleep. // ROM_SysCtlPeripheralClockGating(true); // // Enable the GPIO port that is used for the on-board LED. // ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); // // Enable the GPIO pins for the LED (PF2). // ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2); // // Initialize the UART. // ConfigureUART(); UARTprintf("\033[2JuDMA Example\n"); // // Show the clock frequency on the display. // UARTprintf("Tiva C Series @ %u MHz\n\n", ROM_SysCtlClockGet() / 1000000); // // Show statistics headings. // UARTprintf("CPU Memory UART Remaining\n"); UARTprintf("Usage Transfers Transfers Time\n"); // // Configure SysTick to occur 100 times per second, to use as a time // reference. Enable SysTick to generate interrupts. // ROM_SysTickPeriodSet(ROM_SysCtlClockGet() / SYSTICKS_PER_SECOND); ROM_SysTickIntEnable(); ROM_SysTickEnable(); // // Initialize the CPU usage measurement routine. // CPUUsageInit(ROM_SysCtlClockGet(), SYSTICKS_PER_SECOND, 2); // // Enable the uDMA controller at the system level. Enable it to continue // to run while the processor is in sleep. // ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UDMA); ROM_SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_UDMA); // // Enable the uDMA controller error interrupt. This interrupt will occur // if there is a bus error during a transfer. // ROM_IntEnable(INT_UDMAERR); // // Enable the uDMA controller. // ROM_uDMAEnable(); // // Point at the control table to use for channel control structures. // ROM_uDMAControlBaseSet(ui8ControlTable); // // Initialize the uDMA memory to memory transfers. // InitSWTransfer(); // // Initialize the uDMA UART transfers. // InitUART1Transfer(); // // Remember the current SysTick seconds count. // ui32PrevSeconds = g_ui32Seconds; // // Remember the current count of memory buffer transfers. // ui32PrevXferCount = g_ui32MemXferCount; // // Loop until the button is pressed. The processor is put to sleep // in this loop so that CPU utilization can be measured. // while(1) { // // Check to see if one second has elapsed. If so, the make some // updates. // if(g_ui32Seconds != ui32PrevSeconds) { // // Turn on the LED as a heartbeat // GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, GPIO_PIN_2); // // Print a message to the display showing the CPU usage percent. // The fractional part of the percent value is ignored. // UARTprintf("\r%3d%% ", g_ui32CPUUsage >> 16); // // Remember the new seconds count. // ui32PrevSeconds = g_ui32Seconds; // // Calculate how many memory transfers have occurred since the last // second. // ui32XfersCompleted = g_ui32MemXferCount - ui32PrevXferCount; // // Remember the new transfer count. // ui32PrevXferCount = g_ui32MemXferCount; // // Compute how many bytes were transferred in the memory transfer // since the last second. // ui32BytesTransferred = ui32XfersCompleted * MEM_BUFFER_SIZE * 4; // // Print a message showing the memory transfer rate. // if(ui32BytesTransferred >= 100000000) { UARTprintf("%3d MB/s ", ui32BytesTransferred / 1000000); } else if(ui32BytesTransferred >= 10000000) { UARTprintf("%2d.%01d MB/s ", ui32BytesTransferred / 1000000, (ui32BytesTransferred % 1000000) / 100000); } else if(ui32BytesTransferred >= 1000000) { UARTprintf("%1d.%02d MB/s ", ui32BytesTransferred / 1000000, (ui32BytesTransferred % 1000000) / 10000); } else if(ui32BytesTransferred >= 100000) { UARTprintf("%3d KB/s ", ui32BytesTransferred / 1000); } else if(ui32BytesTransferred >= 10000) { UARTprintf("%2d.%01d KB/s ", ui32BytesTransferred / 1000, (ui32BytesTransferred % 1000) / 100); } else if(ui32BytesTransferred >= 1000) { UARTprintf("%1d.%02d KB/s ", ui32BytesTransferred / 1000, (ui32BytesTransferred % 1000) / 10); } else if(ui32BytesTransferred >= 100) { UARTprintf("%3d B/s ", ui32BytesTransferred); } else if(ui32BytesTransferred >= 10) { UARTprintf("%2d B/s ", ui32BytesTransferred); } else { UARTprintf("%1d B/s ", ui32BytesTransferred); } // // Calculate how many UART transfers have occurred since the last // second. // ui32XfersCompleted = (g_ui32RxBufACount + g_ui32RxBufBCount - ui32PrevUARTCount); // // Remember the new UART transfer count. // ui32PrevUARTCount = g_ui32RxBufACount + g_ui32RxBufBCount; // // Compute how many bytes were transferred by the UART. The number // of bytes received is multiplied by 2 so that the TX bytes // transferred are also accounted for. // ui32BytesTransferred = ui32XfersCompleted * UART_RXBUF_SIZE * 2; // // Print a message showing the UART transfer rate. // if(ui32BytesTransferred >= 1000000) { UARTprintf("%1d.%02d MB/s ", ui32BytesTransferred / 1000000, (ui32BytesTransferred % 1000000) / 10000); } else if(ui32BytesTransferred >= 100000) { UARTprintf("%3d KB/s ", ui32BytesTransferred / 1000); } else if(ui32BytesTransferred >= 10000) { UARTprintf("%2d.%01d KB/s ", ui32BytesTransferred / 1000, (ui32BytesTransferred % 1000) / 100); } else if(ui32BytesTransferred >= 1000) { UARTprintf("%1d.%02d KB/s ", ui32BytesTransferred / 1000, (ui32BytesTransferred % 1000) / 10); } else if(ui32BytesTransferred >= 100) { UARTprintf("%3d B/s ", ui32BytesTransferred); } else if(ui32BytesTransferred >= 10) { UARTprintf("%2d B/s ", ui32BytesTransferred); } else { UARTprintf("%1d B/s ", ui32BytesTransferred); } // // Print a spinning line to make it more apparent that there is // something happening. // UARTprintf("%2ds", 10 - ui32PrevSeconds); // // Turn off the LED. // GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 0); } // // Put the processor to sleep if there is nothing to do. This allows // the CPU usage routine to measure the number of free CPU cycles. // If the processor is sleeping a lot, it can be hard to connect to // the target with the debugger. // ROM_SysCtlSleep(); // // See if we have run int32_t enough and exit the loop if so. // if(g_ui32Seconds >= 10) { break; } }
//***************************************************************************** // //! Initializes the user interface. //! //! This function initializes the user interface modules (on-board and serial), //! preparing them to operate and control the motor drive. //! //! \return None. // //***************************************************************************** void UIInit(void) { unsigned long ulSysTickVal; // // Enable the GPIO peripherals needed for the button and LEDs // SysCtlPeripheralEnable(USER_BUTTON_GPIO_PERIPH); SysCtlPeripheralEnable(LED_GPIO_PERIPH); // // Set up button GPIO as input, and LEDs as outputs, and turn them off // GPIODirModeSet(USER_BUTTON_PORT, USER_BUTTON_PIN, GPIO_DIR_MODE_IN); GPIODirModeSet(STATUS_LED_PORT, STATUS_LED_PIN, GPIO_DIR_MODE_OUT); GPIODirModeSet(MODE_LED_PORT, MODE_LED_PIN, GPIO_DIR_MODE_OUT); GPIOPinWrite(STATUS_LED_PORT, STATUS_LED_PIN, 0); GPIOPinWrite(MODE_LED_PORT, MODE_LED_PIN, 0); // // Set up the LED blinking function // BlinkInit(STATUS_LED, STATUS_LED_PORT, STATUS_LED_PIN); BlinkInit(MODE_LED, MODE_LED_PORT, MODE_LED_PIN); BlinkStart(MODE_LED, UI_INT_RATE / 2, UI_INT_RATE / 2, eUIMode + 1); // // Enable the ADC peripheral, needed for potentiometer // SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_ADC0); // // Set the ADC to run at the maximum rate of 500 ksamples. // HWREG(SYSCTL_RCGC0) |= 0x00000200; HWREG(SYSCTL_SCGC0) |= 0x00000200; // // Program sequencer for collecting ADC sample for potentiometer // position, bus voltage, and temperature sensor. // ADCSequenceConfigure(ADC0_BASE, UI_ADC_SEQUENCER, ADC_TRIGGER_PROCESSOR, UI_ADC_PRIORITY); ADCSequenceStepConfigure(ADC0_BASE, UI_ADC_SEQUENCER, 0, POT_ADC_CHAN); ADCSequenceStepConfigure(ADC0_BASE, UI_ADC_SEQUENCER, 1, BUSV_ADC_CHAN); ADCSequenceStepConfigure(ADC0_BASE, UI_ADC_SEQUENCER, 2, ADC_CTL_TS | ADC_CTL_END); ADCSequenceEnable(ADC0_BASE, UI_ADC_SEQUENCER); ADCProcessorTrigger(ADC0_BASE, UI_ADC_SEQUENCER); // take initial sample // // initialize the lower level, // positioner, which handles computing all the motion control // StepperInit(); // // Get a pointer to the stepper status. // pStepperStatus = StepperGetMotorStatus(); // // Force an update of all the parameters (sets defaults). // UISetPWMFreq(); UISetChopperBlanking(); UISetMotorParms(); UISetControlMode(); UISetDecayMode(); UISetStepMode(); UISetFixedOnTime(); // // Initialize the flash parameter block driver. // FlashPBInit(FLASH_PB_START, FLASH_PB_END, FLASH_PB_SIZE); // // Initialize the serial user interface. // UISerialInit(); IntPrioritySet(INT_UART0, UI_SER_INT_PRI); // // Make sure that the UART doesnt get put to sleep // SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_UART0); // // Initialize the on-board user interface. // UIOnboardInit(GPIOPinRead(USER_BUTTON_PORT, USER_BUTTON_PIN), 0); // // Initialize the processor usage routine. // CPUUsageInit(SysCtlClockGet(), UI_INT_RATE, 2); // // Configure SysTick to provide a periodic user interface interrupt. // SysTickPeriodSet(SysCtlClockGet() / UI_INT_RATE); SysTickIntEnable(); SysTickEnable(); IntPrioritySet(FAULT_SYSTICK, SYSTICK_INT_PRI); // // A delay is needed to let the current sense line discharge after // reset, before the current fault parameter is configured. The // two loops below let the systick roll around once before proceeding. // ulSysTickVal = SysTickValueGet(); // // Wait for systick to reach 0 and roll over to top. // while(SysTickValueGet() <= ulSysTickVal) { } // // Wait for systick to get back to the starting value. // while(SysTickValueGet() > ulSysTickVal) { } // // Now set the current fault parameter (after the delay above). // UISetFaultParms(); // // Load stored parameters from flash, if any are available. // UIParamLoad(); }
//***************************************************************************** // // This example demonstrates how to use the uDMA controller to transfer data // between memory buffers and to and from a peripheral, in this case a UART. // The uDMA controller is configured to repeatedly transfer a block of data // from one memory buffer to another. It is also set up to repeatedly copy a // block of data from a buffer to the UART output. The UART data is looped // back so the same data is received, and the uDMA controlled is configured to // continuously receive the UART data using ping-pong buffers. // // The processor is put to sleep when it is not doing anything, and this allows // collection of CPU usage data to see how much CPU is being used while the // data transfers are ongoing. // //***************************************************************************** int main(void) { static unsigned long ulPrevSeconds; static unsigned long ulPrevXferCount; static unsigned long ulPrevUARTCount = 0; unsigned long ulXfersCompleted; unsigned long ulBytesTransferred; unsigned long ulButton; // // Set the clocking to run from the PLL at 50 MHz. // ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); // // Enable peripherals to operate when CPU is in sleep. // ROM_SysCtlPeripheralClockGating(true); // // Set the push button as an input with a pull-up. // ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); ROM_GPIODirModeSet(GPIO_PORTB_BASE, GPIO_PIN_4, GPIO_DIR_MODE_IN); ROM_GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_4, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); // // Initialize the UART. // ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); ROM_SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_UART0); GPIOPinConfigure(GPIO_PA0_U0RX); GPIOPinConfigure(GPIO_PA1_U0TX); ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); UARTStdioInit(0); UARTprintf("\033[2JuDMA Example\n"); // // Show the clock frequency and exit instructions. // UARTprintf("Stellaris @ %u MHz\n", ROM_SysCtlClockGet() / 1000000); UARTprintf("Press button to use debugger.\n\n"); // // Show statistics headings. // UARTprintf("CPU Memory UART\n"); UARTprintf("Usage Transfers Transfers\n"); // // Configure SysTick to occur 100 times per second, to use as a time // reference. Enable SysTick to generate interrupts. // ROM_SysTickPeriodSet(ROM_SysCtlClockGet() / SYSTICKS_PER_SECOND); ROM_SysTickIntEnable(); ROM_SysTickEnable(); // // Initialize the CPU usage measurement routine. // CPUUsageInit(ROM_SysCtlClockGet(), SYSTICKS_PER_SECOND, 2); // // Enable the uDMA controller at the system level. Enable it to continue // to run while the processor is in sleep. // ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UDMA); ROM_SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_UDMA); // // Enable the uDMA controller error interrupt. This interrupt will occur // if there is a bus error during a transfer. // ROM_IntEnable(INT_UDMAERR); // // Enable the uDMA controller. // ROM_uDMAEnable(); // // Point at the control table to use for channel control structures. // ROM_uDMAControlBaseSet(ucControlTable); // // Initialize the uDMA memory to memory transfers. // InitSWTransfer(); // // Initialize the uDMA UART transfers. // InitUART1Transfer(); // // Remember the current SysTick seconds count. // ulPrevSeconds = g_ulSeconds; // // Remember the current count of memory buffer transfers. // ulPrevXferCount = g_ulMemXferCount; // // Loop until the button is pressed. The processor is put to sleep // in this loop so that CPU utilization can be measured. When the // processor is sleeping a lot, it can be hard to connect to the target // with the debugger. Pressing the button will cause this loop to exit // and the processor will no longer sleep. // while(1) { // // Check for the select button press. If the button is pressed, // then exit this loop. // ulButton = ROM_GPIOPinRead(GPIO_PORTB_BASE, GPIO_PIN_4); if(!ulButton) { break; } // // Check to see if one second has elapsed. If so, the make some // updates. // if(g_ulSeconds != ulPrevSeconds) { // // Print a message to the display showing the CPU usage percent. // The fractional part of the percent value is ignored. // UARTprintf("\r%3d%% ", g_ulCPUUsage >> 16); // // Remember the new seconds count. // ulPrevSeconds = g_ulSeconds; // // Calculate how many memory transfers have occurred since the last // second. // ulXfersCompleted = g_ulMemXferCount - ulPrevXferCount; // // Remember the new transfer count. // ulPrevXferCount = g_ulMemXferCount; // // Compute how many bytes were transferred in the memory transfer // since the last second. // ulBytesTransferred = ulXfersCompleted * MEM_BUFFER_SIZE * 4; // // Print a message showing the memory transfer rate. // if(ulBytesTransferred >= 100000000) { UARTprintf("%3d MB/s ", ulBytesTransferred / 1000000); } else if(ulBytesTransferred >= 10000000) { UARTprintf("%2d.%01d MB/s ", ulBytesTransferred / 1000000, (ulBytesTransferred % 1000000) / 100000); } else if(ulBytesTransferred >= 1000000) { UARTprintf("%1d.%02d MB/s ", ulBytesTransferred / 1000000, (ulBytesTransferred % 1000000) / 10000); } else if(ulBytesTransferred >= 100000) { UARTprintf("%3d KB/s ", ulBytesTransferred / 1000); } else if(ulBytesTransferred >= 10000) { UARTprintf("%2d.%01d KB/s ", ulBytesTransferred / 1000, (ulBytesTransferred % 1000) / 100); } else if(ulBytesTransferred >= 1000) { UARTprintf("%1d.%02d KB/s ", ulBytesTransferred / 1000, (ulBytesTransferred % 1000) / 10); } else if(ulBytesTransferred >= 100) { UARTprintf("%3d B/s ", ulBytesTransferred); } else if(ulBytesTransferred >= 10) { UARTprintf("%2d B/s ", ulBytesTransferred); } else { UARTprintf("%1d B/s ", ulBytesTransferred); } // // Calculate how many UART transfers have occurred since the last // second. // ulXfersCompleted = (g_ulRxBufACount + g_ulRxBufBCount - ulPrevUARTCount); // // Remember the new UART transfer count. // ulPrevUARTCount = g_ulRxBufACount + g_ulRxBufBCount; // // Compute how many bytes were transferred by the UART. The number // of bytes received is multiplied by 2 so that the TX bytes // transferred are also accounted for. // ulBytesTransferred = ulXfersCompleted * UART_RXBUF_SIZE * 2; // // Print a message showing the UART transfer rate. // if(ulBytesTransferred >= 1000000) { UARTprintf("%1d.%02d MB/s ", ulBytesTransferred / 1000000, (ulBytesTransferred % 1000000) / 10000); } else if(ulBytesTransferred >= 100000) { UARTprintf("%3d KB/s ", ulBytesTransferred / 1000); } else if(ulBytesTransferred >= 10000) { UARTprintf("%2d.%01d KB/s ", ulBytesTransferred / 1000, (ulBytesTransferred % 1000) / 100); } else if(ulBytesTransferred >= 1000) { UARTprintf("%1d.%02d KB/s ", ulBytesTransferred / 1000, (ulBytesTransferred % 1000) / 10); } else if(ulBytesTransferred >= 100) { UARTprintf("%3d B/s ", ulBytesTransferred); } else if(ulBytesTransferred >= 10) { UARTprintf("%2d B/s ", ulBytesTransferred); } else { UARTprintf("%1d B/s ", ulBytesTransferred); } // // Print a spinning line to make it more apparent that there is // something happening. // UARTprintf("%c", g_pcTwirl[ulPrevSeconds % 4]); } // // Put the processor to sleep if there is nothing to do. This allows // the CPU usage routine to measure the number of free CPU cycles. // If the processor is sleeping a lot, it can be hard to connect to // the target with the debugger. // ROM_SysCtlSleep(); }