Arduino-like millis() function.

Dependents:   QSL_SimplePublish MAX30100_FirstTry MAX30100_FirstTry MAX30100_V04 ... more

Arduino-like millis() function.

Returns the number of milliseconds elapsed since the millisStart() function has been called.
It will roll over back to zero after roughly 49.7 days.
If you would like to create short term timers or to trigger short term events then consider to use Timer, Timeout, Ticker, wait or us_ticker_read. For more details have a look at the Handbook.
In case you are looking for scheduling of long term events then you could be interested also in the RTC library or the Clock library.

Example of use:

#include "mbed.h"
#include "millis.h"

Serial  pc(USBTX, USBRX);

int main() {
    millisStart();
    while(1) {
        pc.printf("millis = %d\r\n", millis());        
        wait(1.0);
    }
}


NOTE: Make sure you call millisStart() before using millis().

Warning

Works only on mbed boards equipped with SysTick!

millis.h

Committer:
hudakz
Date:
2016-06-02
Revision:
2:ac7586424119
Parent:
1:69c49c2be760

File content as of revision 2:ac7586424119:

#ifndef MILLIS_H
#define MILLIS_H
/*
 millis.h
 Copyright (c) 2016 Zoltan Hudak <hudakz@inbox.com>
 All rights reserved.

 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */

void           millisStart(void);
unsigned long  millis(void);

#endif