ad5680: cap value to MAX_VALUE

This commit is contained in:
Astro 2020-09-06 19:06:31 +02:00
parent e5c9ee8ed0
commit f76ae453a9

View File

@ -46,6 +46,7 @@ impl<SPI: Transfer<u8>, S: OutputPin> Dac<SPI, S> {
} }
pub fn set(&mut self, value: u32) -> Result<(), SPI::Error> { pub fn set(&mut self, value: u32) -> Result<(), SPI::Error> {
let value = value.min(MAX_VALUE);
let mut buf = [ let mut buf = [
(value >> 14) as u8, (value >> 14) as u8,
(value >> 6) as u8, (value >> 6) as u8,