⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qs_ek-lm3s2965_revc.c

📁 最新版IAR FOR ARM(EWARM)5.11中的代码例子
💻 C
📖 第 1 页 / 共 2 页
字号:
            unsigned long ulHeight, unsigned long ulDelay)
{
    unsigned char *pucDest, ucHigh, ucLow;
    unsigned long ulLoop1, ulLoop2;
    const unsigned char *pucSrc;
    long lIdx;

    //
    // Loop through thirty two intensity levels to fade the logo in from black.
    //
    for(lIdx = 1; lIdx <= 32; 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);
    }

    //
    // 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)
{
    //
    // 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_8);

    //
    // Get the system clock speed.
    //
    g_ulSystemClock = SysCtlClockGet();

    //
    // Enable the peripherals used by the application.
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);

    //
    // Configure the GPIOs used to read the state of the on-board push buttons.
    //
    GPIOPinTypeGPIOInput(GPIO_PORTF_BASE,
                         GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7);
    GPIOPadConfigSet(GPIO_PORTF_BASE,
                     GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7,
                     GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
    GPIOPinTypeGPIOInput(GPIO_PORTG_BASE, GPIO_PIN_4);
    GPIOPadConfigSet(GPIO_PORTG_BASE, GPIO_PIN_4, 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_PORTG_BASE, GPIO_PIN_3);
    GPIOPinTypeGPIOOutput(GPIO_PORTG_BASE, GPIO_PIN_2);
    GPIOPinWrite(GPIO_PORTG_BASE, GPIO_PIN_2, 0);

    //
    // Initialize the CAN controller.
    //
    CANConfigure();

    //
    // 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 PWM for generating music and sound effects.
    //
    AudioOn();

    //
    // Configure SysTick to periodically interrupt.
    //
    SysTickPeriodSet(g_ulSystemClock / CLOCK_RATE);
    SysTickIntEnable();
    SysTickEnable();

    //
    // Delay for a bit to allow the initial display flash to subside.
    //
    Delay(CLOCK_RATE / 4);

    //
    // Play the intro music.
    //
    AudioPlaySong(g_pusIntro, sizeof(g_pusIntro) / 2);

    //
    // 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

    //
    // 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 + -