Example host software for the Maxim Integrated MAX5715 12-bit 4-channel voltage-output DAC. Hosted on the MAX32625MBED.

Dependencies:   MAX5715

Revision:
0:cb3754747a08
Child:
1:f82c4c7fe134
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Mar 26 23:57:53 2019 +0000
@@ -0,0 +1,82 @@
+/*******************************************************************************
+* 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.
+*******************************************************************************
+*/
+
+#include "mbed.h"
+//#include "max32625.h"
+#include "MAX5715.h"
+#include "USBSerial.h"
+
+// TODO: does mbed audience require C++ wrapper around driver?
+
+// TODO: simplify 'board support package' for mbed audience
+
+//MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3);
+//DigitalOut rLED(LED1);
+//DigitalOut gLED(LED2);
+//DigitalOut bLED(LED3);
+//DigitalOut selectPin(P3_0); // Pin 3_0 is used to drive chip enable low
+SPI spi(SPI1_MOSI, SPI1_MISO, SPI1_SCK); // mosi, miso, sclk spi1 TARGET_MAX32635MBED: P1_1 P1_2 P1_0 Arduino 10-pin header D11 D12 D13
+DigitalOut spi_cs(SPI1_SS); // TARGET_MAX32635MBED: P1_3 Arduino 10-pin header D10
+MAX5715 g_MAX5715_device(spi, spi_cs, MAX5715::MAX5715_IC);
+
+int main()
+{
+    //MAX5715 dac(spi, spi_cs, MAX5715::MAX5715_IC);
+    //dac.Init();
+
+    g_MAX5715_device.Init();
+    g_MAX5715_device.REF(MAX5715::REF_AlwaysOn_2V500);
+
+    //uint16_t code = 4095;
+    //g_MAX5715_device.CODEallLOADall(code);
+
+    //
+    uint16_t ch = 0;
+    uint16_t code = 0xccc;
+    g_MAX5715_device.CODEnLOADn(ch, code);
+    //
+    ch = 1;
+    code = 0x800;
+    g_MAX5715_device.CODEnLOADn(ch, code);
+    //
+    ch = 2;
+    code = 0x666;
+    g_MAX5715_device.CODEnLOADn(ch, code);
+    //
+    ch = 3;
+    code = 0xFFF;
+    g_MAX5715_device.CODEnLOADn(ch, code);
+
+    //wait(1.0);
+    //wait(1.0);
+}