mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
19549: pkg/littlefs2: bump version to 2.6 r=benpicco a=benpicco 19608: build system: fix `make compile-commands BUILD_IN_DOCKER=1` r=benpicco a=maribu ### Contribution description Just run `make compile-commands` outside of docker, as the compile commands generated in the docker container won't be helpful for tools outside of the container anyway. 19657: drivers/mpu9x50: clean up code r=benpicco a=maribu ### Contribution description Avoid using floating point arithmetic and some minor cleanups. Co-authored-by: Benjamin Valentin <benjamin.valentin@ml-pa.com> Co-authored-by: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
This commit is contained in:
commit
40d0f64a04
@ -728,6 +728,15 @@ else
|
||||
_LINK = $(if $(CPPMIX),$(LINKXX),$(LINK)) $$(find $(BASELIBS:%.module=$(BINDIR)/%/) -name "*.o" 2> /dev/null | sort) $(ARCHIVES_GROUP) $(LINKFLAGS) $(LINKFLAGPREFIX)-Map=$(BINDIR)/$(APPLICATION).map
|
||||
endif # BUILDOSXNATIVE
|
||||
|
||||
COMPILE_COMMANDS_PATH ?= $(RIOTBASE)/compile_commands.json
|
||||
COMPILE_COMMANDS_FLAGS ?= --clangd
|
||||
.PHONY: compile-commands
|
||||
compile-commands: $(BUILDDEPS)
|
||||
$(Q)DIRS="$(DIRS)" APPLICATION_BLOBS="$(BLOBS)" \
|
||||
"$(MAKE)" -C $(APPDIR) -f $(RIOTMAKE)/application.inc.mk compile-commands
|
||||
$(Q)$(RIOTTOOLS)/compile_commands/compile_commands.py $(COMPILE_COMMANDS_FLAGS) $(BINDIR) \
|
||||
> $(COMPILE_COMMANDS_PATH)
|
||||
|
||||
ifeq ($(BUILD_IN_DOCKER),1)
|
||||
link: ..in-docker-container
|
||||
else
|
||||
@ -751,15 +760,6 @@ $(APPLICATION_MODULE).module: pkg-build $(BUILDDEPS)
|
||||
"$(MAKE)" -C $(APPDIR) -f $(RIOTMAKE)/application.inc.mk
|
||||
$(APPLICATION_MODULE).module: FORCE
|
||||
|
||||
COMPILE_COMMANDS_PATH ?= $(RIOTBASE)/compile_commands.json
|
||||
COMPILE_COMMANDS_FLAGS ?= --clangd
|
||||
.PHONY: compile-commands
|
||||
compile-commands: $(BUILDDEPS)
|
||||
$(Q)DIRS="$(DIRS)" APPLICATION_BLOBS="$(BLOBS)" \
|
||||
"$(MAKE)" -C $(APPDIR) -f $(RIOTMAKE)/application.inc.mk compile-commands
|
||||
$(Q)$(RIOTTOOLS)/compile_commands/compile_commands.py $(COMPILE_COMMANDS_FLAGS) $(BINDIR) \
|
||||
> $(COMPILE_COMMANDS_PATH)
|
||||
|
||||
# Other modules are built by application.inc.mk and packages building
|
||||
_SUBMAKE_LIBS = $(filter-out $(APPLICATION_MODULE).module $(APPDEPS), $(BASELIBS) $(ARCHIVES))
|
||||
$(_SUBMAKE_LIBS): $(APPLICATION_MODULE).module pkg-build
|
||||
|
@ -236,28 +236,19 @@ int mpu9x50_set_compass_power(mpu9x50_t *dev, mpu9x50_pwr_t pwr_conf)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline uint32_t gyro_fsr_enum_to_value(mpu9x50_gyro_ranges_t fsr)
|
||||
{
|
||||
return 250U << fsr;
|
||||
}
|
||||
|
||||
int mpu9x50_read_gyro(const mpu9x50_t *dev, mpu9x50_results_t *output)
|
||||
{
|
||||
uint8_t data[6];
|
||||
int16_t temp;
|
||||
float fsr;
|
||||
|
||||
switch (dev->conf.gyro_fsr) {
|
||||
case MPU9X50_GYRO_FSR_250DPS:
|
||||
fsr = 250.0;
|
||||
break;
|
||||
case MPU9X50_GYRO_FSR_500DPS:
|
||||
fsr = 500.0;
|
||||
break;
|
||||
case MPU9X50_GYRO_FSR_1000DPS:
|
||||
fsr = 1000.0;
|
||||
break;
|
||||
case MPU9X50_GYRO_FSR_2000DPS:
|
||||
fsr = 2000.0;
|
||||
break;
|
||||
default:
|
||||
return -2;
|
||||
}
|
||||
assert((unsigned)dev->conf.gyro_fsr <= (unsigned)MPU9X50_GYRO_FSR_2000DPS);
|
||||
|
||||
uint32_t fsr = gyro_fsr_enum_to_value(dev->conf.gyro_fsr);
|
||||
|
||||
/* Acquire exclusive access */
|
||||
i2c_acquire(DEV_I2C);
|
||||
@ -267,38 +258,29 @@ int mpu9x50_read_gyro(const mpu9x50_t *dev, mpu9x50_results_t *output)
|
||||
i2c_release(DEV_I2C);
|
||||
|
||||
/* Normalize data according to configured full scale range */
|
||||
temp = (data[0] << 8) | data[1];
|
||||
temp = byteorder_lebuftohs(&data[0]);
|
||||
output->x_axis = (temp * fsr) / MAX_VALUE;
|
||||
temp = (data[2] << 8) | data[3];
|
||||
temp = byteorder_lebuftohs(&data[2]);
|
||||
output->y_axis = (temp * fsr) / MAX_VALUE;
|
||||
temp = (data[4] << 8) | data[5];
|
||||
temp = byteorder_lebuftohs(&data[4]);
|
||||
output->z_axis = (temp * fsr) / MAX_VALUE;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline uint32_t accel_fsr_enum_to_value(mpu9x50_accel_ranges_t fsr)
|
||||
{
|
||||
return 2000U << fsr;
|
||||
}
|
||||
|
||||
int mpu9x50_read_accel(const mpu9x50_t *dev, mpu9x50_results_t *output)
|
||||
{
|
||||
uint8_t data[6];
|
||||
int16_t temp;
|
||||
float fsr;
|
||||
|
||||
switch (dev->conf.accel_fsr) {
|
||||
case MPU9X50_ACCEL_FSR_2G:
|
||||
fsr = 2000.0;
|
||||
break;
|
||||
case MPU9X50_ACCEL_FSR_4G:
|
||||
fsr = 4000.0;
|
||||
break;
|
||||
case MPU9X50_ACCEL_FSR_8G:
|
||||
fsr = 8000.0;
|
||||
break;
|
||||
case MPU9X50_ACCEL_FSR_16G:
|
||||
fsr = 16000.0;
|
||||
break;
|
||||
default:
|
||||
return -2;
|
||||
}
|
||||
assert((unsigned)dev->conf.accel_fsr <= (unsigned)MPU9X50_ACCEL_FSR_16G);
|
||||
|
||||
uint32_t fsr = accel_fsr_enum_to_value(dev->conf.accel_fsr);
|
||||
|
||||
/* Acquire exclusive access */
|
||||
i2c_acquire(DEV_I2C);
|
||||
@ -308,16 +290,25 @@ int mpu9x50_read_accel(const mpu9x50_t *dev, mpu9x50_results_t *output)
|
||||
i2c_release(DEV_I2C);
|
||||
|
||||
/* Normalize data according to configured full scale range */
|
||||
temp = (data[0] << 8) | data[1];
|
||||
temp = byteorder_lebuftohs(&data[0]);
|
||||
output->x_axis = (temp * fsr) / MAX_VALUE;
|
||||
temp = (data[2] << 8) | data[3];
|
||||
temp = byteorder_lebuftohs(&data[2]);
|
||||
output->y_axis = (temp * fsr) / MAX_VALUE;
|
||||
temp = (data[4] << 8) | data[5];
|
||||
temp = byteorder_lebuftohs(&data[4]);
|
||||
output->z_axis = (temp * fsr) / MAX_VALUE;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int16_t convert_magnometer(int16_t raw, uint8_t adjust)
|
||||
{
|
||||
int32_t tmp = raw;
|
||||
/* Compute sensitivity adjustment */
|
||||
tmp += tmp * ((int32_t)adjust - 128) / 256;
|
||||
/* return normalized data */
|
||||
return (tmp * 3) / 10;
|
||||
}
|
||||
|
||||
int mpu9x50_read_compass(const mpu9x50_t *dev, mpu9x50_results_t *output)
|
||||
{
|
||||
uint8_t data[6];
|
||||
@ -329,22 +320,12 @@ int mpu9x50_read_compass(const mpu9x50_t *dev, mpu9x50_results_t *output)
|
||||
/* Release the bus */
|
||||
i2c_release(DEV_I2C);
|
||||
|
||||
output->x_axis = (data[1] << 8) | data[0];
|
||||
output->y_axis = (data[3] << 8) | data[2];
|
||||
output->z_axis = (data[5] << 8) | data[4];
|
||||
|
||||
/* Compute sensitivity adjustment */
|
||||
output->x_axis = (int16_t) (((float)output->x_axis) *
|
||||
((((dev->conf.compass_x_adj - 128) * 0.5) / 128.0) + 1));
|
||||
output->y_axis = (int16_t) (((float)output->y_axis) *
|
||||
((((dev->conf.compass_y_adj - 128) * 0.5) / 128.0) + 1));
|
||||
output->z_axis = (int16_t) (((float)output->z_axis) *
|
||||
((((dev->conf.compass_z_adj - 128) * 0.5) / 128.0) + 1));
|
||||
|
||||
/* Normalize data according to full-scale range */
|
||||
output->x_axis = output->x_axis * 0.3;
|
||||
output->y_axis = output->y_axis * 0.3;
|
||||
output->z_axis = output->z_axis * 0.3;
|
||||
output->x_axis = convert_magnometer(byteorder_lebuftohs(&data[0]),
|
||||
dev->conf.compass_x_adj);
|
||||
output->y_axis = convert_magnometer(byteorder_lebuftohs(&data[2]),
|
||||
dev->conf.compass_y_adj);
|
||||
output->z_axis = convert_magnometer(byteorder_lebuftohs(&data[4]),
|
||||
dev->conf.compass_z_adj);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -374,18 +355,18 @@ int mpu9x50_set_gyro_fsr(mpu9x50_t *dev, mpu9x50_gyro_ranges_t fsr)
|
||||
}
|
||||
|
||||
switch (fsr) {
|
||||
case MPU9X50_GYRO_FSR_250DPS:
|
||||
case MPU9X50_GYRO_FSR_500DPS:
|
||||
case MPU9X50_GYRO_FSR_1000DPS:
|
||||
case MPU9X50_GYRO_FSR_2000DPS:
|
||||
i2c_acquire(DEV_I2C);
|
||||
i2c_write_reg(DEV_I2C, DEV_ADDR,
|
||||
MPU9X50_GYRO_CFG_REG, (fsr << 3), 0);
|
||||
i2c_release(DEV_I2C);
|
||||
dev->conf.gyro_fsr = fsr;
|
||||
break;
|
||||
default:
|
||||
return -2;
|
||||
case MPU9X50_GYRO_FSR_250DPS:
|
||||
case MPU9X50_GYRO_FSR_500DPS:
|
||||
case MPU9X50_GYRO_FSR_1000DPS:
|
||||
case MPU9X50_GYRO_FSR_2000DPS:
|
||||
i2c_acquire(DEV_I2C);
|
||||
i2c_write_reg(DEV_I2C, DEV_ADDR,
|
||||
MPU9X50_GYRO_CFG_REG, (fsr << 3), 0);
|
||||
i2c_release(DEV_I2C);
|
||||
dev->conf.gyro_fsr = fsr;
|
||||
break;
|
||||
default:
|
||||
return -2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -398,18 +379,18 @@ int mpu9x50_set_accel_fsr(mpu9x50_t *dev, mpu9x50_accel_ranges_t fsr)
|
||||
}
|
||||
|
||||
switch (fsr) {
|
||||
case MPU9X50_ACCEL_FSR_2G:
|
||||
case MPU9X50_ACCEL_FSR_4G:
|
||||
case MPU9X50_ACCEL_FSR_8G:
|
||||
case MPU9X50_ACCEL_FSR_16G:
|
||||
i2c_acquire(DEV_I2C);
|
||||
i2c_write_reg(DEV_I2C, DEV_ADDR,
|
||||
MPU9X50_ACCEL_CFG_REG, (fsr << 3), 0);
|
||||
i2c_release(DEV_I2C);
|
||||
dev->conf.accel_fsr = fsr;
|
||||
break;
|
||||
default:
|
||||
return -2;
|
||||
case MPU9X50_ACCEL_FSR_2G:
|
||||
case MPU9X50_ACCEL_FSR_4G:
|
||||
case MPU9X50_ACCEL_FSR_8G:
|
||||
case MPU9X50_ACCEL_FSR_16G:
|
||||
i2c_acquire(DEV_I2C);
|
||||
i2c_write_reg(DEV_I2C, DEV_ADDR,
|
||||
MPU9X50_ACCEL_CFG_REG, (fsr << 3), 0);
|
||||
i2c_release(DEV_I2C);
|
||||
dev->conf.accel_fsr = fsr;
|
||||
break;
|
||||
default:
|
||||
return -2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -1,7 +1,7 @@
|
||||
PKG_NAME=littlefs2
|
||||
PKG_URL=https://github.com/ARMmbed/littlefs.git
|
||||
# v2.5.1
|
||||
PKG_VERSION=6a53d76e90af33f0656333c1db09bd337fa75d23
|
||||
# v2.6
|
||||
PKG_VERSION=66f07563c333a6cfe25e51633ded6851568a0d49
|
||||
PKG_LICENSE=Apache-2.0
|
||||
|
||||
include $(RIOTBASE)/pkg/pkg.mk
|
||||
|
Loading…
Reference in New Issue
Block a user