Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

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 public:
00031     LoRaWANTimeHandler();
00032     ~LoRaWANTimeHandler();
00033 
00034     /** Activates the timer subsystem.
00035      *
00036      * Embeds EventQueue object to timer subsystem which is subsequently
00037      * used to extract timer information.
00038      *
00039      * @param [in] queue  Handle to EventQueue object
00040      */
00041     void activate_timer_subsystem(events::EventQueue *queue);
00042 
00043     /** Read the current time.
00044      *
00045      * @return time The current time.
00046      */
00047     lorawan_time_t get_current_time(void);
00048 
00049     /** Return the time elapsed since a fixed moment in time.
00050      *
00051      * @param [in] saved_time    The fixed moment in time.
00052      * @return     time          The elapsed time.
00053      */
00054     lorawan_time_t get_elapsed_time(lorawan_time_t saved_time);
00055 
00056     /** Initializes the timer object.
00057      *
00058      * @remark The TimerSetValue function must be called before starting the timer.
00059      *         This function initializes the time-stamp and reloads the value at 0.
00060      *
00061      * @param [in] obj          The structure containing the timer object parameters.
00062      * @param [in] callback     The function callback called at the end of the timeout.
00063      */
00064     void init(timer_event_t &obj, mbed::Callback<void()> callback);
00065 
00066     /** Starts and adds the timer object to the list of timer events.
00067      *
00068      * @param [in] obj     The structure containing the timer object parameters.
00069      * @param [in] timeout The new timeout value.
00070      */
00071     void start(timer_event_t &obj, const uint32_t timeout);
00072 
00073     /** Stops and removes the timer object from the list of timer events.
00074      *
00075      * @param [in] obj The structure containing the timer object parameters.
00076      */
00077     void stop(timer_event_t &obj);
00078 
00079 private:
00080     events::EventQueue *_queue;
00081 };
00082 
00083 #endif // MBED_LORAWAN_SYS_TIMER_H__