SmartMesh QSL for STM32F4 version

Fork of COG-AD4050_QSL by APS Lab

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers dn_time.cpp Source File

dn_time.cpp

00001 /*
00002 Copyright (c) 2016, Dust Networks. All rights reserved.
00003 
00004 Port of the time module to the NUCLEO-L053R8.
00005 
00006 \license See attached DN_LICENSE.txt.
00007 */
00008 
00009 #include "dn_time.h"
00010 #include "mbed.h"
00011 #include "millis.h"
00012 #include "dn_debug.h"
00013 
00014 //=========================== defines =========================================
00015 
00016 
00017 //=========================== variables =======================================
00018 
00019 
00020 //=========================== prototypes ======================================
00021 
00022 
00023 //=========================== public ==========================================
00024 
00025 uint32_t dn_time_ms(void)
00026 {
00027     /*
00028     A simple library that utilize SysTick is used instead of the mbed Timer
00029     class, as the latter is based on 32-bit microsecond counter and thus
00030     overflows long before 32-bits of milliseconds are used.
00031     */
00032     uint32_t ms = millis();
00033     return ms;
00034 }
00035 
00036 void dn_sleep_ms(uint32_t milliseconds)
00037 {
00038      /*
00039      A simple delay is used for simplicity in this example.
00040      To save power, we could instead have initialized a timer to fire an
00041      interrupt after the set number of milliseconds, followed by entering
00042      a low-power sleep mode. Upon wake up, we would have to check that we
00043      were indeed woken by said interrupt (and e.g. not an USART interrupt)
00044      to decide if we should go back to sleep or not.
00045      */
00046      wait_ms(milliseconds);
00047 }
00048 
00049 //=========================== private =========================================
00050 
00051 
00052 //=========================== helpers =========================================
00053