📄 hal.c
字号:
#include "handsfree_private.h"
#include "handsfree.h"
#include <codec.h>
#include <message.h>
/* Scale the supplied gain to be within the specified range */
static uint16 scaleGainToRange(uint8 gain, uint16 max_range, uint16 max_gain)
{
return (((((gain * 10) * max_range)/max_gain) + 5)/10);
}
/*
hfHalSetSpeakerGain
Set the speaker volume.
*/
void hfHalSetSpeakerGain(uint8 vol)
{
uint16 scaled_val = 0;
/* Get the range supported by the codec */
uint16 range = CodecOutputGainRange() - 1;
/* If the range is zero don't bother setting anything */
if (!range)
return;
/* If the range is not zero scale the gain to be in that range */
scaled_val = scaleGainToRange(vol, range, 15);
/* Set the codec gain */
CodecSetOutputGain(scaled_val);
}
/*
hfHalSetMicrophoneGain
Set the microphone gain.
*/
void hfHalSetMicrophoneGain(uint8 gain)
{
uint16 scaled_val = 0;
/* Get the range supported by the codec */
uint16 range = CodecInputGainRange() - 1;
/* If the range is zero don't bother setting anything */
if (!range)
return;
/* If the range is not zero scale the gain to be in that range */
scaled_val = scaleGainToRange(gain, range, 15);
/* Set the codec gain */
CodecSetInputGain(scaled_val);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -