/* * Copyright (c) 2021 HPMicro * * SPDX-License-Identifier: BSD-3-Clause * */ #include #include "board.h" #include "test.h" #ifdef TEST_EN #include "bsp_V8M_YY_led.h" #include "bsp_V8M_YY_pwm.h" #include "bsp_V8M_YY_adc.h" #include "hard_system.h" #include "hard_system_time.h" #include "hard_system_delay.h" #include "hard_system_timer.h" #include "hard_imu_uart3.h" #include "hard_rc_sbus.h" #include "hard_can.h" #include "hard_sbus_out.h" #include "main.h" #include "hpm_math.h" #endif /* 1 手册:中断源优先级,有效值为 0 到 7。 2 注意:内存缓存问题 catch 如果DMA要访问​ → 必须用非缓存宏 如果多核要共享​ → 必须用非缓存宏 如果频繁被中断更新​ → 建议用非缓存宏 其他情况​ → 不用修饰,让编译器优化 3 注意配置顺序 IO-时钟-外设 4 XDMA,作为主设备连接到 AXI 系统总线 HDMA,作为主设备连接到 AHB 外设总线 当 XDMA 的 destination 为 DRAM 时,如果 burst 大于等于 16,那 destsize 必须为 64bit。 DMAMUX 的输出 0∼7 连接到外设总线 DMA 控制器 HDMA,DMAMUX 的输出 8∼15 连接到系统总线 DMA 控制器 XDMA 它们都连接在统一的 DMAMUX(DMA 多路复用器) DMAMUX将所有外设的 DMA 请求(Request)统一管理,然后根据你的配置分配给 HDMA 或 XDMA 的任意空闲通道 5 注意cfg文件和一些前置的工程配置文件,可能导致编译出错 运行出错 仿真不了 重点:链接文件、yaml、板级cfg文件 */ uint64_t delta_time; #define PI (3.1415926f) void start_time(void) { delta_time = hpm_csr_get_core_mcycle(); } uint32_t get_end_time(void) { delta_time = hpm_csr_get_core_mcycle() - delta_time; return delta_time; } float theta ; float sin_theta; static void test_hard(void) { // v8m_yy_led_test(); // v8m_yy_motor_pwm_test(); // v8m_yy_adc_test(); // timer0_test(); // cpu_delay_test(); // timer1_test(); // can2_test(); // imu_uart3_test(); // uart2_sbus_test(); // system_test(); // sbus_uart2_out_test(); while(1) { theta += PI*0.1; sin_theta = hpm_dsp_sin_f32(theta); board_delay_ms(200); printf("sin theta is %f\r\n", sin_theta); } } int main(void) { board_init(); float i = 9.8f; sin_theta = hpm_dsp_sin_f32(theta); printf("hello world %f\n", i); printf("sin theta is %f\r\n", sin_theta); test_hard(); return 0; } //// DMA 最大4k