基本功能全实现了,扩张功能实现了IIC和录音机,还实现了WIFI上传。有问题可以提出来,供大家一起讨论。图片附件
单片机源程序如下:
- #include "sys.h"
- #include "delay.h"
- #include "usart.h"
- #include "led.h"
- #include "lcd.h"
- #include "key.h"
- #include "usmart.h"
- #include "malloc.h"
- #include "w25qxx.h"
- #include "sdio_sdcard.h"
- #include "ff.h"
- #include "exfuns.h"
- #include "fontupd.h"
- #include "text.h"
- #include "wm8978.h"
- #include "audioplay.h"
- #include "recorder.h"
- #include "24cxx.h"
- #include "dht11.h"
- #include "adc.h"
- #include "timer.h"
- #include "cgq.h"
- #include "usart2.h"
- #include "wifi.h"
- u8 volume = 32;
- u8 action_sign;
- extern u8 temperature,humidity,led_state,speed,temp1,temp2;
- int main(void)
- {
- u8 key;
- u8 number_table[7];
- NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//设置系统中断优先级分组2
- delay_init(168); //初始化延时函数
- uart_init(115200); //初始化串口波特率为115200
- Usart3_Init(115200);
- LED_Init(); //初始化LED
- LCD_Init(); //LCD初始化
- KEY_Init(); //按键初始化
- W25QXX_Init(); //初始化W25Q128
- WM8978_Init(); //初始化WM8978
- WM8978_HPvol_Set(40,40); //耳机音量设置
- WM8978_SPKvol_Set(volume); //喇叭音量设置
- Adc_Init();
-
- TIM5_CH1_Cap_Init(0XFFFFFFFF,84-1); //以1Mhz的频率计数
- WiFi_ResetIO_Init();
- usmart_dev.init(84); //初始化USMART
- while(DHT11_Init())
- {
- printf("DHT11不存在");
- }
-
- my_mem_init(SRAMIN); //初始化内部内存池
- my_mem_init(SRAMCCM); //初始化CCM内存池
- exfuns_init(); //为fatfs相关变量申请内存
- f_mount(fs[0],"0:",1); //挂载SD卡
- POINT_COLOR=RED;
- while(AT24CXX_Check())//检测不到24c02
- {
- LCD_ShowString(30,110,200,16,16,"24C02 Check Failed!");
- delay_ms(500);
- LCD_ShowString(30,110,200,16,16,"Please Check! ");
- delay_ms(500);
- LED0=!LED0;//DS0闪烁
- }
- while(font_init()) //检查字库
- {
- LCD_ShowString(30,40,200,16,16,"Font Error!");
- delay_ms(200);
- LCD_Fill(30,40,240,66,WHITE);//清除显示
- delay_ms(200);
- }
- POINT_COLOR=RED;
- Show_Str(30,50,200,16,"Explorer STM32开发板",16,0);
- Show_Str(30,70,200,16,"车载系统",16,0);
- Show_Str(30,90,200,16,"2020年12月13日",16,0);
- Show_Str(30,110,200,16,"KEY0:播放器 KEY2:录音机",16,0);
- Show_Str(30,130,200,16,"KEY1:传感器 KEY3:调速 ",16,0);
-
- AT24CXX_Read(0,number_table,7);
- if(number_table[0] == 128)
- {
- temperature = number_table[1];
- humidity = number_table[2];
- led_state = number_table[3];
- speed = number_table[4];
- temp1 = number_table[5];
- temp2 = number_table[6];
- //printf("%d-%d-%d-%d-%d-%d\r\n",temperature,humidity,led_state,speed,temp1,temp2);
- }
- initial_interface();
- TIM2_Int_Init(20000,8399);
- while(1)
- {
- key = KEY_Scan(0);
- switch(key)
- {
- case KEY0_PRES:audio_play();initial_interface();break;
- case KEY2_PRES:wav_recorder();initial_interface();break;
- case KEY1_PRES:cc();initial_interface();break;
- case WKUP_PRES:xgsd();initial_interface();break;
- }
- }
- }
复制代码
所有资料51hei提供下载:
代码.7z
(821 KB, 下载次数: 16)
|