[PATCH v4] hw/sensor: Add lsm303dlhc magnetometer device

2022-01-30 Thread Kevin Townsend
DLHC_MAG=y'. Signed-off-by: Kevin Townsend --- hw/sensor/Kconfig | 4 + hw/sensor/lsm303dlhc_mag.c| 556 ++ hw/sensor/meson.build | 1 + tests/qtest/lsm303dlhc-mag-test.c | 148 tests/qtest/meson.build | 1 +

Re: [PATCH v3] hw/sensor: Add lsm303dlhc magnetometer device

2021-09-28 Thread Kevin Townsend
Hi Peter, On Mon, 27 Sept 2021 at 18:39, Peter Maydell wrote: > I thought we'd agreed to implement the whole of the auto-increment > logic, not just for specific registers ? > Thanks again for the feedback. Dealing with one register value at a time (versus a buffer of response values) does simp

Re: [PATCH v3] hw/sensor: Add lsm303dlhc magnetometer device

2021-09-27 Thread Kevin Townsend
Hi Peter, Thanks for the updated review. On Mon, 27 Sept 2021 at 18:39, Peter Maydell wrote: > I thought we'd agreed to implement the whole of the auto-increment > logic, not just for specific registers ? > The problem I have here is ... how many bytes are we willing to buffer? There's no reas

[PATCH v3] hw/sensor: Add lsm303dlhc magnetometer device

2021-09-21 Thread Kevin Townsend
This commit adds emulation of the magnetometer on the LSM303DLHC. It allows the magnetometer's X, Y and Z outputs to be set via the mag-x, mag-y and mag-z properties, as well as the 12-bit temperature output via the temperature property. Signed-off-by: Kevin Townsend --- hw/sensor/Kc

Re: [PATCH v2] hw/sensor: Add lsm303dlhc magnetometer device

2021-09-20 Thread Kevin Townsend
HI Peter, On Mon, 20 Sept 2021 at 19:20, Peter Maydell wrote: > > Is 0.001 uT OK to use as a starting point? I think that's enough for most > > sensors I'm aware of. > > The thing is that the starting point is also the finishing point: > once we have released something that uses a particular set

Re: [PATCH v2] hw/sensor: Add lsm303dlhc magnetometer device

2021-09-20 Thread Kevin Townsend
On Mon, 20 Sept 2021 at 17:14, Peter Maydell wrote: > That's OK -- our "int" properties are int64_t. So we could easily > fit something like 1 == 1. uT, in case we might want > the extra precision in future. That would be 1,000,000 == 1 G > (assuming I haven't messed up my arithmetic ;-))

Re: [PATCH v2] hw/sensor: Add lsm303dlhc magnetometer device

2021-09-20 Thread Kevin Townsend
On Mon, 20 Sept 2021 at 15:52, Peter Maydell wrote: > >> Why "lsb" ? > >> > > > > In my head, using LSB seemed more precise since I know exactly what > value will > > be set to the registers, and exactly what I will get back when reading > versus passing > > in a float that's needs to be conveted

Re: [PATCH v2] hw/sensor: Add lsm303dlhc magnetometer device

2021-09-20 Thread Kevin Townsend
Hi Peter, Thanks for the review, and sorry for the slow reply, just getting back from holidays myself. On Thu, 26 Aug 2021 at 17:39, Peter Maydell wrote: > > So if I'm reading the datasheet correctly, the LM303DLHC is > really two completely distinct i2c devices in a single > package with diffe

[PATCH v2] hw/sensor: Add lsm303dlhc magnetometer device

2021-08-15 Thread Kevin Townsend
This commit adds emulation of the magnetometer on the LSM303DLHC. It allows the magnetometer's X, Y and Z outputs to be set via the mag_x, mag_y and mag_z properties, as well as the 12-bit temperature output via the temperature property. Signed-off-by: Kevin Townsend --- hw/sensor/Kc

[no subject]

2021-08-15 Thread Kevin Townsend
Updates the proposed LSM303DLHC magnetometer device following review by Philippe Mathieu-Daudé. This has been tested with Zephyr 2.6.0, as follows: $ west build -p auto -b mps2_an521 \ zephyr/samples/sensor/sensor_shell/ \ -- -DCONFIG_I2C_SHELL=y $ qemu-system-arm -M mps2-an521 -device loade

[PATCH] hw/sensor: Add lsm303dlhc magnetometer device

2021-08-14 Thread Kevin Townsend
This commit adds emulation of the magnetometer on the LSM303DLHC. It allows the magnetometer's X, Y and Z outputs to be set via the magn_x, magn_y and magn_z properties, as well as the 12-bit temperature output via the temperature property. Signed-off-by: Kevin Townsend --- hw/sensor/Kc