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