Stefan Scholz / ETL
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers timer.h Source File

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_TIMER__
00030 #define __ETL_TIMER__
00031 
00032 #include <stdint.h>
00033 
00034 #include "platform.h "
00035 
00036 #include "atomic.h"
00037 
00038 //*****************************************************************************
00039 // Definitions common to timers.
00040 //*****************************************************************************
00041 
00042 namespace etl
00043 {
00044 #ifdef ETL_TIMER_SEMAPHORE_TYPE
00045   typedef ETL_TIMER_SEMAPHORE_TYPE timer_semaphore_t;
00046 #else
00047   typedef etl::atomic_uint32_t timer_semaphore_t;
00048 #endif
00049 
00050   //***************************************************************************
00051   /// Common definitions for the timer framework.
00052   //***************************************************************************
00053   struct timer
00054   {
00055     // Timer modes.
00056     struct mode
00057     {
00058       enum
00059       {
00060         SINGLE_SHOT = false,
00061         REPEATING   = true
00062       };
00063 
00064       typedef bool type;
00065     };
00066 
00067     // Timer start status.
00068     struct start
00069     {
00070       enum
00071       {
00072         DELAYED   = false,
00073         IMMEDIATE = true
00074       };
00075 
00076       typedef bool type;
00077     };
00078 
00079     // Timer id.
00080     struct id
00081     {
00082       enum
00083       {
00084         NO_TIMER = 255
00085       };
00086 
00087       typedef uint_least8_t type;
00088     };
00089 
00090     // Timer state.
00091     struct state
00092     {
00093       enum
00094       {
00095         INACTIVE = 0xFFFFFFFF
00096       };
00097     };
00098   };
00099 }
00100 
00101 #endif
00102