app.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #include "app/app.h"
  2. #include "bsp/bsp.h"
  3. #include "os/os_task.h"
  4. #include "libs/logger.h"
  5. #include "libs/utils.h"
  6. #include "foc/motor/motor.h"
  7. #include "foc/samples.h"
  8. #include "prot/can_foc_msg.h"
  9. #include "prot/can_message.h"
  10. #include "libs/time_measure.h"
  11. #include "app/nv_storage.h"
  12. static u32 _app_low_task(void *args);
  13. extern void PMSM_FOC_LogDebug(void);
  14. extern measure_time_t g_meas_hall;
  15. extern measure_time_t g_meas_foc;
  16. extern measure_time_t g_meas_timeup;
  17. static void mc_exec_log(void) {
  18. sys_debug("intval = %d, exec = %d, err = %d, %d, %d, count = %d\n", g_meas_foc.intval_time, g_meas_foc.exec_time, g_meas_foc.intval_time_error, g_meas_foc.intval_low_err, g_meas_foc.intval_hi_err, g_meas_foc.exec_count);
  19. sys_debug("timeup intval = %d, err = %d\n\n", g_meas_timeup.intval_time, g_meas_timeup.intval_time_error);
  20. PMSM_FOC_LogDebug();
  21. }
  22. void app_start(void){
  23. set_log_level(MOD_SYSTEM, L_debug);
  24. can_message_init();
  25. restore_config();
  26. mc_init();
  27. shark_task_create(_app_low_task, NULL);
  28. sys_debug("mc start\n");
  29. shark_task_run();
  30. }
  31. static void _can_report_info(void) {
  32. //can_report_speed(0x45, PMSM_FOC_GetSpeed());
  33. }
  34. static u32 _app_low_task(void *args) {
  35. wdog_reload();
  36. _can_report_info();
  37. mc_exec_log();
  38. return 1000;
  39. }