20200716 read Status Register each second

Dependencies:   SDFileSystem mbed-os-example-ble-GattServer max32630fthr

Committer:
aureliocarella
Date:
Thu Jul 16 14:59:04 2020 +0000
Revision:
21:51e162c130a9
20200716

Who changed what in which revision?

UserRevisionLine numberNew contents of line
aureliocarella 21:51e162c130a9 1 /*******************************************************************************
aureliocarella 21:51e162c130a9 2 * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
aureliocarella 21:51e162c130a9 3 *
aureliocarella 21:51e162c130a9 4 * Permission is hereby granted, free of charge, to any person obtaining a
aureliocarella 21:51e162c130a9 5 * copy of this software and associated documentation files (the "Software"),
aureliocarella 21:51e162c130a9 6 * to deal in the Software without restriction, including without limitation
aureliocarella 21:51e162c130a9 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
aureliocarella 21:51e162c130a9 8 * and/or sell copies of the Software, and to permit persons to whom the
aureliocarella 21:51e162c130a9 9 * Software is furnished to do so, subject to the following conditions:
aureliocarella 21:51e162c130a9 10 *
aureliocarella 21:51e162c130a9 11 * The above copyright notice and this permission notice shall be included
aureliocarella 21:51e162c130a9 12 * in all copies or substantial portions of the Software.
aureliocarella 21:51e162c130a9 13 *
aureliocarella 21:51e162c130a9 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
aureliocarella 21:51e162c130a9 15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
aureliocarella 21:51e162c130a9 16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
aureliocarella 21:51e162c130a9 17 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
aureliocarella 21:51e162c130a9 18 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
aureliocarella 21:51e162c130a9 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
aureliocarella 21:51e162c130a9 20 * OTHER DEALINGS IN THE SOFTWARE.
aureliocarella 21:51e162c130a9 21 *
aureliocarella 21:51e162c130a9 22 * Except as contained in this notice, the name of Maxim Integrated
aureliocarella 21:51e162c130a9 23 * Products, Inc. shall not be used except as stated in the Maxim Integrated
aureliocarella 21:51e162c130a9 24 * Products, Inc. Branding Policy.
aureliocarella 21:51e162c130a9 25 *
aureliocarella 21:51e162c130a9 26 * The mere transfer of this software does not imply any licenses
aureliocarella 21:51e162c130a9 27 * of trade secrets, proprietary technology, copyrights, patents,
aureliocarella 21:51e162c130a9 28 * trademarks, maskwork rights, or any other form of intellectual
aureliocarella 21:51e162c130a9 29 * property whatsoever. Maxim Integrated Products, Inc. retains all
aureliocarella 21:51e162c130a9 30 * ownership rights.
aureliocarella 21:51e162c130a9 31 *******************************************************************************
aureliocarella 21:51e162c130a9 32 */
aureliocarella 21:51e162c130a9 33 #ifndef _DEVICE_LOGGING_H_
aureliocarella 21:51e162c130a9 34 #define _DEVICE_LOGGING_H_
aureliocarella 21:51e162c130a9 35
aureliocarella 21:51e162c130a9 36 #include "mbed.h"
aureliocarella 21:51e162c130a9 37
aureliocarella 21:51e162c130a9 38 /**
aureliocarella 21:51e162c130a9 39 * @brief Class that is used to store device logging parameters when logging to
aureliocarella 21:51e162c130a9 40 * flash or streaming usb
aureliocarella 21:51e162c130a9 41 */
aureliocarella 21:51e162c130a9 42 class Device_Logging {
aureliocarella 21:51e162c130a9 43 public:
aureliocarella 21:51e162c130a9 44 /**
aureliocarella 21:51e162c130a9 45 * @brief Check if logging is enabled for this device
aureliocarella 21:51e162c130a9 46 */
aureliocarella 21:51e162c130a9 47 int isLoggingEnabled(void);
aureliocarella 21:51e162c130a9 48 /**
aureliocarella 21:51e162c130a9 49 * @brief Returns the sample rate for the device, rate is in seconds
aureliocarella 21:51e162c130a9 50 */
aureliocarella 21:51e162c130a9 51 int getLoggingSampleRate(void);
aureliocarella 21:51e162c130a9 52 /**
aureliocarella 21:51e162c130a9 53 * @brief Initialize the sampling rate for the device
aureliocarella 21:51e162c130a9 54 * @param sampleRate Rate to log device output in seconds
aureliocarella 21:51e162c130a9 55 */
aureliocarella 21:51e162c130a9 56 void initStart(int sampleRate);
aureliocarella 21:51e162c130a9 57 /**
aureliocarella 21:51e162c130a9 58 * @brief Gets a value that represents when device needs to be sampled again,
aureliocarella 21:51e162c130a9 59 * used for datalogging and usb streaming
aureliocarella 21:51e162c130a9 60 */
aureliocarella 21:51e162c130a9 61 int getNextSampleTime(void);
aureliocarella 21:51e162c130a9 62 /**
aureliocarella 21:51e162c130a9 63 * @brief Sets a value that represents when device needs to be sampled again,
aureliocarella 21:51e162c130a9 64 * used for datalogging and usb streaming
aureliocarella 21:51e162c130a9 65 * @param time Time for next sample in seconds, time is relative to a timer
aureliocarella 21:51e162c130a9 66 */
aureliocarella 21:51e162c130a9 67 void setNextSampleTime(int time);
aureliocarella 21:51e162c130a9 68 /**
aureliocarella 21:51e162c130a9 69 * @brief Disables further datalog and streaming sampling for the device
aureliocarella 21:51e162c130a9 70 * @param time Time for next sample in seconds, time is relative to a timer
aureliocarella 21:51e162c130a9 71 */
aureliocarella 21:51e162c130a9 72 void stop(void);
aureliocarella 21:51e162c130a9 73
aureliocarella 21:51e162c130a9 74 private:
aureliocarella 21:51e162c130a9 75 /// The sample rate in seconds
aureliocarella 21:51e162c130a9 76 int sampleRate;
aureliocarella 21:51e162c130a9 77 /// If logging is enabled or not
aureliocarella 21:51e162c130a9 78 int enabled;
aureliocarella 21:51e162c130a9 79 /// Bookkeeping var to keep track of the next sample time
aureliocarella 21:51e162c130a9 80 int nextSampleTime;
aureliocarella 21:51e162c130a9 81 };
aureliocarella 21:51e162c130a9 82
aureliocarella 21:51e162c130a9 83 #endif /* _DEVICE_LOGGING_H_ */
aureliocarella 21:51e162c130a9 84