蓝牙协议完成
This commit is contained in:
@ -62,7 +62,8 @@ typedef struct {
|
||||
// -- 速度 --
|
||||
uint16_t speed_cms;
|
||||
// -- 气压计 --
|
||||
//...
|
||||
int adc_P;
|
||||
int adc_T;
|
||||
} BLE_send_data_t;
|
||||
|
||||
static int count = 0;
|
||||
@ -101,9 +102,10 @@ void SC7U22_static_calibration(void){
|
||||
extern u16 SC7U22_calibration_id;
|
||||
extern u8 SC7U22_init;
|
||||
first_set_flag = 0;
|
||||
SC7U22_init = 1;
|
||||
SC7U22_init = 0x11;
|
||||
close_process(&SC7U22_calibration_id, "SC7U22_calibration");
|
||||
u8 send2_1[5] = {0xBB,0xBE,0x02,0x00,0x01};
|
||||
u8 send2_1[5] = {0xBB,0xBE,0x02,0x00,0x00};
|
||||
send2_1[4] = SC7U22_init;
|
||||
send_data_to_ble_client(&send2_1,5);
|
||||
}
|
||||
if(count > 100){
|
||||
@ -134,14 +136,19 @@ void start_collect_fuc(void){
|
||||
signed short gyr_data_buf[3];
|
||||
float angle[3];
|
||||
float quaternion_output[3];
|
||||
|
||||
// -- 读数据 --
|
||||
SL_SC7U22_RawData_Read(acc_data_buf,gyr_data_buf);
|
||||
mmc5603nj_read_origin_data(mmc5603nj_buffer);
|
||||
bmp280_read_originanl_data(&BLE_send_data_tmp.adc_P, &BLE_send_data_tmp.adc_T);
|
||||
|
||||
memcpy(&combined_raw_data[0], acc_data_buf, 3 * sizeof(signed short));
|
||||
memcpy(&combined_raw_data[3], gyr_data_buf, 3 * sizeof(signed short));
|
||||
|
||||
// -- 四元数 --
|
||||
status = Q_SL_SC7U22_Angle_Output(0, combined_raw_data, angle,NULL, 0, quaternion_output);
|
||||
|
||||
// -- 速度计算 --
|
||||
memcpy(acc_data_buf, &combined_raw_data[0], 3 * sizeof(signed short));
|
||||
memcpy(gyr_data_buf, &combined_raw_data[3], 3 * sizeof(signed short));
|
||||
uint16_t speed = sensor_processing_task(acc_data_buf,gyr_data_buf,angle, quaternion_output);
|
||||
@ -211,10 +218,40 @@ void BLE_send_fuc(void){
|
||||
// 拷贝磁力计数据
|
||||
memcpy(&mag_packet[4], data_to_send.mmc5603nj_buffer, sizeof(data_to_send.mmc5603nj_buffer));
|
||||
|
||||
// 调用实际的蓝牙发送函数
|
||||
send_data_to_ble_client(&mag_packet, MAG_PACKET_LEN);
|
||||
}
|
||||
|
||||
// --- 封装并发送压力机计数据 ---
|
||||
{
|
||||
// 协议定义: 包头(2) + 长度(1) + 类型(1) + 数据(8) = 12字节
|
||||
const uint8_t PT_PACKET_LEN = 12;
|
||||
const uint8_t PT_PAYLOAD_LEN = 9; // 类型(1) + 数据(8)
|
||||
const uint8_t PT_TYPE = 0x03;
|
||||
|
||||
uint8_t pt_packet[PT_PACKET_LEN];
|
||||
|
||||
// 填充包头
|
||||
pt_packet[0] = 0xBB;
|
||||
pt_packet[1] = 0xBE;
|
||||
pt_packet[2] = PT_PAYLOAD_LEN;
|
||||
pt_packet[3] = PT_TYPE;
|
||||
|
||||
// 打包压力数据 data_to_send.adc_P (占 pt_packet[4] 到 pt_packet[7])
|
||||
pt_packet[4] = (uint8_t)(data_to_send.adc_P & 0xFF); // 最低字节 (LSB)
|
||||
pt_packet[5] = (uint8_t)((data_to_send.adc_P >> 8) & 0xFF);
|
||||
pt_packet[6] = (uint8_t)((data_to_send.adc_P >> 16) & 0xFF);
|
||||
pt_packet[7] = (uint8_t)((data_to_send.adc_P >> 24) & 0xFF); // 最高字节 (MSB)
|
||||
|
||||
// 打包温度数据 data_to_send.adc_T (占 pt_packet[8] 到 pt_packet[11])
|
||||
pt_packet[8] = (uint8_t)(data_to_send.adc_T & 0xFF); // 最低字节 (LSB)
|
||||
pt_packet[9] = (uint8_t)((data_to_send.adc_T >> 8) & 0xFF);
|
||||
pt_packet[10] = (uint8_t)((data_to_send.adc_T >> 16) & 0xFF);
|
||||
pt_packet[11] = (uint8_t)((data_to_send.adc_T >> 24) & 0xFF); // 最高字节 (MSB)
|
||||
|
||||
send_data_to_ble_client(&pt_packet, PT_PACKET_LEN);
|
||||
}
|
||||
|
||||
|
||||
// --- 封装并发送速度数据 ---
|
||||
{
|
||||
// 协议定义: 包头(2) + 长度(1) + 类型(1) + 数据(2) = 6字节
|
||||
@ -240,7 +277,7 @@ void BLE_send_fuc(void){
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static u8 bmp280_test_id = 0;
|
||||
void xtell_task_create(void){
|
||||
|
||||
#if TCFG_GSENOR_USER_IIC_TYPE
|
||||
@ -261,4 +298,23 @@ void xtell_task_create(void){
|
||||
|
||||
circle_buffer_init(&BLE_send_buff, BLE_send_data, SENSOR_DATA_BUFFER_SIZE, sizeof(BLE_send_data_t));
|
||||
|
||||
bmp280_init();
|
||||
extern void bmp280_test(void);
|
||||
xlog("barometer start measeure\n");
|
||||
// create_process(&bmp280_test_id,"bmp280_test",NULL, bmp280_test, 100);
|
||||
float Temp = 0;
|
||||
float Press = 0;
|
||||
xlog("test_func\n");
|
||||
bmp280_read_data(&Temp, &Press);
|
||||
xlog("Temp:%.2f, Press:%.2f\n",Temp,Press);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//test
|
||||
//
|
||||
|
||||
void bmp280_test(void){
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user