找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 4615|回复: 6
收起左侧

工控行业STM32单片机程序框架模板源码下载

  [复制链接]
ID:378458 发表于 2018-7-24 14:20 | 显示全部楼层 |阅读模式
IO按键扫描 串口  E2PROM Flash AD DA LCD 触摸屏 fatfs文件系统  外设操作一应俱全,基于时间片轮转的状态机框架
0.png 0.png

STM32单片机源程序如下:
  1. /* Includes ------------------------------------------------------------------*/
  2. #ifndef _ONPCSIMU_
  3.         #include "app.h"
  4. #endif
  5. #include "res.h"
  6. #include "icon.h"
  7. #include "ctrlcfg.h"
  8. #include "ctrl.h"
  9. #include "event.h"
  10. #include "log.h"
  11. #include "string.h"
  12. #include "delay.h"
  13. #include "gui.h"
  14. #include "touch.h"
  15. #include "can_protomod.h"
  16. #include "buzzer.h"
  17. #ifndef _ONPCSIMU_
  18. #include "recipe.h"
  19. #endif

  20. _UINT16 g_mainflag = 0;

  21. extern void idle_modbus(void);
  22. extern void Error_Process (void);
  23. extern _BYTE SetAlarm( _UINT16 id, _UINT16 reference, _UINT16 uls, _UINT16 lls , _UINT16 strid, _UINT16 mode);
  24. extern void welcomTimerout(void);
  25. extern void Comm_Timerout_Check (void);

  26. _UINT32 ad_timer=0 ;
  27. _BYTE tim_100ms =0,time_500ms=0;
  28. extern _UINT16 g_appSta;

  29. int main(void)
  30. {

  31.         if( g_mainflag == 0 )
  32.         {
  33.                 // for test
  34.                 App_Init ();

  35.                 Var_Init ();

  36.                 LCM_SPI_Flash_Init ();

  37.                 gClearScreen (WHITE);

  38.                 Display_ON();
  39.                 BackLight (90);

  40.                 g_mainflag = 1;
  41.         }

  42. #ifndef _ONPCSIMU_
  43.         while (1)
  44. #endif
  45.         {

  46. #ifndef _ONPCSIMU_
  47.                 if((get_milliseconds()-ad_timer)>=(_UINT32)10)
  48.                 {
  49.                         ad_timer = get_milliseconds();
  50.                 //        Get_AD1 ();
  51.                         Touch_Panel_Getxy ();

  52.                         switch (tim_100ms)
  53.                         {
  54.                                 case 0:

  55.                                 break;

  56.                                 case 1:
  57.                                 BeepTimerCb();
  58.                                 break;

  59.                                 case 2:

  60.                                 break;

  61.                                 case 3:

  62.                                 break;

  63.                                 case 4:

  64.                                 break;

  65.                                 case 5:
  66.                                 Backlight_Powersave ();
  67.                                 break;

  68.                                 case 6:

  69.                                 break;

  70.                                 case 7:
  71.                                 Comm_Timerout_Check ();
  72.                                 break;

  73.                                 case 8:


  74.                                 break;

  75.                                 case 9:
  76.                                 time_500ms++ ;
  77.                                 if (time_500ms >= 5)
  78.                                 {
  79.                                         time_500ms = 0;
  80.                                         Error_Process ();
  81.                                 }
  82.                                 break;

  83.                         }

  84.                         tim_100ms ++;

  85.                         if (tim_100ms >= 10)
  86.                                 tim_100ms = 0;
  87.                 }


  88. #else
  89.                 if((get_milliseconds()-ad_timer)>=(_UINT32)10)
  90.                 {
  91.                         ad_timer = get_milliseconds();
  92.                         {
  93.                                 switch (tim_100ms)
  94.                                 {       
  95.                                         case 9:
  96.                                         time_500ms++ ;
  97.                                         if (time_500ms >= 5)
  98.                                         {
  99.                                                 time_500ms = 0;
  100.                                         }

  101.                                         break;
  102.                                         default:
  103.                                         break;
  104.        
  105.                                 }
  106.        
  107.                                 tim_100ms ++;
  108.        
  109.                                 if (tim_100ms >= 10)
  110.                                         tim_100ms = 0;
  111.                         }

  112.                 }

  113. #endif
  114.         }
  115. }


  116. #ifdef _ONPCSIMU_
  117. void idleProcess( void )
  118. {
  119.         main();
  120. }
  121. #endif
复制代码

所有资料51hei提供下载:
demo.rar (1.03 MB, 下载次数: 90)

评分

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

查看全部评分

回复

使用道具 举报

ID:108573 发表于 2019-12-24 12:55 | 显示全部楼层
标记一下
回复

使用道具 举报

ID:332724 发表于 2020-5-27 16:39 | 显示全部楼层
标记一下
回复

使用道具 举报

ID:697069 发表于 2020-5-30 18:28 | 显示全部楼层

标记一下
回复

使用道具 举报

ID:298215 发表于 2020-8-17 09:49 | 显示全部楼层
标记一下
回复

使用道具 举报

ID:949844 发表于 2022-1-29 23:06 | 显示全部楼层
标记一下
回复

使用道具 举报

ID:914666 发表于 2022-2-9 09:57 | 显示全部楼层
51hei有你更精彩
回复

使用道具 举报

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

本版积分规则

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

Powered by 单片机教程网

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