Maxim Integrated MAX5171 14-bit Force/Sense DAC
Dependents: MAX5171BOB_Tester MAX5171BOB_14bit_Remote_Sense_SPI_DAC MAX5171BOB_Serial_Tester
Diff: MAX5171.h
- Revision:
- 4:1984eef51fe3
- Parent:
- 2:d1340b334b0d
- Child:
- 5:e8c0dfaeb53b
--- a/MAX5171.h Fri Jun 21 08:17:41 2019 +0000 +++ b/MAX5171.h Wed Oct 30 15:43:40 2019 -0700 @@ -40,6 +40,7 @@ // System Description = Device driver example // Device Name = MAX5171 // Device Description = Low-Power, Serial, 14-Bit, 1-Channel DACs with Force/Sense Voltage Output and SPI Interface +// Device DeviceBriefDescription = 14-bit Force/Sense DAC // Device Manufacturer = Maxim Integrated // Device PartNumber = MAX5171AEEE+ // Device RegValue_Width = DataWidth16bit_HL @@ -62,10 +63,42 @@ #ifndef __MAX5171_H__ #define __MAX5171_H__ +// 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 MAX5171 Low-Power, Serial, 14-Bit, 1-Channel DACs with Force/Sense Voltage Output and SPI Interface * @@ -75,12 +108,43 @@ * * * - * //---------- CODE GENERATOR: helloCppCodeList * @code - * // CODE GENERATOR: example code includes * // example code includes + * // 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 "MAX5171.h" * * // example code board support @@ -139,38 +203,33 @@ * { * while (1) * { - * // CODE GENERATOR: example code: member function Init * g_MAX5171_device.Init(); * - * // CODE GENERATOR: example code: has no member function REF - * // CODE GENERATOR: example code: member function CODE_LOAD - * // - * uint16_t code = 0xccc; - * g_MAX5171_device.CODE_LOAD(code); - * // - * code = 0x800; + * uint16_t code; + * // + * // example #1 + * code = 0x3332; // 80.0% of full scale REF(2.50V) = 2.00V * g_MAX5171_device.CODE_LOAD(code); * // - * code = 0x666; + * // example #2 + * code = 0x1fff; // 50.0% of full scale REF(2.50V) = 1.25V * g_MAX5171_device.CODE_LOAD(code); * // - * code = 0xFFF; + * // example #3 + * code = 0x1999; // 40.0% of full scale REF(2.50V) = 1.00V + * g_MAX5171_device.CODE_LOAD(code); + * // + * // example #4 + * code = 0x3fff; // 100.0% of full scale REF(2.50V) = 2.50V * g_MAX5171_device.CODE_LOAD(code); * - * // CODE GENERATOR: example code: has no member function CODEallLOADall - * // CODE GENERATOR: example code: has no member function CODEnLOADn - * // CODE GENERATOR: example code: has no member function ScanManual - * // CODE GENERATOR: example code: has no member function ReadAINcode - * wait(3.0); + * // wait(3.0); * } * } * @endcode - * //---------- CODE GENERATOR: end helloCppCodeList */ class MAX5171 { public: -// CODE GENERATOR: TypedefEnum EnumItem declarations -// CODE GENERATOR: TypedefEnum MAX5171_CMD_enum_t //---------------------------------------- /// Command Codes (first byte) /// @@ -189,7 +248,6 @@ CMD_1111_1xxx_xxxx_xxxx_MODE0_DOUT_SCLK_FALLING_EDGE = 0xf800, //!< 16'b1111100000000000 } MAX5171_CMD_enum_t; -// TODO1: CODE GENERATOR: ic_variant -- IC's supported with this driver /** * @brief IC's supported with this driver * @details MAX5171 @@ -200,7 +258,6 @@ //MAX5171_IC = 1 } MAX5171_ic_t; -// TODO1: CODE GENERATOR: class constructor declaration /**********************************************************//** * @brief Constructor for MAX5171 Class. * @@ -210,12 +267,10 @@ * 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] RS_pin - pointer to a DigitalOut pin object * @param[in] PDLb_pin - pointer to a DigitalOut pin object * @param[in] CLRb_pin - pointer to a DigitalOut pin object * @param[in] SHDN_pin - pointer to a DigitalOut pin object - * CODE GENERATOR: class constructor docstrings gpio OutputPin pins * @param[in] UPO_pin - pointer to a DigitalIn pin object * @param[in] ic_variant - which type of MAX5171 is used * @@ -224,18 +279,15 @@ * @return None **************************************************************/ MAX5171(SPI &spi, DigitalOut &cs_pin, // SPI interface - // CODE GENERATOR: class constructor declaration gpio InputPin pins // AnalogOut &FB_pin, // Analog Input to MAX5171 device DigitalOut &RS_pin, // Digital Configuration Input to MAX5171 device DigitalOut &PDLb_pin, // Digital Configuration Input to MAX5171 device DigitalOut &CLRb_pin, // Digital Configuration Input to MAX5171 device DigitalOut &SHDN_pin, // Digital Configuration Input to MAX5171 device - // CODE GENERATOR: class constructor declaration gpio OutputPin pins // AnalogIn &OUT_pin, // Analog Output from MAX5171 device DigitalIn &UPO_pin, // Digital General-Purpose Output from MAX5171 device MAX5171_ic_t ic_variant); -// CODE GENERATOR: class destructor declaration /************************************************************ * @brief Default destructor for MAX5171 Class. * @@ -249,40 +301,35 @@ **************************************************************/ ~MAX5171(); - // 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 MAX5171_device_t, class members instead of global device object public: /// reference voltage, in Volts double VRef; - /// shadow of write-only dacCodeLsbs field CMD_00dd_dddd_dddd_dddd_CODE or CMD_01dd_dddd_dddd_dddd_CODE_LOAD + /// shadow of dacCodeLsbs; write-only dacCodeLsbs field CMD_00dd_dddd_dddd_dddd_CODE or CMD_01dd_dddd_dddd_dddd_CODE_LOAD int16_t DACCode; -// CODE GENERATOR: omit global g_MAX5171_device -// CODE GENERATOR: extern function declarations -// CODE GENERATOR: extern function declaration SPIoutputCS //---------------------------------------- // Assert SPI Chip Select // SPI chip-select for MAX5171 // void SPIoutputCS(int isLogicHigh); -// CODE GENERATOR: extern function declaration SPIwrite16bits //---------------------------------------- // SPI write 16 bits // SPI interface to MAX5171 shift 16 bits mosiData into MAX5171 DIN // void SPIwrite16bits(int16_t mosiData16); -// CODE GENERATOR: class member data private: -// CODE GENERATOR: class member data for SPI interface // SPI object SPI &m_spi; int m_SPI_SCLK_Hz; @@ -292,7 +339,6 @@ // Selector pin object DigitalOut &m_cs_pin; -// CODE GENERATOR: class member data for gpio InputPin pins // InputPin Name = FB // InputPin Description = Feedback Input // InputPin Function = Analog @@ -319,7 +365,6 @@ // InputPin Function = Configuration DigitalOut &m_SHDN_pin; // -// CODE GENERATOR: class member data for gpio OutputPin pins // OutputPin Name = OUT // OutputPin Description = Analog Voltage Output. High impedance in shutdown. Output voltage is limited to VDD. // OutputPin Function = Analog @@ -336,8 +381,8 @@ public: -// CODE GENERATOR: class member function declarations //---------------------------------------- + /// Menu item '!' /// Initialize device /// @return 1 on success; 0 on failure uint8_t Init(void); @@ -413,14 +458,14 @@ //---------------------------------------- /// CMD_1111_0xxx_xxxx_xxxx_MODE1_DOUT_SCLK_RISING_EDGE /// - /// Mode 1, DOUT clocked out on SCLK’s rising edge. + /// Mode 1, DOUT clocked out on SCLK's rising edge. /// @return 1 on success; 0 on failure uint8_t MODE1_DOUT_SCLK_RISING_EDGE(void); //---------------------------------------- /// CMD_1111_1xxx_xxxx_xxxx_MODE0_DOUT_SCLK_FALLING_EDGE /// - /// Mode 0, DOUT clocked out on SCLK’s falling edge (default). + /// Mode 0, DOUT clocked out on SCLK's falling edge (default). /// @return 1 on success; 0 on failure uint8_t MODE0_DOUT_SCLK_FALLING_EDGE(void);