app.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 measure_time_t g_meas_hall;
  14. extern measure_time_t g_meas_foc;
  15. extern measure_time_t g_meas_timeup;
  16. static void mc_exec_log(void) {
  17. sys_debug("intval = %d, err = %d, %d, %d, count = %d\n", g_meas_foc.intval_time, g_meas_foc.intval_time_error, g_meas_foc.intval_low_err, g_meas_foc.intval_hi_err, g_meas_foc.exec_count);
  18. sys_debug("timeup intval = %d, err = %d\n\n", g_meas_timeup.intval_time, g_meas_timeup.intval_time_error);
  19. }
  20. void app_start(void){
  21. set_log_level(MOD_SYSTEM, L_debug);
  22. can_message_init();
  23. restore_config();
  24. mc_init();
  25. shark_task_create(_app_low_task, NULL);
  26. sys_debug("mc start\n");
  27. shark_task_run();
  28. }
  29. static void _can_report_info(void) {
  30. //can_report_speed(0x45, PMSM_FOC_GetSpeed());
  31. }
  32. static u32 _app_low_task(void *args) {
  33. wdog_reload();
  34. _can_report_info();
  35. mc_exec_log();
  36. return 1000;
  37. }