Maxim Integrated / Mbed OS MAX5171BOB_14bit_Remote_Sense_SPI_DAC

Dependencies:   MAX5171

Revision:
0:5da566e61083
Child:
1:8f712114baf7
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Jun 12 19:26:27 2019 +0000
@@ -0,0 +1,148 @@
+// /*******************************************************************************
+// * Copyright (C) 2019 Maxim Integrated Products, Inc., All Rights Reserved.
+// *
+// * Permission is hereby granted, free of charge, to any person obtaining a
+// * copy of this software and associated documentation files (the "Software"),
+// * to deal in the Software without restriction, including without limitation
+// * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// * and/or sell copies of the Software, and to permit persons to whom the
+// * Software is furnished to do so, subject to the following conditions:
+// *
+// * The above copyright notice and this permission notice shall be included
+// * in all copies or substantial portions of the Software.
+// *
+// * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+// * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
+// * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+// * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// * OTHER DEALINGS IN THE SOFTWARE.
+// *
+// * Except as contained in this notice, the name of Maxim Integrated
+// * Products, Inc. shall not be used except as stated in the Maxim Integrated
+// * Products, Inc. Branding Policy.
+// *
+// * The mere transfer of this software does not imply any licenses
+// * of trade secrets, proprietary technology, copyrights, patents,
+// * trademarks, maskwork rights, or any other form of intellectual
+// * property whatsoever. Maxim Integrated Products, Inc. retains all
+// * ownership rights.
+// *******************************************************************************
+// */
+//---------- CODE GENERATOR: testMainCppCodeList
+// CODE GENERATOR: example code includes
+// example code includes
+#include "mbed.h"
+//#include "max32625.h"
+#include "MAX5171.h"
+
+// optional: serial port
+// note: some platforms such as Nucleo-F446RE do not support the USBSerial library.
+// In those cases, remove the USBDevice lib from the project and rebuild.
+#if defined(TARGET_MAX32625MBED)
+#include "USBSerial.h"
+USBSerial serial; // virtual serial port over USB (DEV connector)
+#elif defined(TARGET_MAX32630MBED)
+#include "USBSerial.h"
+USBSerial serial; // virtual serial port over USB (DEV connector)
+#else
+//#include "USBSerial.h"
+Serial serial(USBTX, USBRX); // tx, rx
+#endif
+
+// example code board support
+//MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3);
+//DigitalOut rLED(LED1);
+//DigitalOut gLED(LED2);
+//DigitalOut bLED(LED3);
+//
+// Arduino "shield" connector port definitions (MAX32625MBED shown)
+#if defined(TARGET_MAX32625MBED)
+#define A0 AIN_0
+#define A1 AIN_1
+#define A2 AIN_2
+#define A3 AIN_3
+#define D0 P0_0
+#define D1 P0_1
+#define D2 P0_2
+#define D3 P0_3
+#define D4 P0_4
+#define D5 P0_5
+#define D6 P0_6
+#define D7 P0_7
+#define D8 P1_4
+#define D9 P1_5
+#define D10 P1_3
+#define D11 P1_1
+#define D12 P1_2
+#define D13 P1_0
+#endif
+
+// example code declare SPI interface
+#if defined(TARGET_MAX32625MBED)
+SPI spi(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
+DigitalOut spi_cs(SPI1_SS); // TARGET_MAX32625MBED: P1_3 Arduino 10-pin header D10
+#elif defined(TARGET_MAX32600MBED)
+SPI spi(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi1 TARGET_MAX32600MBED: Arduino 10-pin header D11 D12 D13
+DigitalOut spi_cs(SPI2_SS); // Generic: Arduino 10-pin header D10
+#else
+SPI spi(D11, D12, D13); // mosi, miso, sclk spi1 TARGET_MAX32600MBED: Arduino 10-pin header D11 D12 D13
+DigitalOut spi_cs(D10); // Generic: Arduino 10-pin header D10
+#endif
+
+// example code declare GPIO interface pins
+// AnalogOut FB_pin(Px_x_PortName_To_Be_Determined); // Analog Input to MAX5171 device
+DigitalOut RS_pin(D9); // Digital Configuration Input to MAX5171 device
+DigitalOut PDLb_pin(D8); // Digital Configuration Input to MAX5171 device
+DigitalOut CLRb_pin(D7); // Digital Configuration Input to MAX5171 device
+DigitalOut SHDN_pin(D6); // Digital Configuration Input to MAX5171 device
+// AnalogIn OUT_pin(A0); // Analog Output from MAX5171 device
+DigitalIn UPO_pin(D5); // Digital General-Purpose Output from MAX5171 device
+// example code declare device instance
+MAX5171 g_MAX5171_device(spi, spi_cs, RS_pin, PDLb_pin, CLRb_pin, SHDN_pin, UPO_pin, MAX5171::MAX5171_IC);
+
+// example code main function
+int main()
+{
+    while (1)
+    {
+        // example code: serial port banner message
+    #if defined(TARGET_MAX32625MBED)
+        serial.printf("MAX32625MBED ");
+    #elif defined(TARGET_MAX32600MBED)
+        serial.printf("MAX32600MBED ");
+    #elif defined(TARGET_NUCLEO_F446RE)
+        serial.printf("NUCLEO_F446RE ");
+    #endif
+        serial.printf("MAX5715BOB\r\n");
+
+        //MAX5171 dac(spi, spi_cs, MAX5171::MAX5171_IC);
+        //dac.Init();
+
+        // 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;
+        g_MAX5171_device.CODE_LOAD(code);
+        //
+        code = 0x666;
+        g_MAX5171_device.CODE_LOAD(code);
+        //
+        code = 0xFFF;
+        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);
+    }
+}
+//---------- CODE GENERATOR: end testMainCppCodeList