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