赞
踩
目录
项目成品图片:
哔哩哔哩视频链接:
(资料分享见文末)
基于STM32的智能家居语音系统
功能如下:
- int main ( void )
- {
- /* 系统时钟树配置 */
- RCC_Configuration();
- /* 中断系统配置 */
- NVIC_Configuration();
- /* 初始化硬件延时, 使用滴答定时器完成 */
- delay_init();
- /* 板级初始化 */
- DEBUG_UART_Config( );
- DEBUG_LOG("Bsp init\n");
- /* 上电延时,等待各个模块运行稳定 */
- delay_ms( 200 );
- RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO|RCC_APB2Periph_GPIOB|RCC_APB2Periph_GPIOF, ENABLE); //使能相应接口的时钟,以及RCC_APB2Periph_AFIO
- GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE); //禁用JTAG
- /* 初始化定时器3, 中断频率 1000hz */
- FML_TIME_Init();
- FML_TIME_Register(Sys_timer_handle, 1); //系统时间片,1tick = 1ms
- FML_TIME_Start(Sys_timer_handle); //开启定时
- /* 配置按键引脚 */
- //Key_GPIO_Config(p_SysParamHandle->p_keyhandle);
- /* LED Fan IO 初始化 */
- LED_Init( );
- BEEP_Init();
- Moto_Init();
- /* dht11 初始化 */
- DHT11_Init();
- /* 语音模块初始化 */
- ld3322_init( );
- RegisterLd3322(p_SysParamHandle->psLdHandle, CmdList, CMD_NUM); /*!< 注册指令参数表 */
- Switch_GPIO_Config( );
- /* 机智云SDK初始化 */
- Gizwits_Init();
- /* 0.96OLED初始化 */
- OLED_Init();
- BH1750_Init();
- ADC_Sensor_Init();
- /*!< 延时确保初始页面错误 */
- delay_ms(300);
- /* OLED显示初始画面 */
- OLED_InitPage( );
- while ( 1 )
- {
- /* 传感器数据 */
- if (p_SysParamHandle->u32SensorTim == 0)
- {
- p_SysParamHandle->u32SensorTim = 200;
- p_SysParamHandle->u16Lightness = bh_data_read( ); //!< 读取光照强度
- get_mq2_value( &p_SysParamHandle->fMqValue ); //!< 读取烟雾浓度
- DHT11_Read_TempAndHumidity( p_SysParamHandle->psDHT11DataHandle );//!< 读取温湿度
- }
- /* ld3320语音识别模块 */
- uint16_t index;
- if (psLdHandle->bl_rev_cmd_flg == CMD_REV_OK)
- {
- psLdHandle->bl_rev_cmd_flg = CMD_REV_NO_OK;
- for (index=0; index<psLdHandle->u16_cmd_num; index++)
- {
- if (!strcmp(psLdHandle->pCmdTable[index].cmd_str, psLdHandle->pu8_rev_cmd_buf))
- {
- psLdHandle->pCmdTable[index].funCallback();
- DEBUG_LOG("Ld3322 check OK\n");
- break;
- }
- }
- if (index == psLdHandle->u16_cmd_num)
- {
- DEBUG_LOG("Ld3322 Erorr\n");
- }
- User_MemSet(psLdHandle->pu8_rev_cmd_buf, 0x0, 30);
- }
- /* 机智云云端协议处理 - 任务 */
- gizwitsHandle( p_SysParamHandle->p_DataPoint );
- /* 机智云数据同步 - 任务 */
- app_SyncData_Task( p_SysParamHandle );
- /* oled参数更新 - 任务 */
- char str[16] = {0};
- if (p_SysParamHandle->u32LcdUpdateTim == 0)
- {
- /* 任务时间重装载 */
- p_SysParamHandle->u32LcdUpdateTim = 1000;
- sprintf(str, "%d", p_SysParamHandle->psDHT11DataHandle->temp_int);
- OLED_ShowCnAndAsciiStr(40, 0, str, 2);
- sprintf(str, "%d", p_SysParamHandle->psDHT11DataHandle->humi_int);
- OLED_ShowCnAndAsciiStr(40, 2, str, 2);
- sprintf(str, "%d", p_SysParamHandle->u16Lightness);
- OLED_ShowCnAndAsciiStr(80, 4, str, 2);
- sprintf(str, "%.2f", p_SysParamHandle->fMqValue);
- OLED_ShowCnAndAsciiStr(80, 6, str, 2);
- /* 机智云事件处理 - 线程 */
- app_GizwitsDataEvent_Handle( p_SysParamHandle );
- }
- }
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。