### Get Channel from Index Source: https://docs.rs/dac8568/0.0.12/dac8568/enum.Channel.html Converts a u8 index into its corresponding Channel enum variant. This is useful for deserializing channel information. ```rust pub fn from_index(index: u8) -> Channel ``` -------------------------------- ### DAC8568 Initialization and Release Source: https://docs.rs/dac8568/0.0.12/dac8568/struct.Dac.html Provides methods for creating a new instance of the DAC8568 and for consuming the instance to retrieve the underlying SPI and GPIO pins. ```APIDOC ## Dac::new ### Description Initialize a new instance of dac8568. ### Method `new` ### Parameters - **spi** (SPI) - Description not available - **sync** (SYNC) - Description not available ### Request Example ```rust let dac = Dac::new(spi_instance, sync_pin); ``` ## Dac::release ### Description Consume the dac and return the underlying SPI and GPIO pins used by it. ### Method `release` ### Parameters None ### Request Example ```rust let (spi, sync) = dac.release(); ``` ``` -------------------------------- ### Module asynchronous Source: https://docs.rs/dac8568/0.0.12/dac8568/asynchronous/index.html Documentation for the asynchronous module within the dac8568 crate. ```APIDOC ## Module asynchronous ### Description The asynchronous module provides non-blocking interfaces for communicating with the DAC8568 digital-to-analog converter. ``` -------------------------------- ### Clone to Uninitialized Memory (Nightly) Source: https://docs.rs/dac8568/0.0.12/dac8568/enum.Channel.html Implements the experimental `clone_to_uninit` method, allowing cloning into uninitialized memory. This is a nightly-only feature and requires careful usage. ```rust unsafe fn clone_to_uninit(&self, dest: *mut u8) ``` -------------------------------- ### Message Construction Methods Source: https://docs.rs/dac8568/0.0.12/dac8568/struct.Message.html Methods for generating specific command messages for the DAC device. ```APIDOC ## get_internal_reference_message ### Description Generates a message to switch the DAC8568 between external and internal 2.5v reference. ### Parameters - **internal** (bool) - Required - If true, switches to internal reference; if false, uses external. ## get_voltage_message ### Description Generates a message to update a specific DAC channel with a given value. ### Parameters - **channel** (Channel) - Required - The target DAC channel. - **value** (u16) - Required - The 16-bit input code. - **is_inverted** (bool) - Required - Whether the signal should be inverted. ## get_software_reset_message ### Description Generates a message to trigger a software reset, returning all registers to their default power-on state. ``` -------------------------------- ### Blanket Implementations for Async Source: https://docs.rs/dac8568/0.0.12/dac8568/mode/struct.Async.html Details the blanket implementations available for the Async struct. ```APIDOC ## Blanket Implementations ### impl Any for T where T: 'static + ?Sized, #### fn type_id(&self) -> TypeId Gets the `TypeId` of `self`. Read more ### impl Borrow for T where T: ?Sized, #### fn borrow(&self) -> &T Immutably borrows from an owned value. Read more ### impl BorrowMut for T where T: ?Sized, #### fn borrow_mut(&mut self) -> &mut T Mutably borrows from an owned value. Read more ### impl From for T #### fn from(t: T) -> T Returns the argument unchanged. ### impl Into for T where U: From, #### fn into(self) -> U Calls `U::from(self)`. That is, this conversion is whatever the implementation of `From for U` chooses to do. ### impl TryFrom for T where U: Into, #### type Error = Infallible The type returned in the event of a conversion error. #### fn try_from(value: U) -> Result>::Error> Performs the conversion. ### impl TryInto for T where U: TryFrom, #### type Error = >::Error The type returned in the event of a conversion error. #### fn try_into(self) -> Result>::Error> Performs the conversion. ``` -------------------------------- ### DAC8568 Crate Overview Source: https://docs.rs/dac8568/0.0.12/dac8568/index.html Overview of the dac8568 crate, including its purpose and main components. ```APIDOC ## Crate dac8568 A small library for using the TI DAC8568, DAC7568 and DAC8168. ### Modules - `asynchronous` - `blocking` - `mode` ### Structs - `Dac` (DAC8568) - `Message` (The Message that is eventually serialized and transmitted to the DAC) ### Enums - `Channel` (The broadcast channel) - `ControlType` (The message control type) - `DacError` (DAC Related errors) ``` -------------------------------- ### Channel Trait Implementations Source: https://docs.rs/dac8568/0.0.12/dac8568/enum.Channel.html Details the various trait implementations for the Channel enum, including Clone, Debug, PartialEq, Copy, Eq, and others. ```APIDOC ## Trait Implementations for Channel ### impl Clone for Channel * `clone(&self) -> Channel`: Returns a duplicate of the value. * `clone_from(&mut self, source: &Self)`: Performs copy-assignment from `source`. ### impl Debug for Channel * `fmt(&self, f: &mut Formatter<'_>) -> Result`: Formats the value using the given formatter. ### impl PartialEq for Channel * `eq(&self, other: &Channel) -> bool`: Tests for `self` and `other` values to be equal. * `ne(&self, other: &Rhs) -> bool`: Tests for `!=`. ### impl Copy for Channel (No methods to display, indicates the type is copyable) ### impl Eq for Channel (No methods to display, indicates the type implements total equality) ### impl StructuralPartialEq for Channel (No methods to display) ### Auto Trait Implementations * `Freeze` * `RefUnwindSafe` * `Send` * `Sync` * `Unpin` * `UnwindSafe` ### Blanket Implementations * `impl Any for T` * `type_id(&self) -> TypeId`: Gets the `TypeId` of `self`. * `impl Borrow for T` * `borrow(&self) -> &T`: Immutably borrows from an owned value. * `impl BorrowMut for T` * `borrow_mut(&mut self) -> &mut T`: Mutably borrows from an owned value. * `impl CloneToUninit for T` (Nightly-only experimental API) * `unsafe fn clone_to_uninit(&self, dest: *mut u8)`: Performs copy-assignment from `self` to `dest`. * `impl From for T` * `from(t: T) -> T`: Returns the argument unchanged. * `impl Into for T` * `into(self) -> U`: Calls `U::from(self)`. * `impl TryFrom for T` * `type Error = Infallible` * `try_from(value: U) -> Result>::Error>`: Performs the conversion. * `impl TryInto for T` * `type Error = >::Error` * `try_into(self) -> Result>::Error>`: Performs the conversion. ``` -------------------------------- ### Auto Trait Implementations for Async Source: https://docs.rs/dac8568/0.0.12/dac8568/mode/struct.Async.html Lists the auto trait implementations for the Async struct. ```APIDOC ## Auto Trait Implementations ### impl Freeze for Async ### impl RefUnwindSafe for Async ### impl Send for Async ### impl Sync for Async ### impl Unpin for Async ### impl UnwindSafe for Async ``` -------------------------------- ### DAC8568 Async Operations Source: https://docs.rs/dac8568/0.0.12/dac8568/struct.Dac.html Asynchronous methods for controlling the DAC8568, including setting voltage, configuring internal/external references, and resetting the device. ```APIDOC ## Dac::set_voltage (Async) ### Description Set the specified value to the given channel. This will update the DAC to output the desired voltage. ### Method `set_voltage` ### Parameters - **channel** (Channel) - The DAC channel to set. - **voltage** (u16) - The desired voltage value. ### Request Example ```rust let result = dac.set_voltage(Channel::Ch1, 4095).await; ``` ### Response #### Success Response (Result<(), DacError>) - **Ok**: Operation successful. - **Err**: An error occurred during the operation. ## Dac::use_internal_reference (Async) ### Description Configure the DAC to use its internal reference mode of 2.5v rather than using an external voltage reference. ### Method `use_internal_reference` ### Parameters None ### Request Example ```rust let result = dac.use_internal_reference().await; ``` ### Response #### Success Response (Result<(), DacError>) - **Ok**: Operation successful. - **Err**: An error occurred during the operation. ## Dac::use_external_reference (Async) ### Description Configure the DAC to use its external reference mode rather than using the internal reference. ### Method `use_external_reference` ### Parameters None ### Request Example ```rust let result = dac.use_external_reference().await; ``` ### Response #### Success Response (Result<(), DacError>) - **Ok**: Operation successful. - **Err**: An error occurred during the operation. ## Dac::reset (Async) ### Description Perform a software reset, clearing out all registers. This resets all DAC channels to their power-on default settings. ### Method `reset` ### Parameters None ### Request Example ```rust let result = dac.reset().await; ``` ### Response #### Success Response (Result<(), DacError>) - **Ok**: Operation successful. - **Err**: An error occurred during the operation. ``` -------------------------------- ### Async Struct Source: https://docs.rs/dac8568/0.0.12/dac8568/mode/struct.Async.html Details about the Async struct and its purpose in the dac8568 crate. ```APIDOC ## Struct Async ### Summary ```rust pub struct Async; ``` ### Description Asynchronous implementation ``` -------------------------------- ### Try Conversion Source: https://docs.rs/dac8568/0.0.12/dac8568/enum.Channel.html Implements the `try_from` method for attempting conversions between types, returning a Result. This is used when a conversion might fail. ```rust fn try_from(value: U) -> Result>::Error> ``` -------------------------------- ### Into Conversion Source: https://docs.rs/dac8568/0.0.12/dac8568/enum.Channel.html Implements the `into` method, which converts a type T into another type U using the From trait. This provides a convenient way to perform conversions. ```rust fn into(self) -> U ``` -------------------------------- ### Clone Channel From Source: https://docs.rs/dac8568/0.0.12/dac8568/enum.Channel.html Implements the clone_from method for the Channel enum, enabling efficient copying of values. This is part of the Clone trait implementation. ```rust fn clone_from(&mut self, source: &Self) ``` -------------------------------- ### Compare Channel for Equality Source: https://docs.rs/dac8568/0.0.12/dac8568/enum.Channel.html Implements the PartialEq trait for the Channel enum, enabling comparison of enum variants for equality using the `==` operator. This is fundamental for conditional logic. ```rust fn eq(&self, other: &Channel) -> bool ``` -------------------------------- ### Channel::from_index Source: https://docs.rs/dac8568/0.0.12/dac8568/enum.Channel.html Converts a u8 index into its corresponding Channel variant. ```APIDOC ## Method: Channel::from_index ### Description Get Channel from an index. ### Signature ```rust pub fn from_index(index: u8) -> Channel ``` ### Parameters * **index** (u8) - The index to convert into a Channel. ``` -------------------------------- ### Generate DAC control messages Source: https://docs.rs/dac8568/0.0.12/dac8568/struct.Message.html Methods for creating specific command messages for the DAC device. ```rust pub fn get_internal_reference_message(internal: bool) -> Message ``` ```rust pub fn get_voltage_message( channel: Channel, value: u16, is_inverted: bool, ) -> Message ``` ```rust pub fn get_software_reset_message() -> Message ``` -------------------------------- ### Identity Conversion Source: https://docs.rs/dac8568/0.0.12/dac8568/enum.Channel.html Implements the `from` method for any type T, returning the input value unchanged. This is a trivial implementation of the From trait. ```rust fn from(t: T) -> T ``` -------------------------------- ### Compare Channel for Inequality Source: https://docs.rs/dac8568/0.0.12/dac8568/enum.Channel.html Implements the `ne` method for the Channel enum, providing inequality comparison using the `!=` operator. This is part of the PartialEq trait. ```rust fn ne(&self, other: &Rhs) -> bool ``` -------------------------------- ### Try Into Conversion Source: https://docs.rs/dac8568/0.0.12/dac8568/enum.Channel.html Implements the `try_into` method, which attempts to convert a type T into another type U using the TryFrom trait. This is useful for fallible conversions. ```rust fn try_into(self) -> Result>::Error> ``` -------------------------------- ### TryFrom Trait - try_into Method Source: https://docs.rs/dac8568/0.0.12/dac8568/struct.Dac.html The `try_into` method attempts to convert a value into another type, returning a `Result` to indicate success or failure. ```APIDOC ## fn try_into(self) -> Result>::Error> ### Description Performs the conversion. This method attempts to convert the current value (`self`) into a target type `U`. The conversion might fail, in which case an error is returned. The specific error type is determined by the `TryFrom` trait implementation for the target type `U`. ### Method Implicitly called via the `TryInto` trait, which is automatically implemented when `TryFrom` is implemented. ### Endpoint N/A (This is a trait method, not a network endpoint) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example ```rust let value: i32 = 10; let result: Result = value.try_into(); // Attempt to convert i32 to u8 match result { Ok(converted_value) => println!("Successfully converted to u8: {}", converted_value), Err(e) => println!("Conversion failed: {}", e), } ``` ### Response #### Success Response (Ok) - **U** (type) - The successfully converted value of type `U`. #### Error Response (Err) - **>::Error** (type) - The error that occurred during the conversion. The specific type depends on the `TryFrom` implementation. #### Response Example ```json { "Ok": 10 // Example of a successful conversion } ``` ```json { "Err": "value out of range" // Example of a failed conversion } ``` ``` -------------------------------- ### DAC8568 Output Inversion Source: https://docs.rs/dac8568/0.0.12/dac8568/struct.Dac.html Method to control the output signal inversion of the DAC. ```APIDOC ## Dac::set_inverted_output ### Description Sets the output signal of the DAC to be inverted or non-inverted (default). Useful if the hardware engineer has designed an inverting gain stage after the DAC output. ### Method `set_inverted_output` ### Parameters - **state** (bool) - `true` to invert the output, `false` for non-inverted output. ### Request Example ```rust dac.set_inverted_output(true); ``` ``` -------------------------------- ### DacError Trait Implementations Source: https://docs.rs/dac8568/0.0.12/dac8568/enum.DacError.html Details on the trait implementations for the DacError enum, including Clone, Debug, Copy, and blanket implementations. ```APIDOC ## Trait Implementations ### impl Clone for DacError #### fn clone(&self) -> DacError Returns a duplicate of the value. #### fn clone_from(&mut self, source: &Self) Performs copy-assignment from `source`. ### impl Debug for DacError #### fn fmt(&self, f: &mut Formatter<'_>) -> Result Formats the value using the given formatter. ### impl Copy for DacError ### Auto Trait Implementations ### impl Freeze for DacError ### impl RefUnwindSafe for DacError ### impl Send for DacError ### impl Sync for DacError ### impl Unpin for DacError ### impl UnwindSafe for DacError ### Blanket Implementations ### impl Any for T #### fn type_id(&self) -> TypeId Gets the `TypeId` of `self`. ### impl Borrow for T #### fn borrow(&self) -> &T Immutably borrows from an owned value. ### impl BorrowMut for T #### fn borrow_mut(&mut self) -> &mut T Mutably borrows from an owned value. ### impl CloneToUninit for T #### unsafe fn clone_to_uninit(&self, dest: *mut u8) Performs copy-assignment from `self` to `dest`. ### impl From for T #### fn from(t: T) -> T Returns the argument unchanged. ### impl Into for T #### fn into(self) -> U Calls `U::from(self)`. ### impl TryFrom for T #### type Error = Infallible #### fn try_from(value: U) -> Result>::Error> Performs the conversion. ### impl TryInto for T #### type Error = >::Error #### fn try_into(self) -> Result>::Error> Performs the conversion. ``` -------------------------------- ### Message Struct Details Source: https://docs.rs/dac8568/0.0.12/dac8568/index.html Details about the Message struct, which represents data transmitted to the DAC. ```APIDOC ## Struct Message The Message that is eventually serialized and transmitted to the DAC. The input shift register (SR) of the DAC7568, DAC8168, and DAC8568 is 32 bits wide, and consists of four Prefix bits (DB31 to DB28), four control bits (DB27 to DB24), 16 databits (DB23 to DB4), and four additional feature bits. The 16 databits comprise the 16-, 14-, or 12-bit input code. ``` -------------------------------- ### Format Channel for Debug Source: https://docs.rs/dac8568/0.0.12/dac8568/enum.Channel.html Implements the Debug trait for the Channel enum, providing a way to format the enum for debugging purposes. This is crucial for inspecting enum values. ```rust fn fmt(&self, f: &mut Formatter<'_>) -> Result ``` -------------------------------- ### DAC8568 Blocking Operations Source: https://docs.rs/dac8568/0.0.12/dac8568/struct.Dac.html Blocking (synchronous) methods for controlling the DAC8568, including setting voltage, configuring internal/external references, and resetting the device. ```APIDOC ## Dac::set_voltage (Blocking) ### Description Set the specified value to the given channel. This will update the DAC to output the desired voltage. ### Method `set_voltage` ### Parameters - **channel** (Channel) - The DAC channel to set. - **voltage** (u16) - The desired voltage value. ### Request Example ```rust let result = dac.set_voltage(Channel::Ch1, 4095); ``` ### Response #### Success Response (Result<(), DacError>) - **Ok**: Operation successful. - **Err**: An error occurred during the operation. ## Dac::use_internal_reference (Blocking) ### Description Configure the DAC to use its internal reference mode of 2.5v rather than using an external voltage reference. ### Method `use_internal_reference` ### Parameters None ### Request Example ```rust let result = dac.use_internal_reference(); ``` ### Response #### Success Response (Result<(), DacError>) - **Ok**: Operation successful. - **Err**: An error occurred during the operation. ## Dac::use_external_reference (Blocking) ### Description Configure the DAC to use its external reference mode rather than using the internal reference. ### Method `use_external_reference` ### Parameters None ### Request Example ```rust let result = dac.use_external_reference(); ``` ### Response #### Success Response (Result<(), DacError>) - **Ok**: Operation successful. - **Err**: An error occurred during the operation. ## Dac::reset (Blocking) ### Description Perform a software reset, clearing out all registers. This resets all DAC channels to their power-on default settings. ### Method `reset` ### Parameters None ### Request Example ```rust let result = dac.reset(); ``` ### Response #### Success Response (Result<(), DacError>) - **Ok**: Operation successful. - **Err**: An error occurred during the operation. ``` -------------------------------- ### Clone Channel Source: https://docs.rs/dac8568/0.0.12/dac8568/enum.Channel.html Implements the Clone trait for the Channel enum, allowing instances to be duplicated. This is a standard trait for types that can be copied. ```rust fn clone(&self) -> Channel ``` -------------------------------- ### Struct: dac8568::mode::Blocking Source: https://docs.rs/dac8568/0.0.12/dac8568/mode/struct.Blocking.html The Blocking struct represents the blocking implementation mode for the dac8568 device driver. ```APIDOC ## Struct: dac8568::mode::Blocking ### Description A struct representing the blocking implementation mode for the dac8568 crate. ### Definition ```rust pub struct Blocking; ``` ### Auto Trait Implementations - Freeze - RefUnwindSafe - Send - Sync - Unpin - UnwindSafe ``` -------------------------------- ### Retrieve message payload Source: https://docs.rs/dac8568/0.0.12/dac8568/struct.Message.html Methods to extract the serialized 32-bit payload from a Message instance. ```rust pub fn get_payload_word(&self) -> u32 ``` ```rust pub fn get_payload_bytes(&self) -> [u8; 4] ``` -------------------------------- ### Define Message struct Source: https://docs.rs/dac8568/0.0.12/dac8568/struct.Message.html The internal structure of the Message type used for DAC communication. ```rust pub struct Message { /* private fields */ } ``` -------------------------------- ### Define Channel Enum Source: https://docs.rs/dac8568/0.0.12/dac8568/enum.Channel.html Defines an enum for communication channels, including broadcast and no message options. Each variant is associated with a u8 index. ```rust pub enum Channel { A = 0, B = 1, C = 2, D = 3, E = 4, F = 5, G = 6, H = 7, NOMSG = 8, BROADCAST = 9, } ``` -------------------------------- ### Message Payload Retrieval Source: https://docs.rs/dac8568/0.0.12/dac8568/struct.Message.html Methods to retrieve the serialized representation of the constructed message. ```APIDOC ## get_payload_word ### Description Returns the full 32-bit message payload as a u32 integer. ## get_payload_bytes ### Description Returns the message payload as a 4-byte array ([u8; 4]). ``` -------------------------------- ### Type ID for Any Source: https://docs.rs/dac8568/0.0.12/dac8568/enum.Channel.html Implements the `type_id` method for any type T, returning its unique TypeId. This is part of the Any trait, used for runtime type identification. ```rust fn type_id(&self) -> TypeId ``` -------------------------------- ### Define Blocking struct Source: https://docs.rs/dac8568/0.0.12/dac8568/mode/struct.Blocking.html The definition of the Blocking struct used for blocking mode operations. ```rust pub struct Blocking; ``` -------------------------------- ### Borrow Mutably Source: https://docs.rs/dac8568/0.0.12/dac8568/enum.Channel.html Implements the `borrow_mut` method for any type T, providing mutable access to the value. This is part of the BorrowMut trait, enabling exclusive references. ```rust fn borrow_mut(&mut self) -> &mut T ``` -------------------------------- ### Borrow Value Source: https://docs.rs/dac8568/0.0.12/dac8568/enum.Channel.html Implements the `borrow` method for any type T, providing immutable access to the value. This is part of the Borrow trait, enabling shared references. ```rust fn borrow(&self) -> &T ``` -------------------------------- ### DacError Enum Source: https://docs.rs/dac8568/0.0.12/dac8568/enum.DacError.html The DacError enum represents errors that can occur during DAC operations. It is marked as non-exhaustive. ```APIDOC ## Enum DacError ### Description DAC Related errors ### Variants (Non-exhaustive) This enum is marked as non-exhaustive. Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants. #### BusWriteError Unable to write to bus ``` -------------------------------- ### Channel Enum Source: https://docs.rs/dac8568/0.0.12/dac8568/enum.Channel.html The Channel enum represents different communication channels, including specific channels (A-H), a 'no message' state, and a broadcast option. ```APIDOC ## Enum Channel ### Summary ```rust pub enum Channel { A = 0, B = 1, C = 2, D = 3, E = 4, F = 5, G = 6, H = 7, NOMSG = 8, BROADCAST = 9, } ``` ### Variants * **A = 0**: Channel A * **B = 1**: Channel B * **C = 2**: Channel C * **D = 3**: Channel D * **E = 4**: Channel E * **F = 5**: Channel F * **G = 6**: Channel G * **H = 7**: Channel H * **NOMSG = 8**: No message * **BROADCAST = 9**: Broadcast (all channels) ``` -------------------------------- ### Define ControlType Enum Source: https://docs.rs/dac8568/0.0.12/dac8568/enum.ControlType.html The ControlType enum specifies the command type for DAC communication. ```rust pub enum ControlType { WriteToInputRegister = 0, UpdateRegister = 1, WriteToChannelAndUpdateAllRegisters = 2, WriteToChannelAndUpdateSingleRegister = 3, PowerDownComm = 4, WriteToClearCodeRegister = 5, WriteToLDACRegister = 6, SoftwareReset = 7, } ``` -------------------------------- ### ControlType Enum Source: https://docs.rs/dac8568/0.0.12/dac8568/enum.ControlType.html The ControlType enum defines various control messages for interacting with registers and communication channels. ```APIDOC ## Enum ControlType ### Description The message control type. ### Variants * **WriteToInputRegister** = 0 Write to input register [Untested] * **UpdateRegister** = 1 Update register [Untested] * **WriteToChannelAndUpdateAllRegisters** = 2 Write to channel and update all registers [Untested] * **WriteToChannelAndUpdateSingleRegister** = 3 Write to channel and update single register * **PowerDownComm** = 4 Power down [Untested] * **WriteToClearCodeRegister** = 5 Write to clear code register [Untested] * **WriteToLDACRegister** = 6 Write to LDAC register [Untested] * **SoftwareReset** = 7 Software reset [Untested] ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.