Knight KE / Mbed OS Game_Master
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers LoRaWANTimer.h Source File

LoRaWANTimer.h

00001 /**
00002  / _____)             _              | |
00003 ( (____  _____ ____ _| |_ _____  ____| |__
00004  \____ \| ___ |    (_   _) ___ |/ ___)  _ \
00005  _____) ) ____| | | || |_| ____( (___| | | |
00006 (______/|_____)_|_|_| \__)_____)\____)_| |_|
00007     (C)2013 Semtech
00008 
00009 Description: Timer objects and scheduling management
00010 
00011 License: Revised BSD License, see LICENSE.TXT file include in the project
00012 
00013 Maintainer: Miguel Luis and Gregory Cristian
00014 
00015 
00016 Copyright (c) 2017, Arm Limited and affiliates.
00017 
00018 SPDX-License-Identifier: BSD-3-Clause
00019 */
00020 
00021 #ifndef MBED_LORAWAN_SYS_TIMER_H__
00022 #define MBED_LORAWAN_SYS_TIMER_H__
00023 
00024 #include <stdint.h>
00025 #include "events/EventQueue.h"
00026 
00027 #include "lorawan_data_structures.h"
00028 
00029 class LoRaWANTimeHandler
00030 {
00031 public:
00032     LoRaWANTimeHandler();
00033     ~LoRaWANTimeHandler();
00034 
00035     /** Activates the timer subsystem.
00036      *
00037      * Embeds EventQueue object to timer subsystem which is subsequently
00038      * used to extract timer information.
00039      *
00040      * @param [in] queue  Handle to EventQueue object
00041      */
00042     void activate_timer_subsystem(events::EventQueue *queue);
00043 
00044     /** Read the current time.
00045      *
00046      * @return time The current time.
00047      */
00048     lorawan_time_t get_current_time(void);
00049 
00050     /** Return the time elapsed since a fixed moment in time.
00051      *
00052      * @param [in] saved_time    The fixed moment in time.
00053      * @return     time          The elapsed time.
00054      */
00055     lorawan_time_t get_elapsed_time(lorawan_time_t saved_time);
00056 
00057     /** Initializes the timer object.
00058      *
00059      * @remark The TimerSetValue function must be called before starting the timer.
00060      *         This function initializes the time-stamp and reloads the value at 0.
00061      *
00062      * @param [in] obj          The structure containing the timer object parameters.
00063      * @param [in] callback     The function callback called at the end of the timeout.
00064      */
00065      void init(timer_event_t &obj, mbed::Callback<void()> callback);
00066 
00067     /** Starts and adds the timer object to the list of timer events.
00068      *
00069      * @param [in] obj     The structure containing the timer object parameters.
00070      * @param [in] timeout The new timeout value.
00071      */
00072     void start(timer_event_t &obj, const uint32_t timeout);
00073 
00074     /** Stops and removes the timer object from the list of timer events.
00075      *
00076      * @param [in] obj The structure containing the timer object parameters.
00077      */
00078     void stop(timer_event_t &obj);
00079 
00080 private:
00081     events::EventQueue *_queue;
00082 };
00083 
00084 #endif // MBED_LORAWAN_SYS_TIMER_H__