|
| 1 | +driver: bq27441 |
| 2 | +driver_class: BQ27441 |
| 3 | +i2c_address: 0x55 |
| 4 | + |
| 5 | +# I2C config for hardware tests (STeaMi board - STM32WB55) |
| 6 | +i2c: |
| 7 | + id: 1 |
| 8 | + |
| 9 | +# Register values for mock tests |
| 10 | +# BQ27441 uses 2-byte little-endian registers read via struct.unpack("<h") |
| 11 | +# The constructor calls power_up() -> set_capacity() -> writeExtendedData() |
| 12 | +# which enters config mode (needs CFGUPMODE flag in FLAGS register). |
| 13 | +mock_registers: |
| 14 | + # CONTROL (0x00): status word (unsealed, INITCOMP set) |
| 15 | + 0x00: [0x80, 0x00] |
| 16 | + # FLAGS (0x06): CFGUPMODE | BAT_DET | DSG — needed for enterConfig/exitConfig |
| 17 | + 0x06: [0x19, 0x00] |
| 18 | + # VOLTAGE (0x04): 3700 mV |
| 19 | + 0x04: [0x74, 0x0E] |
| 20 | + # REM_CAPACITY (0x0C): 600 mAh |
| 21 | + 0x0C: [0x58, 0x02] |
| 22 | + # FULL_CAPACITY (0x0E): 650 mAh |
| 23 | + 0x0E: [0x8A, 0x02] |
| 24 | + # AVG_CURRENT (0x10): 50 mA |
| 25 | + 0x10: [0x32, 0x00] |
| 26 | + # AVG_POWER (0x18): 185 mW |
| 27 | + 0x18: [0xB9, 0x00] |
| 28 | + # SOC (0x1C): 92% |
| 29 | + 0x1C: [0x5C, 0x00] |
| 30 | + # SOH (0x20): 99% (low byte = percent, high byte = status) |
| 31 | + 0x20: [0x63, 0x00] |
| 32 | + |
| 33 | +tests: |
| 34 | + - name: "Read voltage" |
| 35 | + action: call |
| 36 | + method: voltage |
| 37 | + expect: 3700 |
| 38 | + mode: [mock] |
| 39 | + |
| 40 | + - name: "Read state of charge" |
| 41 | + action: call |
| 42 | + method: state_of_charge |
| 43 | + expect: 92 |
| 44 | + mode: [mock] |
| 45 | + |
| 46 | + - name: "Read remaining capacity" |
| 47 | + action: call |
| 48 | + method: capacity_remaining |
| 49 | + expect: 600 |
| 50 | + mode: [mock] |
| 51 | + |
| 52 | + - name: "Read full capacity" |
| 53 | + action: call |
| 54 | + method: capacity_full |
| 55 | + expect: 650 |
| 56 | + mode: [mock] |
| 57 | + |
| 58 | + - name: "Read average current" |
| 59 | + action: call |
| 60 | + method: current_average |
| 61 | + expect: 50 |
| 62 | + mode: [mock] |
| 63 | + |
| 64 | + - name: "Read average power" |
| 65 | + action: call |
| 66 | + method: power |
| 67 | + expect: 185 |
| 68 | + mode: [mock] |
| 69 | + |
| 70 | + - name: "Read state of health" |
| 71 | + action: call |
| 72 | + method: state_of_health |
| 73 | + expect: 99 |
| 74 | + mode: [mock] |
| 75 | + |
| 76 | + - name: "Battery connected check" |
| 77 | + action: manual |
| 78 | + prompt: "Une batterie est-elle connectée à la carte ?" |
| 79 | + expect_true: true |
| 80 | + mode: [hardware] |
| 81 | + |
| 82 | + - name: "Device type is BQ27441" |
| 83 | + action: call |
| 84 | + method: is_valid_device |
| 85 | + expect: true |
| 86 | + mode: [hardware] |
| 87 | + |
| 88 | + - name: "Voltage in plausible range" |
| 89 | + action: call |
| 90 | + method: voltage |
| 91 | + expect_range: [3000, 4300] |
| 92 | + mode: [hardware] |
| 93 | + |
| 94 | + - name: "State of charge in valid range" |
| 95 | + action: call |
| 96 | + method: state_of_charge |
| 97 | + expect_range: [0, 100] |
| 98 | + mode: [hardware] |
| 99 | + |
| 100 | + - name: "Remaining capacity positive" |
| 101 | + action: call |
| 102 | + method: capacity_remaining |
| 103 | + expect_range: [0, 1000] |
| 104 | + mode: [hardware] |
| 105 | + |
| 106 | + - name: "Full capacity positive" |
| 107 | + action: call |
| 108 | + method: capacity_full |
| 109 | + expect_range: [100, 1000] |
| 110 | + mode: [hardware] |
| 111 | + |
| 112 | + - name: "Average current readable" |
| 113 | + action: call |
| 114 | + method: current_average |
| 115 | + expect_not_none: true |
| 116 | + mode: [hardware] |
| 117 | + |
| 118 | + - name: "Average power readable" |
| 119 | + action: call |
| 120 | + method: power |
| 121 | + expect_not_none: true |
| 122 | + mode: [hardware] |
| 123 | + |
| 124 | + - name: "State of health in valid range" |
| 125 | + action: call |
| 126 | + method: state_of_health |
| 127 | + expect_range: [0, 100] |
| 128 | + mode: [hardware] |
| 129 | + |
| 130 | + - name: "Battery info summary" |
| 131 | + action: manual |
| 132 | + display: |
| 133 | + - method: voltage |
| 134 | + label: "Tension" |
| 135 | + unit: "mV" |
| 136 | + - method: state_of_charge |
| 137 | + label: "Charge" |
| 138 | + unit: "%" |
| 139 | + - method: capacity_remaining |
| 140 | + label: "Capacité restante" |
| 141 | + unit: "mAh" |
| 142 | + - method: capacity_full |
| 143 | + label: "Capacité totale" |
| 144 | + unit: "mAh" |
| 145 | + - method: current_average |
| 146 | + label: "Courant moyen" |
| 147 | + unit: "mA" |
| 148 | + - method: state_of_health |
| 149 | + label: "Santé batterie" |
| 150 | + unit: "%" |
| 151 | + prompt: "Ces valeurs sont-elles cohérentes avec l'état de la batterie ?" |
| 152 | + expect_true: true |
| 153 | + mode: [hardware] |
0 commit comments