|
9 | 9 | #define DT_DRV_COMPAT invensense_icm42688
|
10 | 10 |
|
11 | 11 | #include <zephyr/drivers/sensor.h>
|
| 12 | +#include <zephyr/drivers/sensor/icm42688.h> |
12 | 13 | #include <zephyr/drivers/spi.h>
|
13 | 14 | #include <zephyr/sys/byteorder.h>
|
14 | 15 |
|
@@ -162,6 +163,23 @@ static int icm42688_attr_set(const struct device *dev, enum sensor_channel chan,
|
162 | 163 | return -EINVAL;
|
163 | 164 | }
|
164 | 165 | new_config.batch_ticks = val->val1;
|
| 166 | + } else if ((enum sensor_attribute_icm42688)attr == |
| 167 | + SENSOR_ATTR_ICM42688_PIN9_FUNCTION) { |
| 168 | + if (val->val1 != ICM42688_PIN9_FUNCTION_INT2 && |
| 169 | + val->val1 != ICM42688_PIN9_FUNCTION_FSYNC && |
| 170 | + val->val1 != ICM42688_PIN9_FUNCTION_CLKIN) { |
| 171 | + LOG_ERR("Unknown pin function"); |
| 172 | + return -EINVAL; |
| 173 | + } |
| 174 | + |
| 175 | + /* TODO: Allow this if FSYNC is configurable later. */ |
| 176 | + if (val->val1 == ICM42688_PIN9_FUNCTION_FSYNC) { |
| 177 | + LOG_ERR("FSYNC is disabled, PIN9_FUNCTION should not be set to " |
| 178 | + "FSYNC"); |
| 179 | + return -ENOTSUP; |
| 180 | + } |
| 181 | + |
| 182 | + new_config.pin9_function = val->val1; |
165 | 183 | } else {
|
166 | 184 | LOG_ERR("Unsupported attribute");
|
167 | 185 | res = -EINVAL;
|
@@ -219,6 +237,10 @@ static int icm42688_attr_get(const struct device *dev, enum sensor_channel chan,
|
219 | 237 | if (attr == SENSOR_ATTR_BATCH_DURATION) {
|
220 | 238 | val->val1 = cfg->batch_ticks;
|
221 | 239 | val->val2 = 0;
|
| 240 | + } else if ((enum sensor_attribute_icm42688)attr == |
| 241 | + SENSOR_ATTR_ICM42688_PIN9_FUNCTION) { |
| 242 | + val->val1 = cfg->pin9_function; |
| 243 | + val->val2 = 0; |
222 | 244 | } else {
|
223 | 245 | LOG_ERR("Unsupported attribute");
|
224 | 246 | res = -EINVAL;
|
@@ -313,7 +335,8 @@ void icm42688_unlock(const struct device *dev)
|
313 | 335 | .fifo_hires = false, \
|
314 | 336 | .interrupt1_drdy = false, \
|
315 | 337 | .interrupt1_fifo_ths = false, \
|
316 |
| - .interrupt1_fifo_full = false \ |
| 338 | + .interrupt1_fifo_full = false, \ |
| 339 | + .pin9_function = ICM42688_PIN9_FUNCTION_INT2 \ |
317 | 340 | }
|
318 | 341 |
|
319 | 342 | #define ICM42688_DEFINE_DATA(inst) \
|
|
0 commit comments