main.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * Copyright (c) 2021 HPMicro
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. *
  6. */
  7. #include <stdio.h>
  8. #include "board.h"
  9. #include "test.h"
  10. #ifdef TEST_EN
  11. #include "bsp_V8M_YY_led.h"
  12. #include "bsp_V8M_YY_pwm.h"
  13. #include "bsp_V8M_YY_adc.h"
  14. #include "hard_system.h"
  15. #include "hard_system_time.h"
  16. #include "hard_system_delay.h"
  17. #include "hard_system_timer.h"
  18. #include "hard_imu_uart3.h"
  19. #include "hard_rc_sbus.h"
  20. #include "hard_can.h"
  21. #include "hard_sbus_out.h"
  22. #include "hard_flash_gd25q16.h"
  23. #include "drv_usart.h"
  24. #include "soft_sdcard.h"
  25. #include "bsp_V8M_flash.h"
  26. #include "soft_voltage.h"
  27. #include "main.h"
  28. #include "hpm_math.h"
  29. #endif
  30. /*
  31. 1 手册:中断源优先级,有效值为 0 到 7。
  32. 2 注意:内存缓存问题 catch
  33. 如果DMA要访问​ → 必须用非缓存宏
  34. 如果多核要共享​ → 必须用非缓存宏
  35. 如果频繁被中断更新​ → 建议用非缓存宏
  36. 其他情况​ → 不用修饰,让编译器优化
  37. 3 注意配置顺序 IO-时钟-外设
  38. 4 XDMA,作为主设备连接到 AXI 系统总线 HDMA,作为主设备连接到 AHB 外设总线
  39. 当 XDMA 的 destination 为 DRAM 时,如果 burst 大于等于 16,那 destsize 必须为 64bit。
  40. DMAMUX 的输出 0∼7 连接到外设总线 DMA 控制器 HDMA,DMAMUX 的输出 8∼15 连接到系统总线 DMA 控制器 XDMA
  41. 它们都连接在统一的 DMAMUX(DMA 多路复用器)
  42. DMAMUX将所有外设的 DMA 请求(Request)统一管理,然后根据你的配置分配给 HDMA 或 XDMA 的任意空闲通道
  43. 5 注意cfg文件和一些前置的工程配置文件,可能导致编译出错 运行出错 仿真不了 重点:链接文件、yaml、板级cfg文件
  44. */
  45. uint64_t delta_time;
  46. #define PI (3.1415926f)
  47. void start_time(void)
  48. {
  49. delta_time = hpm_csr_get_core_mcycle();
  50. }
  51. uint32_t get_end_time(void)
  52. {
  53. delta_time = hpm_csr_get_core_mcycle() - delta_time;
  54. return delta_time;
  55. }
  56. float theta ;
  57. float sin_theta;
  58. #ifdef TEST_EN
  59. static void test_hard(void)
  60. {
  61. // v8m_yy_led_test();
  62. // v8m_yy_motor_pwm_test();
  63. // v8m_yy_adc_test();
  64. // timer0_test();
  65. // cpu_delay_test();
  66. // timer1_test();
  67. can2_test();
  68. // imu_uart3_test();
  69. // uart2_sbus_test();
  70. // system_test();
  71. // sbus_uart2_out_test();
  72. // test_gd25q16_quick();
  73. // sd_test_demo();
  74. // run_flash_tests();
  75. // run_time_test();
  76. // run_system_test_with_reset(100);
  77. // soft_vol_test();
  78. while(1)
  79. {
  80. theta += PI*0.1;
  81. sin_theta = hpm_dsp_sin_f32(theta);
  82. //uart_test_main(0);
  83. board_delay_ms(200);
  84. //printf("sin theta is %f\r\n", sin_theta);
  85. }
  86. }
  87. #endif
  88. int main(void)
  89. {
  90. board_init();
  91. float i = 9.8f;
  92. sin_theta = hpm_dsp_sin_f32(theta);
  93. //printf("hello world %f\n", i);
  94. //printf("sin theta is %f\r\n", sin_theta);
  95. #ifdef TEST_EN
  96. test_hard();
  97. #endif
  98. return 0;
  99. }
  100. // DMA 最大4k