V.06 11/3

Dependencies:   FT6206 SDFileSystem SPI_TFT_ILI9341 TFT_fonts

Fork of ATT_AWS_IoT_demo by attiot

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers timer_interface.h Source File

timer_interface.h

Go to the documentation of this file.
00001 /*******************************************************************************
00002  * Copyright (c) 2014 IBM Corp.
00003  *
00004  * All rights reserved. This program and the accompanying materials
00005  * are made available under the terms of the Eclipse Public License v1.0
00006  * and Eclipse Distribution License v1.0 which accompany this distribution.
00007  *
00008  * The Eclipse Public License is available at
00009  *    http://www.eclipse.org/legal/epl-v10.html
00010  * and the Eclipse Distribution License is available at
00011  *   http://www.eclipse.org/org/documents/edl-v10.php.
00012  *
00013  * Contributors:
00014  *    Allan Stockdill-Mander - initial API and implementation and/or initial documentation
00015  *******************************************************************************/
00016 
00017 /**
00018  * @file timer_interface.h
00019  * @brief Timer interface definition for MQTT client.
00020  *
00021  * Defines an interface to timers that can be used by other system
00022  * components.  MQTT client requires timers to handle timeouts and
00023  * MQTT keep alive.
00024  * Starting point for porting the SDK to the timer hardware layer of a new platform.
00025  */
00026 
00027 #ifndef __TIMER_INTERFACE_H_
00028 #define __TIMER_INTERFACE_H_
00029 
00030 #ifdef __cplusplus
00031 extern "C" {
00032 #endif
00033 
00034 /**
00035  * The platform specific timer header that defines the Timer struct
00036  */
00037 #include "timer_platform.h"
00038 
00039 #include <stdint.h>
00040 #include <stdbool.h>
00041 
00042 /**
00043  * @brief Timer Type
00044  *
00045  * Forward declaration of a timer struct.  The definition of this struct is
00046  * platform dependent.  When porting to a new platform add this definition
00047  * in "timer_<platform>.h" and include that file above.
00048  *
00049  */
00050 //typedef mbed::Timer Timer;
00051 typedef TimerExt Timer;
00052 
00053 char expired(Timer* timer);
00054 void countdown(Timer* timer, unsigned int timeout);
00055 void InitTimer(Timer* timer);
00056 
00057 /**
00058  * @brief Check if a timer is expired
00059  *
00060  * Call this function passing in a timer to check if that timer has expired.
00061  *
00062  * @param Timer - pointer to the timer to be checked for expiration
00063  * @return bool - true = timer expired, false = timer not expired
00064  */
00065 bool has_timer_expired(Timer *);
00066 
00067 /**
00068  * @brief Create a timer (milliseconds)
00069  *
00070  * Sets the timer to expire in a specified number of milliseconds.
00071  *
00072  * @param Timer - pointer to the timer to be set to expire in milliseconds
00073  * @param uint32_t - set the timer to expire in this number of milliseconds
00074  */
00075 void countdown_ms(Timer *, uint32_t);
00076 
00077 /**
00078  * @brief Create a timer (seconds)
00079  *
00080  * Sets the timer to expire in a specified number of seconds.
00081  *
00082  * @param Timer - pointer to the timer to be set to expire in seconds
00083  * @param uint32_t - set the timer to expire in this number of seconds
00084  */
00085 void countdown_sec(Timer *, uint32_t);
00086 
00087 /**
00088  * @brief Check the time remaining on a given timer
00089  *
00090  * Checks the input timer and returns the number of milliseconds remaining on the timer.
00091  *
00092  * @param Timer - pointer to the timer to be set to checked
00093  * @return int - milliseconds left on the countdown timer
00094  */
00095 uint32_t left_ms(Timer *);
00096 
00097 /**
00098  * @brief Initialize a timer
00099  *
00100  * Performs any initialization required to the timer passed in.
00101  *
00102  * @param Timer - pointer to the timer to be initialized
00103  */
00104 void init_timer(Timer *);
00105 
00106 #ifdef __cplusplus
00107 }
00108 #endif
00109 
00110 #endif //__TIMER_INTERFACE_H_
00111 
00112 
00113