main.c 2.5 KB

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