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.
ecl_timer.h
00001 /****************************************************************************** 00002 The MIT License(MIT) 00003 00004 Embedded Template Library. 00005 https://github.com/ETLCPP/etl 00006 https://www.etlcpp.com 00007 00008 Copyright(c) 2017 jwellbelove 00009 00010 Permission is hereby granted, free of charge, to any person obtaining a copy 00011 of this software and associated documentation files(the "Software"), to deal 00012 in the Software without restriction, including without limitation the rights 00013 to use, copy, modify, merge, publish, distribute, sublicense, and / or sell 00014 copies of the Software, and to permit persons to whom the Software is 00015 furnished to do so, subject to the following conditions : 00016 00017 The above copyright notice and this permission notice shall be included in all 00018 copies or substantial portions of the Software. 00019 00020 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00021 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00022 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE 00023 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00024 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00025 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 00026 SOFTWARE. 00027 ******************************************************************************/ 00028 00029 #ifndef __ETL_C_TIMER_FRAMEWORK__ 00030 #define __ETL_C_TIMER_FRAMEWORK__ 00031 00032 #include <stdint.h> 00033 00034 #include "ecl_user.h" 00035 00036 // Pass/fail results. 00037 enum 00038 { 00039 ECL_TIMER_FAIL = 0, 00040 ECL_TIMER_PASS = 1, 00041 }; 00042 00043 typedef int ecl_timer_result_t; 00044 00045 // Enable states. 00046 enum 00047 { 00048 ECL_TIMER_DISABLED = ECL_TIMER_FAIL, 00049 ECL_TIMER_ENABLED = ECL_TIMER_PASS 00050 }; 00051 00052 typedef int ecl_timer_enable_t; 00053 00054 // Timer modes. 00055 enum 00056 { 00057 ECL_TIMER_SINGLE_SHOT = 0, 00058 ECL_TIMER_REPEATING = 1 00059 }; 00060 00061 typedef char ecl_timer_mode_t; 00062 00063 // Timer start action. 00064 enum 00065 { 00066 ECL_TIMER_START_DELAYED = 0, 00067 ECL_TIMER_START_IMMEDIATE = 1 00068 }; 00069 00070 typedef char ecl_timer_start_t; 00071 00072 // Timer identifiers. 00073 enum 00074 { 00075 ECL_TIMER_NO_TIMER = 255 00076 }; 00077 00078 typedef uint_least8_t ecl_timer_id_t; 00079 00080 // Timer times. 00081 #define ECL_TIMER_INACTIVE 0xFFFFFFFF 00082 00083 typedef uint32_t ecl_timer_time_t; 00084 00085 //************************************************************************* 00086 /// The configuration of a timer. 00087 //************************************************************************* 00088 struct ecl_timer_config 00089 { 00090 void (*pcallback)(); 00091 ecl_timer_time_t period; 00092 ecl_timer_time_t delta; 00093 ecl_timer_id_t id; 00094 uint_least8_t previous; 00095 uint_least8_t next; 00096 char repeating; 00097 }; 00098 00099 //************************************************************************* 00100 /// The API. 00101 //************************************************************************* 00102 void ecl_timer_data_init_default(struct ecl_timer_config* ptimer_data_); 00103 void ecl_timer_data_init(struct ecl_timer_config* ptimer_data_, ecl_timer_id_t id_, void(*pcallback_)(), ecl_timer_time_t period_, ecl_timer_mode_t repeating_); 00104 ecl_timer_result_t ecl_timer_is_active(struct ecl_timer_config* ptimer_data_); 00105 void ecl_set_timer_inactive(struct ecl_timer_config* ptimer_data_); 00106 void ecl_timer_init(struct ecl_timer_config* ptimers_, uint_least8_t max_timers_); 00107 ecl_timer_id_t ecl_timer_register(void(*pcallback_)(), ecl_timer_time_t period_, ecl_timer_mode_t repeating_); 00108 ecl_timer_result_t ecl_timer_unregister(ecl_timer_id_t id_); 00109 void ecl_timer_enable(ecl_timer_enable_t state_); 00110 ecl_timer_result_t ecl_timer_is_running(void); 00111 void ecl_timer_clear(void); 00112 ecl_timer_result_t ecl_timer_tick(uint32_t count); 00113 ecl_timer_result_t ecl_timer_start(ecl_timer_id_t id_, ecl_timer_start_t immediate_); 00114 ecl_timer_result_t ecl_timer_stop(ecl_timer_id_t id_); 00115 ecl_timer_result_t ecl_timer_set_period(ecl_timer_id_t id_, ecl_timer_time_t period_); 00116 ecl_timer_result_t ecl_timer_set_mode(ecl_timer_id_t id_, ecl_timer_mode_t repeating_); 00117 00118 #endif 00119
Generated on Tue Jul 12 2022 14:05:40 by
