From f76ae453a9fb47832e104f972b128f3653f1150c Mon Sep 17 00:00:00 2001 From: Astro Date: Sun, 6 Sep 2020 19:06:31 +0200 Subject: [PATCH] ad5680: cap value to MAX_VALUE --- src/ad5680.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ad5680.rs b/src/ad5680.rs index 32287d3..24217f3 100644 --- a/src/ad5680.rs +++ b/src/ad5680.rs @@ -46,6 +46,7 @@ impl, S: OutputPin> Dac { } pub fn set(&mut self, value: u32) -> Result<(), SPI::Error> { + let value = value.min(MAX_VALUE); let mut buf = [ (value >> 14) as u8, (value >> 6) as u8,