本文整理汇总了C++中GrContextDpyWidthGet函数的典型用法代码示例。如果您正苦于以下问题:C++ GrContextDpyWidthGet函数的具体用法?C++ GrContextDpyWidthGet怎么用?C++ GrContextDpyWidthGet使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GrContextDpyWidthGet函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
BMP180AppCallback, &g_sBMP180Inst);
//
// Wait for initialization callback to indicate reset request is complete.
//
while(g_vui8DataFlag == 0)
{
//
// Wait for I2C Transactions to complete.
//
}
//
// Reset the data ready flag
//
g_vui8DataFlag = 0;
//
// Enable the system ticks at 10 hz.
//
MAP_SysTickPeriodSet(ui32SysClock / (10 * 3));
MAP_SysTickIntEnable();
MAP_SysTickEnable();
//
// Configure PQ4 to control the blue LED.
//
MAP_GPIOPinTypeGPIOOutput(GPIO_PORTQ_BASE, GPIO_PIN_4);
//
// Print temperature, pressure and altitude labels once on the LCD.
//
GrStringDraw(&sContext, "Temperature", 11,
((GrContextDpyWidthGet(&sContext) / 2) - 96),
((GrContextDpyHeightGet(&sContext) - 32) / 2) - 24, 1);
GrStringDraw(&sContext, "Pressure", 8,
((GrContextDpyWidthGet(&sContext) / 2) - 63),
(GrContextDpyHeightGet(&sContext) - 32) / 2, 1);
GrStringDraw(&sContext, "Altitude", 8,
((GrContextDpyWidthGet(&sContext) / 2) - 59),
((GrContextDpyHeightGet(&sContext) - 32) / 2) + 24, 1);
//
// Begin the data collection and printing. Loop Forever.
//
while(1)
{
//
// Read the data from the BMP180 over I2C. This command starts a
// temperature measurement. Then polls until temperature is ready.
// Then automatically starts a pressure measurement and polls for that
// to complete. When both measurement are complete and in the local
// buffer then the application callback is called from the I2C
// interrupt context. Polling is done on I2C interrupts allowing
// processor to continue doing other tasks as needed.
//
BMP180DataRead(&g_sBMP180Inst, BMP180AppCallback, &g_sBMP180Inst);
while(g_vui8DataFlag == 0)
{
//
// Wait for the new data set to be available.
//
}
//
// Reset the data ready flag.
示例2: main
//.........这里部分代码省略.........
GrStringDraw(&sContext, "Touch center of circles to calibrate", -1, 0, 0, 1);
GrCircleDraw(&sContext, 32, 24, 10);
GrFlush(&sContext);
TouchScreenCalibrationPoint(32, 24, 0);
GrCircleDraw(&sContext, 280, 200, 10);
GrFlush(&sContext);
TouchScreenCalibrationPoint(280, 200, 1);
GrCircleDraw(&sContext, 200, 40, 10);
GrFlush(&sContext);
TouchScreenCalibrationPoint(200, 40, 2);
//
// Calculate and set calibration matrix
//
long* plCalibrationMatrix = TouchScreenCalibrate();
//
// Write out calibration data if successful
//
if(plCalibrationMatrix)
{
char pcStringBuf[20];
usprintf(pcStringBuf, "A %d", plCalibrationMatrix[0]);
GrStringDraw(&sContext, pcStringBuf, -1, 0, 20, 1);
usprintf(pcStringBuf, "B %d", plCalibrationMatrix[1]);
GrStringDraw(&sContext, pcStringBuf, -1, 0, 40, 1);
usprintf(pcStringBuf, "C %d", plCalibrationMatrix[2]);
GrStringDraw(&sContext, pcStringBuf, -1, 0, 60, 1);
usprintf(pcStringBuf, "D %d", plCalibrationMatrix[3]);
GrStringDraw(&sContext, pcStringBuf, -1, 0, 80, 1);
usprintf(pcStringBuf, "E %d", plCalibrationMatrix[4]);
GrStringDraw(&sContext, pcStringBuf, -1, 0, 100, 1);
usprintf(pcStringBuf, "F %d", plCalibrationMatrix[5]);
GrStringDraw(&sContext, pcStringBuf, -1, 0, 120, 1);
usprintf(pcStringBuf, "Div %d", plCalibrationMatrix[6]);
GrStringDraw(&sContext, pcStringBuf, -1, 0, 140, 1);
TouchScreenCalibrationPoint(0,0,0); // wait for dummy touch
}
//
// Enable touch screen event handler for grlib widgets
//
TouchScreenCallbackSet(WidgetPointerMessage);
//
// Fill the top 24 rows of the screen with blue to create the banner.
//
sRect.sXMin = 0;
sRect.sYMin = 0;
sRect.sXMax = GrContextDpyWidthGet(&sContext) - 1;
sRect.sYMax = 23;
GrContextForegroundSet(&sContext, ClrDarkBlue);
GrRectFill(&sContext, &sRect);
//
// Put a white box around the banner.
//
GrContextForegroundSet(&sContext, ClrWhite);
GrRectDraw(&sContext, &sRect);
//
// Put the application name in the middle of the banner.
//
GrContextFontSet(&sContext, &g_sFontCm20);
GrStringDrawCentered(&sContext, "grlib demo", -1,
GrContextDpyWidthGet(&sContext) / 2, 8, 0);
//
// Add the title block and the previous and next buttons to the widget
// tree.
//
WidgetAdd(WIDGET_ROOT, (tWidget *)&g_sPrevious);
WidgetAdd(WIDGET_ROOT, (tWidget *)&g_sTitle);
WidgetAdd(WIDGET_ROOT, (tWidget *)&g_sNext);
//
// Add the first panel to the widget tree.
//
g_ulPanel = 0;
WidgetAdd(WIDGET_ROOT, (tWidget *)g_psPanels);
CanvasTextSet(&g_sTitle, g_pcPanelNames[0]);
//
// Issue the initial paint request to the widgets.
//
WidgetPaint(WIDGET_ROOT);
//
// Loop forever handling widget messages.
//
while(1)
{
//
// Process any messages in the widget message queue.
//
WidgetMessageQueueProcess();
}
}
示例3: main
//*****************************************************************************
//
// A simple demonstration of the features of the TivaWare Graphics Library.
//
//*****************************************************************************
int
main(void)
{
tContext sContext;
tRectangle sRect;
//
// The FPU should be enabled because some compilers will use floating-
// point registers, even for non-floating-point code. If the FPU is not
// enabled this will cause a fault. This also ensures that floating-
// point operations could be added to this application and would work
// correctly and use the hardware floating-point unit. Finally, lazy
// stacking is enabled for interrupt handlers. This allows floating-
// point instructions to be used within interrupt handlers, but at the
// expense of extra stack usage.
//
FPUEnable();
FPULazyStackingEnable();
//
// Run from the PLL at 120 MHz.
//
g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
SYSCTL_OSC_MAIN |
SYSCTL_USE_PLL |
SYSCTL_CFG_VCO_480), 120000000);
//
// Initialize the display driver.
//
Kentec320x240x16_SSD2119Init(g_ui32SysClock);
//
// Initialize the graphics context.
//
GrContextInit(&sContext, &g_sKentec320x240x16_SSD2119);
//
// Fill the top 24 rows of the screen with blue to create the banner.
//
sRect.i16XMin = 0;
sRect.i16YMin = 0;
sRect.i16XMax = GrContextDpyWidthGet(&sContext) - 1;
sRect.i16YMax = 23;
GrContextForegroundSet(&sContext, ClrDarkBlue);
GrRectFill(&sContext, &sRect);
//
// Put a white box around the banner.
//
GrContextForegroundSet(&sContext, ClrWhite);
GrRectDraw(&sContext, &sRect);
//
// Put the application name in the middle of the banner.
//
GrContextFontSet(&sContext, &g_sFontCm20);
GrStringDrawCentered(&sContext, "grlib demo", -1,
GrContextDpyWidthGet(&sContext) / 2, 8, 0);
//
// Configure and enable uDMA
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_UDMA);
SysCtlDelay(10);
uDMAControlBaseSet(&psDMAControlTable[0]);
uDMAEnable();
//
// Initialize the touch screen driver and have it route its messages to the
// widget tree.
//
TouchScreenInit(g_ui32SysClock);
TouchScreenCallbackSet(WidgetPointerMessage);
//
// Add the title block and the previous and next buttons to the widget
// tree.
//
WidgetAdd(WIDGET_ROOT, (tWidget *)&g_sPrevious);
WidgetAdd(WIDGET_ROOT, (tWidget *)&g_sTitle);
WidgetAdd(WIDGET_ROOT, (tWidget *)&g_sNext);
//
// Add the first panel to the widget tree.
//
g_ui32Panel = 0;
WidgetAdd(WIDGET_ROOT, (tWidget *)g_psPanels);
CanvasTextSet(&g_sTitle, g_pcPanei32Names[0]);
//
// Issue the initial paint request to the widgets.
//
WidgetPaint(WIDGET_ROOT);
//.........这里部分代码省略.........
示例4: main
//*****************************************************************************
//
// This is the main example program. It checks to see that the interrupts are
// processed in the correct order when they have identical priorities,
// increasing priorities, and decreasing priorities. This exercises interrupt
// preemption and tail chaining.
//
//*****************************************************************************
int
main(void)
{
uint_fast8_t ui8Error;
uint32_t ui32SysClock;
//
// Run from the PLL at 120 MHz.
//
ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
SYSCTL_OSC_MAIN | SYSCTL_USE_PLL |
SYSCTL_CFG_VCO_480), 120000000);
//
// Configure the device pins.
//
PinoutSet();
//
// Initialize the display driver.
//
Kentec320x240x16_SSD2119Init(ui32SysClock);
//
// Initialize the graphics context.
//
GrContextInit(&g_sContext, &g_sKentec320x240x16_SSD2119);
//
// Draw the application frame.
//
FrameDraw(&g_sContext, "interrupts");
//
// Put the status header text on the display.
//
GrContextFontSet(&g_sContext, g_psFontCm20);
GrStringDrawCentered(&g_sContext, "Active: Pending: ", -1,
GrContextDpyWidthGet(&g_sContext) / 2, 150, 0);
//
// Configure the B3, L1 and L0 to be outputs to indicate entry/exit of one
// of the interrupt handlers.
//
GPIOPinTypeGPIOOutput(GPIO_A_BASE, GPIO_A_PIN);
GPIOPinTypeGPIOOutput(GPIO_B_BASE, GPIO_B_PIN);
GPIOPinTypeGPIOOutput(GPIO_C_BASE, GPIO_C_PIN);
GPIOPinWrite(GPIO_A_BASE, GPIO_A_PIN, 0);
GPIOPinWrite(GPIO_B_BASE, GPIO_B_PIN, 0);
GPIOPinWrite(GPIO_C_BASE, GPIO_C_PIN, 0);
//
// Set up and enable the SysTick timer. It will be used as a reference
// for delay loops in the interrupt handlers. The SysTick timer period
// will be set up for 100 times per second.
//
ROM_SysTickPeriodSet(ui32SysClock / 100);
ROM_SysTickEnable();
//
// Reset the error indicator.
//
ui8Error = 0;
//
// Enable interrupts to the processor.
//
ROM_IntMasterEnable();
//
// Enable the interrupts.
//
ROM_IntEnable(INT_GPIOA);
ROM_IntEnable(INT_GPIOB);
ROM_IntEnable(INT_GPIOC);
//
// Indicate that the equal interrupt priority test is beginning.
//
GrStringDrawCentered(&g_sContext, "Equal Priority", -1,
GrContextDpyWidthGet(&g_sContext) / 2, 60, 1);
//
// Set the interrupt priorities so they are all equal.
//
ROM_IntPrioritySet(INT_GPIOA, 0x00);
ROM_IntPrioritySet(INT_GPIOB, 0x00);
ROM_IntPrioritySet(INT_GPIOC, 0x00);
//
// Reset the interrupt flags.
//
//.........这里部分代码省略.........
示例5: AcquireInit
//*****************************************************************************
//
// This function initializes the ADC hardware in preparation for data
// acquisition.
//
//*****************************************************************************
void
AcquireInit(void)
{
unsigned long ulChan;
//
// Enable the ADC peripherals and the associated GPIO port
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOP);
ROM_SysCtlADCSpeedSet(SYSCTL_ADCSPEED_125KSPS);
ROM_GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 |GPIO_PIN_7 | GPIO_PIN_3);
ROM_GPIOPinTypeADC(GPIO_PORTP_BASE, GPIO_PIN_0);
// ROM_ADCReferenceSet(ADC0_BASE, ADC_REF_EXT_3V);
//ROM_ADCR
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
HWREG(GPIO_PORTB_BASE + GPIO_O_AMSEL) |= GPIO_PIN_6;
ADCSequenceDisable(ADC0_BASE,SEQUENCER);
ROM_ADCSequenceConfigure(ADC0_BASE, SEQUENCER, ADC_TRIGGER_TIMER, 0);
for(ulChan = 0; ulChan < 2; ulChan++)
{
unsigned long ulChCtl;
if (ulChan ==1)
{
ROM_ADCSequenceStepConfigure(ADC0_BASE, SEQUENCER, ulChan, ADC_CTL_CH1|ADC_CTL_IE | ADC_CTL_END);
}
else if(ulChan==0)
{
ulChCtl = ADC_CTL_CH0;
ROM_ADCSequenceStepConfigure(ADC0_BASE, SEQUENCER, ulChan, ADC_CTL_CH0);
}
}
ADCHardwareOversampleConfigure(ADC0_BASE, 1);
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
//SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);
ROM_TimerConfigure(TIMER0_BASE,TIMER_CFG_32_BIT_PER );
//100 micro
unsigned long freq=SAMPLING_FREQUENCY;
unsigned long period=(2*ROM_SysCtlClockGet()/(freq));
ROM_TimerLoadSet(TIMER0_BASE, TIMER_A,period);
ROM_TimerControlTrigger(TIMER0_BASE, TIMER_A, true);
//ROM_TimerConfigure(TIMER1_BASE, TIMER_CFG_PERIODIC);
//ROM_TimerLoadSet(TIMER1_BASE, TIMER_A, ROM_SysCtlClockGet() /2);
CFAL96x64x16Init();
GrContextInit(&sDisplayContext, &g_sCFAL96x64x16);
sRect1.sXMin = 0;
sRect1.sYMin = 0;
sRect1.sXMax = GrContextDpyWidthGet(&sDisplayContext) - 1;
sRect1.sYMax = 23;
sRect2.sXMin = 0;
sRect2.sYMin = 23;
sRect2.sXMax = GrContextDpyWidthGet(&sDisplayContext) - 1;
sRect2.sYMax = GrContextDpyHeightGet(&sDisplayContext) - 1;
snprintf(text,sizeof(text),"STart");
GrContextForegroundSet(&sDisplayContext, ClrDarkBlue);
GrRectFill(&sDisplayContext, &sRect1);
GrContextForegroundSet(&sDisplayContext, ClrWhite);
//GrRectDraw(&sDisplayContext, &sRect1);
GrContextFontSet(&sDisplayContext, g_pFontCm12);
GrStringDrawCentered(&sDisplayContext,text, -1,
GrContextDpyWidthGet(&sDisplayContext) / 2, 10, 0);
//GrContextForegroundSet(&sDisplayContext, ClrDarkBlue);
//GrRectFill(&sDisplayContext, &sRect1);
//GrContextForegroundSet(&sDisplayContext, ClrWhite);
//GrRectDraw(&sDisplayContext, &sRect1);
/*GrContextForegroundSet(&sDisplayContext, ClrDarkBlue);
//.........这里部分代码省略.........
示例6: main
//*****************************************************************************
//
// A simple application demonstrating use of the boot loader,
//
//*****************************************************************************
int
main(void)
{
tRectangle sRect;
tContext sContext;
unsigned long ulSysClock;
//
// 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 system clock to run at 50MHz from the PLL
//
ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ |
SYSCTL_OSC_MAIN);
ulSysClock = ROM_SysCtlClockGet();
//
// Initialize the peripherals that each of the boot loader flavors
// supports. Since this example is intended for use with any of the
// boot loaders and we don't know which is actually in use, we cover all
// bases and initialize for serial, Ethernet and USB use here.
//
SetupForUART();
SetupForUSB();
//
// Initialize the buttons driver.
//
ButtonsInit();
//
// Initialize the display driver.
//
CFAL96x64x16Init();
//
// Initialize the graphics context.
//
GrContextInit(&sContext, &g_sCFAL96x64x16);
//
// Fill the top part of the screen with blue to create the banner.
//
sRect.sXMin = 0;
sRect.sYMin = 0;
sRect.sXMax = GrContextDpyWidthGet(&sContext) - 1;
sRect.sYMax = 9;
GrContextForegroundSet(&sContext, ClrDarkBlue);
GrRectFill(&sContext, &sRect);
//
// Change foreground for white text.
//
GrContextForegroundSet(&sContext, ClrWhite);
//
// Put the application name in the middle of the banner.
//
GrContextFontSet(&sContext, g_pFontFixed6x8);
GrStringDrawCentered(&sContext, "boot-demo2", -1,
GrContextDpyWidthGet(&sContext) / 2, 4, 0);
GrStringDrawCentered(&sContext, "Press select", -1,
GrContextDpyWidthGet(&sContext) / 2, 20, false);
GrStringDrawCentered(&sContext, "button to", -1,
GrContextDpyWidthGet(&sContext) / 2, 30, false);
GrStringDrawCentered(&sContext, "update.", -1,
GrContextDpyWidthGet(&sContext) / 2, 40, false);
//
// Wait for select button to be pressed.
//
while ((ButtonsPoll(0, 0) & SELECT_BUTTON) == 0)
{
ROM_SysCtlDelay(ulSysClock / 1000);
}
GrStringDrawCentered(&sContext, " ", -1,
GrContextDpyWidthGet(&sContext) / 2, 20, true);
GrStringDrawCentered(&sContext, " Updating... ", -1,
GrContextDpyWidthGet(&sContext) / 2, 30, true);
GrStringDrawCentered(&sContext, " ", -1,
GrContextDpyWidthGet(&sContext) / 2, 40, true);
//
// Transfer control to the boot loader.
//
JumpToBootLoader();
//
//.........这里部分代码省略.........
示例7: UpdateStatus
//*****************************************************************************
//
// This function updates the status area of the screen. It uses the current
// state of the application to print the status bar.
//
//*****************************************************************************
void
UpdateStatus(char *pcString, uint32_t ui32Buttons, bool bClrBackground)
{
tRectangle sRect;
//
// Fill the bottom rows of the screen with blue to create the status area.
//
sRect.i16XMin = 0;
sRect.i16YMin = GrContextDpyHeightGet(&g_sContext) -
DISPLAY_BANNER_HEIGHT - 1;
sRect.i16XMax = GrContextDpyWidthGet(&g_sContext) - 1;
sRect.i16YMax = sRect.i16YMin + DISPLAY_BANNER_HEIGHT;
//
// Were we asked to clear the background of the status area?
//
GrContextBackgroundSet(&g_sContext, DISPLAY_BANNER_BG);
if(bClrBackground)
{
//
// Draw the background of the banner.
//
GrContextForegroundSet(&g_sContext, DISPLAY_BANNER_BG);
GrRectFill(&g_sContext, &sRect);
//
// Put a white box around the banner.
//
GrContextForegroundSet(&g_sContext, DISPLAY_BANNER_FG);
GrRectDraw(&g_sContext, &sRect);
}
//
// Write the current state to the left of the status area.
//
GrContextFontSet(&g_sContext, g_psFontFixed6x8);
//
// Update the status on the screen.
//
if(pcString != 0)
{
UARTprintf(pcString);
UARTprintf("\n");
GrStringDraw(&g_sContext, pcString, -1, 10, sRect.i16YMin + 4, 1);
g_ui32Buttons = ui32Buttons;
}
else if(iUSBState == eStateNoDevice)
{
//
// Mouse is currently disconnected.
//
UARTprintf("no device\n");
GrStringDraw(&g_sContext, "no device ", -1, 10, sRect.i16YMin + 4,
1);
}
else if(iUSBState == eStateMouseConnected)
{
//
// Mouse is connected.
//
UARTprintf("connected\n");
GrStringDraw(&g_sContext, "connected ", -1, 10, sRect.i16YMin + 4,
1);
}
else if(iUSBState == eStateUnknownDevice)
{
//
// Some other (unknown) device is connected.
//
UARTprintf("unknown device\n");
GrStringDraw(&g_sContext, "unknown device", -1, 10, sRect.i16YMin + 4,
1);
}
else if(iUSBState == eStatePowerFault)
{
//
// Power fault.
//
UARTprintf("power fault\n");
GrStringDraw(&g_sContext, "power fault ", -1, 10, sRect.i16YMin + 4,
1);
}
UpdateButtons();
}
示例8: main
//*****************************************************************************
//
// Demonstrate the use of the USB stick update example.
//
//*****************************************************************************
int
main(void)
{
uint_fast32_t ui32Count;
tContext sContext;
tRectangle sRect;
//
// 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 system clock to run at 50MHz from the PLL.
//
ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_16MHZ);
//
// Initialize the display driver.
//
CFAL96x64x16Init();
//
// Initialize the graphics context.
//
GrContextInit(&sContext, &g_sCFAL96x64x16);
//
// Fill the top 24 rows of the screen with blue to create the banner.
//
sRect.i16XMin = 0;
sRect.i16YMin = 0;
sRect.i16XMax = GrContextDpyWidthGet(&sContext) - 1;
sRect.i16YMax = 9;
GrContextForegroundSet(&sContext, ClrDarkBlue);
GrRectFill(&sContext, &sRect);
//
// Put a white box around the banner.
//
GrContextForegroundSet(&sContext, ClrWhite);
GrRectDraw(&sContext, &sRect);
//
// Put the application name in the middle of the banner.
//
GrContextFontSet(&sContext, g_psFontFixed6x8);
GrStringDrawCentered(&sContext, "usb-stick-demo", -1,
GrContextDpyWidthGet(&sContext) / 2, 4, 0);
//
// Indicate what is happening.
//
GrStringDrawCentered(&sContext, "Press the", -1,
GrContextDpyWidthGet(&sContext) / 2, 20, 0);
GrStringDrawCentered(&sContext, "select button to", -1,
GrContextDpyWidthGet(&sContext) / 2, 30, 0);
GrStringDrawCentered(&sContext, "start the USB", -1,
GrContextDpyWidthGet(&sContext) / 2, 40, 0);
GrStringDrawCentered(&sContext, "stick updater.", -1,
GrContextDpyWidthGet(&sContext) / 2, 50, 0);
//
// Flush any cached drawing operations.
//
GrFlush(&sContext);
//
// Enable the GPIO module which the select button is attached to.
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOM);
//
// Enable the GPIO pin to read the user button.
//
ROM_GPIODirModeSet(GPIO_PORTM_BASE, GPIO_PIN_4, GPIO_DIR_MODE_IN);
MAP_GPIOPadConfigSet(GPIO_PORTM_BASE, GPIO_PIN_4, GPIO_STRENGTH_2MA,
GPIO_PIN_TYPE_STD_WPU);
//
// Wait for the pullup to take effect or the next loop will exist too soon.
//
SysCtlDelay(1000);
//
// Wait until the select button has been pressed for ~40ms (in order to
// debounce the press).
//
ui32Count = 0;
while(1) {
//
// See if the button is pressed.
//.........这里部分代码省略.........
示例9: main
//*****************************************************************************
//
// This is the main loop that runs the application.
//
//*****************************************************************************
int
main(void)
{
FRESULT FileResult;
tRectangle sRect;
//
// Initially wait for device connection.
//
g_eState = STATE_NO_DEVICE;
//
// Set the clocking to run directly from the crystal.
//
SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_8MHZ);
//
// Enable Clocking to the USB controller.
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_USB0);
//
// Enable the peripherals used by this example.
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOH);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
//
// Set the USB pins to be controlled by the USB controller.
//
GPIOPinTypeUSBDigital(GPIO_PORTH_BASE, GPIO_PIN_3 | GPIO_PIN_4);
//
// The LM3S3748 board uses a USB mux that must be switched to use the
// host connecter and not the device connecter.
//
GPIOPinTypeGPIOOutput(USB_MUX_GPIO_BASE, USB_MUX_GPIO_PIN);
GPIOPinWrite(USB_MUX_GPIO_BASE, USB_MUX_GPIO_PIN, USB_MUX_SEL_HOST);
//
// Turn on USB Phy clock.
//
SysCtlUSBPLLEnable();
//
// Set the system tick to fire 100 times per second.
//
SysTickPeriodSet(SysCtlClockGet()/100);
SysTickIntEnable();
SysTickEnable();
//
// Enable the uDMA controller and set up the control table base.
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_UDMA);
uDMAEnable();
uDMAControlBaseSet(g_sDMAControlTable);
//
// 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 = SPLASH_HEIGHT - 1;
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_sFontFixed6x8);
//.........这里部分代码省略.........
示例10: main
//*****************************************************************************
//
// This example demonstrates how to send a string of data to the UART.
//
//*****************************************************************************
int
main(void)
{
tRectangle sRect;
tContext sContext;
//
// 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 directly from the crystal.
//
ROM_SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_16MHZ);
//
// Initialize the display driver.
//
CFAL96x64x16Init();
//
// Initialize the graphics context.
//
GrContextInit(&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(&sContext) - 1;
sRect.i16YMax = 9;
GrContextForegroundSet(&sContext, ClrDarkBlue);
GrRectFill(&sContext, &sRect);
//
// Change foreground for white text.
//
GrContextForegroundSet(&sContext, ClrWhite);
//
// Put the application name in the middle of the banner.
//
GrContextFontSet(&sContext, g_psFontFixed6x8);
GrStringDrawCentered(&sContext, "uart-echo", -1,
GrContextDpyWidthGet(&sContext) / 2, 4, 0);
//
// Initialize the display and write some instructions.
//
GrStringDrawCentered(&sContext, "Connect a", -1,
GrContextDpyWidthGet(&sContext) / 2, 20, false);
GrStringDrawCentered(&sContext, "terminal", -1,
GrContextDpyWidthGet(&sContext) / 2, 30, false);
GrStringDrawCentered(&sContext, "to UART0.", -1,
GrContextDpyWidthGet(&sContext) / 2, 40, false);
GrStringDrawCentered(&sContext, "115000,N,8,1", -1,
GrContextDpyWidthGet(&sContext) / 2, 50, false);
//
// Enable the peripherals used by this example.
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
//
// Enable processor interrupts.
//
ROM_IntMasterEnable();
//
// Set GPIO A0 and A1 as UART pins.
//
ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
//
// Configure the UART for 115,200, 8-N-1 operation.
//
ROM_UARTConfigSetExpClk(UART0_BASE, ROM_SysCtlClockGet(), 115200,
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
UART_CONFIG_PAR_NONE));
//
// Enable the UART interrupt.
//
ROM_IntEnable(INT_UART0);
ROM_UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT);
//
// Prompt for text to be entered.
//
//.........这里部分代码省略.........
示例11: main
//*****************************************************************************
//
// This example demonstrates the use of the watchdog timer.
//
//*****************************************************************************
int
main(void)
{
tRectangle sRect;
//
// Set the clocking to run directly from the crystal.
//
ROM_SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_16MHZ);
//
// Set the device pinout appropriately for this board.
//
PinoutSet();
//
// Initialize the touch screen driver.
//
TouchScreenInit();
TouchScreenCallbackSet(WatchdogTouchCallback);
//
// Initialize the display driver.
//
Kitronix320x240x16_SSD2119Init();
//
// Initialize the graphics context and find the middle X coordinate.
//
GrContextInit(&g_sContext, &g_sKitronix320x240x16_SSD2119);
//
// 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, "watchdog", -1,
GrContextDpyWidthGet(&g_sContext) / 2, 8, 0);
//
// Show the state and offer some instructions to the user.
//
GrContextFontSet(&g_sContext, g_pFontCmss20);
GrStringDrawCentered(&g_sContext, "Watchdog is being fed.", -1,
GrContextDpyWidthGet(&g_sContext) / 2 ,
(GrContextDpyHeightGet(&g_sContext) / 2), 1);
GrContextFontSet(&g_sContext, g_pFontCmss14);
GrStringDrawCentered(&g_sContext, "Tap the screen to starve the watchdog",
-1, GrContextDpyWidthGet(&g_sContext) / 2 ,
(GrContextDpyHeightGet(&g_sContext) / 2) + 20, 1);
//
// Enable the peripherals used by this example.
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_WDOG0);
//
// Enable processor interrupts.
//
ROM_IntMasterEnable();
//
// Set GPIO PF3 as an output. This drives an LED on the board that will
// toggle when a watchdog interrupt is processed.
//
ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_3);
ROM_GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_3, 0);
//
// Enable the watchdog interrupt.
//
ROM_IntEnable(INT_WATCHDOG);
//
// Set the period of the watchdog timer.
//
ROM_WatchdogReloadSet(WATCHDOG0_BASE, ROM_SysCtlClockGet());
//
//.........这里部分代码省略.........
示例12: main
//*****************************************************************************
//
// This example decrypts blocks ciphertext using AES128 and AES256 in GCM
// mode. It does the decryption first without uDMA and then with uDMA.
// The results are checked after each operation.
//
//*****************************************************************************
int
main(void)
{
uint32_t pui32PlainText[64], pui32Tag[4], pui32Y0[4], ui32Errors, ui32Idx;
uint32_t *pui32Key, ui32IVLength, *pui32IV, ui32DataLength;
uint32_t *pui32ExpPlainText, ui32AuthDataLength, *pui32AuthData;
uint32_t *pui32CipherText, *pui32ExpTag;
uint32_t ui32KeySize;
uint32_t ui32SysClock;
uint8_t ui8Vector;
tContext sContext;
//
// Run from the PLL at 120 MHz.
//
ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
SYSCTL_OSC_MAIN |
SYSCTL_USE_PLL |
SYSCTL_CFG_VCO_480), 120000000);
//
// Configure the device pins.
//
PinoutSet();
//
// Initialize the display driver.
//
Kentec320x240x16_SSD2119Init(ui32SysClock);
//
// Initialize the graphics context.
//
GrContextInit(&sContext, &g_sKentec320x240x16_SSD2119);
//
// Draw the application frame.
//
FrameDraw(&sContext, "aes-gcm-decrypt");
//
// Show some instructions on the display
//
GrContextFontSet(&sContext, g_psFontCm20);
GrContextForegroundSet(&sContext, ClrWhite);
GrStringDrawCentered(&sContext, "Connect a terminal to", -1,
GrContextDpyWidthGet(&sContext) / 2, 60, false);
GrStringDrawCentered(&sContext, "UART0 (115200,N,8,1)", -1,
GrContextDpyWidthGet(&sContext) / 2, 80, false);
GrStringDrawCentered(&sContext, "for more information.", -1,
GrContextDpyWidthGet(&sContext) / 2, 100, false);
//
// Initialize local variables.
//
ui32Errors = 0;
for(ui32Idx = 0; ui32Idx < 16; ui32Idx++)
{
pui32PlainText[ui32Idx] = 0;
}
for(ui32Idx = 0; ui32Idx < 4; ui32Idx++)
{
pui32Tag[ui32Idx] = 0;
}
//
// Enable stacking for interrupt handlers. This allows floating-point
// instructions to be used within interrupt handlers, but at the expense of
// extra stack usage.
//
ROM_FPUStackingEnable();
//
// Enable AES interrupts.
//
ROM_IntEnable(INT_AES0);
//
// Enable debug output on UART0 and print a welcome message.
//
ConfigureUART();
UARTprintf("Starting AES GCM decryption demo.\n");
GrStringDrawCentered(&sContext, "Starting demo...", -1,
GrContextDpyWidthGet(&sContext) / 2, 140, false);
//
// Enable the uDMA module.
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UDMA);
//
// Setup the control table.
//
//.........这里部分代码省略.........
示例13: main
/*****************************************************************************
*
* This is the main loop that runs the application.
*
*****************************************************************************/
int main(void)
{
tRectangle sRect;
MMUConfigAndEnable();
/* Enable USB module clock */
USB0ModuleClkConfig();
/* configures arm interrupt controller to generate raster interrupt */
USBInterruptEnable();
/* LCD Back light setup */
LCDBackLightEnable();
/* UPD Pin setup */
UPDNPinControl();
/* Delay timer setup */
DelayTimerSetup();
/* Configures raster to display image */
SetUpLCD();
/* Configures raster to display image and Copy palette info into buffer */
LCDInit();
GrOffScreen24BPPInit(&g_s35_800x480x24Display, g_pucBuffer, LCD_WIDTH, LCD_HEIGHT);
/* Initialize a drawing context. */
GrContextInit(&g_sContext, &g_s35_800x480x24Display);
/* enable End of frame interrupt */
RasterEndOfFrameIntEnable(SOC_LCDC_0_REGS);
/* enable raster */
RasterEnable(SOC_LCDC_0_REGS);
/* Fill the top 24 rows of the screen with blue to create the banner. */
sRect.sXMin = 0;
sRect.sYMin = 0;
sRect.sXMax = GrContextDpyWidthGet(&g_sContext) - 1;
sRect.sYMax = (MAX_ROW_NUM - 1);
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_sFontCm20);
GrStringDrawCentered(&g_sContext, "usb-dev-composite", -1,
GrContextDpyWidthGet(&g_sContext) / 2, 10, 0);
/* Show the various static text elements on the color STN display. */
GrContextFontSet(&g_sContext, TEXT_FONT);
GrContextForegroundSet(&g_sContext, ClrViolet);
GrStringDraw(&g_sContext, "CDC Serial 1 :-", -1, CDC1_STR_X_POSITION,
CDC1_STR_Y_POSITION, false);
GrStringDraw(&g_sContext, "CDC Serial 2 :-", -1, CDC2_STR_X_POSITION,
CDC1_STR_Y_POSITION, false);
GrContextForegroundSet(&g_sContext, ClrWhite);
GrStringDraw(&g_sContext, "Tx bytes:", -1, CDC1_STR_X_POSITION,
(CDC1_STR_Y_POSITION + CDC_STR_Y_DIFF), false);
GrStringDraw(&g_sContext, "Tx buffer:", -1, CDC1_STR_X_POSITION,
(CDC1_STR_Y_POSITION + (CDC_STR_Y_DIFF * 2)), false);
GrStringDraw(&g_sContext, "Rx bytes:", -1, CDC1_STR_X_POSITION,
(CDC1_STR_Y_POSITION + (CDC_STR_Y_DIFF * 4)), false);
GrStringDraw(&g_sContext, "Rx buffer:", -1, CDC1_STR_X_POSITION,
(CDC1_STR_Y_POSITION + (CDC_STR_Y_DIFF * 5)), false);
DrawBufferMeter(&g_sContext, CDC1_BUF_METER_X_POS, CDC1_BUF_METER_Y_POS);
DrawBufferMeter(&g_sContext, CDC1_BUF_METER_X_POS,
(CDC1_BUF_METER_Y_POS + CDC_BUF_METER_Y_DIFF));
GrStringDraw(&g_sContext, "Tx bytes:", -1, CDC2_STR_X_POSITION,
(CDC2_STR_Y_POSITION + CDC_STR_Y_DIFF), false);
GrStringDraw(&g_sContext, "Tx buffer:", -1, CDC2_STR_X_POSITION,
(CDC2_STR_Y_POSITION + (CDC_STR_Y_DIFF * 2)), false);
GrStringDraw(&g_sContext, "Rx bytes:", -1, CDC2_STR_X_POSITION,
(CDC2_STR_Y_POSITION + (CDC_STR_Y_DIFF * 4)), false);
GrStringDraw(&g_sContext, "Rx buffer:", -1, CDC2_STR_X_POSITION,
(CDC2_STR_Y_POSITION + (CDC_STR_Y_DIFF * 5)), false);
DrawBufferMeter(&g_sContext, CDC2_BUF_METER_X_POS, CDC2_BUF_METER_Y_POS);
DrawBufferMeter(&g_sContext, CDC2_BUF_METER_X_POS,
//.........这里部分代码省略.........
示例14: main
//*****************************************************************************
//
// This example encrypts a block of payload using AES128 in CCM mode. It
// does the encryption first without uDMA and then with uDMA. The results
// are checked after each operation.
//
//*****************************************************************************
int
main(void)
{
uint32_t pui32CipherText[16], pui32Tag[4], ui32Errors, ui32Idx;
uint32_t ui32PayloadLength, ui32TagLength;
uint32_t ui32NonceLength, ui32AuthDataLength;
uint32_t *pui32Nonce, *pui32AuthData, ui32SysClock;
uint32_t *pui32Key, *pui32Payload, *pui32ExpCipherText;
uint32_t ui32Keysize;
uint8_t ui8Vector;
uint8_t *pui8ExpTag, *pui8Tag;
tContext sContext;
//
// Run from the PLL at 120 MHz.
//
ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
SYSCTL_OSC_MAIN |
SYSCTL_USE_PLL |
SYSCTL_CFG_VCO_480), 120000000);
//
// Configure the device pins.
//
PinoutSet();
//
// Initialize the display driver.
//
Kentec320x240x16_SSD2119Init(ui32SysClock);
//
// Initialize the graphics context.
//
GrContextInit(&sContext, &g_sKentec320x240x16_SSD2119);
//
// Draw the application frame.
//
FrameDraw(&sContext, "aes-ccm-encrypt");
//
// Show some instructions on the display
//
GrContextFontSet(&sContext, g_psFontCm20);
GrStringDrawCentered(&sContext, "Connect a terminal to", -1,
GrContextDpyWidthGet(&sContext) / 2, 60, false);
GrStringDrawCentered(&sContext, "UART0 (115200,N,8,1)", -1,
GrContextDpyWidthGet(&sContext) / 2, 80, false);
GrStringDrawCentered(&sContext, "for more information.", -1,
GrContextDpyWidthGet(&sContext) / 2, 100, false);
//
// Initialize local variables.
//
ui32Errors = 0;
for(ui32Idx = 0; ui32Idx < 16; ui32Idx++)
{
pui32CipherText[ui32Idx] = 0;
}
for(ui32Idx = 0; ui32Idx < 4; ui32Idx++)
{
pui32Tag[ui32Idx] = 0;
}
pui8Tag = (uint8_t *)pui32Tag;
//
// Enable stacking for interrupt handlers. This allows floating-point
// instructions to be used within interrupt handlers, but at the expense of
// extra stack usage.
//
ROM_FPUStackingEnable();
//
// Configure the system clock to run off the internal 16MHz oscillator.
//
MAP_SysCtlClockFreqSet(SYSCTL_OSC_INT | SYSCTL_USE_OSC, 16000000);
//
// Enable AES interrupts.
//
ROM_IntEnable(INT_AES0);
//
// Enable debug output on UART0 and print a welcome message.
//
ConfigureUART();
UARTprintf("Starting AES CCM encryption demo.\n");
GrStringDrawCentered(&sContext, "Starting demo...", -1,
GrContextDpyWidthGet(&sContext) / 2, 140, false);
//
// Enable the uDMA module.
//.........这里部分代码省略.........
示例15: UpdateStatus
//*****************************************************************************
//
// This function updates the status area of the screen. It uses the current
// state of the application to print the status bar.
//
//*****************************************************************************
void
UpdateStatus(char *pcString, bool bClrBackground)
{
tRectangle sRect;
//
//
//
GrContextBackgroundSet(&g_sContext, DISPLAY_BANNER_BG);
if(bClrBackground)
{
//
// Fill the bottom rows of the screen with blue to create the status area.
//
sRect.i16XMin = 0;
sRect.i16YMin = GrContextDpyHeightGet(&g_sContext) -
DISPLAY_BANNER_HEIGHT;
sRect.i16XMax = GrContextDpyWidthGet(&g_sContext) - 1;
sRect.i16YMax = sRect.i16YMin + DISPLAY_BANNER_HEIGHT - 1;
//
// Draw the background of the banner.
//
GrContextForegroundSet(&g_sContext, DISPLAY_BANNER_BG);
GrRectFill(&g_sContext, &sRect);
//
// Put a white box around the banner.
//
GrContextForegroundSet(&g_sContext, DISPLAY_BANNER_FG);
GrRectDraw(&g_sContext, &sRect);
}
else
{
//
// Fill the bottom rows of the screen with blue to create the status area.
//
sRect.i16XMin = 1;
sRect.i16YMin = GrContextDpyHeightGet(&g_sContext) -
DISPLAY_BANNER_HEIGHT + 1;
sRect.i16XMax = GrContextDpyWidthGet(&g_sContext) - 2;
sRect.i16YMax = sRect.i16YMin + DISPLAY_BANNER_HEIGHT - 3;
//
// Draw the background of the banner.
//
GrContextForegroundSet(&g_sContext, DISPLAY_BANNER_BG);
GrRectFill(&g_sContext, &sRect);
//
// White text in the banner.
//
GrContextForegroundSet(&g_sContext, DISPLAY_BANNER_FG);
}
//
// Write the current state to the left of the status area.
//
GrContextFontSet(&g_sContext, g_psFontFixed6x8);
//
// Update the status on the screen.
//
if(pcString != 0)
{
GrStringDrawCentered(&g_sContext, pcString,
-1, GrContextDpyWidthGet(&g_sContext) / 2,
58, 1);
}
}