Example host software for the Maxim Integrated MAX541 16-Bit, Unbuffered Output Voltage DAC. Hosted on the MAX32625MBED.

Dependencies:   MAX541

Committer:
whismanoid
Date:
Mon Apr 22 21:19:12 2019 +0000
Revision:
0:416025725155
Child:
1:6382a70336f4
max541 tested on max32625mbed spi1 (arduino D13/D12/D11/D10)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
whismanoid 0:416025725155 1 /*******************************************************************************
whismanoid 0:416025725155 2 * Copyright (C) 2019 Maxim Integrated Products, Inc., All Rights Reserved.
whismanoid 0:416025725155 3 *
whismanoid 0:416025725155 4 * Permission is hereby granted, free of charge, to any person obtaining a
whismanoid 0:416025725155 5 * copy of this software and associated documentation files (the "Software"),
whismanoid 0:416025725155 6 * to deal in the Software without restriction, including without limitation
whismanoid 0:416025725155 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
whismanoid 0:416025725155 8 * and/or sell copies of the Software, and to permit persons to whom the
whismanoid 0:416025725155 9 * Software is furnished to do so, subject to the following conditions:
whismanoid 0:416025725155 10 *
whismanoid 0:416025725155 11 * The above copyright notice and this permission notice shall be included
whismanoid 0:416025725155 12 * in all copies or substantial portions of the Software.
whismanoid 0:416025725155 13 *
whismanoid 0:416025725155 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
whismanoid 0:416025725155 15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
whismanoid 0:416025725155 16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
whismanoid 0:416025725155 17 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
whismanoid 0:416025725155 18 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
whismanoid 0:416025725155 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
whismanoid 0:416025725155 20 * OTHER DEALINGS IN THE SOFTWARE.
whismanoid 0:416025725155 21 *
whismanoid 0:416025725155 22 * Except as contained in this notice, the name of Maxim Integrated
whismanoid 0:416025725155 23 * Products, Inc. shall not be used except as stated in the Maxim Integrated
whismanoid 0:416025725155 24 * Products, Inc. Branding Policy.
whismanoid 0:416025725155 25 *
whismanoid 0:416025725155 26 * The mere transfer of this software does not imply any licenses
whismanoid 0:416025725155 27 * of trade secrets, proprietary technology, copyrights, patents,
whismanoid 0:416025725155 28 * trademarks, maskwork rights, or any other form of intellectual
whismanoid 0:416025725155 29 * property whatsoever. Maxim Integrated Products, Inc. retains all
whismanoid 0:416025725155 30 * ownership rights.
whismanoid 0:416025725155 31 *******************************************************************************
whismanoid 0:416025725155 32 */
whismanoid 0:416025725155 33
whismanoid 0:416025725155 34 #include "mbed.h"
whismanoid 0:416025725155 35 #include "MAX541.h"
whismanoid 0:416025725155 36
whismanoid 0:416025725155 37 SPI spi_max541(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:416025725155 38 DigitalOut spi_max541_cs(SPI1_SS); // TARGET_MAX32635MBED: P1_3 Arduino 10-pin header D10
whismanoid 0:416025725155 39
whismanoid 0:416025725155 40 // alternate spi connection
whismanoid 0:416025725155 41 // SPI spi2_max541(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi2 TARGET_MAX32635MBED: P2_5 P2_6 P2_4 Arduino 2x3-pin header; microSD
whismanoid 0:416025725155 42 // DigitalOut spi2_max541_cs(SPI2_SS); // TARGET_MAX32635MBED: P2_7 Arduino 2x3-pin header
whismanoid 0:416025725155 43
whismanoid 0:416025725155 44 int main()
whismanoid 0:416025725155 45 {
whismanoid 0:416025725155 46 MAX541 max541(spi_max541, spi_max541_cs);
whismanoid 0:416025725155 47 max541.VRef = 3.30;
whismanoid 0:416025725155 48
whismanoid 0:416025725155 49 double voltageV = 1.0f;
whismanoid 0:416025725155 50 max541.Set_Voltage(voltageV);
whismanoid 0:416025725155 51
whismanoid 0:416025725155 52 //wait(1.0);
whismanoid 0:416025725155 53 //wait(1.0);
whismanoid 0:416025725155 54 }