Commit 3893d91b authored by whooie's avatar whooie
Browse files

add convenience function for setting the output mode of the ad5791 DAC

parent 3cf46df9
......@@ -26,6 +26,7 @@ from lib.system import (
CONNECTIONS,
FLIR,
MOGRF,
ad5791_init_val,
)
from lib.dataio import (
get_timestamp,
......
......@@ -74,3 +74,20 @@ FLIR = Grasshopper(FLIR_SERIAL)
MOGRF_COM = 3
MOGRF = MOGDriver("COM", MOGRF_COM)
def ad5791_init_val(register: int, value: int) -> int:
"""
Returns the 24-bit integer value to send to the AD5791 DAC encoding the
operation mode.
Parameters
----------
register : uint8
value : uint24
"""
r = register % 256
B10 = value % 65536
B2 = (value >> 16) % 256
return (((B2 & 0x0f) | r) << 16) + B10
AD5791_CTRL = ad5791_init_val(0x20, 0x0012)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment