📄 qs_ek-lm3s1968.c
字号:
//
// Get a point to the upper left corner of the frame buffer where the
// logo will be placed.
//
pucDest = (g_pucFrame + (((96 - ulHeight) / 2) * 64) +
((128 - ulWidth) / 4));
//
// Copy the logo into the frame buffer, scaling the intensity. Loop
// over the rows.
//
for(ulLoop1 = 0; ulLoop1 < ulHeight; ulLoop1++)
{
//
// Loop over the columns.
//
for(ulLoop2 = 0; ulLoop2 < (ulWidth / 2); ulLoop2++)
{
//
// Get the two nibbles of the next byte from the source.
//
ucHigh = pucSrc[ulLoop2] >> 4;
ucLow = pucSrc[ulLoop2] & 15;
//
// Scale the intensity of the two nibbles.
//
ucHigh = ((unsigned long)ucHigh * lIdx) / 32;
ucLow = ((unsigned long)ucLow * lIdx) / 32;
//
// Write the two nibbles to the frame buffer.
//
pucDest[ulLoop2] = (ucHigh << 4) | ucLow;
}
//
// Increment to the next row of the source and destination.
//
pucSrc += (ulWidth / 2);
pucDest += 64;
}
//
// Wait until an update has been requested.
//
while(HWREGBITW(&g_ulFlags, FLAG_UPDATE) == 0)
{
}
//
// Clear the update request flag.
//
HWREGBITW(&g_ulFlags, FLAG_UPDATE) = 0;
//
// Display the local frame buffer on the display.
//
RIT128x96x4ImageDraw(g_pucFrame, 0, 0, 128, 96);
}
//
// Delay for the specified time while the logo is displayed.
//
Delay(ulDelay);
//
// Loop through the thirty two intensity levels to face the logo back to
// black.
//
for(lIdx = 31; lIdx >= 0; lIdx--)
{
//
// Clear the local frame buffer.
//
for(ulLoop1 = 0; ulLoop1 < sizeof(g_pucFrame); ulLoop1 += 4)
{
*(unsigned long *)(g_pucFrame + ulLoop1) = 0;
}
//
// Get a pointer to the beginning of the logo.
//
pucSrc = pucLogo;
//
// Get a point to the upper left corner of the frame buffer where the
// logo will be placed.
//
pucDest = (g_pucFrame + (((96 - ulHeight) / 2) * 64) +
((128 - ulWidth) / 4));
//
// Copy the logo into the frame buffer, scaling the intensity. Loop
// over the rows.
//
for(ulLoop1 = 0; ulLoop1 < ulHeight; ulLoop1++)
{
//
// Loop over the columns.
//
for(ulLoop2 = 0; ulLoop2 < (ulWidth / 2); ulLoop2++)
{
//
// Get the two nibbles of the next byte from the source.
//
ucHigh = pucSrc[ulLoop2] >> 4;
ucLow = pucSrc[ulLoop2] & 15;
//
// Scale the intensity of the two nibbles.
//
ucHigh = ((unsigned long)ucHigh * lIdx) / 32;
ucLow = ((unsigned long)ucLow * lIdx) / 32;
//
// Write the two nibbles to the frame buffer.
//
pucDest[ulLoop2] = (ucHigh << 4) | ucLow;
}
//
// Increment to the next row of the source and destination.
//
pucSrc += (ulWidth / 2);
pucDest += 64;
}
//
// Wait until an update has been requested.
//
while(HWREGBITW(&g_ulFlags, FLAG_UPDATE) == 0)
{
}
//
// Clear the update request flag.
//
HWREGBITW(&g_ulFlags, FLAG_UPDATE) = 0;
//
// Display the local frame buffer on the display.
//
RIT128x96x4ImageDraw(g_pucFrame, 0, 0, 128, 96);
}
}
//*****************************************************************************
//
// 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)
{
unsigned char bSkipIntro;
//
// If running on Rev A2 silicon, turn the LDO voltage up to 2.75V. This is
// a workaround to allow the PLL to operate reliably.
//
if(DEVICE_IS_REVA2)
{
SysCtlLDOSet(SYSCTL_LDO_2_75V);
}
//
// Set the clocking to run at 50MHz from the PLL.
//
SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_8MHZ);
SysCtlPWMClockSet(SYSCTL_PWMDIV_1);
//
// Get the system clock speed.
//
g_ulSystemClock = SysCtlClockGet();
//
// Enable the peripherals used by the application.
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOH);
SysCtlPeripheralEnable(SYSCTL_PERIPH_HIBERNATE);
SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM);
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
//
// Configure the GPIOs used to read the state of the on-board push buttons.
//
GPIOPinTypeGPIOInput(GPIO_PORTG_BASE,
GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 |
GPIO_PIN_7);
GPIOPadConfigSet(GPIO_PORTG_BASE,
GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 |
GPIO_PIN_7, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
//
// Configure the LED, speaker, and UART GPIOs as required.
//
GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
GPIOPinTypePWM(GPIO_PORTH_BASE, GPIO_PIN_1);
GPIOPinTypeGPIOOutput(GPIO_PORTG_BASE, GPIO_PIN_2);
GPIOPinWrite(GPIO_PORTG_BASE, GPIO_PIN_2, 0);
//
// Check to see if this is a wake from hibernation. If so, then skip past
// the introductory audio and splash screen.
//
if(HibernateIsActive() && (HibernateIntStatus(0) & HIBERNATE_INT_PIN_WAKE))
{
bSkipIntro = 1;
}
else
{
bSkipIntro = 0;
}
//
// Initialize the Hibernation module, which is used for storing the high
// score.
//
HibernateEnableExpClk(SysCtlClockGet());
HibernateClockSelect(HIBERNATE_CLOCK_SEL_DIV128);
//
// Configure the first UART for 115,200, 8-N-1 operation.
//
UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 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, 'W');
UARTCharPut(UART0_BASE, 'e');
UARTCharPut(UART0_BASE, 'l');
UARTCharPut(UART0_BASE, 'c');
UARTCharPut(UART0_BASE, 'o');
UARTCharPut(UART0_BASE, 'm');
UARTCharPut(UART0_BASE, 'e');
UARTCharPut(UART0_BASE, '\r');
UARTCharPut(UART0_BASE, '\n');
//
// Initialize the OSRAM OLED display.
//
RIT128x96x4Init(3500000);
//
// Initialize the Class-D audio driver.
//
ClassDInit(g_ulSystemClock);
//
// Wait until the Class-D audio driver has completed its startup.
//
while(ClassDBusy())
{
}
//
// Configure SysTick to periodically interrupt.
//
SysTickPeriodSet(g_ulSystemClock / CLOCK_RATE);
SysTickIntEnable();
SysTickEnable();
//
// If this is a wake from hibernation, then skip the splash screen and
// audio.
//
if(!bSkipIntro)
{
//
// Delay for a bit to allow the initial display flash to subside.
//
Delay(CLOCK_RATE / 4);
//
// Play the intro music.
//
ClassDPlayADPCM(g_pucIntro, sizeof(g_pucIntro));
//
// Display the Luminary Micro logo for five seconds.
//
DisplayLogo(g_pucLMILogo, 120, 42, 5 * CLOCK_RATE);
//
// Display the Keil/ARM logo for five seconds.
//
#if defined(rvmdk) || defined(__ARMCC_VERSION)
DisplayLogo(g_pucKeilLogo, 128, 40, 5 * CLOCK_RATE);
#endif
//
// Display the IAR logo for five seconds.
//
#if defined(ewarm)
DisplayLogo(g_pucIarLogo, 102, 61, 5 * CLOCK_RATE);
#endif
//
// Display the CodeSourcery logo for five seconds.
//
#if defined(gcc) || defined(sourcerygxx)
DisplayLogo(g_pucCodeSourceryLogo, 128, 34, 5 * CLOCK_RATE);
#endif
}
//
// Set bit for select switch, to make sure that the button press to wake
// does not start the game. This will require the button to be released,
// then pressed in order to start the game.
//
g_ucSwitches &= ~0x10;
//
// 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 + -