Arun Raj / Mbed OS MAXREFDES101_SOURCE

Dependencies:   max32630fthr Adafruit_FeatherOLED USBDevice

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers TempComm.h Source File

TempComm.h

00001 /*******************************************************************************
00002  * Copyright (C) 2017 Maxim Integrated Products, Inc., All Rights Reserved.
00003  *
00004  * Permission is hereby granted, free of charge, to any person obtaining a
00005  * copy of this software and associated documentation files (the "Software"),
00006  * to deal in the Software without restriction, including without limitation
00007  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
00008  * and/or sell copies of the Software, and to permit persons to whom the
00009  * Software is furnished to do so, subject to the following conditions:
00010  *
00011  * The above copyright notice and this permission notice shall be included
00012  * in all copies or substantial portions of the Software.
00013  *
00014  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00015  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00016  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00017  * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
00018  * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
00019  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00020  * OTHER DEALINGS IN THE SOFTWARE.
00021  *
00022  * Except as contained in this notice, the name of Maxim Integrated
00023  * Products, Inc. shall not be used except as stated in the Maxim Integrated
00024  * Products, Inc. Branding Policy.
00025  *
00026  * The mere transfer of this software does not imply any licenses
00027  * of trade secrets, proprietary technology, copyrights, patents,
00028  * trademarks, maskwork rights, or any other form of intellectual
00029  * property whatsoever. Maxim Integrated Products, Inc. retains all
00030  * ownership rights.
00031  *******************************************************************************
00032  */
00033 
00034 #ifndef _TEMPCOMM_H_
00035 #define _TEMPCOMM_H_
00036 
00037 #include "mbed.h"
00038 #include "SensorComm.h"
00039 #include "USBSerial.h"
00040 #include "MAX30205.h"
00041 
00042 /**
00043  * @brief   TempComm Temperature sensor command handler class.
00044  * @details
00045  */
00046 class TempComm: public SensorComm
00047 {
00048 public:
00049 
00050     /* PUBLIC FUNCTION DECLARATIONS */
00051     /**
00052     * @brief    TempComm constructor.
00053     *
00054     */
00055     TempComm(USBSerial* USB);
00056 
00057     /* PROTECTED FUNCTION DECLARATIONS */
00058     /**
00059     * @brief    Parses Sensor Studio commands.
00060     * @details  Parses and executes commands. Prints command result to i/o device.
00061     * @returns true if sensor acted upon the command, false if command was unknown
00062     */
00063     bool parse_command(const char* cmd);
00064 
00065     /**
00066     * @brief      Fill in buffer with sensor data
00067     *
00068     * @param[in]      buf Buffer to fill data into
00069     * @param[in]      size Maximum size of buffer
00070     * @param[out]   Number of bytes written to buffer
00071     */
00072     int data_report_execute(char* buf, int size);
00073 
00074     /**
00075     * @brief    Stop collecting data and disable sensor
00076     */
00077     void stop();
00078 
00079     //sc... track whether the temperature can be read
00080     void TempComm_Set_ReadTempStatus(bool en);
00081 
00082     //sc... track whether the temperature can be read
00083     void TempComm_Set_ReadTempStatus_Ticker();
00084 
00085     volatile float TempComm_instant_temp_celsius;
00086 
00087 private:
00088     /* PRIVATE TYPE DEFINITIONS */
00089     typedef enum _cmd_state_t {
00090         get_tp_format_mode0=0,
00091         read_tp_mode0,
00092         set_cfg_sr,
00093         get_reg,
00094         set_reg,
00095         dump_regs,
00096         NUM_CMDS,
00097     } cmd_state_t;
00098 
00099     typedef struct __attribute__((packed)) {
00100         uint32_t start_byte :8;
00101         uint32_t smpleCnt   :8;  //Represent 0-127
00102         uint32_t tp         :16; //TP ADC data
00103         uint8_t             :0;  //Needed to align crc to byte boundary
00104         uint8_t crc8        :8;
00105     } tp0_comm_packet;
00106 
00107     /* PRIVATE VARIABLES */
00108     USBSerial *m_USB;
00109     volatile char m_can_read_temp_;
00110     Ticker m_tempcomm_ticker_;
00111     // read temp ticker settings
00112     float ticker_period_second_;
00113     uint32_t sampling_period_ms_;
00114 
00115 
00116 };
00117 
00118 #endif /* _PPGCOMM_H_ */