72 lines
2.0 KiB
C
72 lines
2.0 KiB
C
#include "app_config.h"
|
|
#include "app_dependence.h"
|
|
#include "interface.h"
|
|
|
|
#include "app_frm_monitor.h"
|
|
#include "app_frm_signal.h"
|
|
#include "app_frm_timer.h"
|
|
|
|
#include "app_test.h"
|
|
|
|
uint8_t IP1[4] = { 192, 168, 17, 33 }; //IP address
|
|
|
|
|
|
// 定时器结构体
|
|
Timer test_timer;
|
|
|
|
// 定时器信号处理函数
|
|
void testTimerProcess(void *signal_id)
|
|
{
|
|
(void)signal_id; // 标记变量为已使用,避免编译器警告
|
|
static uint32_t start_time = 0;
|
|
// short hx,hy,hz=0;
|
|
|
|
|
|
printf("testAPP: %d us \n",getCurrentTime() - start_time);
|
|
|
|
// uint8_t arrtest4[10] = {0x56,0x56,0x04};
|
|
|
|
printf("AccX:%f,AccY:%f,AccZ:%f,",Acc[0],Acc[1],Acc[2]);
|
|
printf("GyroX:%f,GyroY:%f,GyroZ:%f\r\n",Gyro[0],Gyro[1],Gyro[2]);//使用串口打印加速度,角速度数据
|
|
printf("RM3100 hx: %d, hy: %d, hz: %d\r\n", navigation_output1.bit_data.magnetic_x_axis, navigation_output1.bit_data.magnetic_y_axis, navigation_output1.bit_data.magnetic_z_axis);
|
|
|
|
|
|
// uint8_t tesr1 = 0;
|
|
// uint8_t tesr2 = 0;
|
|
|
|
// tesr1 ++;
|
|
// wrbyte_24c02(0x10,tesr1);
|
|
// Delay_Ms(2);
|
|
// tesr2 = rdbyte_24c02(0x10);
|
|
// printf("tesr1:%d,tesr2:%d,",tesr1,tesr2);
|
|
|
|
|
|
// uint8_t arrtest8[10] = {0x56,0x56,0x01,0,0,0,0,0,0,0};
|
|
// uartSendto(UART4, arrtest4, 5);
|
|
// uartSendto(UART8, arrtest8, 5);
|
|
// uartSendto(UART6, arrtest4, 5);
|
|
// uartSendto(UART7, arrtest8, 10);
|
|
// ETHUDPTxLen = 8;
|
|
// UdpSendToData(SocketId,arrtest4,ÐUDPTxLen,IP1,8011);//测试
|
|
|
|
|
|
start_time = getCurrentTime();
|
|
|
|
// 再次启动定时器,实现周期定时
|
|
timerStart(&test_timer, 1000,1);
|
|
}
|
|
|
|
|
|
// APP模块的初始化
|
|
void testAppInit(void)
|
|
{
|
|
// 初始化定时器
|
|
timerInit(&test_timer);
|
|
// 订阅定时器信号,用于停止电机
|
|
subscribe(&test_timer, testTimerProcess);
|
|
|
|
printf("testAPP: initial OK %d\n",getCurrentTime());
|
|
|
|
timerStart(&test_timer, 1000,1);//1ms
|
|
}
|