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

📄 ad1819a.cpp

📁 WinCE 3.0 BSP, 包含Inter SA1110, Intel_815E, Advantech_PCM9574 等
💻 CPP
字号:
// AD1819A.cpp: implementation of the CAD1819A class.
//
//	This class abstracts the specific functionality of the Analog
//  Devices AD1819A codec
//
//////////////////////////////////////////////////////////////////////



#include "AD1819A.h"

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

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

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

}

CAD1819A::~CAD1819A()
{

}

bool CAD1819A::SetSampleRate(bool bInput, DWORD dwFrequency)
{
	FUNCMSG2("+CAD1819A::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?AD1819_ADC_SAMPLE_RATE:AD1819_DAC_SAMPLE_RATE;
	

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

bool CAD1819A::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;

	// wait for all sections to power up
	while(nAttempts >0 && (wReg & 0x000F) != 0x00F)
	{
		Sleep(200);
		m_pController->ReadAC97(AD1819_POWER_STATUS, wReg);
		nAttempts--;
	}
	if ((wReg & 0x000F) != 0x000F)
	{
		ERRMSG1("AD1819_POWER_STATUS invalid: 0x%4.4x", wReg);
		return false;
	}

//	m_pController->ReadAC97(AD1819_CONTROL, wReg);
//	INFMSG1("AD1819_CONTROL is 0x%4.4x", wReg);
//	wReg |= AD1819_DACZ;	
//	m_pController->WriteAC97(AD1819_CONTROL, wReg);

	// 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("-CAD1819A::Reset() success");
	return true;
}

⌨️ 快捷键说明

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