音量控制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
#include
#include
#include
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(vol80) 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 <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;
}
SAE更新J3105电动汽车充电推荐做法
5G与视频的完美结合
中兴天机Axon10Pro评测 现阶段国内智能手机市场的一个强有力搅局者
144芯光缆交接箱_144芯光缆交接箱外观与结构_144芯光缆交接箱配置安装
浅谈消费级机器人现状
音量控制M62446的驱动C程序
自动奶茶机如何实现缺料提醒功能
如何使用Vivado设计套件配合Xilinx评估板的设计
如何将智能电视打造成家庭核心大屏设备?
入选龙岗百优产品 华科创智会议平板广受关注
电脑城楼层职能划分严谨 仍能维持生存
实验室建立计量管理体系的重要性和意义
瑞萨电子宣布推出5款新产品 扩充其16位微控制器(MCU)产品线
华为荣耀magic八曲面屏,直接上图颜值要爆炸
新基建风口下对电力产业会造成哪些影响
什么是蓝牙?它如何工作的?
芯启源科技自主研发GPS功分器产品概述
什么是Portal
抗生素检测仪的性能及主要参数
思尔芯CEO深刻洞见: 新应用、新技术、新市场下的大规模数字电路设计