;
文章:行业新闻EDA文摘电源技术无线通信测量仪表嵌入式类电子技术制造技术半导体网络/协议展会实验家电维修  
  下载:EDA教程电源技术电子书籍电子元件无线通信通信网络电路图纸嵌入式类单片机传感/控制电子教材模拟数字
.... 音视频类
消费电子机械电子行业软件C/C++FPGA/ASIC规则标准家电维修DSPIC资料ARM软件电路图电子技术论坛
 
位置:电子发烧友 > 行业新闻 > 电子技术 > 电路图 > IC应用电路图 >音量控制M62446的驱动C程序 退出登录 用户管理
栏目导航


· 保护电路图 · 嵌入式类电子电路图
· 电源技术电子电路图 · 无线通信电子电路图
· 光电隔离电子电路图 · 光电开关电子电路图
· 信号处理电子电路图 · 消费类电子电路图
· 照明灯电路图 · 光电报警电子电路图
· 耳机电路图 · 电动机控制电路图
· 功率放大器电路图 · 汽车电路图
· 遥控电路图 · 电工基础电路图
· 电工仪表电路图 · 可控硅电路图
· 彩灯电路图 · IC应用电路图
· 电视机电路图 · 555集成电路大全
· 运算放大器电路 · 电子管功放电路
· 定时器电路图 · 温控电路图
· 供水电路图 · 洗碗机电路图
· 消毒柜电路图 · 热水器电路图
· 电饭锅电路图
热门文章
· [组图] 电子元器件基础知识...
· [图文] USB接口定义
· [图文] 三极管开关电路图
· [组图] RS232 RS485接口原理...
· [组图] [组图]电动车充电器...
· [组图] 电子捕鱼器电路图
· [组图] 高品质音调电路的制...
· [组图] JRC4558电路
· [图文] M51134P低音炮电路图...
· [图文] TL494脉宽调制控制电...
相关文章

· 6*128 LED点阵屏C程...
· DS18B20 MSP430 C程...
· lc72130的应用C程序...
· [图文] 用于MAX7456随屏显示...
· [图文] 用于MAX7456随屏显示...
· cs5550 c程序
· ht1621 c程序
· x5045 c程序-x5045读...
· max7219显示程序-C程...
· 单片机12864 c程序

音量控制M62446的驱动C程序
作者:佚名  来源:不详  发布时间:2008-7-7 17:48:49 减小字体 增大字体

音量控制M62446的驱动C程序
音量控制M62446 m62446 pdf
//-------------------------------------------------------------------------
// M62446 drving routines, VER 1.0
//
// COPYRIGHT (C) 2000, Enbia Technology Inc.
// Target: 8031
// AUTHOR: STEVEN LUO
//
// Revision History:
// 2001/1/5 - Original Version
//
//-------------------------------------------------------------------------
#include <reg51.h>
#include <types.h>
#include <intrins.h>
#include <bin.h>
extern BOOL PIN_M62446_LATCH;
extern BOOL PIN_M62446_DATA;
extern BOOL PIN_M62446_CLK;
static idata WORD shadow_word00=0;
static idata WORD shadow_word01=0;
static idata WORD shadow_word10=0;
static idata WORD shadow_word11=0; // for storing the control word status //
static BOOL bM62446Muted; // Set when 62446 is muted
static void Write_M62446_Word(WORD myword);
//-------------------------------------------------------------------------
// Name: Volume_Validate
// Description:
// Arguments:
// Return value: none
//-------------------------------------------------------------------------
static BYTE Volume_Validate(char vol){
if(vol<0)vol=0; // negative, should be 0
else if(vol >80) vol=80; // >80, set to 80
return 80 - vol; // Down to Up
}
//-------------------------------------------------------------------------
// Name: Mute_M62446
// Description:
// Arguments:
// Return value: none
//-------------------------------------------------------------------------
void Mute_M62446(void){
Write_M62446_Word(0xa141); // B1010000 1010000 01, B10100001_01000001
Write_M62446_Word(0xa142);
Write_M62446_Word(0xa143);
bM62446Muted = 1;
}
//-------------------------------------------------------------------------
// Name: UnMute_M62446
// Description:
// Arguments:
// Return value: none
//-------------------------------------------------------------------------
void UnMute_M62446(void){
shadow_word01&=0xfffc; shadow_word01|=0x01; Write_M62446_Word(shadow_word01);
shadow_word10&=0xfffc; shadow_word10|=0x02; Write_M62446_Word(shadow_word10);
shadow_word11&=0xfffc; shadow_word11|=0x03; Write_M62446_Word(shadow_word11);
bM62446Muted = 0;
}
//-------------------------------------------------------------------------
// Name: Write_M62446_Left
// Description: This function Write 2 bytes to M62446
// Arguments:
// Return value: none
//-------------------------------------------------------------------------
void Write_M62446_Left(char vol){
WORD temp;
temp=Volume_Validate(vol);
temp<<=9;
shadow_word01&=0x01ff;
shadow_word01|=temp;
// DE=0;DF=1;
shadow_word01&=0xfffc; shadow_word01|=0x01;
if (bM62446Muted) return;
Write_M62446_Word(shadow_word01);
}
//-------------------------------------------------------------------------
// Name: Write_M62446_Right
// Description: This function Write 2 bytes to M62446
// Arguments:
// Return value: none
//-------------------------------------------------------------------------
void Write_M62446_Right(char vol){
WORD temp;
temp=Volume_Validate(vol);
temp<<=2;
shadow_word01&=0xfe03;
shadow_word01|=temp;
// DE=0;DF=1;
shadow_word01&=0xfffc; shadow_word01|=0x01;
if (bM62446Muted) return;
Write_M62446_Word(shadow_word01);
}
//-------------------------------------------------------------------------
// Name: Write_M62446_Center
// Description: This function Write 2 bytes to M62446
// Arguments:
// Return value: none
//-------------------------------------------------------------------------
void Write_M62446_Center(char vol){
WORD temp;
temp=Volume_Validate(vol);
temp<<=9;
shadow_word10&=0x01ff;
shadow_word10|=temp;
// DE=1;DF=0;
shadow_word10&=0xfffc; shadow_word10|=0x02;
if (bM62446Muted) return;
Write_M62446_Word(shadow_word10);
}
//-------------------------------------------------------------------------
// Name: Write_M62446_SubWoofer
// Description: This function Write 2 bytes to M62446
// Arguments:
// Return value: none
//-------------------------------------------------------------------------
void Write_M62446_SubWoofer(char vol){
WORD temp;
temp=Volume_Validate(vol);
temp<<=2;
shadow_word10&=0xfe03;
shadow_word10|=temp;
// DE=1;DF=0;
shadow_word10&=0xfffc; shadow_word10|=0x02;
if (bM62446Muted) return;
Write_M62446_Word(shadow_word10);
}
//-------------------------------------------------------------------------
// Name: Write_M62446_SurLeft
// Description: This function Write 2 bytes to M62446
// Arguments:
// Return value: none
//-------------------------------------------------------------------------
void Write_M62446_SurLeft(char vol){
WORD temp;
temp=Volume_Validate(vol);
temp<<=9;
shadow_word11&=0x01ff;
shadow_word11|=temp;
// DE=1;DF=1;
shadow_word11&=0xfffc; shadow_word11|=0x03;
if (bM62446Muted) return;
Write_M62446_Word(shadow_word11);
}
//-------------------------------------------------------------------------
// Name: Write_M62446_SurRight
// Description: This function Write 2 bytes to M62446
// Arguments:
// Return value: none
//-------------------------------------------------------------------------
void Write_M62446_SurRight(char vol){
WORD temp;
temp=Volume_Validate(vol);
temp<<=2;
shadow_word11&=0xfe03;
shadow_word11|=temp;
// DE=1;DF=1;
shadow_word11&=0xfffc; shadow_word11|=0x03;
if (bM62446Muted) return;
Write_M62446_Word(shadow_word11);
}
static BYTE code Treble_Bass_TAB[11]={
0x0e, // 0, -10db
0x0c, // 1, -8db
0x0b, // 2, -6db
0x0a, // 3, -4db
0x09, // 4, -2db
0x00, // 5, 0db
0x01, // 6, +2db
0x02, // 7, +4db
0x03, // 8, +6db
0x04, // 9, +8db
0x06 // 10, +10db
};
//-------------------------------------------------------------------------
// Name: Write_M62446_Treble
// Description: This function Write 2 bytes to M62446
// Arguments: 0-20,
// 0: -10db
// 10: 0db
// 20 +10db
// Return value: none
//-------------------------------------------------------------------------
void Write_M62446_Treble(BYTE Treble){
WORD temp;
Treble=Treble_Bass_TAB[Treble];
temp=Treble;
temp<<=12;
shadow_word00&=0x0fff;
shadow_word00|=temp;
// DE=0;DF=0;
shadow_word00&=0xfffc;
Write_M62446_Word(shadow_word00);
}
//-------------------------------------------------------------------------
// Name: Write_M62446_Bass
// Description: This function Write 2 bytes to M62446
// Arguments: 0-20,
// 0: -10db
// 10: 0db
// 20 +10db
// Return value: none
//-------------------------------------------------------------------------
void Write_M62446_Bass(BYTE Bass){
WORD temp;
Bass=Treble_Bass_TAB[Bass];
temp=Bass;
temp<<=4;
shadow_word00&=0xff0f;
shadow_word00|=temp;
// DE=0;DF=0;
shadow_word00&=0xfffc;
Write_M62446_Word(shadow_word00);
}
//-------------------------------------------------------------------------
// Name: Write_M62446_Bypass
// Description: This function Write 2 bytes to M62446
// Arguments: 1, bypass on, 0: off
// Return value: none
//-------------------------------------------------------------------------
void Write_M62446_Bypass(BOOL bOnOff){
if (bOnOff) shadow_word00 |= 0x0004; // On
else shadow_word00 &= 0xfffb; // off
// DE=0;DF=0;
shadow_word00 &= 0xfffc;
Write_M62446_Word(shadow_word00);
}
//-------------------------------------------------------------------------
// Name: Write_M62446_Output
// Description: This function Write 2 bytes to M62446
// Arguments: port=1-4, BYTE=1 or 0
// Return value: none
//-------------------------------------------------------------------------
void Write_M62446_Output(BYTE port, BOOL bOnoff){
WORD temp, mask=1;
temp=bOnoff;
temp <<= (12-port);
mask <<= (12-port);
shadow_word00&=~mask;
shadow_word00|=temp;
// DE=0;DF=0;
shadow_word00&=0xfffc;
Write_M62446_Word(shadow_word00);
}
#define DELAY() {_nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_();_nop_(); _nop_();
_nop_(); _nop_();}
//-------------------------------------------------------------------------
// Name: Write_M62446_Word
// Description: This function Write 2 bytes to M62446
// Arguments:
// Return value: none
//-------------------------------------------------------------------------
static void Write_M62446_Word(WORD myword){
register BYTE i;
PIN_M62446_LATCH=0;
for (i=16;i>0;--i){
if(myword & 0x8000) PIN_M62446_DATA=1; // MSB first
else PIN_M62446_DATA=0;
myword<<=1; // Rotate Right
DELAY();
PIN_M62446_CLK=1;
DELAY();
PIN_M62446_CLK=0;
}
DELAY();
PIN_M62446_LATCH=1;
}

[] [返回上一页] [打 印] [收 藏]
 

上一篇文章:ht1621 c程序
∷相关文章评论∷    (评论内容只代表网友观点,与本站立场无关!) [更多评论...]
 
关于本站- 意见反馈 - 网站导航 - 帮助 - 隐私政策 - 联系我们 - 使用条款 - 安全承诺 - 友情连接
站长QQ:39550527 Powered by: 飓风网络(电路图
Copyright 2006-2008 Elecfans.Com.电子发烧友: 粤ICP备07065979号All Rights Reserved