音量控制M62446的驱动C程序
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
音量控制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(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;