📄 qs_ev-lm3s811.c
字号:
//
// Loop over the columns of the logo.
//
for(ulLoop = 0; ulLoop < ulWidth; ulLoop++)
{
//
// Copy 8 - N scan lines from the first row of the logo and
// N scan lines from the second row of the logo to the first
// row of the local frame buffer.
//
g_pucFrame[ulX + ulLoop] =
((pucLogo[ulLoop] >> ulBit) |
(pucLogo[ulLoop + ulWidth] << (8 - ulBit)));
//
// Copy 8 - N scan lines from the second row of the logo to the
// second row of the local frame buffer.
//
g_pucFrame[ulX + ulLoop + 96] = (pucLogo[ulLoop + ulWidth] >>
ulBit);
}
}
else
{
//
// Loop over the columns of the logo.
//
for(ulLoop = 0; ulLoop < ulWidth; ulLoop++)
{
//
// Copy 16 - N scan lines of of the second row of the logo to
// the first row of the local frame buffer.
//
g_pucFrame[ulX + ulLoop] = (pucLogo[ulLoop + ulWidth] >>
(ulBit - 8));
}
}
//
// Display the local frame buffer on the display.
//
OSRAMImageDraw(g_pucFrame, 0, 0, 96, 2);
//
// Wait for a twentieth of a second.
//
for(ulLoop = 0; ulLoop < (CLOCK_RATE / 20); ulLoop++)
{
//
// Wait until a SysTick interrupt has occurred.
//
while(!HWREGBITW(&g_ulFlags, FLAG_CLOCK_TICK))
{
}
//
// Clear the SysTick interrupt flag.
//
HWREGBITW(&g_ulFlags, FLAG_CLOCK_TICK) = 0;
}
}
}
//*****************************************************************************
//
// Scrolls a wide image across the display.
//
//*****************************************************************************
static void
ScrollImage(const unsigned char *pucImage, unsigned long ulWidth)
{
unsigned long ulLoop, ulIdx;
//
// Loop over the columns of the image plus the columns of the display,
// scrolling the image across the dipslay from right to left one column at
// a time.
//
for(ulIdx = 1; ulIdx <= (ulWidth + 96); ulIdx++)
{
//
// Clear the local frame buffer.
//
for(ulLoop = 0; ulLoop < 192; ulLoop += 4)
{
*(unsigned long *)(g_pucFrame + ulLoop) = 0;
}
//
// See if the image has reached the left side of the display.
//
if(ulIdx <= 96)
{
//
// Copy the first N columns of the image to the right side of the
// local frame buffer.
//
for(ulLoop = 0; ulLoop < ulIdx; ulLoop++)
{
g_pucFrame[ulLoop + 96 - ulIdx] = pucImage[ulLoop];
g_pucFrame[ulLoop + 96 - ulIdx + 96] =
pucImage[ulLoop + ulWidth];
}
}
//
// See if the right side of the image has reached the right side of the
// display.
//
else if(ulIdx < ulWidth)
{
//
// Copy 96 columns from the middle of the image to the local frame
// buffer.
//
for(ulLoop = 0; ulLoop < 96; ulLoop++)
{
g_pucFrame[ulLoop] = pucImage[ulLoop + ulIdx - 96];
g_pucFrame[ulLoop + 96] =
pucImage[ulLoop + ulIdx - 96 + ulWidth];
}
}
//
// Otherwise, the right side of the image has already reached the right
// side of the display.
//
else
{
//
// Copy the right N columns of the image to the left side of the
// local frame buffer.
//
for(ulLoop = 0; ulLoop < (ulWidth + 96 - ulIdx); ulLoop++)
{
g_pucFrame[ulLoop] = pucImage[ulLoop + ulIdx - 96];
g_pucFrame[ulLoop + 96] =
pucImage[ulLoop + ulIdx - 96 + ulWidth];
}
}
//
// Display the local frame buffer on the display.
//
OSRAMImageDraw(g_pucFrame, 0, 0, 96, 2);
//
// Wait for a thirtieth of a second.
//
for(ulLoop = 0; ulLoop < (CLOCK_RATE / 30); ulLoop++)
{
//
// Wait until a SysTick interrupt has occurred.
//
while(!HWREGBITW(&g_ulFlags, FLAG_CLOCK_TICK))
{
}
//
// Clear the SysTick interrupt flag.
//
HWREGBITW(&g_ulFlags, FLAG_CLOCK_TICK) = 0;
}
}
}
//*****************************************************************************
//
// The main code for the application. It sets up the peripherals, displays the
// splash screens, and then manages the interaction between the game and the
// screen saver.
//
//*****************************************************************************
int
main(void)
{
//
// Set the clocking to run at 20MHz from the PLL.
//
SysCtlClockSet(SYSCTL_SYSDIV_10 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_6MHZ);
//
// Enable the peripherals used by the application.
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
//
// Configure the ADC to sample the potentiometer when the timer expires.
// After sampling, the ADC will interrupt the processor; this is used as
// the heartbeat for the game.
//
ADCSequenceConfigure(ADC_BASE, 0, ADC_TRIGGER_TIMER, 0);
ADCSequenceStepConfigure(ADC_BASE, 0, 0,
ADC_CTL_CH0 | ADC_CTL_IE | ADC_CTL_END);
ADCSequenceEnable(ADC_BASE, 0);
ADCIntEnable(ADC_BASE, 0);
IntEnable(INT_ADC0);
//
// Configure the first timer to generate a 10 kHz PWM signal for driving
// the user LED.
//
TimerConfigure(TIMER0_BASE, TIMER_CFG_16_BIT_PAIR | TIMER_CFG_B_PWM);
TimerLoadSet(TIMER0_BASE, TIMER_B, (SysCtlClockGet() / 10000) - 1);
TimerMatchSet(TIMER0_BASE, TIMER_B, 0);
TimerControlLevel(TIMER0_BASE, TIMER_B, true);
TimerEnable(TIMER0_BASE, TIMER_B);
//
// Configure the second timer to generate triggers to the ADC to sample the
// potentiometer.
//
TimerConfigure(TIMER1_BASE, TIMER_CFG_32_BIT_PER);
TimerLoadSet(TIMER1_BASE, TIMER_A, SysCtlClockGet() / 120);
TimerControlStall(TIMER1_BASE, TIMER_A, true);
TimerControlTrigger(TIMER1_BASE, TIMER_A, true);
TimerEnable(TIMER1_BASE, TIMER_A);
//
// Configure the LED, push button, and UART GPIOs as required.
//
GPIODirModeSet(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1, GPIO_DIR_MODE_HW);
GPIODirModeSet(GPIO_PORTC_BASE, PUSH_BUTTON, GPIO_DIR_MODE_IN);
GPIODirModeSet(GPIO_PORTC_BASE, USER_LED, GPIO_DIR_MODE_OUT);
GPIOPinWrite(GPIO_PORTC_BASE, USER_LED, 0);
//
// Configure the first UART for 115,200, 8-N-1 operation.
//
UARTConfigSet(UART0_BASE, 115200,
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
UART_CONFIG_PAR_NONE));
UARTEnable(UART0_BASE);
//
// Send a welcome message to the UART.
//
UARTCharPut(UART0_BASE, 'L');
UARTCharPut(UART0_BASE, 'M');
UARTCharPut(UART0_BASE, '3');
UARTCharPut(UART0_BASE, 'S');
UARTCharPut(UART0_BASE, '8');
UARTCharPut(UART0_BASE, '1');
UARTCharPut(UART0_BASE, '1');
UARTCharPut(UART0_BASE, '\r');
UARTCharPut(UART0_BASE, '\n');
//
// Initialize the OSRAM OLED display.
//
OSRAMInit(true);
//
// Display the Luminary Micro logo for five seconds.
//
DisplayLogo(g_pucLMILogo, 6, 83, 5 * CLOCK_RATE);
//
// Display the Keil/ARM logo for five seconds.
//
DisplayLogo(g_pucKeilLogo, 10, 76, 5 * CLOCK_RATE);
//
// Scroll the design contest image.
//
ScrollImage(g_pucDesignLogo, 300);
//
// Throw away any button presses that may have occurred while the splash
// screens were being displayed.
//
HWREGBITW(&g_ulFlags, FLAG_BUTTON_PRESS) = 0;
//
// Loop forever.
//
while(1)
{
//
// Display the main screen.
//
if(MainScreen())
{
//
// The button was pressed, so start the game.
//
PlayGame();
}
else
{
//
// The button was not pressed during the timeout period, so start
// the screen saver.
//
ScreenSaver();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -