cun
This commit is contained in:
@ -61,7 +61,7 @@ typedef struct {
|
||||
// -- 磁力计 --
|
||||
uint8_t mmc5603nj_buffer[9];
|
||||
// -- 速度 --
|
||||
int speed_cms;
|
||||
uint16_t speed_cms;
|
||||
// -- 气压计 --
|
||||
//...
|
||||
} BLE_send_data_t;
|
||||
@ -70,7 +70,7 @@ static int count = 0;
|
||||
|
||||
// --- 环形缓冲区 ---
|
||||
static circle_buffer_t BLE_send_buff; // 环形缓冲区管理结构体
|
||||
|
||||
BLE_send_data_t BLE_send_data[SENSOR_DATA_BUFFER_SIZE];
|
||||
|
||||
//END -- 变量定义
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -124,7 +124,7 @@ void start_collect_fuc(void){
|
||||
static int initialized = 0;
|
||||
static int calibration_done = 0;
|
||||
char status = 0;
|
||||
BLE_send_data_t BLE_send_data;
|
||||
BLE_send_data_t BLE_send_data_tmp;
|
||||
uint8_t mmc5603nj_buffer[9];
|
||||
signed short acc_data_buf[3];
|
||||
signed short gyr_data_buf[3];
|
||||
@ -140,14 +140,32 @@ void start_collect_fuc(void){
|
||||
|
||||
memcpy(acc_data_buf, &combined_raw_data[0], 3 * sizeof(signed short));
|
||||
memcpy(gyr_data_buf, &combined_raw_data[3], 3 * sizeof(signed short));
|
||||
int speed = sensor_processing_task(acc_data_buf,gyr_data_buf,angle, quaternion_output);
|
||||
uint16_t speed = sensor_processing_task(acc_data_buf,gyr_data_buf,angle, quaternion_output);
|
||||
|
||||
// -- 数据包装进结构体 --
|
||||
memcpy(BLE_send_data_tmp.acc_data, acc_data_buf, 3 * sizeof(signed short));
|
||||
memcpy(BLE_send_data_tmp.gyr_data, gyr_data_buf, 3 * sizeof(signed short));
|
||||
memcpy(BLE_send_data_tmp.mmc5603nj_buffer, mmc5603nj_buffer, 9);
|
||||
BLE_send_data_tmp.speed_cms = speed;
|
||||
|
||||
// -- 放进缓冲区 --
|
||||
if(circle_buffer_is_full(&BLE_send_buff) == 0){
|
||||
circle_buffer_write(&BLE_send_buff, &BLE_send_data_tmp);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ble数据发送
|
||||
*
|
||||
*/
|
||||
void BLE_send_fuc(void){
|
||||
BLE_send_data_t BLE_send_data_tmp;
|
||||
if(circle_buffer_is_empty(&BLE_send_buff) == 0){
|
||||
circle_buffer_read(&BLE_send_buff, &BLE_send_data_tmp);
|
||||
}
|
||||
|
||||
memcpy(BLE_send_data.acc_data, acc_data_buf, 3 * sizeof(signed short));
|
||||
memcpy(BLE_send_data.gyr_data, gyr_data_buf, 3 * sizeof(signed short));
|
||||
memcpy(BLE_send_data.mmc5603nj_buffer, mmc5603nj_buffer, 9);
|
||||
BLE_send_data.speed_cms = speed;
|
||||
|
||||
|
||||
}
|
||||
@ -171,6 +189,6 @@ void xtell_task_create(void){
|
||||
|
||||
xlog("xtell_task_create\n");
|
||||
|
||||
circle_buffer_init(&BLE_send_buff, sensor_read_buffer, SENSOR_DATA_BUFFER_SIZE, sizeof(BLE_send_data_t));
|
||||
circle_buffer_init(&BLE_send_buff, BLE_send_data, SENSOR_DATA_BUFFER_SIZE, sizeof(BLE_send_data_t));
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user