📄 audio.c
字号:
/****************************************************************************/
/* TEXAS INSTRUMENTS PROPRIETARY INFORMATION */
/* */
/* (c) Copyright, Texas Instruments Incorporated, 2006. */
/* All Rights Reserved. */
/* */
/* Property of Texas Instruments Incorporated. Restricted Rights - */
/* Use, duplication, or disclosure is subject to restrictions set */
/* forth in TI's program license agreement and associated documentation. */
/****************************************************************************/
/****************************************************************************/
/* audio.c */
/* */
/* Controls audio device */
/****************************************************************************/
#include "common.h"
#include "gpio.h"
#include "pwm.h"
#include "audio.h"
#include "gpioFunction.h"
#include "sysmon.h"
#include "dbmessage.h"
EXEC_CC_ENUM audio_init( void )
{
/* initialize gpio pin, and set 0% duty cycle */
GPIO_EnableAlternativeFunction( GPIO_PWM_OUT_4, FALSE );
GPIO_SetPinConfig( GIO_VOLUME, GIOCFG_OUTPUT, FALSE, GIOCFG_ACTIVE );
return EXEC_CC_PASS;
}
EXEC_CC_ENUM audio_powerNormal( void )
{
/* for now, set the volume to 100% when entering normal power */
audio_SetVolume( 100 );
return EXEC_CC_PASS;
}
EXEC_CC_ENUM audio_powerStandby( void )
{
audio_SetVolume( 0 );
return EXEC_CC_PASS;
}
void audio_SetVolume( uint08 volume )
{
PWM_OutConfigStruct pwmCfg;
if( volume == 0 )
{
GPIO_EnableAlternativeFunction( GPIO_PWM_OUT_4, FALSE );
GPIO_SetPinConfig( GIO_VOLUME, GIOCFG_OUTPUT, FALSE, GIOCFG_ACTIVE );
}
else if( volume == 100 )
{
GPIO_EnableAlternativeFunction( GPIO_PWM_OUT_4, FALSE );
GPIO_SetPinConfig( GIO_VOLUME, GIOCFG_OUTPUT, TRUE, GIOCFG_ACTIVE );
}
else
{
GPIO_EnableAlternativeFunction( GPIO_PWM_OUT_4, TRUE );
pwmCfg.FreqHz = 100000; /* configure for 100 kHz */
pwmCfg.DutyCycle = volume;
pwmCfg.PortEnabled = TRUE;
pwmCfg.OutputEnabled = TRUE;
PWM_SetOutPortConfig( PWM_OUT4, &pwmCfg );
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -