177 lines
4.8 KiB
C
177 lines
4.8 KiB
C
#include "debug.h"
|
||
|
||
/* 增加到主文件
|
||
void rf_init(void)
|
||
{
|
||
uint8_t addr[] = {0xa5,0x5a,0x11};
|
||
spi_init();
|
||
xn297l_init(addr,TX_ADR_WIDTH,RF_CHN,TX_PLOAD_WIDTH,XN297L_RF_POWER_P_11|RF_RATE_2M);
|
||
xn297l_tx_mode();
|
||
}
|
||
*/
|
||
|
||
|
||
uint8_t __dbg_data_up_0(void);
|
||
uint8_t __dbg_data_up_1(void);
|
||
uint8_t __dbg_data_up_2(void);
|
||
|
||
uint8_t dbg_update(void)
|
||
{
|
||
uint8_t (*func[])() = {
|
||
#if __PXGS_DEBUG_IMU != 0
|
||
__dbg_data_up_0,
|
||
#endif
|
||
#if __PXGS_DEBUG_ADC_PWM != 0
|
||
__dbg_data_up_1,
|
||
#endif
|
||
#if __PXGS_DEBUG_ALTHOLD != 0
|
||
__dbg_data_up_2,
|
||
#endif
|
||
NULL
|
||
};
|
||
uint8_t rf_bak_mode = 0xFF;
|
||
static uint8_t index = 0x00;
|
||
if(func[index] != NULL){
|
||
rf_bak_mode = func[index]();
|
||
index++;
|
||
if(func[index] == NULL){
|
||
index = 0;
|
||
}
|
||
}
|
||
else{
|
||
index = 0;
|
||
}
|
||
return rf_bak_mode;
|
||
}
|
||
|
||
//IMU数据
|
||
uint8_t __dbg_data_up_00(void)
|
||
{
|
||
uint8_t i;
|
||
#pragma pack(1)
|
||
struct{
|
||
//字符串数据包,长度<=30
|
||
struct{
|
||
PXGS_LEN_TYPE len;
|
||
PXGS_MID_TYPE mid;
|
||
uint8_t dat[25];
|
||
uint8_t datend;
|
||
}str;
|
||
}frame;
|
||
#pragma pack()
|
||
|
||
//加速度打包
|
||
frame.str.len = sizeof(frame.str) - 1;
|
||
frame.str.mid = PXGS_U_MID_PLOT_00;
|
||
for(i=0;i<10;i++) {
|
||
frame.str.dat[i] = '0'+i; //ps: 请添加数据
|
||
}
|
||
frame.str.datend = '\r';
|
||
return donglex_ex_send(&frame,sizeof(frame));
|
||
}
|
||
|
||
//IMU数据
|
||
uint8_t __dbg_data_up_0(void)
|
||
{
|
||
#pragma pack(1)
|
||
struct{
|
||
//加速度
|
||
struct{
|
||
PXGS_LEN_TYPE len;
|
||
PXGS_MID_TYPE mid;
|
||
PXGS_U_MID_PLOT_00_DATA_TYPE dat[3];
|
||
}acc;
|
||
//陀螺仪
|
||
struct{
|
||
PXGS_LEN_TYPE len;
|
||
PXGS_MID_TYPE mid;
|
||
PXGS_U_MID_PLOT_00_DATA_TYPE dat[3];
|
||
}gyro;
|
||
}frame;
|
||
#pragma pack()
|
||
|
||
//加速度打包
|
||
frame.acc.len = sizeof(frame.acc) - 1;
|
||
frame.acc.mid = PXGS_U_MID_PLOT_00;
|
||
frame.acc.dat[0] = PXGS_U_MID_PLOT_00_DATA_PACK(0); //ps: 请添加数据
|
||
frame.acc.dat[1] = PXGS_U_MID_PLOT_01_DATA_PACK(100); //ps: 请添加数据
|
||
frame.acc.dat[2] = PXGS_U_MID_PLOT_02_DATA_PACK(200); //ps: 请添加数据
|
||
|
||
//加速度打包
|
||
frame.gyro.len = sizeof(frame.gyro) - 1;
|
||
frame.gyro.mid = PXGS_U_MID_PLOT_03;
|
||
frame.gyro.dat[0] = PXGS_U_MID_PLOT_03_DATA_PACK(300); //ps: 请添加数据
|
||
frame.gyro.dat[1] = PXGS_U_MID_PLOT_04_DATA_PACK(400); //ps: 请添加数据
|
||
frame.gyro.dat[2] = PXGS_U_MID_PLOT_05_DATA_PACK(500); //ps: 请添加数据
|
||
|
||
return donglex_ex_send(&frame,sizeof(frame));
|
||
}
|
||
|
||
uint8_t __dbg_data_up_1(void)
|
||
{
|
||
#pragma pack(1)
|
||
struct{
|
||
|
||
//卡死电压
|
||
struct{
|
||
PXGS_LEN_TYPE len;
|
||
PXGS_MID_TYPE mid;
|
||
PXGS_U_MID_PLOT_14_DATA_TYPE dat[5];
|
||
}pwm;
|
||
|
||
//电池电压
|
||
struct{
|
||
PXGS_LEN_TYPE len;
|
||
PXGS_MID_TYPE mid;
|
||
PXGS_U_MID_PLOT_0C_DATA_TYPE dat[5];
|
||
}vol;
|
||
}frame;
|
||
#pragma pack()
|
||
|
||
//pwm总转速,M0/M1/M2/M3转速
|
||
frame.pwm.len = sizeof(frame.pwm) - 1;
|
||
frame.pwm.mid = PXGS_U_MID_PLOT_14;
|
||
frame.pwm.dat[0] = PXGS_U_MID_PLOT_14_DATA_PACK(200); //ps: 请添加数据
|
||
frame.pwm.dat[1] = PXGS_U_MID_PLOT_15_DATA_PACK(200); //ps: 请添加数据
|
||
frame.pwm.dat[2] = PXGS_U_MID_PLOT_16_DATA_PACK(200); //ps: 请添加数据
|
||
frame.pwm.dat[3] = PXGS_U_MID_PLOT_17_DATA_PACK(200); //ps: 请添加数据
|
||
frame.pwm.dat[4] = PXGS_U_MID_PLOT_18_DATA_PACK(200); //ps: 请添加数据
|
||
|
||
//卡死电压M0/M1/M2/M3,电池电压
|
||
frame.vol.len = sizeof(frame.vol) - 1;
|
||
frame.vol.mid = PXGS_U_MID_PLOT_0C;
|
||
frame.vol.dat[0] = PXGS_U_MID_PLOT_0C_DATA_PACK(300); //ps: 请添加数据
|
||
frame.vol.dat[1] = PXGS_U_MID_PLOT_0D_DATA_PACK(300); //ps: 请添加数据
|
||
frame.vol.dat[2] = PXGS_U_MID_PLOT_0E_DATA_PACK(300); //ps: 请添加数据
|
||
frame.vol.dat[3] = PXGS_U_MID_PLOT_0F_DATA_PACK(300); //ps: 请添加数据
|
||
frame.vol.dat[4] = PXGS_U_MID_PLOT_10_DATA_PACK(300); //ps: 请添加数据
|
||
|
||
return donglex_ex_send(&frame,sizeof(frame));
|
||
}
|
||
|
||
uint8_t __dbg_data_up_2(void)
|
||
{
|
||
#pragma pack(1)
|
||
struct{
|
||
struct{
|
||
PXGS_LEN_TYPE len;
|
||
PXGS_MID_TYPE mid;
|
||
PXGS_U_MID_PLOT_19_DATA_TYPE dat[6];
|
||
}alt;
|
||
}frame;
|
||
#pragma pack()
|
||
|
||
//气压计,融合高度....
|
||
frame.alt.len = sizeof(frame.alt) - 1;
|
||
frame.alt.mid = PXGS_U_MID_PLOT_19;
|
||
frame.alt.dat[0] = PXGS_U_MID_PLOT_19_DATA_PACK(400); //ps: 请添加数据
|
||
frame.alt.dat[1] = PXGS_U_MID_PLOT_1A_DATA_PACK(400); //ps: 请添加数据
|
||
frame.alt.dat[2] = PXGS_U_MID_PLOT_1B_DATA_PACK(400); //ps: 请添加数据
|
||
frame.alt.dat[3] = PXGS_U_MID_PLOT_1C_DATA_PACK(400); //ps: 请添加数据
|
||
frame.alt.dat[4] = PXGS_U_MID_PLOT_1D_DATA_PACK(400); //ps: 请添加数据
|
||
frame.alt.dat[5] = PXGS_U_MID_PLOT_1E_DATA_PACK(400); //ps: 请添加数据
|
||
|
||
return donglex_ex_send(&frame,sizeof(frame));
|
||
}
|
||
|