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

Dependencies:   MAX5715

main.cpp

Committer:
whismanoid
Date:
2019-05-06
Revision:
2:015f0dc1ff16
Parent:
1:f82c4c7fe134
Child:
3:9db1ff35500e

File content as of revision 2:015f0dc1ff16:

// /*******************************************************************************
// * 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.
// *******************************************************************************
// */
// example code includes
#include "mbed.h"
//#include "max32625.h"
#include "MAX5715.h"
#include "USBSerial.h"

// example code board support
//MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3);
//DigitalOut rLED(LED1);
//DigitalOut gLED(LED2);
//DigitalOut bLED(LED3);
//
// Arduino connector port definitions (MAX32625MBED shown)
// optional: uncomment these lines, update port definitions for other target board
// #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

// example code declare SPI interface
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

// example code declare GPIO interface pins
DigitalOut LDACb_pin(D9); // Digital Trigger Input to device
DigitalOut CLRb_pin(D8); // Digital Trigger Input to device
// AnalogOut &REF_pin(Px_x_PortName_To_Be_Determined); // Reference Input to device
// AnalogIn &OUTA_pin(A0); // Analog Output from device
// AnalogIn &OUTB_pin(A1); // Analog Output from device
// AnalogIn &OUTC_pin(A2); // Analog Output from device
// AnalogIn &OUTD_pin(A3); // Analog Output from device
// DigitalIn &RDYb_pin(Px_x_PortName_To_Be_Determined); // Digital DaisyChain Output from device
// example code declare device instance
MAX5715 g_MAX5715_device(spi, spi_cs, LDACb_pin, CLRb_pin, MAX5715::MAX5715_IC);

// example code main function
int main()
{
    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);
}