Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: MAX44000 PWM_Tone_Library nexpaq_mdk
Fork of LED_Demo by
m2mtimerpimpl.h
00001 /* 00002 * Copyright (c) 2015 ARM Limited. All rights reserved. 00003 * SPDX-License-Identifier: Apache-2.0 00004 * Licensed under the Apache License, Version 2.0 (the License); you may 00005 * not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an AS IS BASIS, WITHOUT 00012 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #ifndef M2M_TIMER_PIMPL_H__ 00018 #define M2M_TIMER_PIMPL_H__ 00019 00020 #include "ns_types.h" 00021 00022 #include "mbed-client/m2mtimerobserver.h" 00023 00024 class M2MTimerPimpl { 00025 private: 00026 00027 // Prevents the use of assignment operator 00028 M2MTimerPimpl& operator=(const M2MTimerPimpl& other); 00029 00030 // Prevents the use of copy constructor 00031 M2MTimerPimpl(const M2MTimerPimpl& other); 00032 public: 00033 00034 /** 00035 * Constructor. 00036 */ 00037 M2MTimerPimpl(M2MTimerObserver& _observer); 00038 00039 /** 00040 * Destructor. 00041 */ 00042 virtual ~M2MTimerPimpl(); 00043 00044 /** 00045 * Starts timer 00046 * @param interval Timer's interval in milliseconds 00047 * @param single_shot defines if timer is ticked 00048 * once or is it restarted everytime timer is expired. 00049 */ 00050 void start_timer(uint64_t interval, M2MTimerObserver::Type type, bool single_shot = true); 00051 00052 /** 00053 * @brief Starts timer in DTLS manner 00054 * @param intermediate_interval Intermediate interval to use, must be smaller than tiotal (usually 1/4 of total) 00055 * @param total_interval Total interval to use; This is the timeout value of a DTLS packet 00056 * @param type Type of the timer 00057 */ 00058 void start_dtls_timer(uint64_t intermediate_interval, uint64_t total_interval, M2MTimerObserver::Type type); 00059 00060 /** 00061 * Stops timer. 00062 * This cancels the ongoing timer. 00063 */ 00064 void stop_timer(); 00065 00066 /** 00067 * Callback function for timer completion. 00068 */ 00069 void timer_expired(); 00070 00071 /** 00072 * @brief Checks if the intermediate interval has passed 00073 * @return true if interval has passed, false otherwise 00074 */ 00075 bool is_intermediate_interval_passed(); 00076 00077 /** 00078 * @brief Checks if the total interval has passed 00079 * @return true if interval has passed, false otherwise 00080 */ 00081 bool is_total_interval_passed(); 00082 00083 inline int8_t get_timer_id() const; 00084 00085 private: 00086 00087 void start(); 00088 void cancel(); 00089 00090 private: 00091 M2MTimerObserver& _observer; 00092 bool _single_shot; 00093 uint64_t _interval; 00094 M2MTimerObserver::Type _type; 00095 00096 uint64_t _intermediate_interval; 00097 uint64_t _total_interval; 00098 uint8_t _status; 00099 bool _dtls_type; 00100 00101 // this is the timer-id of this object, used to map the 00102 // timer event callback to the correct object. 00103 int8_t _timer_id; 00104 00105 static int8_t _tasklet_id; 00106 static int8_t _next_timer_id; 00107 00108 friend class M2MTimer; 00109 }; 00110 00111 inline int8_t M2MTimerPimpl::get_timer_id() const 00112 { 00113 return _timer_id; 00114 } 00115 00116 #endif //M2M_TIMER_PIMPL_H__
Generated on Tue Jul 12 2022 12:28:39 by
