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:
Sat May 12 03:59:43 2018 +0000
Revision:
1:a7990c969d1a
Parent:
0:a3f9ce6b99f5
Child:
2:07fde4ba8e91
Sample read, writes for the DS4424

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 1:a7990c969d1a 44
phonemacro 1:a7990c969d1a 45 I2C i2cBus(P3_4, P3_5);
phonemacro 1:a7990c969d1a 46
phonemacro 1:a7990c969d1a 47 DS4424 ds4424_dac(i2cBus, DS4424::DS4424_I2C_SLAVE_ADRS0, DS4424::DS4424_IC);
phonemacro 0:a3f9ce6b99f5 48
phonemacro 0:a3f9ce6b99f5 49 // main() runs in its own thread in the OS
phonemacro 0:a3f9ce6b99f5 50 // (note the calls to Thread::wait below for delays)
phonemacro 0:a3f9ce6b99f5 51 int main()
phonemacro 0:a3f9ce6b99f5 52 {
phonemacro 0:a3f9ce6b99f5 53 int32_t value[4]={0,0,0,0};
phonemacro 0:a3f9ce6b99f5 54 int ret, i;
phonemacro 1:a7990c969d1a 55
phonemacro 0:a3f9ce6b99f5 56 DigitalOut rLED(LED1, LED_OFF);
phonemacro 0:a3f9ce6b99f5 57 DigitalOut gLED(LED2, LED_OFF);
phonemacro 0:a3f9ce6b99f5 58 DigitalOut bLED(LED3, LED_OFF);
phonemacro 0:a3f9ce6b99f5 59
phonemacro 0:a3f9ce6b99f5 60
phonemacro 0:a3f9ce6b99f5 61 bLED = LED_ON;
phonemacro 0:a3f9ce6b99f5 62 gLED = LED_ON;
phonemacro 0:a3f9ce6b99f5 63
phonemacro 1:a7990c969d1a 64 i2cBus.frequency(400000);
phonemacro 0:a3f9ce6b99f5 65
phonemacro 1:a7990c969d1a 66 // read each channel
phonemacro 0:a3f9ce6b99f5 67 ret = ds4424_dac.writeRaw(127, DS4424::REG_OUT0);
phonemacro 0:a3f9ce6b99f5 68 ret = ds4424_dac.writeRaw(2, DS4424::REG_OUT1);
phonemacro 0:a3f9ce6b99f5 69 ret = ds4424_dac.writeRaw(-127, DS4424::REG_OUT2);
phonemacro 0:a3f9ce6b99f5 70 ret = ds4424_dac.writeRaw(-2, DS4424::REG_OUT3);
phonemacro 0:a3f9ce6b99f5 71
phonemacro 0:a3f9ce6b99f5 72 ret = ds4424_dac.readRaw(value[0], DS4424::REG_OUT0);
phonemacro 0:a3f9ce6b99f5 73 ret = ds4424_dac.readRaw(value[1], DS4424::REG_OUT1);
phonemacro 0:a3f9ce6b99f5 74 ret = ds4424_dac.readRaw(value[2], DS4424::REG_OUT2);
phonemacro 0:a3f9ce6b99f5 75 ret = ds4424_dac.readRaw(value[3], DS4424::REG_OUT3);
phonemacro 0:a3f9ce6b99f5 76 for (i = 0; i < 4; i++) {
phonemacro 0:a3f9ce6b99f5 77 printf("Out%d = %d\r\n", i, value[i]);
phonemacro 0:a3f9ce6b99f5 78 }
phonemacro 1:a7990c969d1a 79 printf("\r\n");
phonemacro 0:a3f9ce6b99f5 80
phonemacro 1:a7990c969d1a 81 while (true) { // Blink the blue-green LED
phonemacro 0:a3f9ce6b99f5 82 bLED = !bLED;
phonemacro 0:a3f9ce6b99f5 83 gLED = !gLED;
phonemacro 0:a3f9ce6b99f5 84 wait(1.0);
phonemacro 0:a3f9ce6b99f5 85 }
phonemacro 0:a3f9ce6b99f5 86
phonemacro 0:a3f9ce6b99f5 87 }
phonemacro 0:a3f9ce6b99f5 88