Changes to enabled on-line compiler

Committer:
JMF
Date:
Wed May 30 20:59:51 2018 +0000
Revision:
0:082731ede69f
Initial commit

Who changed what in which revision?

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