A collection of Analog Devices drivers for the mbed platform

For additional information check out the mbed page of the Analog Devices wiki: https://wiki.analog.com/resources/tools-software/mbed-drivers-all

Committer:
Adrian Suciu
Date:
Thu Aug 18 14:46:42 2016 +0300
Revision:
26:1b988c505139
Parent:
25:b9e3756c9cbb
WIP on cn0391: 86ec328 Improved compatibility with Linux systems

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Adrian Suciu 25:b9e3756c9cbb 1 /**
Adrian Suciu 25:b9e3756c9cbb 2 * @file main.cpp
Adrian Suciu 26:1b988c505139 3 * @brief Main file for the CN0391-example project
Adrian Suciu 25:b9e3756c9cbb 4 * @author Analog Devices Inc.
Adrian Suciu 25:b9e3756c9cbb 5 *
Adrian Suciu 25:b9e3756c9cbb 6 * For support please go to:
Adrian Suciu 25:b9e3756c9cbb 7 * Github: https://github.com/analogdevicesinc/mbed-adi
Adrian Suciu 25:b9e3756c9cbb 8 * Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers
Adrian Suciu 25:b9e3756c9cbb 9 * Product: www.analog.com/EVAL-CN0357-ARDZ
Adrian Suciu 25:b9e3756c9cbb 10 * More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
Adrian Suciu 25:b9e3756c9cbb 11
Adrian Suciu 25:b9e3756c9cbb 12 ********************************************************************************
Adrian Suciu 25:b9e3756c9cbb 13 * Copyright 2016(c) Analog Devices, Inc.
Adrian Suciu 25:b9e3756c9cbb 14 *
Adrian Suciu 25:b9e3756c9cbb 15 * All rights reserved.
Adrian Suciu 25:b9e3756c9cbb 16 *
Adrian Suciu 25:b9e3756c9cbb 17 * Redistribution and use in source and binary forms, with or without
Adrian Suciu 25:b9e3756c9cbb 18 * modification, are permitted provided that the following conditions are met:
Adrian Suciu 25:b9e3756c9cbb 19 * - Redistributions of source code must retain the above copyright
Adrian Suciu 25:b9e3756c9cbb 20 * notice, this list of conditions and the following disclaimer.
Adrian Suciu 25:b9e3756c9cbb 21 * - Redistributions in binary form must reproduce the above copyright
Adrian Suciu 25:b9e3756c9cbb 22 * notice, this list of conditions and the following disclaimer in
Adrian Suciu 25:b9e3756c9cbb 23 * the documentation and/or other materials provided with the
Adrian Suciu 25:b9e3756c9cbb 24 * distribution.
Adrian Suciu 25:b9e3756c9cbb 25 * - Neither the name of Analog Devices, Inc. nor the names of its
Adrian Suciu 25:b9e3756c9cbb 26 * contributors may be used to endorse or promote products derived
Adrian Suciu 25:b9e3756c9cbb 27 * from this software without specific prior written permission.
Adrian Suciu 25:b9e3756c9cbb 28 * - The use of this software may or may not infringe the patent rights
Adrian Suciu 25:b9e3756c9cbb 29 * of one or more patent holders. This license does not release you
Adrian Suciu 25:b9e3756c9cbb 30 * from the requirement that you obtain separate licenses from these
Adrian Suciu 25:b9e3756c9cbb 31 * patent holders to use this software.
Adrian Suciu 25:b9e3756c9cbb 32 * - Use of the software either in source or binary form, must be run
Adrian Suciu 25:b9e3756c9cbb 33 * on or directly connected to an Analog Devices Inc. component.
Adrian Suciu 25:b9e3756c9cbb 34 *
Adrian Suciu 25:b9e3756c9cbb 35 * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
Adrian Suciu 25:b9e3756c9cbb 36 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
Adrian Suciu 25:b9e3756c9cbb 37 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
Adrian Suciu 25:b9e3756c9cbb 38 * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
Adrian Suciu 25:b9e3756c9cbb 39 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
Adrian Suciu 25:b9e3756c9cbb 40 * LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
Adrian Suciu 25:b9e3756c9cbb 41 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Adrian Suciu 25:b9e3756c9cbb 42 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Adrian Suciu 25:b9e3756c9cbb 43 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Adrian Suciu 25:b9e3756c9cbb 44 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Adrian Suciu 25:b9e3756c9cbb 45 *
Adrian Suciu 25:b9e3756c9cbb 46 ********************************************************************************/
Adrian Suciu 25:b9e3756c9cbb 47 #include "mbed.h"
Adrian Suciu 26:1b988c505139 48 #include "Thermocouple.h"
Adrian Suciu 26:1b988c505139 49 #include "CN0391.h"
Adrian Suciu 25:b9e3756c9cbb 50
Adrian Suciu 26:1b988c505139 51 Serial pc(SERIAL_TX, SERIAL_RX);
Adrian Suciu 25:b9e3756c9cbb 52
Adrian Suciu 25:b9e3756c9cbb 53 int main()
Adrian Suciu 25:b9e3756c9cbb 54 {
Adrian Suciu 26:1b988c505139 55 pc.baud(115200);
Adrian Suciu 26:1b988c505139 56 //Thermocouple *tcarray[4] = {new Thermocouple_Type_E, new Thermocouple_Type_E,new Thermocouple_Type_B,new Thermocouple_Type_B}
Adrian Suciu 26:1b988c505139 57 CN0391 cn0391(D10);
Adrian Suciu 26:1b988c505139 58 pc.printf("Reset the AD7124\r\n");
Adrian Suciu 26:1b988c505139 59 cn0391.reset();
Adrian Suciu 26:1b988c505139 60 wait_ms(500);
Adrian Suciu 26:1b988c505139 61 pc.printf("Init the AD7124\r\n");
Adrian Suciu 26:1b988c505139 62 cn0391.init();
Adrian Suciu 26:1b988c505139 63 wait_ms(500);
Adrian Suciu 26:1b988c505139 64 pc.printf("Done\r\n");
Adrian Suciu 25:b9e3756c9cbb 65
Adrian Suciu 26:1b988c505139 66 cn0391.set_thermocouple_type(CN0391::CHANNEL_P1, new Thermocouple_Type_E);
Adrian Suciu 26:1b988c505139 67 cn0391.set_thermocouple_type(CN0391::CHANNEL_P2, new Thermocouple_Type_B);
Adrian Suciu 26:1b988c505139 68 cn0391.set_thermocouple_type(CN0391::CHANNEL_P3, new Thermocouple_Type_J);
Adrian Suciu 26:1b988c505139 69 cn0391.set_thermocouple_type(CN0391::CHANNEL_P4, new Thermocouple_Type_S);
Adrian Suciu 25:b9e3756c9cbb 70
Adrian Suciu 25:b9e3756c9cbb 71
Adrian Suciu 26:1b988c505139 72
Adrian Suciu 26:1b988c505139 73 pc.printf("Calibration current for channel 1: %f\r\n", cn0391.calibrate(CN0391::CHANNEL_P1));
Adrian Suciu 26:1b988c505139 74 pc.printf("Calibration current for channel 2: %f\r\n", cn0391.calibrate(CN0391::CHANNEL_P2));
Adrian Suciu 26:1b988c505139 75 pc.printf("Calibration current for channel 3: %f\r\n", cn0391.calibrate(CN0391::CHANNEL_P3));
Adrian Suciu 26:1b988c505139 76 pc.printf("Calibration current for channel 4: %f\r\n", cn0391.calibrate(CN0391::CHANNEL_P4));
Adrian Suciu 26:1b988c505139 77 while(1) {
Adrian Suciu 26:1b988c505139 78 pc.printf("Thermocouple temperature channel 1: %f\r\n", cn0391.read_channel(CN0391::CHANNEL_P1));
Adrian Suciu 26:1b988c505139 79 pc.printf("Thermocouple temperature channel 2: %f\r\n", cn0391.read_channel(CN0391::CHANNEL_P2));
Adrian Suciu 26:1b988c505139 80 pc.printf("Thermocouple temperature channel 3: %f\r\n", cn0391.read_channel(CN0391::CHANNEL_P3));
Adrian Suciu 26:1b988c505139 81 pc.printf("Thermocouple temperature channel 4: %f\r\n", cn0391.read_channel(CN0391::CHANNEL_P4));
Adrian Suciu 26:1b988c505139 82
Adrian Suciu 26:1b988c505139 83 pc.printf("\r\n");
Adrian Suciu 26:1b988c505139 84
Adrian Suciu 26:1b988c505139 85 wait_ms(1000);
Adrian Suciu 26:1b988c505139 86 }
Adrian Suciu 26:1b988c505139 87 return 0;
Adrian Suciu 25:b9e3756c9cbb 88 }