Skip to content

Commit 70b5002

Browse files
pabigotgalak
authored andcommitted
sensor: adxl372: update for new GPIO API
Update sample overlay for missing chip select and to deconflict with UART TXD. Add GPIO flags to configuration state. Replace callback enable with interrupt enable. Signed-off-by: Peter Bigot <[email protected]>
1 parent d12b336 commit 70b5002

File tree

6 files changed

+23
-10
lines changed

6 files changed

+23
-10
lines changed

drivers/sensor/adxl372/adxl372.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -939,6 +939,7 @@ static const struct adxl372_dev_config adxl372_config = {
939939
#ifdef CONFIG_ADXL372_TRIGGER
940940
.gpio_port = DT_INST_0_ADI_ADXL372_INT1_GPIOS_CONTROLLER,
941941
.int_gpio = DT_INST_0_ADI_ADXL372_INT1_GPIOS_PIN,
942+
.int_flags = DT_INST_0_ADI_ADXL372_INT1_GPIOS_FLAGS,
942943
#endif
943944

944945
.max_peak_detect_mode = IS_ENABLED(CONFIG_ADXL372_PEAK_DETECT_MODE),

drivers/sensor/adxl372/adxl372.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,12 +320,13 @@ struct adxl372_dev_config {
320320
u32_t spi_max_frequency;
321321
#if defined(DT_INST_0_ADI_ADXL372_CS_GPIOS_CONTROLLER)
322322
const char *gpio_cs_port;
323-
u8_t cs_gpio;
323+
gpio_pin_t cs_gpio;
324324
#endif
325325
#endif /* CONFIG_ADXL372_SPI */
326326
#ifdef CONFIG_ADXL372_TRIGGER
327327
const char *gpio_port;
328-
u8_t int_gpio;
328+
gpio_pin_t int_gpio;
329+
gpio_devicetree_flags_t int_flags;
329330
#endif
330331
bool max_peak_detect_mode;
331332

drivers/sensor/adxl372/adxl372_trigger.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ static void adxl372_thread_cb(void *arg)
4545
drv_data->drdy_handler(dev, &drv_data->drdy_trigger);
4646
}
4747

48-
gpio_pin_enable_callback(drv_data->gpio, cfg->int_gpio);
48+
gpio_pin_interrupt_configure(drv_data->gpio, cfg->int_gpio,
49+
GPIO_INT_EDGE_TO_ACTIVE);
4950
}
5051

5152
static void adxl372_gpio_callback(struct device *dev,
@@ -55,7 +56,8 @@ static void adxl372_gpio_callback(struct device *dev,
5556
CONTAINER_OF(cb, struct adxl372_data, gpio_cb);
5657
const struct adxl372_dev_config *cfg = dev->config->config_info;
5758

58-
gpio_pin_disable_callback(dev, cfg->int_gpio);
59+
gpio_pin_interrupt_configure(drv_data->gpio, cfg->int_gpio,
60+
GPIO_INT_DISABLE);
5961

6062
#if defined(CONFIG_ADXL372_TRIGGER_OWN_THREAD)
6163
k_sem_give(&drv_data->gpio_sem);
@@ -97,7 +99,8 @@ int adxl372_trigger_set(struct device *dev,
9799
u8_t int_mask, int_en, status1, status2;
98100
int ret;
99101

100-
gpio_pin_disable_callback(drv_data->gpio, cfg->int_gpio);
102+
gpio_pin_interrupt_configure(drv_data->gpio, cfg->int_gpio,
103+
GPIO_INT_DISABLE);
101104

102105
switch (trig->type) {
103106
case SENSOR_TRIG_THRESHOLD:
@@ -127,7 +130,8 @@ int adxl372_trigger_set(struct device *dev,
127130

128131
adxl372_get_status(dev, &status1, &status2, NULL); /* Clear status */
129132
out:
130-
gpio_pin_enable_callback(drv_data->gpio, cfg->int_gpio);
133+
gpio_pin_interrupt_configure(drv_data->gpio, cfg->int_gpio,
134+
GPIO_INT_EDGE_TO_ACTIVE);
131135

132136
return ret;
133137
}
@@ -145,8 +149,7 @@ int adxl372_init_interrupt(struct device *dev)
145149
}
146150

147151
gpio_pin_configure(drv_data->gpio, cfg->int_gpio,
148-
GPIO_DIR_IN | GPIO_INT | GPIO_INT_EDGE |
149-
GPIO_INT_ACTIVE_HIGH | GPIO_INT_DEBOUNCE);
152+
GPIO_INPUT | cfg->int_flags);
150153

151154
gpio_init_callback(&drv_data->gpio_cb,
152155
adxl372_gpio_callback,

dts/bindings/sensor/adi,adxl372-i2c.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,7 @@ properties:
1111
int1-gpios:
1212
type: phandle-array
1313
required: false
14+
description: |
15+
The INT1 signal defaults to active high as produced by the
16+
sensor. The property value should ensure the flags properly
17+
describe the signal that is presented to the driver.

dts/bindings/sensor/adi,adxl372-spi.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,7 @@ properties:
1212
int1-gpios:
1313
type: phandle-array
1414
required: false
15+
description: |
16+
The INT1 signal defaults to active high as produced by the
17+
sensor. The property value should ensure the flags properly
18+
describe the signal that is presented to the driver.

samples/sensor/adxl372/nrf52_pca10040.overlay

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
*/
66

77
&spi2 {
8-
8+
cs-gpios = <&gpio0 22 0>;
99
adxl372@0 {
1010
compatible = "adi,adxl372";
1111
reg = <0>;
1212
spi-max-frequency = <8000000>;
1313
label = "ADXL372";
14-
int1-gpios = <&gpio0 6 0>;
14+
int1-gpios = <&gpio0 11 GPIO_ACTIVE_HIGH>;
1515
};
1616
};

0 commit comments

Comments
 (0)