FRDM K64F Metronome

Committer:
ram54288
Date:
Sun May 14 18:37:05 2017 +0000
Revision:
0:dbad57390bd1
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ram54288 0:dbad57390bd1 1 /*
ram54288 0:dbad57390bd1 2 * Copyright (c) 2015 ARM Limited. All rights reserved.
ram54288 0:dbad57390bd1 3 * SPDX-License-Identifier: Apache-2.0
ram54288 0:dbad57390bd1 4 * Licensed under the Apache License, Version 2.0 (the License); you may
ram54288 0:dbad57390bd1 5 * not use this file except in compliance with the License.
ram54288 0:dbad57390bd1 6 * You may obtain a copy of the License at
ram54288 0:dbad57390bd1 7 *
ram54288 0:dbad57390bd1 8 * http://www.apache.org/licenses/LICENSE-2.0
ram54288 0:dbad57390bd1 9 *
ram54288 0:dbad57390bd1 10 * Unless required by applicable law or agreed to in writing, software
ram54288 0:dbad57390bd1 11 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
ram54288 0:dbad57390bd1 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
ram54288 0:dbad57390bd1 13 * See the License for the specific language governing permissions and
ram54288 0:dbad57390bd1 14 * limitations under the License.
ram54288 0:dbad57390bd1 15 */
ram54288 0:dbad57390bd1 16 #ifndef M2M_TIMER_H
ram54288 0:dbad57390bd1 17 #define M2M_TIMER_H
ram54288 0:dbad57390bd1 18
ram54288 0:dbad57390bd1 19 #include <stdint.h>
ram54288 0:dbad57390bd1 20 #include "mbed-client/m2mtimerobserver.h"
ram54288 0:dbad57390bd1 21
ram54288 0:dbad57390bd1 22 class M2MTimerPimpl;
ram54288 0:dbad57390bd1 23
ram54288 0:dbad57390bd1 24 /*! \file m2mtimer.h
ram54288 0:dbad57390bd1 25 * \brief M2MTimer.
ram54288 0:dbad57390bd1 26 * Timer class for mbed client.
ram54288 0:dbad57390bd1 27 */
ram54288 0:dbad57390bd1 28 class M2MTimer
ram54288 0:dbad57390bd1 29 {
ram54288 0:dbad57390bd1 30 private:
ram54288 0:dbad57390bd1 31 // Prevents the use of assignment operator
ram54288 0:dbad57390bd1 32 M2MTimer& operator=(const M2MTimer& other);
ram54288 0:dbad57390bd1 33
ram54288 0:dbad57390bd1 34 // Prevents the use of copy constructor
ram54288 0:dbad57390bd1 35 M2MTimer(const M2MTimer& other);
ram54288 0:dbad57390bd1 36
ram54288 0:dbad57390bd1 37 public:
ram54288 0:dbad57390bd1 38
ram54288 0:dbad57390bd1 39 /**
ram54288 0:dbad57390bd1 40 * Constructor.
ram54288 0:dbad57390bd1 41 */
ram54288 0:dbad57390bd1 42 M2MTimer(M2MTimerObserver& observer);
ram54288 0:dbad57390bd1 43
ram54288 0:dbad57390bd1 44 /**
ram54288 0:dbad57390bd1 45 * Destructor.
ram54288 0:dbad57390bd1 46 */
ram54288 0:dbad57390bd1 47 ~M2MTimer();
ram54288 0:dbad57390bd1 48
ram54288 0:dbad57390bd1 49 /**
ram54288 0:dbad57390bd1 50 * \brief Starts the timer.
ram54288 0:dbad57390bd1 51 * \param interval The timer interval in milliseconds.
ram54288 0:dbad57390bd1 52 * \param single_shot Defines whether the timer is ticked once or restarted every time at expiry.
ram54288 0:dbad57390bd1 53 */
ram54288 0:dbad57390bd1 54 void start_timer(uint64_t interval, M2MTimerObserver::Type type, bool single_shot = true);
ram54288 0:dbad57390bd1 55
ram54288 0:dbad57390bd1 56 /**
ram54288 0:dbad57390bd1 57 * \brief Starts the timer in DTLS manner.
ram54288 0:dbad57390bd1 58 * \param intermediate_interval The intermediate interval to use, must be smaller than total (usually 1/4 of total).
ram54288 0:dbad57390bd1 59 * \param total_interval The total interval to use; This is the timeout value of a DTLS packet.
ram54288 0:dbad57390bd1 60 * \param type The type of the timer.
ram54288 0:dbad57390bd1 61 */
ram54288 0:dbad57390bd1 62 void start_dtls_timer(uint64_t intermediate_interval, uint64_t total_interval, M2MTimerObserver::Type type = M2MTimerObserver::Dtls);
ram54288 0:dbad57390bd1 63
ram54288 0:dbad57390bd1 64 /**
ram54288 0:dbad57390bd1 65 * \brief Stops the timer.
ram54288 0:dbad57390bd1 66 * This cancels the ongoing timer.
ram54288 0:dbad57390bd1 67 */
ram54288 0:dbad57390bd1 68 void stop_timer();
ram54288 0:dbad57390bd1 69
ram54288 0:dbad57390bd1 70 /**
ram54288 0:dbad57390bd1 71 * \brief Checks if the intermediate interval has passed.
ram54288 0:dbad57390bd1 72 * \return True if the interval has passed, else false.
ram54288 0:dbad57390bd1 73 */
ram54288 0:dbad57390bd1 74 bool is_intermediate_interval_passed();
ram54288 0:dbad57390bd1 75
ram54288 0:dbad57390bd1 76 /**
ram54288 0:dbad57390bd1 77 * \brief Checks if the total interval has passed.
ram54288 0:dbad57390bd1 78 * \return True if the interval has passed, else false.
ram54288 0:dbad57390bd1 79 */
ram54288 0:dbad57390bd1 80 bool is_total_interval_passed();
ram54288 0:dbad57390bd1 81
ram54288 0:dbad57390bd1 82 private:
ram54288 0:dbad57390bd1 83
ram54288 0:dbad57390bd1 84 M2MTimerObserver& _observer;
ram54288 0:dbad57390bd1 85 M2MTimerPimpl *_private_impl;
ram54288 0:dbad57390bd1 86 friend class Test_M2MTimerImpl_linux;
ram54288 0:dbad57390bd1 87 };
ram54288 0:dbad57390bd1 88
ram54288 0:dbad57390bd1 89 #endif // M2M_TIMER_H