177 lines
4.8 KiB
C
177 lines
4.8 KiB
C
|
#include "debug.h"
|
|||
|
|
|||
|
/* <20><><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD>ļ<EFBFBD>
|
|||
|
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<4D><55><EFBFBD><EFBFBD>
|
|||
|
uint8_t __dbg_data_up_00(void)
|
|||
|
{
|
|||
|
uint8_t i;
|
|||
|
#pragma pack(1)
|
|||
|
struct{
|
|||
|
//<2F>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD><DDB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><=30
|
|||
|
struct{
|
|||
|
PXGS_LEN_TYPE len;
|
|||
|
PXGS_MID_TYPE mid;
|
|||
|
uint8_t dat[25];
|
|||
|
uint8_t datend;
|
|||
|
}str;
|
|||
|
}frame;
|
|||
|
#pragma pack()
|
|||
|
|
|||
|
//<2F><><EFBFBD>ٶȴ<D9B6><C8B4><EFBFBD>
|
|||
|
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: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
}
|
|||
|
frame.str.datend = '\r';
|
|||
|
return donglex_ex_send(&frame,sizeof(frame));
|
|||
|
}
|
|||
|
|
|||
|
//IMU<4D><55><EFBFBD><EFBFBD>
|
|||
|
uint8_t __dbg_data_up_0(void)
|
|||
|
{
|
|||
|
#pragma pack(1)
|
|||
|
struct{
|
|||
|
//<2F><><EFBFBD>ٶ<EFBFBD>
|
|||
|
struct{
|
|||
|
PXGS_LEN_TYPE len;
|
|||
|
PXGS_MID_TYPE mid;
|
|||
|
PXGS_U_MID_PLOT_00_DATA_TYPE dat[3];
|
|||
|
}acc;
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
struct{
|
|||
|
PXGS_LEN_TYPE len;
|
|||
|
PXGS_MID_TYPE mid;
|
|||
|
PXGS_U_MID_PLOT_00_DATA_TYPE dat[3];
|
|||
|
}gyro;
|
|||
|
}frame;
|
|||
|
#pragma pack()
|
|||
|
|
|||
|
//<2F><><EFBFBD>ٶȴ<D9B6><C8B4><EFBFBD>
|
|||
|
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: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
frame.acc.dat[1] = PXGS_U_MID_PLOT_01_DATA_PACK(100); //ps: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
frame.acc.dat[2] = PXGS_U_MID_PLOT_02_DATA_PACK(200); //ps: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
//<2F><><EFBFBD>ٶȴ<D9B6><C8B4><EFBFBD>
|
|||
|
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: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
frame.gyro.dat[1] = PXGS_U_MID_PLOT_04_DATA_PACK(400); //ps: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
frame.gyro.dat[2] = PXGS_U_MID_PLOT_05_DATA_PACK(500); //ps: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
return donglex_ex_send(&frame,sizeof(frame));
|
|||
|
}
|
|||
|
|
|||
|
uint8_t __dbg_data_up_1(void)
|
|||
|
{
|
|||
|
#pragma pack(1)
|
|||
|
struct{
|
|||
|
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ
|
|||
|
struct{
|
|||
|
PXGS_LEN_TYPE len;
|
|||
|
PXGS_MID_TYPE mid;
|
|||
|
PXGS_U_MID_PLOT_14_DATA_TYPE dat[5];
|
|||
|
}pwm;
|
|||
|
|
|||
|
//<2F><><EFBFBD>ص<EFBFBD>ѹ
|
|||
|
struct{
|
|||
|
PXGS_LEN_TYPE len;
|
|||
|
PXGS_MID_TYPE mid;
|
|||
|
PXGS_U_MID_PLOT_0C_DATA_TYPE dat[5];
|
|||
|
}vol;
|
|||
|
}frame;
|
|||
|
#pragma pack()
|
|||
|
|
|||
|
//pwm<77><6D>ת<EFBFBD>٣<EFBFBD>M0/M1/M2/M3ת<33><D7AA>
|
|||
|
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: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
frame.pwm.dat[1] = PXGS_U_MID_PLOT_15_DATA_PACK(200); //ps: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
frame.pwm.dat[2] = PXGS_U_MID_PLOT_16_DATA_PACK(200); //ps: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
frame.pwm.dat[3] = PXGS_U_MID_PLOT_17_DATA_PACK(200); //ps: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
frame.pwm.dat[4] = PXGS_U_MID_PLOT_18_DATA_PACK(200); //ps: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹM0/M1/M2/M3,<2C><><EFBFBD>ص<EFBFBD>ѹ
|
|||
|
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: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
frame.vol.dat[1] = PXGS_U_MID_PLOT_0D_DATA_PACK(300); //ps: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
frame.vol.dat[2] = PXGS_U_MID_PLOT_0E_DATA_PACK(300); //ps: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
frame.vol.dat[3] = PXGS_U_MID_PLOT_0F_DATA_PACK(300); //ps: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
frame.vol.dat[4] = PXGS_U_MID_PLOT_10_DATA_PACK(300); //ps: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
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()
|
|||
|
|
|||
|
//<2F><>ѹ<EFBFBD>ƣ<EFBFBD><C6A3>ںϸ߶<CFB8>....
|
|||
|
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: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
frame.alt.dat[1] = PXGS_U_MID_PLOT_1A_DATA_PACK(400); //ps: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
frame.alt.dat[2] = PXGS_U_MID_PLOT_1B_DATA_PACK(400); //ps: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
frame.alt.dat[3] = PXGS_U_MID_PLOT_1C_DATA_PACK(400); //ps: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
frame.alt.dat[4] = PXGS_U_MID_PLOT_1D_DATA_PACK(400); //ps: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
frame.alt.dat[5] = PXGS_U_MID_PLOT_1E_DATA_PACK(400); //ps: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
return donglex_ex_send(&frame,sizeof(frame));
|
|||
|
}
|
|||
|
|