#include "system/includes.h" #include "btstack/btstack_task.h" #include "app_config.h" #include "app_action.h" #include "asm/pwm_led.h" #include "tone_player.h" #include "ui_manage.h" #include "gpio.h" #include "app_main.h" #include "asm/charge.h" #include "update.h" #include "app_power_manage.h" #include "audio_config.h" #include "app_charge.h" #include "bt_profile_cfg.h" #include "dev_manager/dev_manager.h" #include "update_loader_download.h" #include "LIS2DH12.h" #include "circle_buffer.h" #include "circle_buffer.h" #include "btstack/avctp_user.h" #include "calculate/skiing_tracker.h" /////////////////////////////////////////////////////////////////////////////////////////////////// //宏定义 #define ENABLE_XLOG 1 #ifdef xlog #undef xlog #endif #if ENABLE_XLOG #define xlog(format, ...) printf("[XT:%s] " format, __func__, ##__VA_ARGS__) #else #define xlog(format, ...) ((void)0) #endif // /////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////// //START -- 函数定义 void send_data_to_ble_client(const u8* data, u16 length); extern void create_process(u16* pid, const char* name, void *priv, void (*func)(void *priv), u32 msec); //END -- 函数定义 ////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////// //START -- 变量定义 // --- 任务ID --- static u16 xtell_i2c_test_id; static u16 collect_data_id; static u16 send_data_id; // --- 环形缓冲区 --- #define SENSOR_DATA_BUFFER_SIZE 512 static u8 sensor_data_buffer[SENSOR_DATA_BUFFER_SIZE]; static circle_buffer_t sensor_cb; //--- test --- // 全局变量 u16 gsensor_id=0; u16 test_id=0; //END -- 变量定义 ////////////////////////////////////////////////////////////////////////////////////////////////// // 从环形缓冲区读取数据并发送 void send_sensor_data_task(void) { // printf("xtell_ble_send\n"); } void test(){ signed short acc_data_buf[3] = {0}; signed short gyr_data_buf[3] = {0}; signed short acc_gyro_input[6] = {0}; float Angle_output[3] = {0}; extern void SL_SC7U22_RawData_Read(signed short * acc_data_buf,signed short * gyr_data_buf); SL_SC7U22_RawData_Read(acc_data_buf,gyr_data_buf); acc_gyro_input[0] = acc_data_buf[0]; acc_gyro_input[1] = acc_data_buf[1]; acc_gyro_input[2] = acc_data_buf[2]; acc_gyro_input[3] = gyr_data_buf[0]; acc_gyro_input[4] = gyr_data_buf[1]; acc_gyro_input[5] = gyr_data_buf[2]; // extern unsigned char SL_SC7U22_Angle_Output(unsigned char calibration_en, signed short *acc_gyro_input, float *Angle_output, unsigned char yaw_rst); // SL_SC7U22_Angle_Output(0,acc_gyro_input,Angle_output,1); static int count = 0; if(count >=100){ //1s打印1次 count = 0; xlog("ACC_X:%d, ACC_Y:%d, ACC_Z:%d, GYR_X:%.d, GYR_Y:%d, GYR_Z:%d", acc_gyro_input[0],acc_gyro_input[1],acc_gyro_input[2],acc_gyro_input[3],acc_gyro_input[4],acc_gyro_input[5] ); // xlog("Pitch:%.2f, Roll:%.2f, Yaw:%.2f\n", // Angle_output[0],Angle_output[1],Angle_output[2] // ); } count++; void sensor_processing_task(signed short * acc_data_buf,signed short * gyr_data_buf); sensor_processing_task(acc_data_buf, gyr_data_buf); } void gsensor_test(){ sys_timer_del(gsensor_id); } void xtell_task_create(void){ // int ret = hw_iic_init(0); // xlog("hw_iic_init result:%d\n",ret); // //初始化传感器 // SL_SC7U22_Config(); soft_iic_init(0); gpio_set_direction(IO_PORTE_05,0); //设置PE5 输出模式 gpio_set_pull_up(IO_PORTE_05,1); gpio_direction_output(IO_PORTE_05,1); SL_SC7U22_Config(); // extern u8 LIS2DH12_Config(void); // LIS2DH12_Config(); xlog("xtell_task_create\n"); // 初始化环形缓冲区 circle_buffer_init(&sensor_cb, sensor_data_buffer, SENSOR_DATA_BUFFER_SIZE); //初始化滑雪追踪器 // SkiingTracker_Init(&skiing_data); xlog("SkiingTracker_Init\n"); // create_process(&gsensor_id, "gsensor",NULL, gsensor_test, 1000); create_process(&test_id, "test",NULL, test, 10); }