部分驱动代码完成,待测试
This commit is contained in:
@ -21,6 +21,8 @@
|
||||
#include "calculate/skiing_tracker.h"
|
||||
#include "xtell.h"
|
||||
#include "./ano/ano_protocol.h"
|
||||
#include "./sensor/MMC56.h"
|
||||
#include "./sensor/BMP280.h"
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//宏定义
|
||||
#define ENABLE_XLOG 1
|
||||
@ -460,56 +462,66 @@ void xt_hw_iic_test(){
|
||||
|
||||
void sensor_measure(void){
|
||||
// xlog("=======sensor_read_data START\n");
|
||||
static signed short combined_raw_data[6];
|
||||
static int initialized = 0;
|
||||
static int calibration_done = 0;
|
||||
char status = 0;
|
||||
// static signed short combined_raw_data[6];
|
||||
// static int initialized = 0;
|
||||
// static int calibration_done = 0;
|
||||
// char status = 0;
|
||||
|
||||
if(count_test1 >= 100){
|
||||
count_test1 = 0;
|
||||
xlog("count_test1\n");
|
||||
}
|
||||
count_test1++;
|
||||
// if(count_test1 >= 100){
|
||||
// count_test1 = 0;
|
||||
// xlog("count_test1\n");
|
||||
// }
|
||||
// count_test1++;
|
||||
|
||||
static sensor_data_t tmp;
|
||||
SL_SC7U22_RawData_Read(tmp.acc_data,tmp.gyr_data);
|
||||
// xlog("=======sensor_read_data middle 1\n");
|
||||
memcpy(&combined_raw_data[0], tmp.acc_data, 3 * sizeof(signed short));
|
||||
memcpy(&combined_raw_data[3], tmp.gyr_data, 3 * sizeof(signed short));
|
||||
// static sensor_data_t tmp;
|
||||
// SL_SC7U22_RawData_Read(tmp.acc_data,tmp.gyr_data);
|
||||
// // xlog("=======sensor_read_data middle 1\n");
|
||||
// memcpy(&combined_raw_data[0], tmp.acc_data, 3 * sizeof(signed short));
|
||||
// memcpy(&combined_raw_data[3], tmp.gyr_data, 3 * sizeof(signed short));
|
||||
|
||||
if (!calibration_done) { //第1次启动,开启零漂检测
|
||||
// status = SL_SC7U22_Angle_Output(1, combined_raw_data, tmp.angle, 0);
|
||||
// status = SIX_SL_SC7U22_Angle_Output(1, combined_raw_data, tmp.angle, 0);
|
||||
// status = Original_SL_SC7U22_Angle_Output(1, combined_raw_data, tmp.angle, 0);
|
||||
status = Q_SL_SC7U22_Angle_Output(1, combined_raw_data, tmp.angle, 0, tmp.quaternion_output);
|
||||
// if (!calibration_done) { //第1次启动,开启零漂检测
|
||||
// // status = SL_SC7U22_Angle_Output(1, combined_raw_data, tmp.angle, 0);
|
||||
// // status = SIX_SL_SC7U22_Angle_Output(1, combined_raw_data, tmp.angle, 0);
|
||||
// // status = Original_SL_SC7U22_Angle_Output(1, combined_raw_data, tmp.angle, 0);
|
||||
// status = Q_SL_SC7U22_Angle_Output(1, combined_raw_data, tmp.angle, 0, tmp.quaternion_output);
|
||||
|
||||
int count = 0;
|
||||
if(count > 100){
|
||||
count = 0;
|
||||
char log_buffer[100];
|
||||
// snprintf( log_buffer, sizeof(log_buffer),"status:%d\n",status);
|
||||
// send_data_to_ble_client(&log_buffer,strlen(log_buffer));
|
||||
xlog("status:%d\n", status);
|
||||
}
|
||||
count++;
|
||||
// int count = 0;
|
||||
// if(count > 100){
|
||||
// count = 0;
|
||||
// char log_buffer[100];
|
||||
// // snprintf( log_buffer, sizeof(log_buffer),"status:%d\n",status);
|
||||
// // send_data_to_ble_client(&log_buffer,strlen(log_buffer));
|
||||
// xlog("status:%d\n", status);
|
||||
// }
|
||||
// count++;
|
||||
|
||||
if (status == 1) {
|
||||
calibration_done = 1;
|
||||
printf("Sensor calibration successful! Skiing mode is active.\n");
|
||||
}
|
||||
} else {
|
||||
// printf("Calculate the time interval =============== start\n");
|
||||
// status = SL_SC7U22_Angle_Output(0, combined_raw_data, tmp.angle, 0);
|
||||
// status = SIX_SL_SC7U22_Angle_Output(0, combined_raw_data, tmp.angle, 0);
|
||||
// status = Original_SL_SC7U22_Angle_Output(0, combined_raw_data, tmp.angle, 0);
|
||||
status = Q_SL_SC7U22_Angle_Output(0, combined_raw_data, tmp.angle, 0, tmp.quaternion_output);
|
||||
memcpy(tmp.acc_data, &combined_raw_data[0], 3 * sizeof(signed short));
|
||||
memcpy(tmp.gyr_data, &combined_raw_data[3], 3 * sizeof(signed short));
|
||||
BLE_send_data_t data_by_calculate = sensor_processing_task(tmp.acc_data, tmp.gyr_data,tmp.angle, tmp.quaternion_output);
|
||||
extern void ano_send_attitude_data(float rol, float pit, float yaw, uint8_t fusion_sta) ;
|
||||
ano_send_attitude_data(tmp.angle[0],tmp.angle[1],tmp.angle[2], 1);
|
||||
}
|
||||
// if (status == 1) {
|
||||
// calibration_done = 1;
|
||||
// printf("Sensor calibration successful! Skiing mode is active.\n");
|
||||
// }
|
||||
// } else {
|
||||
// // printf("Calculate the time interval =============== start\n");
|
||||
// // status = SL_SC7U22_Angle_Output(0, combined_raw_data, tmp.angle, 0);
|
||||
// // status = SIX_SL_SC7U22_Angle_Output(0, combined_raw_data, tmp.angle, 0);
|
||||
// // status = Original_SL_SC7U22_Angle_Output(0, combined_raw_data, tmp.angle, 0);
|
||||
// status = Q_SL_SC7U22_Angle_Output(0, combined_raw_data, tmp.angle, 0, tmp.quaternion_output);
|
||||
// memcpy(tmp.acc_data, &combined_raw_data[0], 3 * sizeof(signed short));
|
||||
// memcpy(tmp.gyr_data, &combined_raw_data[3], 3 * sizeof(signed short));
|
||||
// BLE_send_data_t data_by_calculate = sensor_processing_task(tmp.acc_data, tmp.gyr_data,tmp.angle, tmp.quaternion_output);
|
||||
// extern void ano_send_attitude_data(float rol, float pit, float yaw, uint8_t fusion_sta) ;
|
||||
// ano_send_attitude_data(tmp.angle[0],tmp.angle[1],tmp.angle[2], 1);
|
||||
|
||||
|
||||
// }
|
||||
|
||||
mmc5603nj_mag_data_t mag_data;
|
||||
// mmc5603nj_read_mag_data(&mag_data);
|
||||
|
||||
// if(count_test2 > 100){
|
||||
// count_test2++;
|
||||
printf("Mag X: %.4f, Y: %.4f, Z: %.4f Gauss\n", mag_data.x, mag_data.y, mag_data.z);
|
||||
// }
|
||||
// count_test2++;
|
||||
// xlog("=======sensor_read_data END\n");
|
||||
}
|
||||
|
||||
@ -539,8 +551,27 @@ void xtell_task_create(void){
|
||||
// delay_2ms(10);
|
||||
|
||||
SL_SC7U22_Config();
|
||||
// extern u8 LIS2DH12_Config(void);
|
||||
// LIS2DH12_Config();
|
||||
// if (mmc5603nj_init() != 0) {
|
||||
// xlog("MMC5603NJ initialization failed!\n");
|
||||
// }
|
||||
// xlog("MMC5603NJ PID: 0x%02X\n", mmc5603nj_get_pid());
|
||||
// // 启用连续测量模式
|
||||
// mmc5603nj_enable_continuous_mode();
|
||||
// xlog("Continuous measurement mode enabled.\n");
|
||||
|
||||
//iic总线设备扫描
|
||||
extern void i2c_scanner_probe(void);
|
||||
i2c_scanner_probe();
|
||||
|
||||
if(bmp280_init() != 0){
|
||||
xlog("bmp280 init error\n");
|
||||
}
|
||||
float temp, press;
|
||||
bmp280_read_data(&temp, &press);
|
||||
xlog("get temp: %d, get press: %d\n",temp, press);
|
||||
|
||||
|
||||
|
||||
|
||||
xlog("xtell_task_create\n");
|
||||
// 初始化环形缓冲区
|
||||
@ -548,7 +579,7 @@ void xtell_task_create(void){
|
||||
|
||||
|
||||
ano_protocol_init(115200);
|
||||
create_process(&calculate_data_id, "calculate",NULL, sensor_measure, 10);
|
||||
create_process(&calculate_data_id, "calculate",NULL, sensor_measure, 2000);
|
||||
|
||||
circle_buffer_init(&sensor_read, sensor_read_buffer, SENSOR_DATA_BUFFER_SIZE, sizeof(sensor_data_t));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user