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

📄 tonegen.c

📁 sharp的arm920t 7A400的评估板附带光盘Sharp KEVLH7A400 v0.3b Welcome to the SHARP KEV7A400 Evaluation board
💻 C
字号:
 /*****************************************************************************
 *	$Workfile:   tonegen.c  $
 *	$Revision:   1.0  $
 *	$Author:   WellsK  $
 *	$Date:   Sep 22 2002 11:00:24  $
 *
 *	Project: Buzzer example
 *
 *	Description:
 *    Uses the BUZZ output to drive the speaker output. BUZZ is tied to the
 *    overflow state of timer 1.
 * *
 *	Revision History:
 *	$Log:   //smaicnt2/pvcs/VM/CDROM/archives/KEV7A400/Software/Examples/tonegen/tonegen.c-arc  $
 * 
 *    Rev 1.0   Sep 22 2002 11:00:24   WellsK
 * Initial revision.
 * 
 * 
 *	COPYRIGHT (C) 2001 SHARP MICROELECTRONICS OF THE AMERICAS, INC.
 *		CAMAS, WA
 ****************************************************************************/

#include "SMA_colors.h"
#include "SMA_types.h"
#include "SMA_swim.h"
#include "SMA_swim_font.h"
#include "SMA_lcd_driver.h"
#include "LH7A400_lcd_private.h"
#include "KEV7A400_LQ039Q2DS53.h"
#include "LH7A400_cp15_driver.h"
#include "LH7A400_EVB_CPLD_driver.h"
#include "LH7A400_timer_driver.h"

// Logical address of frame buffer (well into SDRAM)
__align (4) static color_type fb [320 * 240];

void wait_for_press (void)
{
    volatile UNS_8 pb;
    INT_32 i;

    // Wait for depress first
    pb = LH7A400_pld_get_pb ();
    while (pb == 0)
    {
        // This small loop prevents the bus from getting hammered
        for (i = 0; i < 1000; i++);

        pb = LH7A400_pld_get_pb ();
    }

    // Now, wait for a press state
    while (pb != 0)
    {
        // This small loop prevents the bus from getting hammered
        for (i = 0; i < 1000; i++);

        pb = LH7A400_pld_get_pb ();
    }
}

int main (void)
{
    INT_32 maxx, maxy;
    INT_32 win;

    // Initialize timer 1
    timer_init (TIMER1);

    // Init LCD driver for '53 display
    lcd_initialize (&KEV7A400_LQ039Q2DS53,
        (void *) LH7A400_cp15_map_virtual_to_physical ((void *) fb));

    // Get horiz and vert size of display from driver
    maxx = (INT_32) lcd_get_xsize ();
    maxy = (INT_32) lcd_get_ysize ();

    // Enable the LCD power and LCD signal buffers
    lcd_disable_enable (1);

    // Turn on the LCD backlight to full brightness
    lcd_set_backlight_intens (lcd_get_max_intens ());

    // Setup SWIM window
    win = swim_window_open (maxx, maxy, fb, 0, 0, (maxx - 1),
        (maxy - 1), 1, WHITE, BLACK, WHITE, 1);

    swim_put_ltext (win, "Buzzer tone generator example!!\n\n");

    swim_put_ltext (win, "A few tones will be output from the speaker on ");
    swim_put_ltext (win, "the EVB.\n\n");

    swim_put_ltext (win, "To use this demo, make sure the following jumpers ");
    swim_put_ltext (win, "set in the following states to enable the buzzer. ");
    swim_put_ltext (win, "If they are not set in these states, power off the ");
    swim_put_ltext (win, "EVB and change them to the correct state to hear ");
    swim_put_ltext (win, "sound.\n\n");

    swim_put_ltext (win, "Jumper JP9 set to pins 2-3 (BUZZ output)\n");
    swim_put_ltext (win, "Jumper JP10 set to open (AMP enabled)\n");

    // Wait for a button to be pressed from the user
    swim_put_ltext (win, "Press any button to continue (SW10 - SW17)\n");

    wait_for_press ();
    
    swim_put_ltext (win, "Tone 1 - 1000Hz\n");
    buzzer_squarewave_start (1000);
    swim_put_ltext (win, "Press any button for next tone.\n");
    wait_for_press ();

    swim_put_ltext (win, "Tone 2 - 4000Hz\n");
    buzzer_squarewave_start (250);
    swim_put_ltext (win, "Press any button for next tone.\n");
    wait_for_press ();

    swim_put_ltext (win, "Tone 3 - 8000Hz\n");
    buzzer_squarewave_start (125);
    swim_put_ltext (win, "Press any button to stop.\n");
    wait_for_press ();
    
    buzzer_squarewave_stop ();

    return 1;
 }
 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -