Skip to content

LSM303DLHC 3D Accelerometer And 3D Magnetometer Driver

License

Notifications You must be signed in to change notification settings

zeoio/lsm303dlhc-driver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 

Repository files navigation

LSM303DLHC 3D Accelerometer and 3D Magnetometer Driver

LSM303DLHC Ultra Compact High Perfomance E-compass 3D Accelerometer and 3D Magnetometer module driver.

Building the source

Developed LSM303DLHC accelerometer driver
  1. Clone the code
git clone https://github.com/Sarlor/lsm303dlhc-driver.git
cd lsm303dlhc-driver/src/acc
  1. Edit the 'Makefile' file, set the correct kernel directory 'KERN_DIR'
vim Makefile
  1. Copy the driver files to the 'hwmon' directory
make cp
  1. Add board-level support code to the appropriate place
vim arch/arm/plat-s5p4418/realarm/device.c
#if defined(CONFIG_SENSORS_LSM303DLHC_ACC) || defined(CONFIG_SENSORS_LSM303DLHC_ACC_MODULE)
#include <linux/i2c.h>

/* CODEC */
static struct i2c_board_info __initdata lsm303dlhc_acc_i2c_bdi = {
	.type   = "lsm303dlhc_acc",
	.addr   = 0x19
 };

 #endif

#if defined(CONFIG_SENSORS_LSM303DLHC_ACC) || defined(CONFIG_SENSORS_LSM303DLHC_ACC_MODULE)
	printk("plat: add accelerometer lsm303dlhc\n");
	i2c_register_board_info(1, &lsm303dlhc_acc_i2c_bdi, 1);
#endif
  1. Modify the kernel configuration file for lsm303dlhc accelerometer
vim drivers/hwmon/Kconfig
config SENSORS_LSM303DLHC_ACC
	tristate "3D accelerometer module"
	depends on I2C
	default n
	help
	Say Y here to enable the Accelerometer module.
	
	If unsure, say N.
vim drivers/hwmon/Makefile
obj-$(CONFIG_SENSORS_LSM303DLHC_ACC)    += lsm303dlhc_acc.o

Developed LSM303DLHC magnetometer driver

  1. Enter the src directory, and edit Makefile file, set the correct kernel directory 'KERN_DIR'
cd src/mag
vim Makefile
  1. Copy the driver files to the 'hwmon' directory
make cp
  1. Add board-level support code to the appropriate place
vim arch/arm/plat-s5p4418/realarm/device.c
#if defined(CONFIG_SENSORS_LSM303DLHC_MAG) || defined(CONFIG_SENSORS_LSM303DLHC_MAG_MODULE)
#include <linux/i2c.h>

/* CODEC */
static struct i2c_board_info __initdata lsm303dlhc_mag_i2c_bdi = {
	.type   = "lsm303dlhc_mag",
	.addr   = 0x1E
};

#endif

#if defined(CONFIG_SENSORS_LSM303DLHC_MAG) || defined(CONFIG_SENSORS_LSM303DLHC_MAG_MODULE)
	printk("plat: add magnetometer lsm303dlhc\n");
	i2c_register_board_info(1, &lsm303dlhc_mag_i2c_bdi, 1);
#endif
  1. Modify the kernel configuration file for lsm303dlhc accelerometer
vim drivers/hwmon/Kconfig
config SENSORS_LSM303DLHC_MAG
	tristate "3D magnetometer module"
	depends on I2C
	default n
	help
	Say Y here to enable the Magnetometer module.

	If unsure, say N.
vim drivers/hwmon/Makefile
obj-$(CONFIG_SENSORS_LSM303DLHC_MAG)    += lsm303dlhc_mag.o

Configure kernel

make menuconfig
Device Drivers -> Hardware Monitoring support -> 3D accelerometer module && 3D magnetometer module

About

LSM303DLHC 3D Accelerometer And 3D Magnetometer Driver

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published