Maxim Integrated 16-Bit, Unbuffered Output Voltage DAC. Driver/library for MAX541

Dependents:   MAX541_Hello_DAC_on_MAX32625MBED MAX5715BOB_Tester MAX11131BOB_Tester MAX5171BOB_Tester ... more

Revision:
2:609e1e5c4d51
Parent:
1:3908aba2ea77
Child:
3:016c812266e7
--- a/MAX541.h	Thu May 09 01:18:42 2019 +0000
+++ b/MAX541.h	Thu May 09 06:19:44 2019 +0000
@@ -1,5 +1,4 @@
 /*******************************************************************************
-* @file MAX541.h
 * Copyright (C) 2019 Maxim Integrated Products, Inc., All Rights Reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
@@ -31,22 +30,39 @@
 * ownership rights.
 *******************************************************************************
 */
+// *********************************************************************
+// @file MAX541.h
+// *********************************************************************
 
+// Prevent multiple declaration
 #ifndef MAX541_H
 #define MAX541_H
 
 #include "mbed.h"
 
-/** @brief MAX541 Ultra-Small, 12-Bit, 4-Channel, Buffered Output Voltage DAC with Internal Reference and SPI Interface
+/**
+* @brief MAX541 Ultra-Small, 12-Bit, 4-Channel, Buffered Output Voltage DAC with Internal Reference and SPI Interface
+ *
  * @version 1.0000.0
  *
  * @details The MAX541 is an SPI programmable voltage DAC.
  * This driver enables writing of voltage ouptut values to the output register.
  *
+ * Datasheet: https://www.maximintegrated.com/MAX541
+ *
  * @code
  * #include "mbed.h"
  * #include "MAX541.h"
  *
+ * // Connect MAX541 to Arduino compatible connector as shown:
+ * //                  MAX541BCPA+
+ * //              --------__--------
+ * //     output --| 1 OUT    VDD 8 |-- IOREF (3V3 or 5V logic supply)
+ * //        GND --| 2 AGND  DGND 7 |-- GND
+ * //       V3.3 --| 3 REF    DIN 6 |-- D11/SPI_MOSI
+ * // D10/SPI_SS --| 4 CS    SCLK 5 |-- D13/SPI_SCLK
+ * //              ------------------
+ *
  * // example code declare SPI interface
  * #if defined(TARGET_MAX32625MBED)
  * SPI spi_max541(SPI1_MOSI, SPI1_MISO, SPI1_SCK); // mosi, miso, sclk spi1 TARGET_MAX32625MBED: P1_1 P1_2 P1_0 Arduino 10-pin header D11 D12 D13
@@ -55,11 +71,11 @@
  * // SPI spi2_max541(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi2 TARGET_MAX32625MBED: P2_5 P2_6 P2_4 Arduino 2x3-pin header; microSD
  * // DigitalOut spi2_max541_cs(SPI2_SS); // TARGET_MAX32625MBED: P2_7 Arduino 2x3-pin header
  * #elif defined(TARGET_MAX32600MBED)
- * SPI spi_max541(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi1 TARGET_MAX32600MBED: Arduino 10-pin header D11 D12 D13
- * DigitalOut spi_max541_cs(SPI2_SS); // Generic: Arduino 10-pin header D10
+ * SPI spi_max541(SPI2_MOSI, SPI2_MISO, SPI2_SCK);
+ * DigitalOut spi_max541_cs(SPI2_SS);
  * #else
- * SPI spi_max541(D11, D12, D13); // mosi, miso, sclk spi1 TARGET_MAX32600MBED: Arduino 10-pin header D11 D12 D13
- * DigitalOut spi_max541_cs(D10); // Generic: Arduino 10-pin header D10
+ * SPI spi_max541(D11, D12, D13); // Arduino 10-pin header
+ * DigitalOut spi_max541_cs(D10); // Arduino 10-pin header
  * #endif
  *
  * int main()
@@ -78,7 +94,7 @@
 {
 public:
 
-    /**********************************************************
+    /** ********************************************************
      * @brief Constructor for MAX541 Class.
      *
      * @details Allows user to use existing SPI object
@@ -90,95 +106,74 @@
      * On Exit:
      *
      * @return None
-     **************************************************************/
+     */
     MAX541(SPI &spi, DigitalOut &cs_pin);
 
-    /**********************************************************
-     * @brief more documentation
+    /** ********************************************************
+     * @brief Default destructor for MAX541 Class.
+     *
+     * @details Destroys SPI object if owner
      *
-     * @details more documentation
+     * On Entry:
      *
-     **************************************************************/
+     * On Exit:
+     *
+     * @return None
+     */
     ~MAX541();
 
 private:
-    /**********************************************************
-     * @brief SPI object
-     *
-     * @details more documentation
-     *
-     **************************************************************/
+    /** SPI object */
     SPI &m_spi;
     int m_SPI_SCLK_Hz;
     int m_SPI_dataMode;
 
-    /**********************************************************
-     * @brief Selector pin object
-     *
-     * @details more documentation
-     *
-     **************************************************************/
+    /** Selector pin object */
     DigitalOut &m_cs_pin;
 
 public:
-    /**********************************************************
-     * @brief more documentation
-     *
-     * @details more documentation
-     *
-     **************************************************************/
+    /** Reference voltage, in Volts.
+     * Default value is 3.3 unless otherwise specified.
+     * For best performance, an external 2.5V reference should be used.
+     */
     double VRef;
 
-    /**********************************************************
-     * @brief more documentation
-     *
-     * @details more documentation
-     *
-     **************************************************************/
+    /** Full-scale (maximum) raw DAC code, in LSBs.
+     */
     const float max541codeFS = (float)((uint32_t)0xffff);
 
-    /**********************************************************
-     * @brief more documentation
+    /** Raw DAC code, in LSBs.
      *
-     * @details more documentation
+     * The DAC output voltage is a function of raw DAC code:
+     * VOUT = VREF * (code / 65536)
      *
-     **************************************************************/
+     * The full-scale voltage is VREF * 65535 / 65536.
+     */
     uint16_t max541_code;
 
-
-    /**********************************************************
-     * @brief set the MAX541 output voltage
+    /** Set the MAX541 output voltage.
      *
-     * @details more documentation
-     *
-     **************************************************************/
+     * @pre VRef = Full-Scale reference voltage, in Volts
+     * @param[in] voltageV = output voltage, in Volts
+     */
     void Set_Voltage(double voltageV);
 
-
-    /**********************************************************
-     * @brief get the MAX541 output voltage
+    /** Get the MAX541 output voltage.
      *
-     * @details more documentation
-     *
-     **************************************************************/
+     * @returns output voltage, in Volts
+     */
     double Get_Voltage() const;
 
-
-    /**********************************************************
-     * @brief set the MAX541 output code
+    /** Set the MAX541 output code.
      *
-     * @details more documentation
-     *
-     **************************************************************/
+     * @param[in] max541_mosiData16 = raw DAC code, in LSBs
+     */
     void Set_Code(int16_t max541_mosiData16);
 
-
-    /**********************************************************
-     * @brief get the MAX541 output code
+    /** Get the MAX541 output code.
      *
-     * @details more documentation
-     *
-     **************************************************************/
+     * @returns raw DAC code, in LSBs
+     */
     uint16_t Get_Code(void) const;
 
 };