蓝牙发送速率提升
This commit is contained in:
@ -717,7 +717,7 @@ struct port_wakeup port0 = {
|
||||
.pullup_down_enable = ENABLE, //配置I/O 内部上下拉是否使能
|
||||
.edge = FALLING_EDGE, //唤醒方式选择,可选:上升沿\下降沿
|
||||
.filter = PORT_FLT_8ms,
|
||||
.iomap = IO_PORTB_01, //唤醒口选择
|
||||
.iomap = IO_PORTA_04, //唤醒口选择
|
||||
};
|
||||
|
||||
#if (TCFG_TEST_BOX_ENABLE || TCFG_CHARGESTORE_ENABLE || TCFG_ANC_BOX_ENABLE || TCFG_UMIDIGI_BOX_ENABLE)
|
||||
|
||||
@ -47,7 +47,7 @@
|
||||
|
||||
*/
|
||||
#define TCFG_HW_I2C0_PORTS 'B'
|
||||
#define TCFG_HW_I2C0_CLK 400000 //硬件IIC波特率:400k
|
||||
#define TCFG_HW_I2C0_CLK 1000000 //硬件IIC波特率:400k
|
||||
|
||||
//*********************************************************************************//
|
||||
// 硬件SPI 配置 //
|
||||
@ -1130,7 +1130,7 @@ DAC硬件上的连接方式,可选的配置:
|
||||
//*********************************************************************************//
|
||||
#if TCFG_USER_BLE_ENABLE
|
||||
#define DUEROS_DMA_EN 0
|
||||
#define TRANS_DATA_EN 0//1 //xtellota
|
||||
// #define TRANS_DATA_EN 0//1 //xtellota
|
||||
#define BLE_HID_EN 0
|
||||
|
||||
#if (DUEROS_DMA_EN)
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
|
||||
#define CONFIG_UPDATE_JUMP_TO_MASK 0 //配置升级到loader的方式0为直接reset,1为跳转(适用于芯片电源由IO口KEEP住的方案,需要注意检查跳转前是否将使用DMA的硬件模块全部关闭)
|
||||
|
||||
#define CONFIG_IO_KEY_EN 0 //配置是否使用IO按键,配合RESET1
|
||||
#define CONFIG_IO_KEY_EN 1 //配置是否使用IO按键,配合RESET1
|
||||
#define CONFIG_UPDATE_WITH_MD5_CHECK_EN 0 //配置升级是否支持MD5校验
|
||||
|
||||
#define CONFIG_ANC_ENABLE 0 //配置是否支持ANC
|
||||
@ -73,8 +73,8 @@
|
||||
|
||||
#if CONFIG_IO_KEY_EN
|
||||
#define CONFIG_SUPPORT_RESET1
|
||||
#define CONFIG_RESET1_PIN PB01 //io pin
|
||||
#define CONFIG_RESET1_TIME 08 //unit:second
|
||||
#define CONFIG_RESET1_PIN PA04 //io pin
|
||||
#define CONFIG_RESET1_TIME 01 //unit:second
|
||||
#define CONFIG_RESET1_LEVEL 0 //tigger level(0/1)
|
||||
#endif
|
||||
|
||||
|
||||
@ -21,9 +21,10 @@
|
||||
#define CONFIG_APP_BT_ENABLE
|
||||
|
||||
#ifdef CONFIG_APP_BT_ENABLE
|
||||
#define TRANS_DATA_EN 0
|
||||
#define BLE_WIRELESS_SERVER_EN 0
|
||||
#define TRANS_DATA_EN 1
|
||||
#define RCSP_BTMATE_EN 0
|
||||
#define RCSP_ADV_EN 1
|
||||
#define RCSP_ADV_EN 0
|
||||
#define AI_APP_PROTOCOL 0
|
||||
#define LL_SYNC_EN 0
|
||||
#define TUYA_DEMO_EN 0
|
||||
|
||||
@ -204,6 +204,18 @@ int app_protocol_sys_event_handler(struct sys_event *event);
|
||||
#define EARPHONE_STATE_SNIFF(a)
|
||||
#define EARPHONE_STATE_ROLE_SWITCH(a)
|
||||
|
||||
#elif BLE_WIRELESS_SERVER_EN
|
||||
#define EARPHONE_STATE_INIT() do { } while(0)
|
||||
#define EARPHONE_STATE_SET_PAGE_SCAN_ENABLE() do { } while(0)
|
||||
#define EARPHONE_STATE_GET_CONNECT_MAC_ADDR() do { } while(0)
|
||||
#define EARPHONE_STATE_CANCEL_PAGE_SCAN() do { } while(0)
|
||||
#define EARPHONE_STATE_ENTER_SOFT_POWEROFF() do { } while(0)
|
||||
#define EARPHONE_STATE_TWS_INIT(a) do { } while(0)
|
||||
#define EARPHONE_STATE_TWS_CONNECTED(a, b) do { } while(0)
|
||||
#define SYS_EVENT_HANDLER_SPECIFIC(a) do { } while(0)
|
||||
#define SYS_EVENT_REMAP(a) 0
|
||||
#define EARPHONE_STATE_SNIFF(a)
|
||||
#define EARPHONE_STATE_ROLE_SWITCH(a)
|
||||
#else
|
||||
int adv_earphone_state_init();
|
||||
int adv_earphone_state_set_page_scan_enable();
|
||||
|
||||
@ -232,7 +232,8 @@ const uint64_t config_btctler_le_features = LE_ENCRYPTION;
|
||||
|
||||
#else
|
||||
const int config_btctler_le_roles = (LE_ADV | LE_SLAVE);
|
||||
const uint64_t config_btctler_le_features = 0;
|
||||
// const uint64_t config_btctler_le_features = 0;
|
||||
const uint64_t config_btctler_le_features = LE_ENCRYPTION | LE_DATA_PACKET_LENGTH_EXTENSION | LE_2M_PHY;
|
||||
#endif
|
||||
#else
|
||||
const int config_btctler_le_roles = 0;
|
||||
@ -280,9 +281,13 @@ const int config_btctler_le_acl_total_nums = 1;
|
||||
const int config_btctler_le_afh_en = 0;
|
||||
const u32 config_vendor_le_bb = 0;
|
||||
|
||||
const int config_btctler_le_rx_nums = 5;
|
||||
const int config_btctler_le_acl_packet_length = 27;
|
||||
const int config_btctler_le_acl_total_nums = 5;
|
||||
// const int config_btctler_le_rx_nums = 5;
|
||||
// const int config_btctler_le_acl_packet_length = 27;
|
||||
// const int config_btctler_le_acl_total_nums = 5;
|
||||
|
||||
const int config_btctler_le_rx_nums = 8;
|
||||
const int config_btctler_le_acl_packet_length = 251;
|
||||
const int config_btctler_le_acl_total_nums = 8;
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
@ -29,6 +29,7 @@
|
||||
#include "asm/rtc.h"
|
||||
#include "system/timer.h"
|
||||
#include "adv_time_stamp_setting.h"
|
||||
#include "btstack/le/le_user.h"
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//宏定义
|
||||
#define ENABLE_XLOG 1
|
||||
@ -433,20 +434,128 @@ void xtell_task_create(void){
|
||||
//test
|
||||
//
|
||||
|
||||
void bmp280_test(void){
|
||||
|
||||
/**
|
||||
* @brief 开始采集传感器数据和计算速度
|
||||
*
|
||||
*/
|
||||
void sensor_task(void){
|
||||
while(1){
|
||||
// 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;
|
||||
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];
|
||||
float angle[3];
|
||||
float quaternion_output[3];
|
||||
|
||||
float temperature = 0;
|
||||
float pressure = 0;
|
||||
|
||||
// -- 读数据 --
|
||||
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);
|
||||
bmp280_read_data(&temperature, &pressure);
|
||||
|
||||
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);
|
||||
|
||||
// -- 数据包装进结构体 --
|
||||
memcpy(&BLE_send_data_tmp.SC7U22_data[0], acc_data_buf, 3 * sizeof(signed short));
|
||||
memcpy(&BLE_send_data_tmp.SC7U22_data[3], gyr_data_buf, 3 * sizeof(signed short));
|
||||
memcpy(BLE_send_data_tmp.mmc5603nj_buffer, mmc5603nj_buffer, 9);
|
||||
BLE_send_data_tmp.temperature = (int16_t)(temperature * 1000.0f);
|
||||
BLE_send_data_tmp.pressure = (int32_t)(pressure * 1000.0f);
|
||||
BLE_send_data_tmp.speed_cms = speed;
|
||||
extern u8 foot_init;
|
||||
BLE_send_data_tmp.foot_state = foot_init;
|
||||
BLE_send_data_tmp.timestamp_ms = get_ms_timer();
|
||||
|
||||
// -- 放进缓冲区 --
|
||||
if(circle_buffer_is_full(&BLE_send_buff) == 0){
|
||||
circle_buffer_write(&BLE_send_buff, &BLE_send_data_tmp);
|
||||
}
|
||||
|
||||
// xlog("=======sensor_read_data END\n");
|
||||
os_time_dly(1);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
#define BUFF_LEN 500
|
||||
static signed char acc_data_buf[BUFF_LEN] = {0};
|
||||
// 1. 定义一个全局的信号量
|
||||
static OS_SEM ble_send_sem;
|
||||
|
||||
void on_ble_can_send(void) {
|
||||
os_sem_post(&ble_send_sem);
|
||||
}
|
||||
int j = 0;
|
||||
void data_send_task(void){
|
||||
while(1){
|
||||
// 等待“发送许可”信号量,如果没许可,任务会在此阻塞
|
||||
// os_sem_pend(&ble_send_sem, 1);
|
||||
|
||||
// static signed char acc_data_buf[60] = {
|
||||
// 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22
|
||||
// };
|
||||
|
||||
acc_data_buf[1] = (uint8_t)(j & 0xFF);
|
||||
acc_data_buf[2] = (uint8_t)(j>>8 & 0xFF);
|
||||
acc_data_buf[3] = (uint8_t)(j>>16 & 0xFF);
|
||||
acc_data_buf[4] = (uint8_t)(j>>24 & 0xFF);
|
||||
|
||||
acc_data_buf[0] = 0xAA;
|
||||
send_data_to_ble_client(&acc_data_buf, 500);
|
||||
// acc_data_buf[0] = 0xBB;
|
||||
// send_data_to_ble_client(&acc_data_buf, 500);
|
||||
// acc_data_buf[0] = 0xCC;
|
||||
// send_data_to_ble_client(&acc_data_buf, 500);
|
||||
// acc_data_buf[0] = 0xDD;
|
||||
// send_data_to_ble_client(&acc_data_buf, 500);
|
||||
|
||||
void gsensor_test(void){
|
||||
#if 1
|
||||
signed short acc_data_buf[3];
|
||||
signed short gyr_data_buf[3];
|
||||
SL_SC7U22_RawData_Read(acc_data_buf,gyr_data_buf);
|
||||
#endif
|
||||
// static signed char acc_data_buf[20] = {
|
||||
// 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
// };
|
||||
// send_data_to_ble_client(&acc_data_buf, 20);
|
||||
// send_data_to_ble_client(&acc_data_buf, 20);
|
||||
// send_data_to_ble_client(&acc_data_buf, 20);
|
||||
// xlog("===========time:%d\n",get_ms_timer());
|
||||
|
||||
j++;
|
||||
os_time_dly(4); //10ms单位
|
||||
}
|
||||
}
|
||||
static u16 gtest_id = 0;
|
||||
void test_func(void){
|
||||
create_process(>est_id,"gtest_id",NULL,gsensor_test,1000);
|
||||
// a. 初始化信号量,初始值为0
|
||||
// os_sem_create(&ble_send_sem, 0);
|
||||
|
||||
// b. 注册回调函数,让协议栈知道在准备好时该调用谁
|
||||
// struct ble_server_operation_t *ble_ops;
|
||||
// ble_get_server_operation_table(&ble_ops);
|
||||
// ble_ops->regist_wakeup_send(NULL, on_ble_can_send);
|
||||
for(int i = 0;i<BUFF_LEN;i++){
|
||||
acc_data_buf[i] = i;
|
||||
}
|
||||
os_task_create(data_send_task,NULL,5,1024,32,"data_send_task");
|
||||
// data_send_task();
|
||||
}
|
||||
@ -20,7 +20,7 @@ Copyright (c) 2022 Silan MEMS. All Rights Reserved.
|
||||
/***使用前请根据实际情况配置以下参数******/
|
||||
/**SC7U22的SDO 接地: 0****************/
|
||||
/**SC7U22的SDO 接电源:1****************/
|
||||
#define SL_SC7U22_SDO_VDD_GND 1
|
||||
#define SL_SC7U22_SDO_VDD_GND 0
|
||||
/*****************************************/
|
||||
/***使用前请根据实际IIC地址配置参数***/
|
||||
/**SC7U22的IIC 接口地址为 7bits: 0****/
|
||||
|
||||
@ -171,6 +171,6 @@ void xtell_app_main()
|
||||
xtell_task_create();
|
||||
|
||||
xlog("==============xtell_app_end================\n");
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -83,7 +83,7 @@ extern u8 init_ok;
|
||||
extern u8 sniff_out;
|
||||
unsigned char xtell_bl_state=0; //存放经典蓝牙的连接状态,0断开,1是连接
|
||||
u8 bt_newname =0;
|
||||
unsigned char xt_ble_new_name[9] = "CM-22222";
|
||||
unsigned char xt_ble_new_name[9] = "CM-4-F9";
|
||||
static u16 play_poweron_ok_timer_id = 0;
|
||||
|
||||
// -- 初始化标志位 --
|
||||
@ -236,7 +236,7 @@ void le_user_app_event_handler(struct sys_event* event){
|
||||
break;
|
||||
case 0x02:
|
||||
extern void test_func(void);
|
||||
// test_func();
|
||||
test_func();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user