标题: 工控行业STM32单片机程序框架模板源码下载 [打印本页]

作者: tjpugyl    时间: 2018-7-24 14:20
标题: 工控行业STM32单片机程序框架模板源码下载
IO按键扫描 串口  E2PROM Flash AD DA LCD 触摸屏 fatfs文件系统  外设操作一应俱全,基于时间片轮转的状态机框架


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, 下载次数: 91)



作者: 神出没    时间: 2019-12-24 12:55
标记一下
作者: sphns    时间: 2020-5-27 16:39
标记一下

作者: karlzhong199619    时间: 2020-5-30 18:28
sphns 发表于 2020-5-27 16:39
标记一下

标记一下
作者: 张广磊    时间: 2020-8-17 09:49
标记一下
作者: starrysky9    时间: 2022-1-29 23:06
标记一下
作者: yinds5092    时间: 2022-2-9 09:57
51hei有你更精彩




欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1