| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- /*
- * Copyright (c) 2021 HPMicro
- *
- * SPDX-License-Identifier: BSD-3-Clause
- *
- */
- #if 0
- #include <stdio.h>
- #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 "hard_flash_gd25q16.h"
- #include "drv_usart.h"
- #include "soft_sdcard.h"
- #include "bsp_V8M_flash.h"
- #include "soft_voltage.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;
- #ifdef TEST_EN
- 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();
- // test_gd25q16_quick();
- // sd_test_demo();
- // run_flash_tests();
- // run_time_test();
- // run_system_test_with_reset(100);
- // soft_vol_test();
- while(1)
- {
- theta += PI*0.1;
- sin_theta = hpm_dsp_sin_f32(theta);
- //uart_test_main(0);
- board_delay_ms(200);
- //printf("sin theta is %f\r\n", sin_theta);
- }
-
- }
- #endif
- 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);
- #ifdef TEST_EN
- test_hard();
- #endif
- return 0;
- }
- // DMA 最大4k
- #endif
- #if 1
- #include "main.h"
- #include "auto_pilot.h"
- #include "data_save.h"
- #include "params.h"
- #include "pilot_init.h"
- #include "soft_can.h"
- #include "soft_flash.h"
- #include "soft_gs.h"
- #include "soft_imu.h"
- #include "soft_port_uart4.h"
- #include "soft_rc_input.h"
- #include "soft_time.h"
- #include "soft_timer.h"
- #include "ver_config.h"
- // while 正常循环不带写FLASH需要
- int main(void)
- {
- // 自驾仪初始化,耗时2.8s
- auto_pilot_init();
- while (1)
- {
- // 解析导航数据
- get_right_ins_data();
- // 主要控制循环
- pilot_main_loop();
- // 控制参数写入flash
- write_par_to_flash();
- // 数据传向地面站
- gs_receive_msg_poll(&gcs_link);
- // 解析地面站的消息
- gs_send_msg_poll(&gcs_link);
- // 解析can总线的消息
- CanTxRxServicePoll();
- // 解析载荷串口的消息数据
- // 发送数据给IMU
- send_msg_to_imu();
- #ifdef REC_DATA_POS
- data_record_service();
- #endif
- // 串口 4 服务函数
- Port4_Service();
- } // while
- } // main
- #endif
- //------------------End of File----------------------------
|