Maxim Integrated MAX5715 12-bit 4-channel voltage-output DAC

Dependents:   MAX5715BOB_Tester MAX5715BOB_12bit_4ch_SPI_DAC MAX5715BOB_Serial_Tester

Revision:
5:7894decf9375
Parent:
4:500c80398f90
Child:
7:3c45adf3efe8
--- a/MAX5715.h	Wed Aug 28 03:21:35 2019 -0700
+++ b/MAX5715.h	Fri Sep 27 10:35:15 2019 +0000
@@ -40,6 +40,7 @@
 // System Description = Device driver example
 // Device Name = MAX5715
 // Device Description = Ultra-Small, 12-Bit, 4-Channel, Buffered Output Voltage DAC with Internal Reference and SPI Interface
+// Device DeviceBriefDescription = 12-bit 4-ch SPI VOUT DAC
 // Device Manufacturer = Maxim Integrated
 // Device PartNumber = MAX5715AAUD+
 // Device RegValue_Width = DataWidth16bit_HL
@@ -62,11 +63,42 @@
 #ifndef __MAX5715_H__
 #define __MAX5715_H__
 
-// standard include for target platform
+// standard include for target platform -- Platform_Include_Boilerplate
 #include "mbed.h"
+// Platforms:
+//   - MAX32625MBED
+//      - supports mbed-os-5.11, requires USBDevice library
+//      - add https://developer.mbed.org/teams/MaximIntegrated/code/USBDevice/
+//      - remove max32630fthr library (if present)
+//      - remove MAX32620FTHR library (if present)
+//   - MAX32600MBED
+//      - remove max32630fthr library (if present)
+//      - remove MAX32620FTHR library (if present)
+//      - Windows 10 note:  Don't connect HDK until you are ready to load new firmware into the board.
+//   - NUCLEO_F446RE
+//      - remove USBDevice library
+//      - remove max32630fthr library (if present)
+//      - remove MAX32620FTHR library (if present)
+//   - NUCLEO_F401RE
+//      - remove USBDevice library
+//      - remove max32630fthr library (if present)
+//      - remove MAX32620FTHR library (if present)
+//   - MAX32630FTHR
+//      - #include "max32630fthr.h"
+//      - add http://os.mbed.org/teams/MaximIntegrated/code/max32630fthr/
+//      - remove MAX32620FTHR library (if present)
+//   - MAX32620FTHR
+//      - #include "MAX32620FTHR.h"
+//      - remove max32630fthr library (if present)
+//      - add https://os.mbed.com/teams/MaximIntegrated/code/MAX32620FTHR/
+//      - not tested yet
+//   - MAX32625PICO
+//      - remove max32630fthr library (if present)
+//      - remove MAX32620FTHR library (if present)
+//      - not tested yet
+//
+// end Platform_Include_Boilerplate
 
-// CODE GENERATOR: conditional defines
-// CODE GENERATOR: class declaration and docstrings
 /**
  * @brief MAX5715 Ultra-Small, 12-Bit, 4-Channel, Buffered Output Voltage DAC with Internal Reference and SPI Interface
  *
@@ -76,13 +108,43 @@
  *
  *
  *
- * //---------- CODE GENERATOR: helloCppCodeList
  * @code
- * // CODE GENERATOR: example code includes
  * // example code includes
- * // standard include for target platform
+ * // standard include for target platform -- Platform_Include_Boilerplate
  * #include "mbed.h"
- * //#include "max32625.h"
+ * // Platforms:
+ * //   - MAX32625MBED
+ * //      - supports mbed-os-5.11, requires USBDevice library
+ * //      - add https://developer.mbed.org/teams/MaximIntegrated/code/USBDevice/
+ * //      - remove max32630fthr library (if present)
+ * //      - remove MAX32620FTHR library (if present)
+ * //   - MAX32600MBED
+ * //      - remove max32630fthr library (if present)
+ * //      - remove MAX32620FTHR library (if present)
+ * //      - Windows 10 note:  Don't connect HDK until you are ready to load new firmware into the board.
+ * //   - NUCLEO_F446RE
+ * //      - remove USBDevice library
+ * //      - remove max32630fthr library (if present)
+ * //      - remove MAX32620FTHR library (if present)
+ * //   - NUCLEO_F401RE
+ * //      - remove USBDevice library
+ * //      - remove max32630fthr library (if present)
+ * //      - remove MAX32620FTHR library (if present)
+ * //   - MAX32630FTHR
+ * //      - #include "max32630fthr.h"
+ * //      - add http://os.mbed.org/teams/MaximIntegrated/code/max32630fthr/
+ * //      - remove MAX32620FTHR library (if present)
+ * //   - MAX32620FTHR
+ * //      - #include "MAX32620FTHR.h"
+ * //      - remove max32630fthr library (if present)
+ * //      - add https://os.mbed.com/teams/MaximIntegrated/code/MAX32620FTHR/
+ * //      - not tested yet
+ * //   - MAX32625PICO
+ * //      - remove max32630fthr library (if present)
+ * //      - remove MAX32620FTHR library (if present)
+ * //      - not tested yet
+ * //
+ * // end Platform_Include_Boilerplate
  * #include "MAX5715.h"
  *
  * // example code board support
@@ -142,51 +204,36 @@
  * {
  *     while (1)
  *     {
- *         // CODE GENERATOR: example code: member function Init
  *         g_MAX5715_device.Init();
  *
- *         // CODE GENERATOR: example code: member function REF
- *         // CODE GENERATOR: example code: device has enumType 'MAX5715_REF_enum_t'
- *         // CODE GENERATOR: TypedefEnum_MAXxxxxx_REF_enum_t_NamesList: REF_EXT, REF_2V500, REF_2V048, REF_4V096, REF_AlwaysOn_EXT, REF_AlwaysOn_2V500, REF_AlwaysOn_2V048, REF_AlwaysOn_4V096
  *         g_MAX5715_device.REF(MAX5715::REF_AlwaysOn_2V500);
  *
- *         // CODE GENERATOR: example code: has no member function CODE_LOAD
- *         // CODE GENERATOR: example code: member function CODEallLOADall
- *         //uint16_t code = 4095;
- *         //g_MAX5715_device.CODEallLOADall(code);
- *
- *         // CODE GENERATOR: example code: member function CODEnLOADn
- *         uint16_t ch;
- *         uint16_t code;
+ *         uint16_t ch;
+ *         uint16_t code;
  *         //
- *         ch = 0;
- *         code = 0x0ccc; // 80.0% 2.00V (REF=2.50V)
+ *         ch = 0;
+ *         code = 0x0ccc; // 80.0% of full scale REF(2.50V) = 2.00V
  *         g_MAX5715_device.CODEnLOADn(ch, code);
  *         //
  *         ch = 1;
- *         code = 0x07ff; // 50.0% 1.25V (REF=2.50V)
+ *         code = 0x07ff; // 50.0% of full scale REF(2.50V) = 1.25V
  *         g_MAX5715_device.CODEnLOADn(ch, code);
  *         //
  *         ch = 2;
- *         code = 0x0666; // 40.0% 1.00V (REF=2.50V)
+ *         code = 0x0666; // 40.0% of full scale REF(2.50V) = 1.00V
  *         g_MAX5715_device.CODEnLOADn(ch, code);
  *         //
  *         ch = 3;
- *         code = 0x0fff; // 100.0% 2.50V (REF=2.50V)
+ *         code = 0x0fff; // 100.0% of full scale REF(2.50V) = 2.50V
  *         g_MAX5715_device.CODEnLOADn(ch, code);
  *
- *         // CODE GENERATOR: example code: has no member function ScanManual
- *         // CODE GENERATOR: example code: has no member function ReadAINcode
  *         wait(3.0);
  *     }
  * }
  * @endcode
- * //---------- CODE GENERATOR: end helloCppCodeList
  */
 class MAX5715 {
 public:
-// CODE GENERATOR: TypedefEnum EnumItem declarations
-// CODE GENERATOR: TypedefEnum MAX5715_CMD_enum_t
     //----------------------------------------
     /// Command Codes (first byte)
     ///
@@ -231,7 +278,6 @@
         CMD_1111_xxxx_NOP = 0xf0, //!< 8'b11110000
     } MAX5715_CMD_enum_t;
 
-// CODE GENERATOR: TypedefEnum MAX5715_POWER_enum_t
     //----------------------------------------
     /// Argument to POWER function
     typedef enum MAX5715_POWER_enum_t {
@@ -241,7 +287,6 @@
         POWERn_PDHiZ = 0x03, //!< 8'b00000011
     } MAX5715_POWER_enum_t;
 
-// CODE GENERATOR: TypedefEnum MAX5715_REF_enum_t
     //----------------------------------------
     /// Argument to REF function ( external? voltage? always on? )
     typedef enum MAX5715_REF_enum_t {
@@ -255,7 +300,6 @@
         REF_AlwaysOn_4V096 = 0x07, //!< 8'b00000111
     } MAX5715_REF_enum_t;
 
-// TODO1: CODE GENERATOR: ic_variant -- IC's supported with this driver
     /**
      * @brief IC's supported with this driver
      * @details MAX5715
@@ -266,7 +310,6 @@
         //MAX5715_IC = 1
     } MAX5715_ic_t;
 
-// TODO1: CODE GENERATOR: class constructor declaration
     /**********************************************************//**
     * @brief Constructor for MAX5715 Class.
     *
@@ -276,10 +319,8 @@
     * On Entry:
     *     @param[in] spi - pointer to existing SPI object
     *     @param[in] cs_pin - pointer to a DigitalOut pin object
-    *     CODE GENERATOR: class constructor docstrings gpio InputPin pins
     *     @param[in] LDACb_pin - pointer to a DigitalOut pin object
     *     @param[in] CLRb_pin - pointer to a DigitalOut pin object
-    *     CODE GENERATOR: class constructor docstrings gpio OutputPin pins
     *     @param[in] ic_variant - which type of MAX5715 is used
     *
     * On Exit:
@@ -287,19 +328,16 @@
     * @return None
     **************************************************************/
     MAX5715(SPI &spi, DigitalOut &cs_pin, // SPI interface
-            // CODE GENERATOR: class constructor declaration gpio InputPin pins
             DigitalOut &LDACb_pin, // Digital Trigger Input to MAX5715 device
             DigitalOut &CLRb_pin, // Digital Trigger Input to MAX5715 device
             // AnalogOut &REF_pin, // Reference Input to MAX5715 device
-            // CODE GENERATOR: class constructor declaration gpio OutputPin pins
             // AnalogIn &OUTA_pin, // Analog Output from MAX5715 device
             // AnalogIn &OUTB_pin, // Analog Output from MAX5715 device
             // AnalogIn &OUTC_pin, // Analog Output from MAX5715 device
             // AnalogIn &OUTD_pin, // Analog Output from MAX5715 device
-            // DigitalIn &RDYb_pin, // Digital DaisyChain Output from MAX5715 device
+            // DigitalIn &RDYb_pin, // Digital DaisyChain Output from MAX5715 device
             MAX5715_ic_t ic_variant);
 
-// CODE GENERATOR: class destructor declaration
     /************************************************************
      * @brief Default destructor for MAX5715 Class.
      *
@@ -313,18 +351,19 @@
      **************************************************************/
     ~MAX5715();
 
-    // CODE GENERATOR: spi_frequency setter declaration
-    /// set SPI SCLK frequency
+    /// Function pointer void f(size_t byteCount, uint8_t mosiData[], uint8_t misoData[])
+    Callback<void(size_t, uint8_t*, uint8_t*)> onSPIprint; //!< optional @ref onSPIprint SPI diagnostic function
+
+    /// set SPI SCLK frequency
     void spi_frequency(int spi_sclk_Hz);
 
 //----------------------------------------
-// CODE GENERATOR: omit typedef enum MAX5715_device_t, class members instead of global device object
 public:
 
     /// reference voltage, in Volts
     double VRef;
 
-    /// DAC Selection: 0=OUTA, 1=OUTB, 2=OUTC, 3=OUTD, 4..15=ALL OUTA,OUTB,OUTC,OUTD; shadow of channel_0_3
+    /// DAC Selection: 0=OUTA, 1=OUTB, 2=OUTC, 3=OUTD, 4..15=ALL OUTA,OUTB,OUTC,OUTD; shadow of channel_0_3
     uint8_t channelNumber_0_3;
 
     /// channel bitmask channel_dcba: 1=OUTA, 2=OUTB, 4=OUTC, 8=OUTD
@@ -342,41 +381,33 @@
     /// shadow of write-only register REF CMD_0111_0rrr
     int16_t Shadow_0111_0rrr_REF;
 
-    /// shadow of dacCodeLsbs; CODE field of write-only register CODE[channel_0_3] CMD_0010_nnnn
+    /// shadow of dacCodeLsbs; CODE field of write-only register CODE[channel_0_3] CMD_0010_nnnn
     int16_t CODE[4];
 
-// CODE GENERATOR: omit global g_MAX5715_device
 
-// CODE GENERATOR: extern function declarations
-// CODE GENERATOR: extern function declaration SPIoutputCS
 //----------------------------------------
 // Assert SPI Chip Select
 // SPI chip-select for MAX5715
 //
     void SPIoutputCS(int isLogicHigh);
 
-// CODE GENERATOR: extern function declaration SPIwrite24bits
 //----------------------------------------
 // SPI write 24 bits
 // SPI interface to MAX5715 shift 24 bits mosiData into MAX5715 DIN
 //
     void SPIwrite24bits(int8_t mosiData8_FF0000, int16_t mosiData16_00FFFF);
 
-// CODE GENERATOR: extern function declaration LDACboutputValue
 //----------------------------------------
 // Assert MAX5715 LDAC pin : High = inactive, Low = load DAC.
 //
     void LDACboutputValue(int isLogicHigh);
 
-// CODE GENERATOR: extern function declaration CLRboutputValue
 //----------------------------------------
 // Assert MAX5715 CLR pin : High = inactive, Low = clear DAC.
 //
     void CLRboutputValue(int isLogicHigh);
 
-// CODE GENERATOR: class member data
 private:
-// CODE GENERATOR: class member data for SPI interface
     // SPI object
     SPI &m_spi;
     int m_SPI_SCLK_Hz;
@@ -386,7 +417,6 @@
     // Selector pin object
     DigitalOut &m_cs_pin;
 
-// CODE GENERATOR: class member data for gpio InputPin pins
 // InputPin Name = LDAC#
 // InputPin Description = Dedicated Active-Low Asynchronous Load DAC.
 // InputPin Function = Trigger
@@ -404,7 +434,6 @@
 // InputPin Function = Reference
     // AnalogOut &m_REF_pin;
 //
-// CODE GENERATOR: class member data for gpio OutputPin pins
 // OutputPin Name = OUTA
 // OutputPin Description = Buffered Channel A DAC Output
 // OutputPin Function = Analog
@@ -436,8 +465,8 @@
 
 public:
 
-// CODE GENERATOR: class member function declarations
     //----------------------------------------
+    /// Menu item '!'
     /// Initialize device
     /// @return 1 on success; 0 on failure
     uint8_t Init(void);
@@ -564,9 +593,9 @@
 
     //----------------------------------------
     /// CMD_0100_0000_0000_dcba_0000_0000_POWERn_Normal
-    /// CMD_0100_0001_0000_dcba_0000_0000_POWERn_PD1k
-    /// CMD_0100_0010_0000_dcba_0000_0000_POWERn_PD100k
-    /// CMD_0100_0011_0000_dcba_0000_0000_POWERn_PDHiZ
+    /// CMD_0100_0001_0000_dcba_0000_0000_POWERn_PD1k
+    /// CMD_0100_0010_0000_dcba_0000_0000_POWERn_PD100k
+    /// CMD_0100_0011_0000_dcba_0000_0000_POWERn_PDHiZ
     ///
     /// Sets the power mode of the selected DACs
     /// (DACs selected with a 1 in the corresponding DACn bit are updated,
@@ -593,7 +622,7 @@
     /// Sets the reference operating mode.
     /// REF Power (B18): 0 = Internal reference is only powered if at least one DAC is powered
     /// 1 = Internal reference is always powered
-    void REF(MAX5715_REF_enum_t ref);
+    void REF(MAX5715_REF_enum_t ref);
 
     //----------------------------------------
     /// CMD_0101_0000_0000_0000_0000_0000_SW_CLEAR