main.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /********************** 头文件 *************************/
  2. #include "main.h"
  3. /********************** 变量区 *************************/
  4. /********************** 函数声明区 *************************/
  5. /********************** 系统函数区 *************************/
  6. void clocks_start( void )
  7. {
  8. NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
  9. NRF_CLOCK->TASKS_HFCLKSTART = 1;
  10. while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0);
  11. }
  12. void FPS_process(void)
  13. {
  14. #if DEBUG_FPS
  15. static uint32_t tim=0;
  16. static uint32_t fps=0;
  17. static uint32_t fps_max=0;
  18. fps = TIME_GetTicks()-fps;
  19. if(fps_max<fps) fps_max = fps;
  20. fps = TIME_GetTicks();
  21. if(TIME_GetTicks()-tim>=1000){ tim = TIME_GetTicks();
  22. SEGGER_RTT_printf(0,"fps=%d\rms\n",fps_max);
  23. fps_max = 0;
  24. }
  25. #endif
  26. }
  27. /********************** 主函数 *************************/
  28. int main(void)
  29. {
  30. clocks_start();
  31. #if DEBUG_EN
  32. ret_code_t err_code;
  33. err_code = NRF_LOG_INIT(NULL);
  34. APP_ERROR_CHECK(err_code);
  35. NRF_LOG_DEFAULT_BACKENDS_INIT();
  36. #endif
  37. USR_Init(); //用户初始化
  38. TIME_Init(); //滴答
  39. while (true)
  40. {
  41. USR_process(); //用户进程
  42. FPS_process();
  43. }
  44. }