Skip to content

Commit

Permalink
Release v0.3.1.0
Browse files Browse the repository at this point in the history
Release v0.3.1.0

Co-Authored-By: Yong Shen <47750708+yongbosch@users.noreply.github.com>
Co-Authored-By: ma-loc <100404916+ma-loc@users.noreply.github.com>
  • Loading branch information
3 people committed May 3, 2023
1 parent 5c07a8a commit b0f581c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 36 deletions.
17 changes: 11 additions & 6 deletions smi230/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,24 @@ OBJS := $(addsuffix .o,$(basename $(SRCS)))
INC_DIRS := $(shell find $(SRC_DIRS) -type d)
INC_FLAGS := $(addprefix -I,$(INC_DIRS))

HAL_TEST ?= true
HAL_TEST ?= false

ifeq ($(HAL_TEST), true)
CPPFLAGS ?= $(INC_FLAGS) -MMD -MP -DPLTF_LINUX_ENABLED -DTEST_APP_ACTIVE
LDFLAGS ?= -lpthread -lstdc++
LDFLAGS ?= -lpthread -lstdc++ -static
OUTPUT ?= smi230_hal_test

all: $(SRCS) clean
arm-linux-gnueabihf-gcc $(CPPFLAGS) -lpthread -lstdc++ $(SRCS) $(LDFLAGS) -o $(OUTPUT)
else
CPPFLAGS ?= $(INC_FLAGS) -MMD -MP -DPLTF_LINUX_ENABLED
LDFLAGS ?= -lpthread -lstdc++ -shared
endif
OUTPUT ?= smi230_hal

hal_test: $(SRCS)
arm-linux-gnueabihf-gcc $(CPPFLAGS) -lpthread -lstdc++ $(SRCS) $(LDFLAGS) -o hal_test
all: $(SRCS) clean
arm-linux-gnueabihf-gcc $(CPPFLAGS) -lpthread -lstdc++ $(SRCS) $(LDFLAGS) -o $(OUTPUT).so
endif

.PHONY: clean
clean:
$(RM) $(TARGET) $(OBJS) $(DEPS) hal_test.d
$(RM) $(TARGET) $(OBJS) $(DEPS) $(OUTPUT).d $(OUTPUT) $(OUTPUT).so
13 changes: 9 additions & 4 deletions smi230/sensord/inc/sensord_hwcntl.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,19 @@ enum BSX4_SENSORLIST_INX
};

/*!bosch sensor generic power mode enum */
enum BST_DEV_OP_MODE
enum BST_DEV_ACC_OP_MODE
{
SENSOR_PM_NORMAL = 0,
SENSOR_PM_LP1,
SENSOR_PM_SUSPEND,
SENSOR_PM_LP2
SENSOR_PM_SUSPEND = 3
};

enum BST_DEV_GYRO_OP_MODE
{
SENSOR_GYRO_PM_NORMAL = 0,
SENSOR_GYRO_PM_SUSPEND = 1
};


#define SENSOR_TYPE_BOSCH_ACTIVITY_RECOGNITION (SENSOR_TYPE_DEVICE_PRIVATE_BASE + 31)
#define SENSOR_STRING_TYPE_BOSCH_AR "com.bosch-BoschSensor.www.activityrecognition"

Expand Down
38 changes: 12 additions & 26 deletions smi230/sensord/sensord_hwcntl_implement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@ EV_FF_STATUS 0x17 EV_MAX 0x1f EV_CNT (EV_MAX+1)
#define SMI230_GYRO_RANGE_1000DPS 1000
#define SMI230_GYRO_RANGE_2000DPS 2000

#define SMI230_GYRO_MAX_FIFO_FRAME 100
#define SMI230_GYRO_BYTES_PER_FIFO_SAMPLE 6
#define SMI230_GYRO_MAX_FIFO_BYTE 100
#define SMI230_GYRO_MAX_FIFO_FRAME (SMI230_GYRO_MAX_FIFO_BYTE / SMI230_GYRO_BYTES_PER_FIFO_SAMPLE)

#define BMA2X2_RANGE_2G 3
#define BMA2X2_RANGE_4G 5
Expand Down Expand Up @@ -776,29 +778,20 @@ static void ap_config_phyACC(bsx_f32_t sample_rate, uint16_t fifo_data_len)
{
if (SAMPLE_RATE_DISABLED == sample_rate)
{
if (1 == is_acc_open)
{
PDEBUG("shutdown acc");

ret = wr_sysfs_oneint("pwr_cfg", acc_input_dir_name, SENSOR_PM_SUSPEND);
#ifdef SMI230_DATA_SYNC
ret = wr_sysfs_oneint("pwr_cfg", gyr_input_dir_name, SENSOR_PM_SUSPEND);
#endif

is_acc_open = 0;
}
}
else
else
{
/*activate is included*/
if (0 == is_acc_open)
{
PDEBUG("set acc active");
ret = wr_sysfs_oneint("pwr_cfg", acc_input_dir_name, SENSOR_PM_NORMAL);
#ifdef SMI230_DATA_SYNC
ret = wr_sysfs_oneint("pwr_cfg", gyr_input_dir_name, SENSOR_PM_NORMAL);
#endif
is_acc_open = 1;

PDEBUG("set acc odr: %f", sample_rate);
odr_Hz = SMI230_convert_ODR(SENSORLIST_INX_ACCELEROMETER, sample_rate);
Expand All @@ -820,7 +813,6 @@ static void ap_config_phyACC(bsx_f32_t sample_rate, uint16_t fifo_data_len)
PINFO("write acc wm as %d samples, in %d bytes", fifo_data_len, fifo_data_len_in_bytes);
ret = wr_sysfs_oneint("fifo_wm", acc_input_dir_name, fifo_data_len_in_bytes);
#endif
}
}

}
Expand All @@ -834,6 +826,7 @@ static void ap_config_phyGYR(bsx_f32_t sample_rate, uint16_t fifo_data_len)
int32_t odr_Hz;
int32_t bandwidth = 0;
int32_t fifo_data_sel_regval;
int32_t fifo_data_len_in_bytes;
float physical_Hz = 0;

PINFO("set physical GYRO rate %f", sample_rate);
Expand Down Expand Up @@ -910,23 +903,14 @@ static void ap_config_phyGYR(bsx_f32_t sample_rate, uint16_t fifo_data_len)
{
if (SAMPLE_RATE_DISABLED == sample_rate)
{
if (1 == is_gyr_open)
{
PDEBUG("shutdown gyro");

ret = wr_sysfs_oneint("pwr_cfg", gyr_input_dir_name, SENSOR_PM_SUSPEND);

is_gyr_open = 0;
}
ret = wr_sysfs_oneint("pwr_cfg", gyr_input_dir_name, SENSOR_GYRO_PM_SUSPEND);
}else
{
/*activate is included*/
if (0 == is_gyr_open)
{
PDEBUG("set gyro active");
ret = wr_sysfs_oneint("pwr_cfg", gyr_input_dir_name, SENSOR_PM_NORMAL);
ret = wr_sysfs_oneint("pwr_cfg", gyr_input_dir_name, SENSOR_GYRO_PM_NORMAL);

is_gyr_open = 1;
#ifndef SMI230_DATA_SYNC
// if in data sync mode, odr is controled through ACC api
PDEBUG("set gyr odr: %f", sample_rate);
Expand All @@ -940,10 +924,11 @@ static void ap_config_phyGYR(bsx_f32_t sample_rate, uint16_t fifo_data_len)
if (fifo_data_len < 1)
fifo_data_len = 1;

PINFO("write gyro wm as %d", fifo_data_len);
ret = wr_sysfs_oneint("fifo_wm", gyr_input_dir_name, fifo_data_len);
fifo_data_len_in_bytes = SMI230_GYRO_BYTES_PER_FIFO_SAMPLE * fifo_data_len;

PINFO("write gyro wm as %d samples, in %d bytes", fifo_data_len, fifo_data_len_in_bytes);
ret = wr_sysfs_oneint("fifo_wm", gyr_input_dir_name, fifo_data_len_in_bytes);
#endif
}
}

}
Expand Down Expand Up @@ -1236,6 +1221,7 @@ int32_t ap_activate(int32_t handle, int32_t enabled)

/*To adapt BSX4 algorithm's way of configuration string, activate_configref_resort() is employed*/
ret = activate_configref_resort(bsx_list_inx, enabled);
ret = 1; //force to control sensor irrespective of previous state
if (ret)
{
if (enabled)
Expand Down

0 comments on commit b0f581c

Please sign in to comment.