Merged in alinjerpelea/nuttx (pull request #1048)
boards: arm: cxd56xx: audio: add power_control and audio_tone_generator * boards: arm: cxd56xx: audio: add power_control Add a simeple way to control the audio power for userspace apps Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com> * boards: arm: cxd56xx: audio: add audio_tone_generator Add a simple way to control the audio buzzer with defined frequency for userspace apps Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com> Approved-by: Gregory Nutt <gnutt@nuttx.org>
This commit is contained in:
parent
fae7e63479
commit
716c7c9bee
@ -939,6 +939,12 @@ CXD56_AUDIO_ECODE cxd56_audio_set_micmap(uint32_t map);
|
||||
|
||||
uint32_t cxd56_audio_get_micmap(void);
|
||||
|
||||
/* Tone generator
|
||||
*
|
||||
* Setup tone generator
|
||||
*/
|
||||
bool board_audio_tone_generator(bool en, int16_t vol, uint16_t freq);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* end of extern "C" */
|
||||
#endif /* __cplusplus */
|
||||
|
@ -47,6 +47,7 @@
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <arch/chip/audio.h>
|
||||
|
||||
#include "chip.h"
|
||||
#include "up_arch.h"
|
||||
@ -104,6 +105,75 @@ static bool check_pin_i2s_mode(uint32_t pin)
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_audio_power_control
|
||||
*
|
||||
* Description:
|
||||
* Power on/off the audio device on the board.
|
||||
*
|
||||
****************************************************************************/
|
||||
bool board_audio_power_control(bool en)
|
||||
{
|
||||
if (en)
|
||||
{
|
||||
/* Enable I2S pin. */
|
||||
|
||||
cxd56_audio_en_i2s_io();
|
||||
|
||||
/* Enable speaker output. */
|
||||
|
||||
cxd56_audio_set_spout(true);
|
||||
|
||||
/* Power on Audio driver */
|
||||
|
||||
if (cxd56_audio_poweron() != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Enable BaseBand driver output */
|
||||
|
||||
if (cxd56_audio_en_output() != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Cancel output mute. */
|
||||
|
||||
board_external_amp_mute_control(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Set output mute. */
|
||||
|
||||
board_external_amp_mute_control(true);
|
||||
|
||||
/* Disable speaker output. */
|
||||
|
||||
cxd56_audio_set_spout(false);
|
||||
|
||||
/* Disable I2S pin. */
|
||||
|
||||
cxd56_audio_dis_i2s_io();
|
||||
|
||||
/* Power off Audio driver */
|
||||
|
||||
if (cxd56_audio_dis_output() != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Disable BaseBand driver output */
|
||||
|
||||
if (cxd56_audio_poweroff() != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_aca_power_control
|
||||
*
|
||||
|
@ -1303,3 +1303,48 @@ uint32_t cxd56_audio_get_micmap(void)
|
||||
{
|
||||
return cxd56_audio_config_get_micmap();
|
||||
}
|
||||
|
||||
bool board_audio_tone_generator(bool en, int16_t vol, uint16_t freq)
|
||||
{
|
||||
if (!en)
|
||||
{
|
||||
/* Stop beep */
|
||||
|
||||
if (cxd56_audio_stop_beep() != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (0 != freq)
|
||||
{
|
||||
/* Set beep frequency parameter */
|
||||
|
||||
if (cxd56_audio_set_beep_freq(freq) != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (255 != vol)
|
||||
{
|
||||
/* Set beep volume parameter */
|
||||
|
||||
if (cxd56_audio_set_beep_vol(vol) != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (en)
|
||||
{
|
||||
/* Play beep */
|
||||
|
||||
if (cxd56_audio_play_beep() != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -63,6 +63,17 @@ extern "C"
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_audio_power_control
|
||||
*
|
||||
* Description:
|
||||
* Power on/off the audio on the board.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
bool board_audio_power_control(bool en);
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_aca_power_control
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user