|
36 | 36 |
|
37 | 37 | _MCP4728_CH_A_MULTI_EEPROM = 0x50
|
38 | 38 |
|
| 39 | +_MCP4728_GENERAL_CALL_ADDRESS = 0x00 |
| 40 | + |
39 | 41 |
|
40 | 42 | class CV:
|
41 | 43 | """struct helper"""
|
@@ -227,6 +229,38 @@ def _chunk(big_list, chunk_size):
|
227 | 229 | for i in range(0, len(big_list), chunk_size):
|
228 | 230 | yield big_list[i : i + chunk_size]
|
229 | 231 |
|
| 232 | + def _general_call(self, byte_command): |
| 233 | + buffer_list = [_MCP4728_GENERAL_CALL_ADDRESS] |
| 234 | + buffer_list += byte_command |
| 235 | + |
| 236 | + buf = bytearray(buffer_list) |
| 237 | + |
| 238 | + with self.i2c_device as i2c: |
| 239 | + i2c.write(buf) |
| 240 | + |
| 241 | + def reset(self): |
| 242 | + """Internal Reset similar to a Power-on Reset (POR). |
| 243 | + The contents of the EEPROM are loaded into each DAC input |
| 244 | + and output registers immediately""" |
| 245 | + |
| 246 | + reset_command = [0x06] |
| 247 | + self._general_call(reset_command) |
| 248 | + |
| 249 | + def wakeup(self): |
| 250 | + """Reset the Power-Down bits (PD1, PD0 = 0,0) and |
| 251 | + Resumes Normal Operation mode""" |
| 252 | + |
| 253 | + wakeup_command = [0x09] |
| 254 | + self._general_call(wakeup_command) |
| 255 | + |
| 256 | + def soft_update(self): |
| 257 | + """Updates all DAC analog outputs (VOUT) at the same time.""" |
| 258 | + |
| 259 | + soft_update_command = [0x08] |
| 260 | + self._general_call(soft_update_command) |
| 261 | + |
| 262 | + # TODO : general_call read address |
| 263 | + |
230 | 264 |
|
231 | 265 | class Channel:
|
232 | 266 | """An instance of a single channel for a multi-channel DAC.
|
|
0 commit comments