7
7
8
8
namespace bsp ::devices::power::CW2015Regs
9
9
{
10
- constexpr inline auto ADDRESS = 0x62 ;
10
+ inline constexpr auto ADDRESS = 0x62 ;
11
11
12
12
struct Config
13
13
{
14
- constexpr static auto ADDRESS = 0x08 ;
14
+ static constexpr auto ADDRESS = 0x08 ;
15
15
16
16
explicit Config (const std::uint8_t raw) : reg{raw}
17
17
{}
18
18
19
- units::SOC get_alert_threshold () const
19
+ [[nodiscard]] units::SOC get_alert_threshold () const
20
20
{
21
21
return (reg & alert_mask) >> alert_shift;
22
22
}
@@ -28,7 +28,7 @@ namespace bsp::devices::power::CW2015Regs
28
28
return *this ;
29
29
}
30
30
31
- bool is_ufg_set () const
31
+ [[nodiscard]] bool is_ufg_set () const
32
32
{
33
33
return (reg & ufg_mask) != 0 ;
34
34
}
@@ -40,7 +40,7 @@ namespace bsp::devices::power::CW2015Regs
40
40
return *this ;
41
41
}
42
42
43
- std::uint8_t get_raw () const
43
+ [[nodiscard]] std::uint8_t get_raw () const
44
44
{
45
45
return reg;
46
46
}
@@ -57,13 +57,13 @@ namespace bsp::devices::power::CW2015Regs
57
57
58
58
struct Mode
59
59
{
60
- constexpr static auto ADDRESS = 0x0A ;
60
+ static constexpr auto ADDRESS = 0x0A ;
61
61
62
62
Mode () = default ;
63
63
explicit Mode (const std::uint8_t raw) : reg{raw}
64
64
{}
65
65
66
- bool is_sleep () const
66
+ [[nodiscard]] bool is_sleep () const
67
67
{
68
68
return (reg & sleep_mask) == sleep_mask;
69
69
}
@@ -92,7 +92,7 @@ namespace bsp::devices::power::CW2015Regs
92
92
return *this ;
93
93
}
94
94
95
- std::uint8_t get_raw () const
95
+ [[nodiscard]] std::uint8_t get_raw () const
96
96
{
97
97
return reg;
98
98
}
@@ -111,15 +111,15 @@ namespace bsp::devices::power::CW2015Regs
111
111
112
112
struct RRT_ALERT
113
113
{
114
- constexpr static auto ADDRESS_H = 0x06 ;
115
- constexpr static auto ADDRESS_L = 0x07 ;
114
+ static constexpr auto ADDRESS_H = 0x06 ;
115
+ static constexpr auto ADDRESS_L = 0x07 ;
116
116
117
- RRT_ALERT (const std::uint8_t lsb, const std::uint8_t msb) : reg{static_cast <uint16_t >(lsb | (msb << 8 ))}
117
+ RRT_ALERT (const std::uint8_t lsb, const std::uint8_t msb) : reg{static_cast <std:: uint16_t >(lsb | (msb << 8 ))}
118
118
{}
119
119
explicit RRT_ALERT (const std::uint16_t reg) : reg{reg}
120
120
{}
121
121
122
- bool is_alert_triggered () const
122
+ [[nodiscard]] bool is_alert_triggered () const
123
123
{
124
124
return (reg & 0x8000 ) == 0 ;
125
125
}
@@ -130,12 +130,12 @@ namespace bsp::devices::power::CW2015Regs
130
130
return *this ;
131
131
}
132
132
133
- std::uint16_t rrt () const
133
+ [[nodiscard]] std::uint16_t rrt () const
134
134
{
135
135
return reg & 0x1FFF ;
136
136
}
137
137
138
- std::uint8_t get_raw () const
138
+ [[nodiscard]] std::uint8_t get_raw () const
139
139
{
140
140
return reg;
141
141
}
@@ -146,20 +146,20 @@ namespace bsp::devices::power::CW2015Regs
146
146
147
147
struct VCELL
148
148
{
149
- constexpr static auto ADDRESS_H = 0x02 ;
150
- constexpr static auto ADDRESS_L = 0x03 ;
149
+ static constexpr auto ADDRESS_H = 0x02 ;
150
+ static constexpr auto ADDRESS_L = 0x03 ;
151
151
152
- VCELL (const std::uint8_t lsb, const std::uint8_t msb) : reg{static_cast <uint16_t >(lsb | (msb << 8 ))}
152
+ VCELL (const std::uint8_t lsb, const std::uint8_t msb) : reg{static_cast <std:: uint16_t >(lsb | (msb << 8 ))}
153
153
{}
154
154
explicit VCELL (const std::uint16_t reg) : reg{reg}
155
155
{}
156
156
157
- units::Voltage get_voltage () const
157
+ [[nodiscard]] units::Voltage get_voltage () const
158
158
{
159
159
return reg & 0x3FFF ;
160
160
}
161
161
162
- std::uint8_t get_raw () const
162
+ [[nodiscard]] std::uint8_t get_raw () const
163
163
{
164
164
return reg;
165
165
}
@@ -170,15 +170,15 @@ namespace bsp::devices::power::CW2015Regs
170
170
171
171
struct SOC
172
172
{
173
- constexpr static auto ADDRESS_H = 0x04 ;
174
- constexpr static auto ADDRESS_L = 0x05 ;
173
+ static constexpr auto ADDRESS_H = 0x04 ;
174
+ static constexpr auto ADDRESS_L = 0x05 ;
175
175
176
- SOC (const std::uint8_t lsb, const std::uint8_t msb) : reg{static_cast <uint16_t >(lsb | (msb << 8 ))}
176
+ SOC (const std::uint8_t lsb, const std::uint8_t msb) : reg{static_cast <std:: uint16_t >(lsb | (msb << 8 ))}
177
177
{}
178
178
explicit SOC (const std::uint16_t reg) : reg{reg}
179
179
{}
180
180
181
- units::Voltage get_soc () const
181
+ [[nodiscard]] units::Voltage get_soc () const
182
182
{
183
183
return (reg & 0xFF00 ) >> 8U ;
184
184
}
@@ -189,26 +189,35 @@ namespace bsp::devices::power::CW2015Regs
189
189
190
190
class BATTINFO
191
191
{
192
- constexpr static auto BATTERY_INFO_SIZE = 64 ;
192
+ static constexpr auto BATTERY_INFO_SIZE = 64 ;
193
193
using Type = const std::array<std::uint8_t , BATTERY_INFO_SIZE>;
194
194
195
- /* got from ODM init code */
196
- constexpr static Type config_info = {
195
+ /* Init code from ODM */
196
+ #if defined(CONFIG_VERSION_PRO) && (CONFIG_VERSION_PRO == 1)
197
+ static constexpr Type config_info = {
198
+ // BH21P_3400mAh_DM140X_PROFILE_20241106
199
+ 0x14 , 0x97 , 0x39 , 0x1B , 0x14 , 0x27 , 0x4A , 0x5C , 0x64 , 0x5E , 0x4B , 0x53 , 0x4D , 0x4E , 0x52 , 0x56 ,
200
+ 0x5B , 0x5C , 0x5A , 0x5B , 0x4F , 0x67 , 0x6B , 0x74 , 0x71 , 0x62 , 0x0A , 0x3E , 0x45 , 0x69 , 0x83 , 0x8F ,
201
+ 0x8E , 0x89 , 0x88 , 0x73 , 0x45 , 0x20 , 0xFF , 0x48 , 0x09 , 0x3B , 0x59 , 0x85 , 0x8F , 0x90 , 0x90 , 0x38 ,
202
+ 0x53 , 0x84 , 0x92 , 0x92 , 0x80 , 0xBF , 0xDE , 0xCB , 0x2F , 0x00 , 0x64 , 0xA5 , 0xB5 , 0xC1 , 0x46 , 0xAE };
203
+ #else
204
+ static constexpr Type config_info = {
197
205
// profile_DEM50X_2nd_20211012
198
206
0x15 , 0x15 , 0x6E , 0x67 , 0x65 , 0x62 , 0x60 , 0x60 , 0x5F , 0x5E , 0x5B , 0x59 , 0x55 , 0x50 , 0x41 , 0x33 ,
199
207
0x2A , 0x26 , 0x24 , 0x27 , 0x31 , 0x46 , 0x55 , 0x5B , 0x47 , 0x4A , 0x0A , 0x3E , 0x38 , 0x58 , 0x59 , 0x63 ,
200
208
0x67 , 0x63 , 0x62 , 0x64 , 0x3D , 0x1B , 0x6F , 0x15 , 0x07 , 0x21 , 0x54 , 0x85 , 0x8F , 0x90 , 0x90 , 0x44 ,
201
209
0x63 , 0x86 , 0x94 , 0x99 , 0x80 , 0x89 , 0xBC , 0xCB , 0x2F , 0x00 , 0x64 , 0xA5 , 0xB5 , 0xC1 , 0x46 , 0xAE };
210
+ #endif
202
211
203
212
public:
204
- constexpr static auto ADDRESS = 0x10 ;
213
+ static constexpr auto ADDRESS = 0x10 ;
205
214
206
- Type::const_iterator begin () const noexcept
215
+ [[nodiscard]] Type::const_iterator begin () const noexcept
207
216
{
208
217
return config_info.begin ();
209
218
}
210
219
211
- Type::const_iterator end () const noexcept
220
+ [[nodiscard]] Type::const_iterator end () const noexcept
212
221
{
213
222
return config_info.end ();
214
223
}
0 commit comments