![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
This is a simple program to read temp reading using 2 wire RTD sensor with the measureware kit.
Fork of ADISense1000_Example_FW by
src/mbed/adi_sense_log.cpp@1:ae66eccef75f, 2018-07-18 (annotated)
- Committer:
- RGurav
- Date:
- Wed Jul 18 11:40:48 2018 +0000
- Revision:
- 1:ae66eccef75f
- Parent:
- 0:76fed7dd9235
connect 2 wire RTD to CJC_0 and read data using Tera
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
seanwilson10 | 0:76fed7dd9235 | 1 | /*! |
seanwilson10 | 0:76fed7dd9235 | 2 | ****************************************************************************** |
seanwilson10 | 0:76fed7dd9235 | 3 | * @file: adi_sense_log.c |
seanwilson10 | 0:76fed7dd9235 | 4 | * @brief: ADI Sense OS-dependent wrapper layer for log functions |
seanwilson10 | 0:76fed7dd9235 | 5 | *----------------------------------------------------------------------------- |
seanwilson10 | 0:76fed7dd9235 | 6 | */ |
seanwilson10 | 0:76fed7dd9235 | 7 | |
seanwilson10 | 0:76fed7dd9235 | 8 | /****************************************************************************** |
seanwilson10 | 0:76fed7dd9235 | 9 | Copyright 2017 (c) Analog Devices, Inc. |
seanwilson10 | 0:76fed7dd9235 | 10 | |
seanwilson10 | 0:76fed7dd9235 | 11 | All rights reserved. |
seanwilson10 | 0:76fed7dd9235 | 12 | |
seanwilson10 | 0:76fed7dd9235 | 13 | Redistribution and use in source and binary forms, with or without |
seanwilson10 | 0:76fed7dd9235 | 14 | modification, are permitted provided that the following conditions are met: |
seanwilson10 | 0:76fed7dd9235 | 15 | - Redistributions of source code must retain the above copyright |
seanwilson10 | 0:76fed7dd9235 | 16 | notice, this list of conditions and the following disclaimer. |
seanwilson10 | 0:76fed7dd9235 | 17 | - Redistributions in binary form must reproduce the above copyright |
seanwilson10 | 0:76fed7dd9235 | 18 | notice, this list of conditions and the following disclaimer in |
seanwilson10 | 0:76fed7dd9235 | 19 | the documentation and/or other materials provided with the |
seanwilson10 | 0:76fed7dd9235 | 20 | distribution. |
seanwilson10 | 0:76fed7dd9235 | 21 | - Neither the name of Analog Devices, Inc. nor the names of its |
seanwilson10 | 0:76fed7dd9235 | 22 | contributors may be used to endorse or promote products derived |
seanwilson10 | 0:76fed7dd9235 | 23 | from this software without specific prior written permission. |
seanwilson10 | 0:76fed7dd9235 | 24 | - The use of this software may or may not infringe the patent rights |
seanwilson10 | 0:76fed7dd9235 | 25 | of one or more patent holders. This license does not release you |
seanwilson10 | 0:76fed7dd9235 | 26 | from the requirement that you obtain separate licenses from these |
seanwilson10 | 0:76fed7dd9235 | 27 | patent holders to use this software. |
seanwilson10 | 0:76fed7dd9235 | 28 | - Use of the software either in source or binary form, must be run |
seanwilson10 | 0:76fed7dd9235 | 29 | on or directly connected to an Analog Devices Inc. component. |
seanwilson10 | 0:76fed7dd9235 | 30 | |
seanwilson10 | 0:76fed7dd9235 | 31 | THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR |
seanwilson10 | 0:76fed7dd9235 | 32 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, |
seanwilson10 | 0:76fed7dd9235 | 33 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
seanwilson10 | 0:76fed7dd9235 | 34 | IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, |
seanwilson10 | 0:76fed7dd9235 | 35 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
seanwilson10 | 0:76fed7dd9235 | 36 | LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR |
seanwilson10 | 0:76fed7dd9235 | 37 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
seanwilson10 | 0:76fed7dd9235 | 38 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
seanwilson10 | 0:76fed7dd9235 | 39 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
seanwilson10 | 0:76fed7dd9235 | 40 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
seanwilson10 | 0:76fed7dd9235 | 41 | * |
seanwilson10 | 0:76fed7dd9235 | 42 | *****************************************************************************/ |
seanwilson10 | 0:76fed7dd9235 | 43 | |
seanwilson10 | 0:76fed7dd9235 | 44 | #include <mbed.h> |
seanwilson10 | 0:76fed7dd9235 | 45 | #include "inc/adi_sense_log.h" |
seanwilson10 | 0:76fed7dd9235 | 46 | |
seanwilson10 | 0:76fed7dd9235 | 47 | #define ADI_SENSE_LOG_UART_BAUDRATE (115200) |
seanwilson10 | 0:76fed7dd9235 | 48 | |
seanwilson10 | 0:76fed7dd9235 | 49 | #ifdef TARGET_STM32F411xE |
seanwilson10 | 0:76fed7dd9235 | 50 | #define ADI_SENSE_LOG_UART_TX_PIN (PA_11) |
seanwilson10 | 0:76fed7dd9235 | 51 | #define ADI_SENSE_LOG_UART_RX_PIN (PA_12) |
seanwilson10 | 0:76fed7dd9235 | 52 | #else |
seanwilson10 | 0:76fed7dd9235 | 53 | #error "unsupported target platform" |
seanwilson10 | 0:76fed7dd9235 | 54 | #endif |
seanwilson10 | 0:76fed7dd9235 | 55 | |
seanwilson10 | 0:76fed7dd9235 | 56 | static Serial *gpUartDevice; |
seanwilson10 | 0:76fed7dd9235 | 57 | |
seanwilson10 | 0:76fed7dd9235 | 58 | #ifdef __cplusplus |
seanwilson10 | 0:76fed7dd9235 | 59 | extern "C" { |
seanwilson10 | 0:76fed7dd9235 | 60 | #endif |
seanwilson10 | 0:76fed7dd9235 | 61 | |
seanwilson10 | 0:76fed7dd9235 | 62 | /* |
seanwilson10 | 0:76fed7dd9235 | 63 | * Open the Log interface and allocate resources |
seanwilson10 | 0:76fed7dd9235 | 64 | */ |
seanwilson10 | 0:76fed7dd9235 | 65 | ADI_SENSE_RESULT adi_sense_LogOpen(void) |
seanwilson10 | 0:76fed7dd9235 | 66 | { |
seanwilson10 | 0:76fed7dd9235 | 67 | gpUartDevice = new Serial(ADI_SENSE_LOG_UART_TX_PIN, |
seanwilson10 | 0:76fed7dd9235 | 68 | ADI_SENSE_LOG_UART_RX_PIN, |
seanwilson10 | 0:76fed7dd9235 | 69 | ADI_SENSE_LOG_UART_BAUDRATE); |
seanwilson10 | 0:76fed7dd9235 | 70 | if (!gpUartDevice) |
seanwilson10 | 0:76fed7dd9235 | 71 | { |
seanwilson10 | 0:76fed7dd9235 | 72 | ADI_SENSE_LOG_ERROR("Failed to allocate memory for Log UART context"); |
seanwilson10 | 0:76fed7dd9235 | 73 | return ADI_SENSE_NO_MEM; |
seanwilson10 | 0:76fed7dd9235 | 74 | } |
seanwilson10 | 0:76fed7dd9235 | 75 | |
seanwilson10 | 0:76fed7dd9235 | 76 | return ADI_SENSE_SUCCESS; |
seanwilson10 | 0:76fed7dd9235 | 77 | } |
seanwilson10 | 0:76fed7dd9235 | 78 | |
seanwilson10 | 0:76fed7dd9235 | 79 | /* |
seanwilson10 | 0:76fed7dd9235 | 80 | * Close the Log interface and free resources |
seanwilson10 | 0:76fed7dd9235 | 81 | */ |
seanwilson10 | 0:76fed7dd9235 | 82 | void adi_sense_LogClose(void) |
seanwilson10 | 0:76fed7dd9235 | 83 | { |
seanwilson10 | 0:76fed7dd9235 | 84 | if (gpUartDevice) |
seanwilson10 | 0:76fed7dd9235 | 85 | { |
seanwilson10 | 0:76fed7dd9235 | 86 | delete gpUartDevice; |
seanwilson10 | 0:76fed7dd9235 | 87 | gpUartDevice = 0; |
seanwilson10 | 0:76fed7dd9235 | 88 | } |
seanwilson10 | 0:76fed7dd9235 | 89 | } |
seanwilson10 | 0:76fed7dd9235 | 90 | |
seanwilson10 | 0:76fed7dd9235 | 91 | /* |
seanwilson10 | 0:76fed7dd9235 | 92 | * Print a log message to the platform log interface |
seanwilson10 | 0:76fed7dd9235 | 93 | */ |
seanwilson10 | 0:76fed7dd9235 | 94 | void adi_sense_Log(ADI_SENSE_LOG_LEVEL level, const char* format, ...) |
seanwilson10 | 0:76fed7dd9235 | 95 | { |
seanwilson10 | 0:76fed7dd9235 | 96 | char buffer[256]; |
seanwilson10 | 0:76fed7dd9235 | 97 | va_list va_args; |
seanwilson10 | 0:76fed7dd9235 | 98 | |
seanwilson10 | 0:76fed7dd9235 | 99 | if (!gpUartDevice) |
seanwilson10 | 0:76fed7dd9235 | 100 | return; |
seanwilson10 | 0:76fed7dd9235 | 101 | |
seanwilson10 | 0:76fed7dd9235 | 102 | va_start(va_args, format); |
seanwilson10 | 0:76fed7dd9235 | 103 | vsnprintf(buffer, sizeof(buffer), format, va_args); |
seanwilson10 | 0:76fed7dd9235 | 104 | va_end(va_args); |
seanwilson10 | 0:76fed7dd9235 | 105 | |
seanwilson10 | 0:76fed7dd9235 | 106 | gpUartDevice->printf("%s\r\n", buffer); |
seanwilson10 | 0:76fed7dd9235 | 107 | } |
seanwilson10 | 0:76fed7dd9235 | 108 | |
seanwilson10 | 0:76fed7dd9235 | 109 | #ifdef __cplusplus |
seanwilson10 | 0:76fed7dd9235 | 110 | } |
seanwilson10 | 0:76fed7dd9235 | 111 | #endif |
seanwilson10 | 0:76fed7dd9235 | 112 |