|
| 1 | +driver: lis2mdl |
| 2 | +driver_class: LIS2MDL |
| 3 | +i2c_address: 0x1E |
| 4 | + |
| 5 | +# I2C config for hardware tests (STeaMi board - STM32WB55) |
| 6 | +i2c: |
| 7 | + id: 1 |
| 8 | + |
| 9 | +# Register values for mock tests |
| 10 | +# These simulate a real LIS2MDL magnetometer |
| 11 | +mock_registers: |
| 12 | + # WHO_AM_I (expected 0x40) |
| 13 | + 0x4F: 0x40 |
| 14 | + # CFG_REG_A (continuous mode, 10Hz, temp comp on) |
| 15 | + 0x60: 0x80 |
| 16 | + # CFG_REG_B (default) |
| 17 | + 0x61: 0x00 |
| 18 | + # CFG_REG_C (BDU enabled) |
| 19 | + 0x62: 0x10 |
| 20 | + # STATUS_REG (new data ready on all axes) |
| 21 | + 0x67: 0x0F |
| 22 | + # OUTX_L..OUTZ_H (simulated magnetic field ~300, -150, 450 LSB) |
| 23 | + # Multi-byte read at 0xE8 (0x68 | 0x80), 6 bytes block |
| 24 | + 0xE8: [0x2C, 0x01, 0x6A, 0xFF, 0xC2, 0x01] |
| 25 | + # TEMP_OUT (simulated ~25°C: 25*8 = 200 = 0x00C8) |
| 26 | + 0x6E: 0xC8 # TEMP_OUT_L |
| 27 | + 0x6F: 0x00 # TEMP_OUT_H |
| 28 | + # Offset registers (all zero) |
| 29 | + 0x45: 0x00 |
| 30 | + 0x46: 0x00 |
| 31 | + 0x47: 0x00 |
| 32 | + 0x48: 0x00 |
| 33 | + 0x49: 0x00 |
| 34 | + 0x4A: 0x00 |
| 35 | + |
| 36 | +tests: |
| 37 | + - name: "Verify WHO_AM_I register" |
| 38 | + action: read_register |
| 39 | + register: 0x4F |
| 40 | + expect: 0x40 |
| 41 | + mode: [mock, hardware] |
| 42 | + |
| 43 | + - name: "Read WHO_AM_I via method" |
| 44 | + action: call |
| 45 | + method: read_who_am_i |
| 46 | + expect: 0x40 |
| 47 | + mode: [mock, hardware] |
| 48 | + |
| 49 | + - name: "Read status register" |
| 50 | + action: call |
| 51 | + method: read_status |
| 52 | + expect_not_none: true |
| 53 | + mode: [mock, hardware] |
| 54 | + |
| 55 | + - name: "Read magnetic field returns tuple" |
| 56 | + action: call |
| 57 | + method: read_magnet |
| 58 | + expect_not_none: true |
| 59 | + mode: [mock] |
| 60 | + |
| 61 | + - name: "Read magnetic field in uT returns tuple" |
| 62 | + action: call |
| 63 | + method: read_magnet_uT |
| 64 | + expect_not_none: true |
| 65 | + mode: [mock] |
| 66 | + |
| 67 | + - name: "Read temperature returns float" |
| 68 | + action: call |
| 69 | + method: read_temperature_c |
| 70 | + expect_not_none: true |
| 71 | + mode: [mock] |
| 72 | + |
| 73 | + - name: "Magnitude in plausible range" |
| 74 | + action: call |
| 75 | + method: magnitude_uT |
| 76 | + expect_range: [10.0, 120.0] |
| 77 | + mode: [hardware] |
| 78 | + |
| 79 | + - name: "Temperature in plausible range" |
| 80 | + action: call |
| 81 | + method: read_temperature_c |
| 82 | + expect_range: [-10.0, 60.0] |
| 83 | + mode: [hardware] |
| 84 | + |
| 85 | + - name: "Magnetic field values feel correct" |
| 86 | + action: manual |
| 87 | + display: |
| 88 | + - method: magnitude_uT |
| 89 | + label: "Magnitude" |
| 90 | + unit: "µT" |
| 91 | + - method: read_temperature_c |
| 92 | + label: "Temperature" |
| 93 | + unit: "°C" |
| 94 | + - method: heading_flat_only |
| 95 | + label: "Heading" |
| 96 | + unit: "°" |
| 97 | + prompt: "Ces valeurs sont-elles cohérentes (magnitude ~25-65µT, cap 0-360°) ?" |
| 98 | + expect_true: true |
| 99 | + mode: [hardware] |
0 commit comments