目录

图片

SYN6288.h

SYN6288.c

stm32f10x_it.h

main.c


图片

如何使用该模块呢,首先,SYN6288是使用串口通讯的,很多模块其实都是使用串口通讯,有助于指令的输入,那么使用串口通讯就简单了,首先配置串口等

SYN6288.h

这里的话我使用的是串口4,当然C8T6的话是只要三个串口的,如何需要使用,可以自行修改串口配置

#ifndef _SYN6288_H_
#define _SYN6288_H_
#include "stm32f10x.h"/**  *******************************************************************************  @File     SYN6288.h*  @Author   Velscode  *  @Email    velscode@gmail.com*  @Brief    TTS 芯片 SYN6288驱动头文件(基于STM32F10x)*            使用了USART2(A2\A3)*******************************************************************************//****************************** SYN6288 引脚配置参数定义***************************************/
#define             SYN6288_GPIO_APBxClock_FUN              RCC_APB2PeriphClockCmd
#define             SYN6288_GPIO_CLK                        RCC_APB2Periph_GPIOC
#define             SYN6288_GPIO_PORT                       GPIOC
#define             SYN6288_GPIO_PIN                        GPIO_Pin_6
#define                     SYN6288_Read_GPIO_IN()                  GPIO_ReadInputDataBit ( SYN6288_GPIO_PORT, SYN6288_GPIO_PIN ) // 串口4-UART4
#define  DEBUG_USARTx                   UART4
#define  DEBUG_USART_CLK                RCC_APB1Periph_UART4
#define  DEBUG_USART_APBxClkCmd         RCC_APB1PeriphClockCmd
#define  DEBUG_USART_BAUDRATE           9600// USART GPIO 引脚宏定义
#define  DEBUG_USART_GPIO_CLK           (RCC_APB2Periph_GPIOC)
#define  DEBUG_USART_GPIO_APBxClkCmd    RCC_APB2PeriphClockCmd#define  DEBUG_USART_TX_GPIO_PORT         GPIOC
#define  DEBUG_USART_TX_GPIO_PIN          GPIO_Pin_10
#define  DEBUG_USART_RX_GPIO_PORT       GPIOC
#define  DEBUG_USART_RX_GPIO_PIN        GPIO_Pin_11#define  DEBUG_USART_IRQ                UART4_IRQn
#define  DEBUG_USART_IRQHandler         UART4_IRQHandlervoid SYN6288_GPIO_Config ( void );
void Usart_SendHalfWord( USART_TypeDef * pUSARTx, uint16_t ch);
void SYN6288_Speech( USART_TypeDef * pUSARTx,char * str );
void SYN688_USART_Config(void);
void Usart_SendByte( USART_TypeDef * pUSARTx, uint8_t ch);
void SYN_FrameInfo(char *HZdata);
void Usart_SendString( USART_TypeDef * pUSARTx, char *str);
/* 音量控制 */
void Volinme(uint8_t Y_L);
/* 语调控制 */
void Intonation(uint8_t Y_L);
/* 语速控制 */
void Speed_pacing(uint8_t Y_L);
/* 人控制 */
void speed_man(uint8_t Y_L);
#endif /*_SYN6288_H_*/
/* End of File ------------------------------------------------------------- */

SYN6288.c

这里的话就是配置参数,还有给SYN6288发指令等

/**
******************************************************************************
*  @File     SYN6288.c
*  @Author   Velscode
*  @Email    velscode@gmail.com
*  @Brief    TTS 芯片 SYN6288驱动源代码文件(基于STM32F10x)
*            使用了USART2(A2\A3)
******************************************************************************
*//* Internal Function Declaration ------------------------------------------- */
void usart2_Init(unsigned int bound);/* Header Files ------------------------------------------------------------ */
#include "SYN6288.h"
#include "string.h"
#include "bsp_SysTick.h"
#include <string.h>/*** @brief  配置嵌套向量中断控制器NVIC* @param  无* @retval 无*/
static void NVIC_Configuration(void)
{NVIC_InitTypeDef NVIC_InitStructure;/* 嵌套向量中断控制器组选择 */NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);/* 配置USART为中断源 */NVIC_InitStructure.NVIC_IRQChannel = DEBUG_USART_IRQ;/* 抢断优先级*/NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;/* 子优先级 */NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;/* 使能中断 */NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;/* 初始化配置NVIC */NVIC_Init(&NVIC_InitStructure);
}
//读忙
void SYN6288_GPIO_Config ( void )
{       /*定义一个GPIO_InitTypeDef类型的结构体*/GPIO_InitTypeDef GPIO_InitStructure;/* 配置 LED1 引脚 */SYN6288_GPIO_APBxClock_FUN(SYN6288_GPIO_CLK, ENABLE);                                                                GPIO_InitStructure.GPIO_Pin = SYN6288_GPIO_PIN; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;   GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init ( SYN6288_GPIO_PORT, & GPIO_InitStructure );   }/*** @brief  USART GPIO 配置,工作参数配置* @param  无* @retval 无*/
void SYN688_USART_Config(void)
{GPIO_InitTypeDef GPIO_InitStructure;USART_InitTypeDef USART_InitStructure;// 打开串口GPIO的时钟DEBUG_USART_GPIO_APBxClkCmd(DEBUG_USART_GPIO_CLK, ENABLE);// 打开串口外设的时钟DEBUG_USART_APBxClkCmd(DEBUG_USART_CLK, ENABLE);// 将USART Tx的GPIO配置为推挽复用模式GPIO_InitStructure.GPIO_Pin = DEBUG_USART_TX_GPIO_PIN;GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;GPIO_Init(DEBUG_USART_TX_GPIO_PORT, &GPIO_InitStructure);// 将USART Rx的GPIO配置为浮空输入模式GPIO_InitStructure.GPIO_Pin = DEBUG_USART_RX_GPIO_PIN;GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;GPIO_Init(DEBUG_USART_RX_GPIO_PORT, &GPIO_InitStructure);// 配置串口的工作参数// 配置波特率USART_InitStructure.USART_BaudRate = DEBUG_USART_BAUDRATE;// 配置 针数据字长USART_InitStructure.USART_WordLength = USART_WordLength_8b;// 配置停止位USART_InitStructure.USART_StopBits = USART_StopBits_1;// 配置校验位USART_InitStructure.USART_Parity = USART_Parity_No ;// 配置硬件流控制USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;// 配置工作模式,收发一起USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;// 完成串口的初始化配置USART_Init(DEBUG_USARTx, &USART_InitStructure);// 串口中断优先级配置NVIC_Configuration();// 使能串口接收中断USART_ITConfig(DEBUG_USARTx, USART_IT_RXNE, ENABLE);    // 使能串口USART_Cmd(DEBUG_USARTx, ENABLE);     // 清除发送完成标志//USART_ClearFlag(USART1, USART_FLAG_TC);
}
//其实是USART2_Send_Byte
/*****************  发送一个字符 **********************/
void Usart_SendByte( USART_TypeDef * pUSARTx, uint8_t ch)
{/* 发送一个字节数据到USART */USART_SendData(pUSARTx,ch);/* 等待发送数据寄存器为空 */while (USART_GetFlagStatus(pUSARTx, USART_FLAG_TXE) == RESET);
}
/*****************  发送字符串 **********************/
void Usart_SendString( USART_TypeDef * pUSARTx, char *str)
{unsigned int k=0;do {Usart_SendByte( pUSARTx, *(str + k) );k++;} while(*(str + k)!='\0');/* 等待发送完成 */while(USART_GetFlagStatus(pUSARTx,USART_FLAG_TC)==RESET){}
}//语音合成
void SYN6288_Speech( USART_TypeDef * pUSARTx,char * str )
{if(SYN6288_Read_GPIO_IN()==Bit_RESET)/* x us后仍为高电平表示数据“1” */{char * p = str;int len = 0,check=0xFD,i;while( *p++ != 0 ){len++;}len+=3;Usart_SendByte(DEBUG_USARTx,0xFD);Usart_SendByte( DEBUG_USARTx,len / 256 );Usart_SendByte( DEBUG_USARTx,len % 256 );check  = check ^ ( len / 256 ) ^ ( len % 256 );Usart_SendByte( DEBUG_USARTx,0x01 );Usart_SendByte( DEBUG_USARTx,0x01 );check = check ^ 0x01 ^ 0x01;for( i = 0; i < len-3; i++ ){Usart_SendByte(DEBUG_USARTx,*str);check ^= ( *str );str++;}Usart_SendByte(DEBUG_USARTx,check);   Delay_ms(150*len);   }}
/* 音量控制 */
void Volinme(uint8_t Y_L)
{uint8_t num ;num = Y_L+48;Usart_SendByte(DEBUG_USARTx,0xFD);Usart_SendByte(DEBUG_USARTx,0x00);Usart_SendByte(DEBUG_USARTx,0x06);Usart_SendByte(DEBUG_USARTx,0x01);Usart_SendByte(DEBUG_USARTx,0x01);Usart_SendByte(DEBUG_USARTx,0x5B);Usart_SendByte(DEBUG_USARTx,0x76);//控制音量Usart_SendByte(DEBUG_USARTx,num);Usart_SendByte(DEBUG_USARTx,0x5D);
//  uint8_t num[9] ;
//
//  num[0] = 0xFD;
//  num[1] = 0x00;
//  num[2] = 0x06;
//  num[3] = 0x01;
//  num[4] = 0x01;
//  num[5] = 0x5B;
//  num[6] = 0x76;
//  //控制音量
//  num[7] = Y_L+48;
//  num[8] = 0x5D;
//
//  Usart_SendByte(DEBUG_USARTx,num[8]);
}
/* 语调控制 */
void Intonation(uint8_t Y_L)
{uint8_t num ;num = Y_L+48;Usart_SendByte(DEBUG_USARTx,0xFD);Usart_SendByte(DEBUG_USARTx,0x00);Usart_SendByte(DEBUG_USARTx,0x06);Usart_SendByte(DEBUG_USARTx,0x01);Usart_SendByte(DEBUG_USARTx,0x01);Usart_SendByte(DEBUG_USARTx,0x5B);Usart_SendByte(DEBUG_USARTx,0x74);//控制音量Usart_SendByte(DEBUG_USARTx,num);Usart_SendByte(DEBUG_USARTx,0x5D);}
/* 语速控制 */
void Speed_pacing(uint8_t Y_L)
{uint8_t num ;num = Y_L+48;Usart_SendByte(DEBUG_USARTx,0xFD);Usart_SendByte(DEBUG_USARTx,0x00);Usart_SendByte(DEBUG_USARTx,0x06);Usart_SendByte(DEBUG_USARTx,0x01);Usart_SendByte(DEBUG_USARTx,0x01);Usart_SendByte(DEBUG_USARTx,0x5B);Usart_SendByte(DEBUG_USARTx,0x73);//控制音量Usart_SendByte(DEBUG_USARTx,num);Usart_SendByte(DEBUG_USARTx,0x5D);}
/* 人控制 */
void speed_man(uint8_t Y_L)
{uint8_t num ;num = Y_L+48;Usart_SendByte(DEBUG_USARTx,0xFD);Usart_SendByte(DEBUG_USARTx,0x00);Usart_SendByte(DEBUG_USARTx,0x07);Usart_SendByte(DEBUG_USARTx,0x01);Usart_SendByte(DEBUG_USARTx,0x01);Usart_SendByte(DEBUG_USARTx,0x5B);Usart_SendByte(DEBUG_USARTx,0x6D);Usart_SendByte(DEBUG_USARTx,0x35);//控制音量Usart_SendByte(DEBUG_USARTx,num);Usart_SendByte(DEBUG_USARTx,0x5D);}
/* End of File ------------------------------------------------------------- */

stm32f10x_it.h

写完配置函数,当然不能忘记配置中断服务,把这段代码加入该文件的中,那么你的SYN8622还差一步就大功告成了

#include "SYN6288.h"// 串口中断服务函数
void DEBUG_USART_IRQHandler(void)
{uint8_t ucCh;if ( USART_GetITStatus ( DEBUG_USARTx, USART_IT_RXNE ) != RESET ){ucCh  = USART_ReceiveData( DEBUG_USARTx );if ( strUSART_Fram_Record .InfBit .FramLength < ( RX_BUF_MAX_LEN - 1 ) )                       //预留1个字节写结束符strUSART_Fram_Record .Data_RX_BUF [ strUSART_Fram_Record .InfBit .FramLength ++ ]  = ucCh;}if ( USART_GetITStatus( DEBUG_USARTx, USART_IT_IDLE ) == SET )                                         //数据帧接收完毕{strUSART_Fram_Record .InfBit .FramFinishFlag = 1;       ucCh = USART_ReceiveData( DEBUG_USARTx );                                                              //由软件序列清除中断标志位(先读USART_SR,然后读USART_DR)   }
}

main.c

#include "bsp_usart1.h"
#include "stm32f10x.h"
#include "bsp_SysTick.h"
#include "SYN6288.h"
void Rap_And_God(void);
/*** @brief  主函数* @param  无* @retval 无*/int main ( void )
{/* 初始化 */USARTx_Config (); //USART_Config ();                                                              //初始化串口1SysTick_Init ();                                                               //配置 SysTick 为 1ms 中断一次                                                         //初始化WiFi模块使用的接口和外设    //初始化RGB彩灯//语音播报系统SYN6288_GPIO_Config();SYN688_USART_Config();printf ( "\r\n 语音控制识别系统(Android+WiFi) \r\n" );while(1){Rap_And_God();};}
/*** @brief  封装语音函数* @param  无* @retval 无*/
void Rap_And_God(void)
{SYN6288_Speech(DEBUG_USARTx,"粉红的长裙");SYN6288_Speech(DEBUG_USARTx,"蓬松的头发");SYN6288_Speech(DEBUG_USARTx,"牵着我的手看最新展出的油画");SYN6288_Speech(DEBUG_USARTx,"无人的街道");SYN6288_Speech(DEBUG_USARTx,"在空荡的家里");SYN6288_Speech(DEBUG_USARTx,"就只剩我一个人狂欢的趴体");SYN6288_Speech(DEBUG_USARTx,"就当是一场梦");SYN6288_Speech(DEBUG_USARTx,"醒了还是很感动");SYN6288_Speech(DEBUG_USARTx,"还是很想被你保护我心里的惨痛");SYN6288_Speech(DEBUG_USARTx,"喜欢我很辛苦");SYN6288_Speech(DEBUG_USARTx,"其实我都清楚");SYN6288_Speech(DEBUG_USARTx,"放心这世界很大我记得你的叮嘱");
}/*********************************************END OF FILE**********************/

STM32传感器外设集--语音模块(SYN6288)相关推荐

  1. STM32传感器外设集--温湿度模块(DHT11)

    目录 原理图 介绍 main.c bsp_dht11.h bsp_dht11.c core_delay.h core_delay.c 原理图 介绍 DHT11是我们最常见的一种温湿度传感器,但是精度不 ...

  2. STM32传感器外设集 -- 蓝牙(HC-05)+超声波(hc-sr04)

    前言 前言:蓝牙外设还没有给大家安排上,今天我就给大家安排上使用蓝牙传输超声波距离的例程,会给大家附带蓝牙的上位机的测试APP 一.模块介绍 1.连接图 蓝牙模块 引脚 超声波传感器 引脚 GND G ...

  3. 基于stm32物联网开发板(3)--SYN6288语音模块

    基于stm32物联网开发板(3)–SYN6288语音模块 1.SYN6288语音模块展示示例 SYN6288语音模块 2.概述   SYN6288-A语音合成模块是一款性价比更高,效果更自然的一款中高 ...

  4. STM32操控外设为什么要先使能时钟

    STM32操控外设为什么要先使能时钟 STM32的新手,一般都会对一个问题很纠结.我也是,就是所谓的"时钟问题".我们在尽心STM32编程时,会痛苦地发现这样一个事实:不管你要干嘛 ...

  5. STM32的外设介绍

    片上资源又叫做外设,英文是peripheral,下面这个表里就是STM32F1系列的外设资源. 我们主要学习的就是STM32的外设,通过程序配置外设来完成我们想要的功能.在这个表中,前两个深颜色的是位 ...

  6. 如何用语音模块SYN6288播报DHT11温湿度传感器传回来的数值

    这两天用YSN6288语音播报温度传感器返回的数值.网上找了不少例程,但都没有合适的.商家给的资料里面只有直接合成中文的函数,但一遇到变量就把它当成英文字母播报了.后来找到一个可以播报整数(传入一个变 ...

  7. STM32外设集 -- 人脸识别门禁系统(K210--HEX协议版本)

    前言 人脸,指纹识别已经走进人们的生活,无疑这方便了人们的生活,也提高了安全和可靠性,所以作为未来的学习方向,我也来接触接触人脸识别(有不足之处请见谅

  8. STM32一键连接JQ8400-FLJQ8900语音模块程序分析

    最近优化了一个项目    需要使用 语音模块     于是采用了JQ8400 语音模块 具体的数据手册  淘宝卖家提供 主要的是一线数据发送的协议格式     由于前期使用了RT-Thread  给自 ...

  9. STM32基本外设超详细44000字教程

    GPIO GPIO(General Purpose Input Output)通用输入输出口 可配置为8种输入输出模式 引脚电平:0V~3.3V,部分引脚可容忍5V 输出模式下可控制端口输出高低电平, ...

最新文章

  1. 你熟悉Git常用的命令吗?(点赞+收藏)
  2. iOS性能之WebP
  3. python小程序源代码-10个Python练手小程序
  4. Ajax.net实现loading登陆的效果
  5. EF中的那些批量操作
  6. Java 第六次作业
  7. 这些年遇到的坑爹问题汇总
  8. 【转载】最短路径之Dijkstra算法详细讲解
  9. 1m带宽可以做mysql数据库吗_服务器的1M带宽够用吗?1M网速是多少?
  10. 真格量化——50期权历史波动率策略
  11. mysql 内存性能优化
  12. 第 7 章 Neutron - 079 - 在 ML2 中 enable local network
  13. Oracle 19c 安装步骤
  14. 小班语言教案《水果屋》
  15. Redis安装(Windows环境下Redis安装)
  16. C++ Primer 5th ed.pdf
  17. 山东理工ACM 1152 C语言实验——求两个整数之和
  18. 各种内部排序方法及其比较实验报告
  19. 2020年wordpress主题开发视频教程、WP主题WP模板开发视频教程
  20. 计算机刻录机无法显示,电脑不识别刻录机是为什么

热门文章

  1. 行走江湖的50条忠告
  2. 充电管理芯片中的一些特性说明
  3. 使用 eMMC 闪存设备的磨损估计
  4. http://www.dewen.net.cn/q/15749/PHP求数组值相加(可重复)等于某值的所有组合
  5. 网站后台拿webshell
  6. 计算机控制技术专业全球排名,2019QS世界大学专业排名,快来看看!
  7. u盘文件看得见却打不开_U盘插入电脑能看到盘符但打不开怎么办
  8. html贝塞尔曲线在线,贝塞尔曲线的一些事情_html/css_WEB-ITnose
  9. 全球与中国聚季铵盐行业调查与未来发展趋势研究报告
  10. php 文件头部(header)信息详解