From 25dead1549558fe43da4a4b02958c2a5d9df45a2 Mon Sep 17 00:00:00 2001 From: Joel Aschmann Date: Sat, 25 Feb 2023 10:42:03 +0100 Subject: [PATCH] DAC: implement https://github.com/RIOT-OS/rust-riot-wrappers/issues/37 --- src/dac.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/dac.rs b/src/dac.rs index e5495bc2..9e5df7e3 100644 --- a/src/dac.rs +++ b/src/dac.rs @@ -15,12 +15,16 @@ pub enum DACError { } impl DACLine { - /// Creates and intializes a new [`DACLine`] from the given - /// unitialized [`dac_t`]. + /// Creates and intializes a new [`DACLine`]. + /// + /// The `index` indicates which dac device from the current board should be used. + /// For information on how many such devices are available for this board please + /// refer to its RIOT documentation. /// /// Returns an Error if the given line does not exist /// on the board. - pub fn new(line: dac_t) -> Result { + pub fn new(index: usize) -> Result { + let line = unsafe { riot_sys::macro_DAC_LINE(index as u32) }; let res = unsafe { riot_sys::dac_init(line) } as i32; const DAC_OK: i32 = riot_sys::DAC_OK as i32;