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

Dependencies:   MAX5715

Committer:
whismanoid
Date:
Mon May 06 17:31:47 2019 +0000
Revision:
2:015f0dc1ff16
Parent:
1:f82c4c7fe134
Child:
3:9db1ff35500e
buildable with test_main fixes

Who changed what in which revision?

UserRevisionLine numberNew contents of line
whismanoid 2:015f0dc1ff16 1 // /*******************************************************************************
whismanoid 2:015f0dc1ff16 2 // * Copyright (C) 2019 Maxim Integrated Products, Inc., All Rights Reserved.
whismanoid 2:015f0dc1ff16 3 // *
whismanoid 2:015f0dc1ff16 4 // * Permission is hereby granted, free of charge, to any person obtaining a
whismanoid 2:015f0dc1ff16 5 // * copy of this software and associated documentation files (the "Software"),
whismanoid 2:015f0dc1ff16 6 // * to deal in the Software without restriction, including without limitation
whismanoid 2:015f0dc1ff16 7 // * the rights to use, copy, modify, merge, publish, distribute, sublicense,
whismanoid 2:015f0dc1ff16 8 // * and/or sell copies of the Software, and to permit persons to whom the
whismanoid 2:015f0dc1ff16 9 // * Software is furnished to do so, subject to the following conditions:
whismanoid 2:015f0dc1ff16 10 // *
whismanoid 2:015f0dc1ff16 11 // * The above copyright notice and this permission notice shall be included
whismanoid 2:015f0dc1ff16 12 // * in all copies or substantial portions of the Software.
whismanoid 2:015f0dc1ff16 13 // *
whismanoid 2:015f0dc1ff16 14 // * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
whismanoid 2:015f0dc1ff16 15 // * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
whismanoid 2:015f0dc1ff16 16 // * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
whismanoid 2:015f0dc1ff16 17 // * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
whismanoid 2:015f0dc1ff16 18 // * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
whismanoid 2:015f0dc1ff16 19 // * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
whismanoid 2:015f0dc1ff16 20 // * OTHER DEALINGS IN THE SOFTWARE.
whismanoid 2:015f0dc1ff16 21 // *
whismanoid 2:015f0dc1ff16 22 // * Except as contained in this notice, the name of Maxim Integrated
whismanoid 2:015f0dc1ff16 23 // * Products, Inc. shall not be used except as stated in the Maxim Integrated
whismanoid 2:015f0dc1ff16 24 // * Products, Inc. Branding Policy.
whismanoid 2:015f0dc1ff16 25 // *
whismanoid 2:015f0dc1ff16 26 // * The mere transfer of this software does not imply any licenses
whismanoid 2:015f0dc1ff16 27 // * of trade secrets, proprietary technology, copyrights, patents,
whismanoid 2:015f0dc1ff16 28 // * trademarks, maskwork rights, or any other form of intellectual
whismanoid 2:015f0dc1ff16 29 // * property whatsoever. Maxim Integrated Products, Inc. retains all
whismanoid 2:015f0dc1ff16 30 // * ownership rights.
whismanoid 2:015f0dc1ff16 31 // *******************************************************************************
whismanoid 2:015f0dc1ff16 32 // */
whismanoid 2:015f0dc1ff16 33 // example code includes
whismanoid 0:cb3754747a08 34 #include "mbed.h"
whismanoid 0:cb3754747a08 35 //#include "max32625.h"
whismanoid 0:cb3754747a08 36 #include "MAX5715.h"
whismanoid 0:cb3754747a08 37 #include "USBSerial.h"
whismanoid 0:cb3754747a08 38
whismanoid 2:015f0dc1ff16 39 // example code board support
whismanoid 0:cb3754747a08 40 //MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3);
whismanoid 0:cb3754747a08 41 //DigitalOut rLED(LED1);
whismanoid 0:cb3754747a08 42 //DigitalOut gLED(LED2);
whismanoid 0:cb3754747a08 43 //DigitalOut bLED(LED3);
whismanoid 2:015f0dc1ff16 44 //
whismanoid 2:015f0dc1ff16 45 // Arduino connector port definitions (MAX32625MBED shown)
whismanoid 2:015f0dc1ff16 46 // optional: uncomment these lines, update port definitions for other target board
whismanoid 2:015f0dc1ff16 47 // #define A0 AIN_0
whismanoid 2:015f0dc1ff16 48 // #define A1 AIN_1
whismanoid 2:015f0dc1ff16 49 // #define A2 AIN_2
whismanoid 2:015f0dc1ff16 50 // #define A3 AIN_3
whismanoid 2:015f0dc1ff16 51 // #define D0 P0_0
whismanoid 2:015f0dc1ff16 52 // #define D1 P0_1
whismanoid 2:015f0dc1ff16 53 // #define D2 P0_2
whismanoid 2:015f0dc1ff16 54 // #define D3 P0_3
whismanoid 2:015f0dc1ff16 55 // #define D4 P0_4
whismanoid 2:015f0dc1ff16 56 // #define D5 P0_5
whismanoid 2:015f0dc1ff16 57 // #define D6 P0_6
whismanoid 2:015f0dc1ff16 58 // #define D7 P0_7
whismanoid 2:015f0dc1ff16 59 #define D8 P1_4
whismanoid 2:015f0dc1ff16 60 #define D9 P1_5
whismanoid 2:015f0dc1ff16 61 // #define D10 P1_3
whismanoid 2:015f0dc1ff16 62 // #define D11 P1_1
whismanoid 2:015f0dc1ff16 63 // #define D12 P1_2
whismanoid 2:015f0dc1ff16 64 // #define D13 P1_0
whismanoid 2:015f0dc1ff16 65
whismanoid 2:015f0dc1ff16 66 // example code declare SPI interface
whismanoid 0:cb3754747a08 67 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
whismanoid 0:cb3754747a08 68 DigitalOut spi_cs(SPI1_SS); // TARGET_MAX32635MBED: P1_3 Arduino 10-pin header D10
whismanoid 2:015f0dc1ff16 69
whismanoid 2:015f0dc1ff16 70 // example code declare GPIO interface pins
whismanoid 2:015f0dc1ff16 71 DigitalOut LDACb_pin(D9); // Digital Trigger Input to device
whismanoid 2:015f0dc1ff16 72 DigitalOut CLRb_pin(D8); // Digital Trigger Input to device
whismanoid 2:015f0dc1ff16 73 // AnalogOut &REF_pin(Px_x_PortName_To_Be_Determined); // Reference Input to device
whismanoid 2:015f0dc1ff16 74 // AnalogIn &OUTA_pin(A0); // Analog Output from device
whismanoid 2:015f0dc1ff16 75 // AnalogIn &OUTB_pin(A1); // Analog Output from device
whismanoid 2:015f0dc1ff16 76 // AnalogIn &OUTC_pin(A2); // Analog Output from device
whismanoid 2:015f0dc1ff16 77 // AnalogIn &OUTD_pin(A3); // Analog Output from device
whismanoid 2:015f0dc1ff16 78 // DigitalIn &RDYb_pin(Px_x_PortName_To_Be_Determined); // Digital DaisyChain Output from device
whismanoid 2:015f0dc1ff16 79 // example code declare device instance
whismanoid 1:f82c4c7fe134 80 MAX5715 g_MAX5715_device(spi, spi_cs, LDACb_pin, CLRb_pin, MAX5715::MAX5715_IC);
whismanoid 0:cb3754747a08 81
whismanoid 2:015f0dc1ff16 82 // example code main function
whismanoid 0:cb3754747a08 83 int main()
whismanoid 0:cb3754747a08 84 {
whismanoid 2:015f0dc1ff16 85 g_MAX5715_device.Init();
whismanoid 0:cb3754747a08 86
whismanoid 0:cb3754747a08 87 g_MAX5715_device.REF(MAX5715::REF_AlwaysOn_2V500);
whismanoid 0:cb3754747a08 88
whismanoid 0:cb3754747a08 89 //uint16_t code = 4095;
whismanoid 0:cb3754747a08 90 //g_MAX5715_device.CODEallLOADall(code);
whismanoid 0:cb3754747a08 91
whismanoid 0:cb3754747a08 92 //
whismanoid 0:cb3754747a08 93 uint16_t ch = 0;
whismanoid 0:cb3754747a08 94 uint16_t code = 0xccc;
whismanoid 0:cb3754747a08 95 g_MAX5715_device.CODEnLOADn(ch, code);
whismanoid 0:cb3754747a08 96 //
whismanoid 0:cb3754747a08 97 ch = 1;
whismanoid 0:cb3754747a08 98 code = 0x800;
whismanoid 0:cb3754747a08 99 g_MAX5715_device.CODEnLOADn(ch, code);
whismanoid 0:cb3754747a08 100 //
whismanoid 0:cb3754747a08 101 ch = 2;
whismanoid 0:cb3754747a08 102 code = 0x666;
whismanoid 0:cb3754747a08 103 g_MAX5715_device.CODEnLOADn(ch, code);
whismanoid 0:cb3754747a08 104 //
whismanoid 0:cb3754747a08 105 ch = 3;
whismanoid 0:cb3754747a08 106 code = 0xFFF;
whismanoid 0:cb3754747a08 107 g_MAX5715_device.CODEnLOADn(ch, code);
whismanoid 0:cb3754747a08 108
whismanoid 0:cb3754747a08 109 //wait(1.0);
whismanoid 0:cb3754747a08 110 }