📄 rfid_sound.c
字号:
// $Id: rfid_Sound.c,v 1.1 2006/09/25 22:08:15 tprescott Exp $
/*****************************************************
Project : rfid_Sound.c
Date : 9/08/2006
Author : Toby Prescott
Company : Atmel
Comments: AVR Studio GCC
Revisions:
v1.0 - Started written for CodeVision
v2.6 - Clean for WinAVR
*****************************************************/
#include "rfid_Sound.h"
unsigned char soundState EEMEM = 1; // Sound On/Off flag
// *******************************************************************************
// * Routine to create a beep using piezo element
// *******************************************************************************
void snd_Play(unsigned char sFreq1, unsigned char sFreq0, unsigned char sTimeLength)
{
unsigned char i,j,k;
if(eeprom_read_byte(&soundState) == 1) // If sound flag = on
{
DDRB |= 0x80; // Set I/O to output
for(i=0; i<sTimeLength; i++) // Loop for beep time
{
PORTB &= ~0x80; // Turn piezo current on
for(j=0; j<sFreq1; j++){for(k=0; k<sFreq1; k++){;}} // Wait for sound count to reach value
PORTB |= 0x80; // Turn piezo current off
for(j=0; j<sFreq0; j++){for(k=0; k<sFreq0; k++){;}} // Wait for sound count to reach value
}
DDRB &= ~0x80; // Set I/O to input
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -