test

Committer:
peyo
Date:
Wed Apr 12 14:07:09 2017 +0200
Revision:
0:cd5404401c2f
first commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
peyo 0:cd5404401c2f 1 /*******************************************************************************
peyo 0:cd5404401c2f 2 * Copyright (c) 2014 IBM Corp.
peyo 0:cd5404401c2f 3 *
peyo 0:cd5404401c2f 4 * All rights reserved. This program and the accompanying materials
peyo 0:cd5404401c2f 5 * are made available under the terms of the Eclipse Public License v1.0
peyo 0:cd5404401c2f 6 * and Eclipse Distribution License v1.0 which accompany this distribution.
peyo 0:cd5404401c2f 7 *
peyo 0:cd5404401c2f 8 * The Eclipse Public License is available at
peyo 0:cd5404401c2f 9 * http://www.eclipse.org/legal/epl-v10.html
peyo 0:cd5404401c2f 10 * and the Eclipse Distribution License is available at
peyo 0:cd5404401c2f 11 * http://www.eclipse.org/org/documents/edl-v10.php.
peyo 0:cd5404401c2f 12 *
peyo 0:cd5404401c2f 13 * Contributors:
peyo 0:cd5404401c2f 14 * Allan Stockdill-Mander - initial API and implementation and/or initial documentation
peyo 0:cd5404401c2f 15 *******************************************************************************/
peyo 0:cd5404401c2f 16
peyo 0:cd5404401c2f 17 /**
peyo 0:cd5404401c2f 18 * @file timer_interface.h
peyo 0:cd5404401c2f 19 * @brief Timer interface definition for MQTT client.
peyo 0:cd5404401c2f 20 *
peyo 0:cd5404401c2f 21 * Defines an interface to timers that can be used by other system
peyo 0:cd5404401c2f 22 * components. MQTT client requires timers to handle timeouts and
peyo 0:cd5404401c2f 23 * MQTT keep alive.
peyo 0:cd5404401c2f 24 * Starting point for porting the SDK to the timer hardware layer of a new platform.
peyo 0:cd5404401c2f 25 */
peyo 0:cd5404401c2f 26
peyo 0:cd5404401c2f 27 #ifndef __TIMER_INTERFACE_H_
peyo 0:cd5404401c2f 28 #define __TIMER_INTERFACE_H_
peyo 0:cd5404401c2f 29
peyo 0:cd5404401c2f 30 #ifdef __cplusplus
peyo 0:cd5404401c2f 31 extern "C" {
peyo 0:cd5404401c2f 32 #endif
peyo 0:cd5404401c2f 33
peyo 0:cd5404401c2f 34 /**
peyo 0:cd5404401c2f 35 * The platform specific timer header that defines the Timer struct
peyo 0:cd5404401c2f 36 */
peyo 0:cd5404401c2f 37 #include "timer_platform.h"
peyo 0:cd5404401c2f 38
peyo 0:cd5404401c2f 39 #include <stdint.h>
peyo 0:cd5404401c2f 40 #include <stdbool.h>
peyo 0:cd5404401c2f 41
peyo 0:cd5404401c2f 42 /**
peyo 0:cd5404401c2f 43 * @brief Timer Type
peyo 0:cd5404401c2f 44 *
peyo 0:cd5404401c2f 45 * Forward declaration of a timer struct. The definition of this struct is
peyo 0:cd5404401c2f 46 * platform dependent. When porting to a new platform add this definition
peyo 0:cd5404401c2f 47 * in "timer_<platform>.h" and include that file above.
peyo 0:cd5404401c2f 48 *
peyo 0:cd5404401c2f 49 */
peyo 0:cd5404401c2f 50 //typedef struct Timer Timer;
peyo 0:cd5404401c2f 51 typedef TimerExt TimerAWS;
peyo 0:cd5404401c2f 52
peyo 0:cd5404401c2f 53 /**
peyo 0:cd5404401c2f 54 * @brief Check if a timer is expired
peyo 0:cd5404401c2f 55 *
peyo 0:cd5404401c2f 56 * Call this function passing in a timer to check if that timer has expired.
peyo 0:cd5404401c2f 57 *
peyo 0:cd5404401c2f 58 * @param Timer - pointer to the timer to be checked for expiration
peyo 0:cd5404401c2f 59 * @return bool - true = timer expired, false = timer not expired
peyo 0:cd5404401c2f 60 */
peyo 0:cd5404401c2f 61 bool has_timer_expired(TimerAWS *);
peyo 0:cd5404401c2f 62
peyo 0:cd5404401c2f 63 /**
peyo 0:cd5404401c2f 64 * @brief Create a timer (milliseconds)
peyo 0:cd5404401c2f 65 *
peyo 0:cd5404401c2f 66 * Sets the timer to expire in a specified number of milliseconds.
peyo 0:cd5404401c2f 67 *
peyo 0:cd5404401c2f 68 * @param Timer - pointer to the timer to be set to expire in milliseconds
peyo 0:cd5404401c2f 69 * @param uint32_t - set the timer to expire in this number of milliseconds
peyo 0:cd5404401c2f 70 */
peyo 0:cd5404401c2f 71 void countdown_ms(TimerAWS *, uint32_t);
peyo 0:cd5404401c2f 72
peyo 0:cd5404401c2f 73 /**
peyo 0:cd5404401c2f 74 * @brief Create a timer (seconds)
peyo 0:cd5404401c2f 75 *
peyo 0:cd5404401c2f 76 * Sets the timer to expire in a specified number of seconds.
peyo 0:cd5404401c2f 77 *
peyo 0:cd5404401c2f 78 * @param Timer - pointer to the timer to be set to expire in seconds
peyo 0:cd5404401c2f 79 * @param uint32_t - set the timer to expire in this number of seconds
peyo 0:cd5404401c2f 80 */
peyo 0:cd5404401c2f 81 void countdown_sec(TimerAWS *, uint32_t);
peyo 0:cd5404401c2f 82
peyo 0:cd5404401c2f 83 /**
peyo 0:cd5404401c2f 84 * @brief Check the time remaining on a given timer
peyo 0:cd5404401c2f 85 *
peyo 0:cd5404401c2f 86 * Checks the input timer and returns the number of milliseconds remaining on the timer.
peyo 0:cd5404401c2f 87 *
peyo 0:cd5404401c2f 88 * @param Timer - pointer to the timer to be set to checked
peyo 0:cd5404401c2f 89 * @return int - milliseconds left on the countdown timer
peyo 0:cd5404401c2f 90 */
peyo 0:cd5404401c2f 91 uint32_t left_ms(TimerAWS *);
peyo 0:cd5404401c2f 92
peyo 0:cd5404401c2f 93 /**
peyo 0:cd5404401c2f 94 * @brief Initialize a timer
peyo 0:cd5404401c2f 95 *
peyo 0:cd5404401c2f 96 * Performs any initialization required to the timer passed in.
peyo 0:cd5404401c2f 97 *
peyo 0:cd5404401c2f 98 * @param Timer - pointer to the timer to be initialized
peyo 0:cd5404401c2f 99 */
peyo 0:cd5404401c2f 100 void init_timer(TimerAWS *);
peyo 0:cd5404401c2f 101
peyo 0:cd5404401c2f 102 #ifdef __cplusplus
peyo 0:cd5404401c2f 103 }
peyo 0:cd5404401c2f 104 #endif
peyo 0:cd5404401c2f 105
peyo 0:cd5404401c2f 106 #endif //__TIMER_INTERFACE_H_