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

📄 一些常用的c语言音响程序(5):收音头控制程序(有些难度) - enbia's blog.mht

📁 一些常用的C语言音响程序(5):收音头控制程序(有些难度)
💻 MHT
📖 第 1 页 / 共 5 页
字号:
From: <由 Microsoft Internet Explorer 5 保存>
Subject: =?gb2312?B?0rvQqbOj08O1xEPT79HU0vTP7LPM0PIoNSmjusrV0vTNt7/Y1sazzNDyKNPQ?=
	=?gb2312?B?0KnE0bbIKSAtIEVuYmlhJ3MgQmxvZw==?=
Date: Fri, 29 Jun 2007 03:41:33 +0800
MIME-Version: 1.0
Content-Type: multipart/related;
	type="text/html";
	boundary="----=_NextPart_000_00D1_01C7B9FF.63C9B130"
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028

This is a multi-part message in MIME format.

------=_NextPart_000_00D1_01C7B9FF.63C9B130
Content-Type: text/html;
	charset="utf-8"
Content-Transfer-Encoding: quoted-printable
Content-Location: http://www.enbia.com/blog/article.asp?id=21

=EF=BB=BF<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" =
"http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<HTML =
xmlns=3D"http://www.w3.org/1999/xhtml"><HEAD><TITLE>=E4=B8=80=E4=BA=9B=E5=
=B8=B8=E7=94=A8=E7=9A=84C=E8=AF=AD=E8=A8=80=E9=9F=B3=E5=93=8D=E7=A8=8B=E5=
=BA=8F(5)=EF=BC=9A=E6=94=B6=E9=9F=B3=E5=A4=B4=E6=8E=A7=E5=88=B6=E7=A8=8B=E5=
=BA=8F(=E6=9C=89=E4=BA=9B=E9=9A=BE=E5=BA=A6) - Enbia's Blog</TITLE>
<META http-equiv=3DContent-Type content=3D"text/html; charset=3Dutf-8">
<META content=3Dfollow,index name=3Drobots><LINK=20
href=3D"http://www.enbia.com/blog/styles/mulog/styles.css" =
type=3Dtext/css=20
rel=3Dstylesheet><LINK title=3D"Enbia's Blog"=20
href=3D"http://www.Enbia.com/blog/feed.asp" type=3Dapplication/rss+xml=20
rel=3Dalternate>
<SCRIPT language=3Djavascript =
src=3D"http://www.enbia.com/blog/common.js"=20
type=3Dtext/javascript></SCRIPT>

<META content=3D"MSHTML 6.00.2900.3059" name=3DGENERATOR></HEAD>
<BODY><!-- Shadows -->
<DIV class=3Ds1>
<DIV class=3Ds2>
<DIV class=3Ds3>
<DIV class=3Ds4>
<DIV class=3Ds5>
<DIV class=3Ds6>
<DIV class=3Ds7>
<DIV class=3Ds8><!-- Shadows -->
<DIV id=3Dwrapper>
<DIV id=3DinnerWrapper>
<DIV id=3Dheader>
<DIV id=3DinnerHeader>
<DIV id=3DblogLogo><A href=3D"http://www.enbia.com/blog/"><IMG =
id=3D"enbia's blog"=20
alt=3D"enbia's blog"=20
src=3D"http://www.enbia.com/blog/styles/mulog/images/logo.gif"></A></DIV>=

<DIV class=3Dblog-desc>A place to share knowledge, joy, =
dream......</DIV>
<DIV id=3Dmenu>
<UL>
  <LI><A href=3D"http://www.enbia.com/blog/default.asp">Index</A>=20
  <LI><A =
href=3D"http://www.enbia.com/blog/default.asp?selected=3Dtrue">Selected=20
  Content</A>=20
  <LI><A href=3D"http://www.enbia.com/blog/gbook.asp">Guestbook</A>=20
  <LI><A href=3D"javascript:showHideSidebar()">Toggle Sidebar</A>=20
  <LI><A href=3D"javascript:showLogin()">Login</A> =
</LI></UL></DIV></DIV></DIV>
<DIV id=3DmainWrapper>
<DIV class=3Dcontent id=3Dcontent>
<DIV id=3DinnerContent>
<DIV class=3Darticle-top>
<DIV class=3Dprev-article><A =
title=3D=E4=B8=80=E4=BA=9B=E5=B8=B8=E7=94=A8=E7=9A=84C=E8=AF=AD=E8=A8=80=E9=
=9F=B3=E5=93=8D=E7=A8=8B=E5=BA=8F(4)=EF=BC=9A=E9=9F=B3=E9=87=8F=E6=8E=A7=E5=
=88=B6M62446=20
href=3D"http://www.enbia.com/blog/article.asp?id=3D20">=C2=AB =
=E4=B8=80=E4=BA=9B=E5=B8=B8=E7=94=A8=E7=9A=84C=E8=AF=AD=E8=A8=80=E9=9F=B3=
=E5=93=8D...</A></DIV>
<DIV class=3Dnext-article><A =
title=3D=E6=97=A0=E7=BA=BF=E6=94=B6=E5=8F=91=E8=8A=AF=E7=89=87=E6=AF=94=E8=
=BE=83=E4=B8=8E=E9=80=89=E6=8B=A9=E2=80=94=E2=80=94CC1000=20
href=3D"http://www.enbia.com/blog/article.asp?id=3D23">=E6=97=A0=E7=BA=BF=
=E6=94=B6=E5=8F=91=E8=8A=AF=E7=89=87=E6=AF=94=E8=BE=83=E4=B8=8E... =
=C2=BB</A></DIV>
<DIV class=3Dcategory-label><A=20
href=3D"http://www.enbia.com/blog/default.asp?cat=3D1">Category:=20
=E6=8A=80=E6=9C=AF=E8=AE=BA=E5=9D=9B</A></DIV></DIV>
<DIV class=3Dtextbox>
<DIV class=3Dtextbox-title>
<H4>=E4=B8=80=E4=BA=9B=E5=B8=B8=E7=94=A8=E7=9A=84C=E8=AF=AD=E8=A8=80=E9=9F=
=B3=E5=93=8D=E7=A8=8B=E5=BA=8F(5)=EF=BC=9A=E6=94=B6=E9=9F=B3=E5=A4=B4=E6=8E=
=A7=E5=88=B6=E7=A8=8B=E5=BA=8F(=E6=9C=89=E4=BA=9B=E9=9A=BE=E5=BA=A6)</H4>=

<DIV class=3Dtextbox-label>[ 2006-01-19 16:39:27 | Author: <A=20
href=3D"http://www.enbia.com/blog/user.asp?act=3Dview&amp;id=3D1">Admin</=
A> ]=20
</DIV></DIV>
<DIV class=3Dtextbox-fontsize>Font Size: <A title=3D"Font Size: Large"=20
href=3D"javascript:setFontSize(14)">Large</A> | <A title=3D"Font Size: =
Medium"=20
href=3D"javascript:setFontSize(11)">Medium</A> | <A title=3D"Font Size: =
Small"=20
href=3D"javascript:setFontSize(9)">Small</A> </DIV>
<DIV class=3Dtextbox-content=20
id=3DtextboxContent>//---------------------------------------------------=
---------------------=20
/************************************************************************=
**<BR>//=20
Tuner, VER 1.0<BR>//<BR>// COPYRIGHT (C) 2002, Enbia Technology =
Inc.<BR>//=20
Target: 89C5X, PLL IC: LC72130/LC72130M&nbsp;&nbsp;<BR>// AUTHOR: STEVEN =

LUO<BR>// <BR>// Revision History:<BR>// &nbsp;&nbsp;2000/12/16 - =
Original=20
Version<BR>// 2001/4/3 - V2.0, ported to=20
RTX51TNY<BR>//<BR>//-----------------------------------------------------=
-------------------=20
<BR>#include &lt;reg51.h&gt;<BR>#include &lt;types.h&gt;<BR>#include=20
&lt;intrins.h&gt;<BR>#include &lt;rtx51tny.h&gt;<BR>#include=20
"tuner_int.h"<BR>#include=20
"dspenm.h"<BR><BR>//-----------------------------------------------------=
----------------------<BR>//=20
Tuner_Initialize<BR>//---------------------------------------------------=
------------------------<BR>void=20
Tuner_Initialize(void){<BR><BR>&nbsp;&nbsp;b_amstep =
&nbsp;&nbsp;&nbsp;&nbsp;=3D=20
Read_EEPROM(EE_AMSTEP) &amp; 0x01;<BR>&nbsp;&nbsp;band=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=3D Read_EEPROM(EE_BAND) &amp;=20
0x01;<BR><BR>&nbsp;&nbsp;cur_count[band] =3D Read_EEPROM(EE_CURCNT_LOW) =
+=20
Read_EEPROM(EE_CURCNT_HIGH) *=20
0x100;<BR><BR>&nbsp;&nbsp;Tuner_Set_Frequency_Int();<BR><BR>&nbsp;&nbsp;d=
wPLL_Shadow_IN2=20
|=3D BO2_ON; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//=20
Unmute<BR>&nbsp;&nbsp;Write_LC72131(MODE_IN1,=20
dwPLL_Shadow_IN1);&nbsp;&nbsp;<BR>&nbsp;&nbsp;Write_LC72131(MODE_IN2,=20
dwPLL_Shadow_IN2);&nbsp;&nbsp;<BR>}<BR><BR>//----------------------------=
-----------------------------------------------<BR>//=20
Tuner_Shutdown<BR>//-----------------------------------------------------=
----------------------<BR>void=20
Tuner_Shutdown(BOOL bonoff){<BR><BR>&nbsp;&nbsp;if=20
(bonoff){<BR>&nbsp;&nbsp;&nbsp;&nbsp;Write_LC72131(MODE_IN1, =
(dwPLL_Shadow_IN1=20
&amp; 0x0fffff) |=20
PLL_OFF_REF);&nbsp;&nbsp;<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;else{<BR>&nbsp;=
&nbsp;&nbsp;&nbsp;Write_LC72131(MODE_IN1,=20
dwPLL_Shadow_IN1);&nbsp;&nbsp;<BR>&nbsp;&nbsp;}<BR>}<BR><BR>//-----------=
----------------------------------------------------------------<BR>//=20
Tuner_Set_AMStep<BR>//---------------------------------------------------=
------------------------<BR>BOOL=20
Tuner_Set_AMStep(BYTE ctrl){<BR><BR>&nbsp;&nbsp;if (ctrl !=3D=20
INQUIRE){<BR>&nbsp;&nbsp;&nbsp;&nbsp;b_amstep =3D !=20
b_amstep;<BR>&nbsp;&nbsp;&nbsp;&nbsp;Write_EEPROM(EE_AMSTEP,=20
b_amstep);<BR>&nbsp;&nbsp;}<BR><BR>&nbsp;&nbsp;return=20
b_amstep;<BR>}<BR><BR>//-------------------------------------------------=
--------------------------<BR>//=20
Tuner_Set_FMStep<BR>//---------------------------------------------------=
------------------------<BR>BOOL=20
Tuner_Set_FMStep(BYTE ctrl){<BR><BR>&nbsp;&nbsp;if (ctrl !=3D=20
INQUIRE){<BR>&nbsp;&nbsp;&nbsp;&nbsp;b_fmstep =3D !=20
b_fmstep;<BR>&nbsp;&nbsp;}<BR><BR>&nbsp;&nbsp;return=20
b_fmstep;<BR>}<BR><BR>//-------------------------------------------------=
--------------------------<BR>//=20
Tuner_Set_Band<BR>//-----------------------------------------------------=
----------------------<BR>BYTE=20
Tuner_Set_Band(BYTE ctrl, WORD *freq){<BR><BR>&nbsp;&nbsp;if (ctrl !=3D=20
INQUIRE){<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;Temp_Mute(1);<BR><BR>&nbsp;&nbsp=
;&nbsp;&nbsp;if=20
(band !=3D BAND_AM) band =3D BAND_AM; else band =3D BAND_FM; =
&nbsp;&nbsp;// 0: am, 1:=20
fm<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;Write_EEPROM(EE_BAND,=20
band);<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;Tuner_Set_Frequency_Int=
();<BR>&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;dwPLL_Shadow_I=
N2=20
|=3D BO2_ON; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//=20
Unmute<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;Write_LC72131(MODE_IN1,=20
dwPLL_Shadow_IN1);&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;Write_LC72131(M=
ODE_IN2,=20
dwPLL_Shadow_IN2);&nbsp;&nbsp;<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;Temp_Mute(0=
);<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;*freq=20
=3D (Count_To_Freq());<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;return=20
band;<BR>}<BR><BR>//-----------------------------------------------------=
----------------------<BR>//=20
Tuner_Set_Mono<BR>//-----------------------------------------------------=
----------------------<BR>BOOL=20
Tuner_Set_Mono(BYTE ctrl){<BR><BR>&nbsp;&nbsp;if (ctrl !=3D=20
INQUIRE){<BR>&nbsp;&nbsp;&nbsp;&nbsp;Temp_Mute(1);<BR><BR>&nbsp;&nbsp;&nb=
sp;&nbsp;bST_MONO=20
=3D ! bST_MONO;<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;dwPLL_Shadow_IN2 &amp;=3D =
~BO3_ON;=20
<BR>&nbsp;&nbsp;&nbsp;&nbsp;if (bST_MONO) {dwPLL_Shadow_IN2 |=3D=20
BO3_ON;}&nbsp;&nbsp;&nbsp;&nbsp;//=20
Stereo<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;//&nbsp;&nbsp;Write_LC72131(MODE_IN=
1,=20
dwPLL_Shadow_IN1);&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;Write_LC72131(M=
ODE_IN2,=20
dwPLL_Shadow_IN2);&nbsp;&nbsp;<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;Temp_Mute(0=
);<BR>&nbsp;&nbsp;}<BR><BR>&nbsp;&nbsp;return=20
bST_MONO;<BR>}<BR><BR>//-------------------------------------------------=
--------------------------<BR>//=20
Tuner_Save_Station<BR>//-------------------------------------------------=
--------------------------<BR>void=20
Tuner_Save_Station(BYTE station){<BR>BYTE ee_addr;<BR><BR>&nbsp;&nbsp;if =

(station &gt; MAX_PRESET_NUMBER) station =3D MAX_PRESET_NUMBER;=20
<BR><BR>&nbsp;&nbsp;ee_addr =3D EE_PRESET_BASE + band * =
(MAX_PRESET_NUMBER + 1) *=20
2 + station *2;<BR><BR>&nbsp;&nbsp;Write_EEPROM(ee_addr, =
cur_count[band]/0x100);=20
Write_EEPROM(ee_addr +1,=20
cur_count[band]&amp;0xff);<BR>}<BR><BR>//--------------------------------=
-------------------------------------------<BR>//=20
Tuner_Restore_Station<BR>//----------------------------------------------=
-----------------------------<BR>WORD=20
Tuner_Restore_Station(BYTE station){<BR>BYTE=20
ee_addr;<BR><BR>&nbsp;&nbsp;Temp_Mute(1);<BR><BR>&nbsp;&nbsp;if (station =
&gt;=20
MAX_PRESET_NUMBER) station =3D MAX_PRESET_NUMBER; =
<BR><BR>&nbsp;&nbsp;ee_addr =3D=20
EE_PRESET_BASE + band * (MAX_PRESET_NUMBER + 1) * 2 + station=20
*2;<BR><BR>&nbsp;&nbsp;cur_count[band]=3D Read_EEPROM(ee_addr) * 0x100 + =

Read_EEPROM(ee_addr=20
+1);<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;Tuner_Set_Frequency_Int();<BR><BR>&nb=
sp;&nbsp;dwPLL_Shadow_IN2=20
|=3D BO2_ON; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//=20
Unmute<BR>&nbsp;&nbsp;Write_LC72131(MODE_IN1,=20
dwPLL_Shadow_IN1);&nbsp;&nbsp;<BR>&nbsp;&nbsp;Write_LC72131(MODE_IN2,=20
dwPLL_Shadow_IN2);&nbsp;&nbsp;<BR><BR>&nbsp;&nbsp;// save the current=20
count<BR>&nbsp;&nbsp;Write_EEPROM(EE_CURCNT_LOW, cur_count[band] &amp; =
0xff);=20
Write_EEPROM(EE_CURCNT_HIGH, cur_count[band] &gt;&gt;=20
8);<BR><BR>&nbsp;&nbsp;Temp_Mute(0);<BR><BR>&nbsp;&nbsp;return=20
(Count_To_Freq());<BR>}<BR><BR>//----------------------------------------=
-----------------------------------<BR>//=20
Tuner_Set_Frequency<BR>//------------------------------------------------=
---------------------------<BR>WORD=20
Tuner_Set_Frequency(BYTE ctrl, WORD freq){<BR>BAND_INFO code=20
*pBInfo;<BR><BR>&nbsp;&nbsp;switch(band){<BR>&nbsp;&nbsp;&nbsp;&nbsp;case=
=20
BAND_AM:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (b_amstep) pBInfo =3D =

&amp;BandInfo_AM_10KHz; else pBInfo =3D &amp;BandInfo_AM_9KHz;=20
break;<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;case=20
BAND_FM:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (b_fmstep) pBInfo =3D =

&amp;BandInfo_FM_100KHz; else pBInfo =3D &amp;BandInfo_FM_50KHz;=20
break;<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;case=20
BAND_SW:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<BR>&nbsp;&nbsp;}<B=
R><BR>&nbsp;&nbsp;switch=20
(ctrl){<BR>&nbsp;&nbsp;&nbsp;&nbsp;case=20
INQUIRE:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return =
(Count_To_Freq());=20
break;<BR>&nbsp;&nbsp;&nbsp;&nbsp;case=20
UP:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cur_count[band] +=3D pBInfo =
-&gt;=20
CntStep; break;<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;case=20
DOWN:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cur_count[band] -=3D pBInfo =
-&gt;=20
CntStep; break;<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;case=20
SET:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ((band =3D=3D BAND_AM) || =
(band =3D=3D=20
BAND_SW)){<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//return=20
cur_count[band] * pBInfo -&gt; FRef -=20
450;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cur_count[band] =
=3D (freq=20
+ 450) / (pBInfo -&gt;=20
FRef);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;else=20
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//return =
cur_count[band] *=20
((FM_FREF *100)/1000) -=20
1070;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cur_count[band] =

⌨️ 快捷键说明

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