找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 1594|回复: 1
打印 上一主题 下一主题
收起左侧

STM32车载娱乐播放与仪表显示程序 2020年计算机能力挑战赛嵌入式

[复制链接]
跳转到指定楼层
楼主
基本功能全实现了,扩张功能实现了IIC和录音机,还实现了WIFI上传。有问题可以提出来,供大家一起讨论。图片附件


单片机源程序如下:
  1. #include "sys.h"
  2. #include "delay.h"  
  3. #include "usart.h"   
  4. #include "led.h"
  5. #include "lcd.h"
  6. #include "key.h"  
  7. #include "usmart.h"   
  8. #include "malloc.h"
  9. #include "w25qxx.h"   
  10. #include "sdio_sdcard.h"
  11. #include "ff.h"  
  12. #include "exfuns.h"   
  13. #include "fontupd.h"
  14. #include "text.h"         
  15. #include "wm8978.h"         
  16. #include "audioplay.h"
  17. #include "recorder.h"
  18. #include "24cxx.h"
  19. #include "dht11.h"
  20. #include "adc.h"
  21. #include "timer.h"
  22. #include "cgq.h"
  23. #include "usart2.h"
  24. #include "wifi.h"        

  25. u8 volume = 32;
  26. u8 action_sign;
  27. extern u8 temperature,humidity,led_state,speed,temp1,temp2;  
  28. int main(void)
  29. {
  30.         u8 key;
  31.         u8 number_table[7];
  32.         NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//设置系统中断优先级分组2
  33.         delay_init(168);  //初始化延时函数
  34.         uart_init(115200);                //初始化串口波特率为115200
  35.         Usart3_Init(115200);   
  36.         LED_Init();                                        //初始化LED
  37.          LCD_Init();                                        //LCD初始化  
  38.          KEY_Init();                                        //按键初始化  
  39.         W25QXX_Init();                                //初始化W25Q128
  40.         WM8978_Init();                                //初始化WM8978
  41.         WM8978_HPvol_Set(40,40);        //耳机音量设置
  42.         WM8978_SPKvol_Set(volume);                //喇叭音量设置
  43.         Adc_Init();
  44.         
  45.         TIM5_CH1_Cap_Init(0XFFFFFFFF,84-1); //以1Mhz的频率计数
  46.         WiFi_ResetIO_Init();
  47.         usmart_dev.init(84);                //初始化USMART
  48.         while(DHT11_Init())
  49.         {
  50.                 printf("DHT11不存在");
  51.         }
  52.         
  53.         my_mem_init(SRAMIN);                //初始化内部内存池
  54.         my_mem_init(SRAMCCM);                //初始化CCM内存池
  55.         exfuns_init();                                //为fatfs相关变量申请内存  
  56.           f_mount(fs[0],"0:",1);                 //挂载SD卡  
  57.         POINT_COLOR=RED;      
  58.         while(AT24CXX_Check())//检测不到24c02
  59.         {
  60.                 LCD_ShowString(30,110,200,16,16,"24C02 Check Failed!");
  61.                 delay_ms(500);
  62.                 LCD_ShowString(30,110,200,16,16,"Please Check!      ");
  63.                 delay_ms(500);
  64.                 LED0=!LED0;//DS0闪烁
  65.         }
  66.         while(font_init())                         //检查字库
  67.         {            
  68.                 LCD_ShowString(30,40,200,16,16,"Font Error!");
  69.                 delay_ms(200);                                 
  70.                 LCD_Fill(30,40,240,66,WHITE);//清除显示            
  71.                 delay_ms(200);                                 
  72.         }           
  73.         POINT_COLOR=RED;      
  74.          Show_Str(30,50,200,16,"Explorer STM32开发板",16,0);                                                                          
  75.         Show_Str(30,70,200,16,"车载系统",16,0);                                             
  76.         Show_Str(30,90,200,16,"2020年12月13日",16,0);
  77.         Show_Str(30,110,200,16,"KEY0:播放器 KEY2:录音机",16,0);
  78.         Show_Str(30,130,200,16,"KEY1:传感器 KEY3:调速  ",16,0);
  79.         
  80.         AT24CXX_Read(0,number_table,7);
  81.         if(number_table[0] == 128)
  82.         {
  83.                 temperature = number_table[1];
  84.                 humidity                 = number_table[2];
  85.                 led_state         = number_table[3];
  86.                 speed                         = number_table[4];
  87.                 temp1                         = number_table[5];
  88.                 temp2                                = number_table[6];
  89.                 //printf("%d-%d-%d-%d-%d-%d\r\n",temperature,humidity,led_state,speed,temp1,temp2);
  90.         }
  91.         initial_interface();
  92.         TIM2_Int_Init(20000,8399);
  93.         while(1)
  94.         {
  95.                 key = KEY_Scan(0);
  96.                 switch(key)
  97.                 {
  98.                         case KEY0_PRES:audio_play();initial_interface();break;
  99.                         case KEY2_PRES:wav_recorder();initial_interface();break;
  100.                         case KEY1_PRES:cc();initial_interface();break;
  101.                         case WKUP_PRES:xgsd();initial_interface();break;
  102.                 }
  103.         }
  104. }
复制代码

所有资料51hei提供下载:
代码.7z (821 KB, 下载次数: 16)


评分

参与人数 1黑币 +50 收起 理由
admin + 50 共享资料的黑币奖励!

查看全部评分

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏1 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:871095 发表于 2020-12-30 17:15 | 只看该作者
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表