This commit is contained in:
lmx
2025-11-03 18:48:15 +08:00
parent 97e85df2f8
commit 671730a351
96 changed files with 170886 additions and 186935 deletions

View File

@ -18,12 +18,24 @@
#include "bt_tws.h"
#endif
#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
spinlock_t iic_lock;
#define LOG_TAG "[GSENSOR]"
#define LOG_ERROR_ENABLE
#define LOG_DEBUG_ENABLE
#define LOG_INFO_ENABLE
#define xlog_ENABLE
/* #define LOG_DUMP_ENABLE */
#define LOG_CLI_ENABLE
#include "debug.h"
@ -82,20 +94,20 @@ void gSensor_int_io_detect(void *priv)
u8 int_io_status = 0;
u8 det_result = 0;
int_io_status = gpio_read(platform_data->gSensor_int_io);
//log_info("status %d\n",int_io_status);
//xlog("status %d\n",int_io_status);
gSensor_hdl->gravity_sensor_ctl(GSENSOR_INT_DET, &int_io_status);
if (gSensor_hdl->gravity_sensor_check == NULL) {
return;
}
det_result = gSensor_hdl->gravity_sensor_check();
if (det_result == 1) {
log_info("GSENSOR_EVENT_CLICK\n");
xlog("GSENSOR_EVENT_CLICK\n");
gSensor_event_to_user(KEY_EVENT_CLICK);
} else if (det_result == 2) {
log_info("GSENSOR_EVENT_DOUBLE_CLICK\n");
xlog("GSENSOR_EVENT_DOUBLE_CLICK\n");
gSensor_event_to_user(KEY_EVENT_DOUBLE_CLICK);
} else if (det_result == 3) {
log_info("GSENSOR_EVENT_THREE_CLICK\n");
xlog("GSENSOR_EVENT_THREE_CLICK\n");
gSensor_event_to_user(KEY_EVENT_TRIPLE_CLICK);
}
}
@ -117,7 +129,7 @@ int gSensor_read_data(u8 *buf, u8 buflen)
//
int get_gSensor_data(short *buf)
{
// printf("%s",__func__);
// xlog("%s",__func__);
axis_info_t accel_data[32];
if (!gpio_read(platform_data->gSensor_int_io)) {
gSensor_hdl->gravity_sensor_ctl(READ_GSENSOR_DATA, accel_data);
@ -126,7 +138,7 @@ int get_gSensor_data(short *buf)
buf[i * 2] = accel_data[i].x;
buf[i * 2 + 1] = accel_data[i].y;
buf[i * 2 + 2] = accel_data[i].z;
// printf("cnt:%1d x:%5d y:%5d z:%5d\n", i, accel_data[i].x, accel_data[i].y, accel_data[i].z);
// xlog("cnt:%1d x:%5d y:%5d z:%5d\n", i, accel_data[i].x, accel_data[i].y, accel_data[i].z);
}
@ -144,7 +156,7 @@ int read_gsensor_buf(short *buf)
static u8 wr_lock;
int read_gsensor_nbuf(short *buf, short datalen)
{
// printf("%s",__func__);
// xlog("%s",__func__);
if (data_w_cbuf == NULL) {
return 0;
}
@ -161,7 +173,7 @@ int read_gsensor_nbuf(short *buf, short datalen)
return 0;
}
} else {
printf("%s NOT ONLINE ", __func__);
xlog("%s NOT ONLINE ", __func__);
return 0;
}
}
@ -175,27 +187,27 @@ void write_gsensor_data_handle(void)
if (gSensor_info->init_flag == 1) {
// if (read_write_status == 0) {
// printf("%s ",__func__);
// xlog("%s ",__func__);
// return;
// }
if (!gpio_read(platform_data->gSensor_int_io)) {
gSensor_hdl->gravity_sensor_ctl(READ_GSENSOR_DATA, accel_data);
/*for(int i=0;i<29;i++){
printf("cnt:%1d x:%5d y:%5d z:%5d\n", i, accel_data[i].x, accel_data[i].y, accel_data[i].z);
xlog("cnt:%1d x:%5d y:%5d z:%5d\n", i, accel_data[i].x, accel_data[i].y, accel_data[i].z);
}*/
u8 wlen;
wlen = cbuf_write(data_w_cbuf, accel_data, 2 * 3 * 29);
/* for(int i=0;i<29;i++){ */
/* printf("sour x=%06d y=%06d z=%06d",accel_data[i].x,accel_data[i].y,accel_data[i].z); */
/* xlog("sour x=%06d y=%06d z=%06d",accel_data[i].x,accel_data[i].y,accel_data[i].z); */
/* } */
if (wlen == 0) {
printf("data_w_cbuf_full");
xlog("data_w_cbuf_full");
}
}
} else {
// printf("%s ",__func__);
// xlog("%s ",__func__);
return ;
}
}
@ -207,7 +219,7 @@ u8 gravity_sensor_command(u8 w_chip_id, u8 register_address, u8 function_command
iic_start(gSensor_info->iic_hdl);
if (0 == iic_tx_byte(gSensor_info->iic_hdl, w_chip_id)) {
ret = 0;
log_e("\n gsen iic wr err 0\n");
xlog("\n gsen iic wr err 0\n");
goto __gcend;
}
@ -215,7 +227,7 @@ u8 gravity_sensor_command(u8 w_chip_id, u8 register_address, u8 function_command
if (0 == iic_tx_byte(gSensor_info->iic_hdl, register_address)) {
ret = 0;
log_e("\n gsen iic wr err 1\n");
xlog("\n gsen iic wr err 1\n");
goto __gcend;
}
@ -223,7 +235,7 @@ u8 gravity_sensor_command(u8 w_chip_id, u8 register_address, u8 function_command
if (0 == iic_tx_byte(gSensor_info->iic_hdl, function_command)) {
ret = 0;
log_e("\n gsen iic wr err 2\n");
xlog("\n gsen iic wr err 2\n");
goto __gcend;
}
@ -236,14 +248,14 @@ __gcend:
u8 _gravity_sensor_get_ndata(u8 r_chip_id, u8 register_address, u8 *buf, u8 data_len)
{
// printf("%s",__func__);
// xlog("%s",__func__);
// spin_lock(&sensor_iic);
/* os_mutex_pend(&SENSOR_IIC_MUTEX,0); */
u8 read_len = 0;
iic_start(gSensor_info->iic_hdl);
if (0 == iic_tx_byte(gSensor_info->iic_hdl, r_chip_id - 1)) {
log_e("\n gsen iic rd err 0\n");
xlog("\n gsen iic rd err 0\n");
read_len = 0;
goto __gdend;
}
@ -251,14 +263,14 @@ u8 _gravity_sensor_get_ndata(u8 r_chip_id, u8 register_address, u8 *buf, u8 data
delay(gSensor_info->iic_delay);
if (0 == iic_tx_byte(gSensor_info->iic_hdl, register_address)) {
log_e("\n gsen iic rd err 1\n");
xlog("\n gsen iic rd err 1\n");
read_len = 0;
goto __gdend;
}
iic_start(gSensor_info->iic_hdl);
if (0 == iic_tx_byte(gSensor_info->iic_hdl, r_chip_id)) {
log_e("\n gsen iic rd err 2\n");
xlog("\n gsen iic rd err 2\n");
read_len = 0;
goto __gdend;
}
@ -302,13 +314,13 @@ int gravity_sensor_init(void *_data)
gSensor_info->iic_hdl = platform_data->iic;
retval = iic_init(gSensor_info->iic_hdl);
log_e("\n gravity_sensor_init\n");
xlog("\n gravity_sensor_init\n");
if (retval < 0) {
log_e("\n open iic for gsensor err\n");
xlog("\n open iic for gsensor err\n");
return retval;
} else {
log_info("\n iic open succ\n");
xlog("\n iic open succ\n");
}
retval = -EINVAL;
@ -320,14 +332,14 @@ int gravity_sensor_init(void *_data)
}
if (retval < 0) {
log_e(">>>gSensor_hdl logo err\n");
xlog(">>>gSensor_hdl logo err\n");
return retval;
}
if (gSensor_hdl->gravity_sensor_init()) {
log_e(">>>>gSensor_Int ERROR\n");
xlog(">>>>gSensor_Int ERROR\n");
} else {
log_info(">>>>gSensor_Int SUCC\n");
xlog(">>>>gSensor_Int SUCC\n");
gSensor_info->init_flag = 1;
if (platform_data->gSensor_int_io != -1) {
gpio_set_pull_up(platform_data->gSensor_int_io, 1);
@ -336,7 +348,7 @@ int gravity_sensor_init(void *_data)
gpio_set_die(platform_data->gSensor_int_io, 1);
data_buf = zalloc(BUF_SIZE);
if (data_buf == NULL) {
printf("gsensor_cbuf_error!");
xlog("gsensor_cbuf_error!");
return 0;
}
@ -347,7 +359,7 @@ int gravity_sensor_init(void *_data)
cbuf_init(data_w_cbuf, data_buf, BUF_SIZE);
/* port_edge_wkup_set_callback(write_gsensor_data_handle); */
/* 已改为使用port_edge_wkup_set_callback_by_index,使用时需要重新实现 */
printf("cbuf_init");
xlog("cbuf_init");
// spin_lock_init(&iic_lock);
// sys_s_hi_timer_add(NULL, gSensor_int_io_detect, 10); //10ms
@ -388,7 +400,7 @@ int gsensor_enable(void)
//工作空间
data_buf = zalloc(BUF_SIZE);
if (data_buf == NULL) {
printf("gsensor_cbuf_error!");
xlog("gsensor_cbuf_error!");
return -1;
}
data_w_cbuf = zalloc(sizeof(cbuffer_t));
@ -396,7 +408,7 @@ int gsensor_enable(void)
return -1;
}
cbuf_init(data_w_cbuf, data_buf, BUF_SIZE);
printf("cbuf_init");
xlog("cbuf_init");
//设置参数
valid = 0;
gSensor_hdl->gravity_sensor_ctl(GSENSOR_RESET_INT, &valid);
@ -404,6 +416,6 @@ int gsensor_enable(void)
if (valid == -1) {
return -1;
}
printf("gsensor_reset_succeed\n");
xlog("gsensor_reset_succeed\n");
return 0;
}