Skip to content

Commit d12b336

Browse files
pabigotgalak
authored andcommitted
sensor: adxl362: update for new GPIO API
Add a sample overlay. Add GPIO flags to configuration state. Replace callback enable with interrupt enable. Signed-off-by: Peter Bigot <[email protected]>
1 parent 52d6df9 commit d12b336

File tree

5 files changed

+32
-5
lines changed

5 files changed

+32
-5
lines changed

drivers/sensor/adxl362/adxl362.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,7 @@ static const struct adxl362_config adxl362_config = {
794794
#if defined(CONFIG_ADXL362_TRIGGER)
795795
.gpio_port = DT_INST_0_ADI_ADXL362_INT1_GPIOS_CONTROLLER,
796796
.int_gpio = DT_INST_0_ADI_ADXL362_INT1_GPIOS_PIN,
797+
.int_flags = DT_INST_0_ADI_ADXL362_INT1_GPIOS_FLAGS,
797798
#endif
798799
};
799800

drivers/sensor/adxl362/adxl362.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,12 @@ struct adxl362_config {
176176
u16_t spi_slave;
177177
#if defined(DT_INST_0_ADI_ADXL362_CS_GPIOS_CONTROLLER)
178178
const char *gpio_cs_port;
179-
u8_t cs_gpio;
179+
gpio_pin_t cs_gpio;
180180
#endif
181181
#if defined(CONFIG_ADXL362_TRIGGER)
182182
const char *gpio_port;
183-
u8_t int_gpio;
183+
gpio_pin_t int_gpio;
184+
gpio_devicetree_flags_t int_flags;
184185
u8_t int1_config;
185186
u8_t int2_config;
186187
#endif

drivers/sensor/adxl362/adxl362_trigger.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,7 @@ int adxl362_init_interrupt(struct device *dev)
140140
}
141141

142142
gpio_pin_configure(drv_data->gpio, cfg->int_gpio,
143-
GPIO_DIR_IN | GPIO_INT | GPIO_INT_EDGE |
144-
GPIO_INT_ACTIVE_HIGH | GPIO_INT_DEBOUNCE);
143+
GPIO_INPUT | cfg->int_flags);
145144

146145
gpio_init_callback(&drv_data->gpio_cb,
147146
adxl362_gpio_callback,
@@ -165,7 +164,8 @@ int adxl362_init_interrupt(struct device *dev)
165164
drv_data->dev = dev;
166165
#endif
167166

168-
gpio_pin_enable_callback(drv_data->gpio, cfg->int_gpio);
167+
gpio_pin_interrupt_configure(drv_data->gpio, cfg->int_gpio,
168+
GPIO_INT_EDGE_TO_ACTIVE);
169169

170170
return 0;
171171
}

dts/bindings/sensor/adi,adxl362.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.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright (c) 2019 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
&spi1 {
8+
status = "okay";
9+
sck-pin = <25>;
10+
mosi-pin = <23>;
11+
miso-pin = <24>;
12+
cs-gpios = <&gpio0 22 0>;
13+
14+
adxl362@0 {
15+
compatible = "adi,adxl362";
16+
label = "ADXL362";
17+
spi-max-frequency = <8000000>;
18+
reg = <0>;
19+
int1-gpios = <&gpio0 11 GPIO_ACTIVE_HIGH>;
20+
};
21+
};

0 commit comments

Comments
 (0)