/*******************************************************************************
|
* File Name : TTS.c
|
* Description :
|
* Created on : 2022Äê4ÔÂ30ÈÕ
|
* Author : hido.ltd
|
*******************************************************************************/
|
|
/*******************************************************************************
|
* Include Files *
|
*******************************************************************************/
|
#include "TTS.h"
|
//#include "GPIO.h"
|
//#include "Delay.h"
|
#include "HIDO_Lock.h"
|
#include "HIDO_VLQueue.h"
|
#include "HIDO_Timer.h"
|
#include "string.h"
|
#include "HIDO_Util.h"
|
#include "global_param.h"
|
#include "PCA9555.h"
|
/*******************************************************************************
|
* Macro *
|
*******************************************************************************/
|
#define TTS_TEXT_QUEUE_CNT 4
|
|
/*******************************************************************************
|
* Type Definition *
|
*******************************************************************************/
|
|
/*******************************************************************************
|
* Local Variable *
|
*******************************************************************************/
|
static HIDO_UINT8 l_au8TTSQueueBuff[1024];
|
static HIDO_VLQStruct l_stTTSQueue;
|
|
/*******************************************************************************
|
* Local Function Declaration *
|
*******************************************************************************/
|
|
/*******************************************************************************
|
* Local Function *
|
*******************************************************************************/
|
|
/*******************************************************************************
|
* Global Function *
|
*******************************************************************************/
|
|
/*******************************************************************************
|
* Function Name : TTS_Play
|
* Description :
|
* Input :
|
* Output :
|
* Return :
|
* Author : hido.ltd
|
* Modified Date: : 2022Äê4ÔÂ30ÈÕ
|
*******************************************************************************/
|
HIDO_INT32 TTS_Play(HIDO_UINT8 *_pu8Data, HIDO_UINT32 _u32Len)
|
{
|
PCA9555_Set_One_Value_Output(TTS_ENABLE,1);
|
delay_ms(800); //±ØÒªÑÓʱ,ÑÓʱÊÇΪÁ˱ÜÃâ˵²»³öÀ´µÚÒ»¸ö×Ö
|
|
if((0 == _u32Len) || (HIDO_NULL == _pu8Data))
|
{
|
return HIDO_ERR;
|
}
|
|
HIDO_VLQMemberStruct *pstMember = HIDO_VLQGetEnqueueMember(&l_stTTSQueue, _u32Len);
|
|
if(HIDO_NULL == pstMember)
|
{
|
return HIDO_ERR;
|
}
|
|
memcpy(pstMember->m_pDataAddr, _pu8Data, _u32Len);
|
HIDO_VLQEnqueue(&l_stTTSQueue, pstMember);
|
|
return HIDO_OK;
|
}
|
|
/*******************************************************************************
|
* Function Name : TTS_GetNextData
|
* Description :
|
* Input :
|
* Output :
|
* Return :
|
* Author : hido.ltd
|
*******************************************************************************/
|
HIDO_VLQMemberStruct *TTS_GetNextData(HIDO_VOID)
|
{
|
return HIDO_VLQGetDequeueMember(&l_stTTSQueue);
|
}
|
|
/*******************************************************************************
|
* Function Name : TTS_ReleaseData
|
* Description :
|
* Input :
|
* Output :
|
* Return :
|
* Author : hido.ltd
|
*******************************************************************************/
|
HIDO_INT32 TTS_ReleaseData(HIDO_VLQMemberStruct *_pstData)
|
{
|
if(_pstData == TTS_GetNextData())
|
{
|
return HIDO_VLQDequeue(&l_stTTSQueue, _pstData);
|
}
|
|
return HIDO_OK;
|
}
|
|
/*******************************************************************************
|
* Function Name : TTS_Init
|
* Description :
|
* Input :
|
* Output :
|
* Return :
|
* Author : hido.ltd
|
*******************************************************************************/
|
HIDO_INT32 TTS_Init(HIDO_VOID)
|
{
|
HIDO_VLQInit(&l_stTTSQueue, l_au8TTSQueueBuff, sizeof(l_au8TTSQueueBuff), TTS_TEXT_QUEUE_CNT);
|
|
return HIDO_OK;
|
}
|