sensor: bmg160: Convert to DTS
Convert bmg160 sensor driver and sample app to utilize device tree. Introduce a dts board overlay on the frdm_k64f board to ensure we at least have a single platform in which the sample gets built. Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
parent
7b8b5524be
commit
62f5ac1ad4
6 changed files with 47 additions and 38 deletions
|
@ -11,25 +11,6 @@ menuconfig BMG160
|
||||||
|
|
||||||
if BMG160
|
if BMG160
|
||||||
|
|
||||||
config BMG160_DRV_NAME
|
|
||||||
string "Driver's name"
|
|
||||||
default "bmg160"
|
|
||||||
help
|
|
||||||
Name for the BMG160 driver which will be used for binding.
|
|
||||||
|
|
||||||
config BMG160_I2C_PORT_NAME
|
|
||||||
string "I2C master controller port name"
|
|
||||||
default "I2C_0"
|
|
||||||
help
|
|
||||||
Master I2C port name through which BMG160 chip is accessed.
|
|
||||||
|
|
||||||
config BMG160_I2C_ADDR
|
|
||||||
hex "BMG160 I2C address"
|
|
||||||
default 0x68
|
|
||||||
help
|
|
||||||
BMG160 chip's I2C address. Chip supports two addresses: 0x68 and 0x69 (if
|
|
||||||
SDO pin is pulled to GND).
|
|
||||||
|
|
||||||
choice
|
choice
|
||||||
prompt "BMG160 I2C bus speed"
|
prompt "BMG160 I2C bus speed"
|
||||||
default BMG160_I2C_SPEED_STANDARD
|
default BMG160_I2C_SPEED_STANDARD
|
||||||
|
@ -80,20 +61,6 @@ config BMG160_THREAD_STACK_SIZE
|
||||||
help
|
help
|
||||||
The thread stack size.
|
The thread stack size.
|
||||||
|
|
||||||
config BMG160_GPIO_PORT_NAME
|
|
||||||
string "GPIO controller port name"
|
|
||||||
depends on BMG160_TRIGGER
|
|
||||||
default "GPIO_0"
|
|
||||||
help
|
|
||||||
The gpio controller the interrupt pin is attached to.
|
|
||||||
|
|
||||||
config BMG160_INT_PIN
|
|
||||||
hex "BMG160 INT PIN"
|
|
||||||
depends on BMG160_TRIGGER
|
|
||||||
default 2
|
|
||||||
help
|
|
||||||
BMG160 interrupt pin.
|
|
||||||
|
|
||||||
choice
|
choice
|
||||||
prompt "Gyroscope range setting."
|
prompt "Gyroscope range setting."
|
||||||
default BMG160_RANGE_RUNTIME
|
default BMG160_RANGE_RUNTIME
|
||||||
|
|
|
@ -328,15 +328,16 @@ int bmg160_init(struct device *dev)
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct bmg160_device_config bmg160_config = {
|
const struct bmg160_device_config bmg160_config = {
|
||||||
.i2c_port = CONFIG_BMG160_I2C_PORT_NAME,
|
.i2c_port = DT_INST_0_BOSCH_BMG160_BUS_NAME,
|
||||||
.i2c_addr = CONFIG_BMG160_I2C_ADDR,
|
.i2c_addr = DT_INST_0_BOSCH_BMG160_BASE_ADDRESS,
|
||||||
.i2c_speed = BMG160_BUS_SPEED,
|
.i2c_speed = BMG160_BUS_SPEED,
|
||||||
#ifdef CONFIG_BMG160_TRIGGER
|
#ifdef CONFIG_BMG160_TRIGGER
|
||||||
.gpio_port = CONFIG_BMG160_GPIO_PORT_NAME,
|
.gpio_port = DT_INST_0_BOSCH_BMG160_INT_GPIOS_CONTROLLER,
|
||||||
.int_pin = CONFIG_BMG160_INT_PIN,
|
.int_pin = DT_INST_0_BOSCH_BMG160_INT_GPIOS_PIN,
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
DEVICE_AND_API_INIT(bmg160, CONFIG_BMG160_DRV_NAME, bmg160_init, &bmg160_data,
|
DEVICE_AND_API_INIT(bmg160, DT_INST_0_BOSCH_BMG160_LABEL, bmg160_init,
|
||||||
|
&bmg160_data,
|
||||||
&bmg160_config, POST_KERNEL, CONFIG_SENSOR_INIT_PRIORITY,
|
&bmg160_config, POST_KERNEL, CONFIG_SENSOR_INIT_PRIORITY,
|
||||||
&bmg160_api);
|
&bmg160_api);
|
||||||
|
|
17
dts/bindings/sensor/bosch,bmg160.yaml
Normal file
17
dts/bindings/sensor/bosch,bmg160.yaml
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
# Copyright (c) 2019, Linaro Limited
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
title: Bosch BMG160 gyroscope
|
||||||
|
|
||||||
|
description: |
|
||||||
|
Bosch BMG160 gyroscope. See more info at:
|
||||||
|
https://www.bosch-sensortec.com/bst/products/all_products/bmg160
|
||||||
|
|
||||||
|
compatible: "bosch,bmg160"
|
||||||
|
|
||||||
|
include: i2c-device.yaml
|
||||||
|
|
||||||
|
properties:
|
||||||
|
int-gpios:
|
||||||
|
type: phandle-array
|
||||||
|
required: false
|
14
samples/sensor/bmg160/boards/frdm_k64f.overlay
Normal file
14
samples/sensor/bmg160/boards/frdm_k64f.overlay
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019, Linaro Ltd.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
&i2c0 {
|
||||||
|
bmg160@68 {
|
||||||
|
compatible = "bosch,bmg160";
|
||||||
|
reg = <0x68>;
|
||||||
|
int-gpios = <&gpioc 6 0>;
|
||||||
|
label = "BMG160";
|
||||||
|
};
|
||||||
|
};
|
|
@ -5,3 +5,4 @@ tests:
|
||||||
harness: sensor
|
harness: sensor
|
||||||
tags: sensors
|
tags: sensors
|
||||||
depends_on: i2c gpio
|
depends_on: i2c gpio
|
||||||
|
filter: dt_compat_enabled("bosch,bmg160")
|
||||||
|
|
|
@ -381,6 +381,15 @@
|
||||||
#define DT_INST_0_BOSCH_BMM150_BUS_NAME ""
|
#define DT_INST_0_BOSCH_BMM150_BUS_NAME ""
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef DT_INST_0_BOSCH_BMG160_LABEL
|
||||||
|
#define DT_INST_0_BOSCH_BMG160_LABEL ""
|
||||||
|
#define DT_INST_0_BOSCH_BMG160_BASE_ADDRESS 0
|
||||||
|
#define DT_INST_0_BOSCH_BMG160_BUS_NAME ""
|
||||||
|
#define DT_INST_0_BOSCH_BMG160_INT_GPIOS_CONTROLLER ""
|
||||||
|
#define DT_INST_0_BOSCH_BMG160_INT_GPIOS_FLAGS 0
|
||||||
|
#define DT_INST_0_BOSCH_BMG160_INT_GPIOS_PIN 0
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* CONFIG_HAS_DTS_I2C */
|
#endif /* CONFIG_HAS_DTS_I2C */
|
||||||
|
|
||||||
#ifndef DT_ADXL372_DEV_NAME
|
#ifndef DT_ADXL372_DEV_NAME
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue