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:
Wed Jan 23 00:48:54 2019 +0000
Revision:
7:bf8c91e28a3b
Parent:
4:51c1a4c4f762
Child:
8:5bbefd9bce9f
Modify the example program to use the processed data (DAC sink/source specified in picoAmps) methods.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
phonemacro 0:a3f9ce6b99f5 1 /*******************************************************************************
phonemacro 7:bf8c91e28a3b 2 * Copyright (C) 2018-2019 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 4:51c1a4c4f762 49 /** main() runs in its own thread in the OS */
phonemacro 4:51c1a4c4f762 50 /** (note the calls to Thread::wait below for delays) */
phonemacro 2:07fde4ba8e91 51 /**
phonemacro 4:51c1a4c4f762 52 * @brief Sample main program for Maxim Integrated DS4424, DS4422
phonemacro 7:bf8c91e28a3b 53 * @version 1.0000.301
phonemacro 4:51c1a4c4f762 54 *
phonemacro 4:51c1a4c4f762 55 * @details Sample main program for DS4424, DS4422
phonemacro 4:51c1a4c4f762 56 * The prints are sent to the terminal window (9600, 8n1).
phonemacro 4:51c1a4c4f762 57 * The program sets the output DAC registers to various values.
phonemacro 4:51c1a4c4f762 58 * These registers are then read back and printed out.
phonemacro 4:51c1a4c4f762 59 * The program then blinks the blue-green LED.
phonemacro 4:51c1a4c4f762 60 * To run the program, drag and drop the .bin file into the
phonemacro 4:51c1a4c4f762 61 * DAPLINK folder. After it finishes flashing, cycle the power or
phonemacro 4:51c1a4c4f762 62 * reset the Pegasus (MAX32630FTHR) after flashing by pressing the button on
phonemacro 4:51c1a4c4f762 63 * the Pegasus next to the battery connector or the button
phonemacro 4:51c1a4c4f762 64 * on the MAXREFDES100HDK.
phonemacro 4:51c1a4c4f762 65 */
phonemacro 0:a3f9ce6b99f5 66 int main()
phonemacro 0:a3f9ce6b99f5 67 {
phonemacro 7:bf8c91e28a3b 68 int32_t in_pAmps[4] = {-193675000, -1525000, 6100000, -16012500};
phonemacro 7:bf8c91e28a3b 69 uint8_t in_raw[4];
phonemacro 7:bf8c91e28a3b 70 int32_t value[4] = {0, 0, 0, 0};
phonemacro 0:a3f9ce6b99f5 71 int ret, i;
phonemacro 7:bf8c91e28a3b 72 int32_t out_pAmps[4] = {0, 0, 0, 0};
phonemacro 7:bf8c91e28a3b 73 uint32_t rfs_board[4] = {40000, 80000, 100000, 160000};
phonemacro 1:a7990c969d1a 74
phonemacro 0:a3f9ce6b99f5 75 DigitalOut rLED(LED1, LED_OFF);
phonemacro 0:a3f9ce6b99f5 76 DigitalOut gLED(LED2, LED_OFF);
phonemacro 0:a3f9ce6b99f5 77 DigitalOut bLED(LED3, LED_OFF);
phonemacro 0:a3f9ce6b99f5 78
phonemacro 0:a3f9ce6b99f5 79 bLED = LED_ON;
phonemacro 0:a3f9ce6b99f5 80 gLED = LED_ON;
phonemacro 0:a3f9ce6b99f5 81
phonemacro 1:a7990c969d1a 82 i2cBus.frequency(400000);
phonemacro 7:bf8c91e28a3b 83 printf("\r\n");
phonemacro 7:bf8c91e28a3b 84
phonemacro 7:bf8c91e28a3b 85 /* write to each channel using picoAmps */
phonemacro 7:bf8c91e28a3b 86 for (i = 0; i < 4; i++) {
phonemacro 7:bf8c91e28a3b 87 ret = ds4424_dac.convert_picoAmps_to_hw_raw(&in_raw[i], in_pAmps[i], rfs_board[i]);
phonemacro 7:bf8c91e28a3b 88 printf("Set picoAmps Out %d picoAmps, hw raw = %d, rfs = %d Ohms\r\n", in_pAmps[i], in_raw[i], rfs_board[i]);
phonemacro 7:bf8c91e28a3b 89 }
phonemacro 7:bf8c91e28a3b 90 printf("\r\n");
phonemacro 7:bf8c91e28a3b 91 ret = ds4424_dac.write_hw_raw(in_raw[0], DS4424::REG_OUT0);
phonemacro 7:bf8c91e28a3b 92 ret = ds4424_dac.write_hw_raw(in_raw[1], DS4424::REG_OUT1);
phonemacro 7:bf8c91e28a3b 93 ret = ds4424_dac.write_hw_raw(in_raw[2], DS4424::REG_OUT2);
phonemacro 7:bf8c91e28a3b 94 ret = ds4424_dac.write_hw_raw(in_raw[3], DS4424::REG_OUT3);
phonemacro 0:a3f9ce6b99f5 95
phonemacro 7:bf8c91e28a3b 96 /* write to each channel using two's complement */
phonemacro 7:bf8c91e28a3b 97 /*
phonemacro 7:bf8c91e28a3b 98 ret = ds4424_dac.write_raw(-127, DS4424::REG_OUT0);
phonemacro 7:bf8c91e28a3b 99 ret = ds4424_dac.write_raw(-2, DS4424::REG_OUT1);
phonemacro 7:bf8c91e28a3b 100 ret = ds4424_dac.write_raw(10, DS4424::REG_OUT2);
phonemacro 7:bf8c91e28a3b 101 ret = ds4424_dac.write_raw(-42, DS4424::REG_OUT3);
phonemacro 7:bf8c91e28a3b 102 */
phonemacro 7:bf8c91e28a3b 103 ret = ds4424_dac.read_hw_raw(in_raw[0], DS4424::REG_OUT0);
phonemacro 7:bf8c91e28a3b 104 ret = ds4424_dac.read_hw_raw(in_raw[1], DS4424::REG_OUT1);
phonemacro 7:bf8c91e28a3b 105 ret = ds4424_dac.read_hw_raw(in_raw[2], DS4424::REG_OUT2);
phonemacro 7:bf8c91e28a3b 106 ret = ds4424_dac.read_hw_raw(in_raw[3], DS4424::REG_OUT3);
phonemacro 7:bf8c91e28a3b 107 for (i = 0; i < 4; i++) {
phonemacro 7:bf8c91e28a3b 108 printf("Read hw raw Out %d = %d\r\n", i, in_raw[i]);
phonemacro 7:bf8c91e28a3b 109 }
phonemacro 7:bf8c91e28a3b 110 printf("\r\n");
phonemacro 0:a3f9ce6b99f5 111
phonemacro 2:07fde4ba8e91 112 ret = ds4424_dac.read_raw(value[0], DS4424::REG_OUT0);
phonemacro 2:07fde4ba8e91 113 ret = ds4424_dac.read_raw(value[1], DS4424::REG_OUT1);
phonemacro 2:07fde4ba8e91 114 ret = ds4424_dac.read_raw(value[2], DS4424::REG_OUT2);
phonemacro 2:07fde4ba8e91 115 ret = ds4424_dac.read_raw(value[3], DS4424::REG_OUT3);
phonemacro 0:a3f9ce6b99f5 116 for (i = 0; i < 4; i++) {
phonemacro 7:bf8c91e28a3b 117 printf("Read raw two's complement Out %d = %d\r\n", i, value[i]);
phonemacro 7:bf8c91e28a3b 118 }
phonemacro 7:bf8c91e28a3b 119 printf("\r\n");
phonemacro 7:bf8c91e28a3b 120
phonemacro 7:bf8c91e28a3b 121 /* Convert two's complement values to picoAmps */
phonemacro 7:bf8c91e28a3b 122 for (i = 0; i < 4; i++) {
phonemacro 7:bf8c91e28a3b 123 ret = ds4424_dac.convert_raw_to_picoAmps(&out_pAmps[i], value[i], rfs_board[i]);
phonemacro 7:bf8c91e28a3b 124 printf("Read Out %d = %d picoAmps, rfs = %d Ohms\r\n", i, out_pAmps[i], rfs_board[i]);
phonemacro 0:a3f9ce6b99f5 125 }
phonemacro 1:a7990c969d1a 126 printf("\r\n");
phonemacro 0:a3f9ce6b99f5 127
phonemacro 1:a7990c969d1a 128 while (true) { // Blink the blue-green LED
phonemacro 0:a3f9ce6b99f5 129 bLED = !bLED;
phonemacro 0:a3f9ce6b99f5 130 gLED = !gLED;
phonemacro 0:a3f9ce6b99f5 131 wait(1.0);
phonemacro 0:a3f9ce6b99f5 132 }
phonemacro 0:a3f9ce6b99f5 133 }