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

📄 lm4548.cpp

📁 WinCE 3.0 BSP, 包含Inter SA1110, Intel_815E, Advantech_PCM9574 等
💻 CPP
字号:
// LM4548.cpp: implementation of the CLM4548 class.
//
//	This class abstracts the specific functionality of the National
//  Semiconductor LM4548 and LM4549 codecs
//
////////////////////////////////////////////////////////////////////////

#include "LM4548.h"

const int MAX_FREQ = 48000;
const int MIN_FREQ = 8000;

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CLM4548::CLM4548(CCX5530Audio *pController):
	CAC97Codec(pController)
{

}

CLM4548::~CLM4548()
{

}

bool CLM4548::SetSampleRate(bool bInput, DWORD dwFrequency)
{
	FUNCMSG2("+CLM4548::SetSampleRate: %s, %d", bInput?(TEXT("recording")):(TEXT("playback")), dwFrequency);
	if  (!m_pController)
		return false;
	
	if (dwFrequency < MIN_FREQ || dwFrequency > MAX_FREQ)
		return false;
	WORD wReg = bInput?LM4548_PCM_LR_ADC_RATE:LM4548_PCM_FRONT_DAC_RATE;

	return m_pController->WriteAC97(wReg, WORD(dwFrequency));
}


bool CLM4548::Reset()
{
	WORD wReg = 0;
	int nAttempts;
	FUNCMSG("+CAD1819A::Reset()");
	if (!m_pController)
		return false;

	// initialize the codec
	m_pController->WriteAC97( AC97_RESET, 0);
	wReg = 0;
	nAttempts = 5;

	while(nAttempts >0 && (wReg & 0x000F) != 0x000F)
	{
		Sleep(200);
		m_pController->ReadAC97(LM4548_POWERDOWN_CTRL_STAT, wReg);
		nAttempts--;
	}
	if ((wReg & 0x000F) != 0x000F)
	{
		ERRMSG1("LM4548_POWERDOWN_CTRL_STAT invalid: 0x%4.4x", wReg);
		return false;
	}

	//enable variable sample rate
	m_pController->ReadAC97( LM4548_EXT_AUDIO_CTRL_STAT, wReg);  // read VRA register
	m_pController->WriteAC97( LM4548_EXT_AUDIO_CTRL_STAT,wReg | 1);  // set the VRA bit to ON

	// set default sample rate

	SetSampleRate(true, 44100);
	SetSampleRate(false, 44100);

	// set default volumes to max

	m_pController->WriteAC97( AC97_MASTER_VOLUME, 0);  // left/right vol to max
	m_pController->WriteAC97( AC97_PCM_OUT_VOL, 0);  // left/right vol to max

	FUNCMSG("-CLM4548::Reset() success");
	return true;
}

⌨️ 快捷键说明

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