drivers: sensors: Support XYZ accel get for adxl362.
Add a possibility to get values of accelerometer measurement for all 3 axis of accelerometer with one channel_get(). Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
This commit is contained in:
parent
ecac194448
commit
cd465ff8c4
2 changed files with 13 additions and 3 deletions
|
@ -614,6 +614,11 @@ static int adxl362_channel_get(const struct device *dev,
|
||||||
case SENSOR_CHAN_ACCEL_Z: /* Acceleration on the Z axis, in m/s^2. */
|
case SENSOR_CHAN_ACCEL_Z: /* Acceleration on the Z axis, in m/s^2. */
|
||||||
adxl362_accel_convert(val, data->acc_z, data->selected_range);
|
adxl362_accel_convert(val, data->acc_z, data->selected_range);
|
||||||
break;
|
break;
|
||||||
|
case SENSOR_CHAN_ACCEL_XYZ: /* Acceleration on the XYZ axis, in m/s^2. */
|
||||||
|
for (size_t i = 0; i < 3; i++) {
|
||||||
|
adxl362_accel_convert(&val[i], data->acc_xyz[i], data->selected_range);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case SENSOR_CHAN_DIE_TEMP: /* Temperature in degrees Celsius. */
|
case SENSOR_CHAN_DIE_TEMP: /* Temperature in degrees Celsius. */
|
||||||
adxl362_temp_convert(val, data->temp);
|
adxl362_temp_convert(val, data->temp);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -194,9 +194,14 @@ struct adxl362_data {
|
||||||
#if DT_INST_SPI_DEV_HAS_CS_GPIOS(0)
|
#if DT_INST_SPI_DEV_HAS_CS_GPIOS(0)
|
||||||
struct spi_cs_control adxl362_cs_ctrl;
|
struct spi_cs_control adxl362_cs_ctrl;
|
||||||
#endif
|
#endif
|
||||||
int16_t acc_x;
|
union {
|
||||||
int16_t acc_y;
|
int16_t acc_xyz[3];
|
||||||
int16_t acc_z;
|
struct {
|
||||||
|
int16_t acc_x;
|
||||||
|
int16_t acc_y;
|
||||||
|
int16_t acc_z;
|
||||||
|
};
|
||||||
|
} __packed;
|
||||||
int16_t temp;
|
int16_t temp;
|
||||||
uint8_t selected_range;
|
uint8_t selected_range;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue