Example host software for the Maxim Integrated MAX31723/MAX31722 Device Temperature Sensor. Hosted on the MAX32630FTHR. The MAX31723 may be used in thermostats, thermometers, and hardware temperature supervisors.

Dependencies:   MAX31723_Digital_Temperature_Sensor max32630fthr USBDevice

Committer:
phonemacro
Date:
Thu May 10 22:59:56 2018 +0000
Revision:
0:a3f9ce6b99f5
Child:
1:a7990c969d1a
Initial Commit for DS4424 Program;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
phonemacro 0:a3f9ce6b99f5 1 /*******************************************************************************
phonemacro 0:a3f9ce6b99f5 2 * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
phonemacro 0:a3f9ce6b99f5 3 *
phonemacro 0:a3f9ce6b99f5 4 * Permission is hereby granted, free of charge, to any person obtaining a
phonemacro 0:a3f9ce6b99f5 5 * copy of this software and associated documentation files (the "Software"),
phonemacro 0:a3f9ce6b99f5 6 * to deal in the Software without restriction, including without limitation
phonemacro 0:a3f9ce6b99f5 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
phonemacro 0:a3f9ce6b99f5 8 * and/or sell copies of the Software, and to permit persons to whom the
phonemacro 0:a3f9ce6b99f5 9 * Software is furnished to do so, subject to the following conditions:
phonemacro 0:a3f9ce6b99f5 10 *
phonemacro 0:a3f9ce6b99f5 11 * The above copyright notice and this permission notice shall be included
phonemacro 0:a3f9ce6b99f5 12 * in all copies or substantial portions of the Software.
phonemacro 0:a3f9ce6b99f5 13 *
phonemacro 0:a3f9ce6b99f5 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
phonemacro 0:a3f9ce6b99f5 15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
phonemacro 0:a3f9ce6b99f5 16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
phonemacro 0:a3f9ce6b99f5 17 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
phonemacro 0:a3f9ce6b99f5 18 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
phonemacro 0:a3f9ce6b99f5 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
phonemacro 0:a3f9ce6b99f5 20 * OTHER DEALINGS IN THE SOFTWARE.
phonemacro 0:a3f9ce6b99f5 21 *
phonemacro 0:a3f9ce6b99f5 22 * Except as contained in this notice, the name of Maxim Integrated
phonemacro 0:a3f9ce6b99f5 23 * Products, Inc. shall not be used except as stated in the Maxim Integrated
phonemacro 0:a3f9ce6b99f5 24 * Products, Inc. Branding Policy.
phonemacro 0:a3f9ce6b99f5 25 *
phonemacro 0:a3f9ce6b99f5 26 * The mere transfer of this software does not imply any licenses
phonemacro 0:a3f9ce6b99f5 27 * of trade secrets, proprietary technology, copyrights, patents,
phonemacro 0:a3f9ce6b99f5 28 * trademarks, maskwork rights, or any other form of intellectual
phonemacro 0:a3f9ce6b99f5 29 * property whatsoever. Maxim Integrated Products, Inc. retains all
phonemacro 0:a3f9ce6b99f5 30 * ownership rights.
phonemacro 0:a3f9ce6b99f5 31 *******************************************************************************
phonemacro 0:a3f9ce6b99f5 32 */
phonemacro 0:a3f9ce6b99f5 33 #include "mbed.h"
phonemacro 0:a3f9ce6b99f5 34 #include "max32630fthr.h"
phonemacro 0:a3f9ce6b99f5 35 #include "DS4424.h"
phonemacro 0:a3f9ce6b99f5 36
phonemacro 0:a3f9ce6b99f5 37 #include "USBSerial.h"
phonemacro 0:a3f9ce6b99f5 38
phonemacro 0:a3f9ce6b99f5 39 MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3);
phonemacro 0:a3f9ce6b99f5 40
phonemacro 0:a3f9ce6b99f5 41 DigitalOut rLED(LED1);
phonemacro 0:a3f9ce6b99f5 42 DigitalOut gLED(LED2);
phonemacro 0:a3f9ce6b99f5 43 DigitalOut bLED(LED3);
phonemacro 0:a3f9ce6b99f5 44
phonemacro 0:a3f9ce6b99f5 45
phonemacro 0:a3f9ce6b99f5 46 // main() runs in its own thread in the OS
phonemacro 0:a3f9ce6b99f5 47 // (note the calls to Thread::wait below for delays)
phonemacro 0:a3f9ce6b99f5 48 int main()
phonemacro 0:a3f9ce6b99f5 49 {
phonemacro 0:a3f9ce6b99f5 50 int32_t value[4]={0,0,0,0};
phonemacro 0:a3f9ce6b99f5 51 int ret, i;
phonemacro 0:a3f9ce6b99f5 52
phonemacro 0:a3f9ce6b99f5 53 DigitalOut rLED(LED1, LED_OFF);
phonemacro 0:a3f9ce6b99f5 54 DigitalOut gLED(LED2, LED_OFF);
phonemacro 0:a3f9ce6b99f5 55 DigitalOut bLED(LED3, LED_OFF);
phonemacro 0:a3f9ce6b99f5 56
phonemacro 0:a3f9ce6b99f5 57
phonemacro 0:a3f9ce6b99f5 58 bLED = LED_ON;
phonemacro 0:a3f9ce6b99f5 59 gLED = LED_ON;
phonemacro 0:a3f9ce6b99f5 60
phonemacro 0:a3f9ce6b99f5 61 // I2C i2cBus(P5_7, P6_0);
phonemacro 0:a3f9ce6b99f5 62 I2C i2cBus(P3_4, P3_5);
phonemacro 0:a3f9ce6b99f5 63 //i2cBus.frequency(400000);
phonemacro 0:a3f9ce6b99f5 64 DS4424 ds4424_dac(i2cBus, DS4424::DS4424_I2C_SLAVE_ADRS0);
phonemacro 0:a3f9ce6b99f5 65
phonemacro 0:a3f9ce6b99f5 66 ret = ds4424_dac.readRaw(value[0], DS4424::REG_OUT0);
phonemacro 0:a3f9ce6b99f5 67 ret = ds4424_dac.readRaw(value[1], DS4424::REG_OUT1);
phonemacro 0:a3f9ce6b99f5 68 ret = ds4424_dac.readRaw(value[2], DS4424::REG_OUT2);
phonemacro 0:a3f9ce6b99f5 69 ret = ds4424_dac.readRaw(value[3], DS4424::REG_OUT3);
phonemacro 0:a3f9ce6b99f5 70 for (i = 0; i < 4; i++) {
phonemacro 0:a3f9ce6b99f5 71 printf("Out%d = %d\r\n", i, value[i]);
phonemacro 0:a3f9ce6b99f5 72 }
phonemacro 0:a3f9ce6b99f5 73 ret = ds4424_dac.writeRaw(127, DS4424::REG_OUT0);
phonemacro 0:a3f9ce6b99f5 74 ret = ds4424_dac.writeRaw(2, DS4424::REG_OUT1);
phonemacro 0:a3f9ce6b99f5 75 ret = ds4424_dac.writeRaw(-127, DS4424::REG_OUT2);
phonemacro 0:a3f9ce6b99f5 76 ret = ds4424_dac.writeRaw(-2, DS4424::REG_OUT3);
phonemacro 0:a3f9ce6b99f5 77
phonemacro 0:a3f9ce6b99f5 78 ret = ds4424_dac.readRaw(value[0], DS4424::REG_OUT0);
phonemacro 0:a3f9ce6b99f5 79 ret = ds4424_dac.readRaw(value[1], DS4424::REG_OUT1);
phonemacro 0:a3f9ce6b99f5 80 ret = ds4424_dac.readRaw(value[2], DS4424::REG_OUT2);
phonemacro 0:a3f9ce6b99f5 81 ret = ds4424_dac.readRaw(value[3], DS4424::REG_OUT3);
phonemacro 0:a3f9ce6b99f5 82 for (i = 0; i < 4; i++) {
phonemacro 0:a3f9ce6b99f5 83 printf("Out%d = %d\r\n", i, value[i]);
phonemacro 0:a3f9ce6b99f5 84 }
phonemacro 0:a3f9ce6b99f5 85
phonemacro 0:a3f9ce6b99f5 86 //ret = ds4424_dac.printRawRegs();
phonemacro 0:a3f9ce6b99f5 87 //ret = ds4424_dac.printRegs();
phonemacro 0:a3f9ce6b99f5 88
phonemacro 0:a3f9ce6b99f5 89 while (true) {
phonemacro 0:a3f9ce6b99f5 90 bLED = !bLED;
phonemacro 0:a3f9ce6b99f5 91 gLED = !gLED;
phonemacro 0:a3f9ce6b99f5 92 wait(1.0);
phonemacro 0:a3f9ce6b99f5 93 }
phonemacro 0:a3f9ce6b99f5 94
phonemacro 0:a3f9ce6b99f5 95 }
phonemacro 0:a3f9ce6b99f5 96