KRAI ITB GARUDAGO / Mbed 2 deprecated krai_roda2019

Dependencies:   mbed pid_dagoz

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers millis.cpp Source File

millis.cpp

00001 /*******************************************************************************
00002  * This file is part of the millis library.                                    *
00003  *                                                                             *
00004  * millis is free software: you can redistribute it and/or                     *
00005  * modify it under the terms of the GNU General Public License as              *
00006  * published by the Free Software Foundation, either version 3 of              *
00007  * the License, or any later version.                                          *
00008  *                                                                             *
00009  * millis is distributed in the hope that it will be useful,                   *
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of              *
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               *
00012  * GNU Lesser General Public License for more details.                         *
00013  *                                                                             *
00014  * millis is distributed in the hope that it will be useful,                   *
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of              *
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               *
00017  * GNU Lesser General Public License for more details.                         *
00018  *                                                                             *
00019  * You should have received a copy of the GNU Lesser General Public            *
00020  * License along with millis. If not, see                                      *
00021  * <http://www.gnu.org/licenses/>.                                             *
00022  ******************************************************************************/
00023 
00024 /*
00025  *  Copyright:  DFRobot
00026  *  name:       millis
00027  *  version:    1.0
00028  *  Author:     lisper (lisper.li@dfrobot.com)
00029  *  Date:       2014-10-30
00030  *  Description:    millis library for mbed
00031  */
00032 
00033 #include "mbed.h"
00034 #include "millis.h"
00035 
00036 static volatile uint32_t millisValue = 0;
00037 
00038 static  Ticker ticker;
00039 
00040 void millisTicker ()
00041 {
00042     millisValue ++;
00043 }
00044 
00045 uint32_t millis ()
00046 {
00047     return millisValue;
00048 }
00049 
00050 void setMillis (uint32_t theValue) {
00051     millisValue = theValue;
00052 }
00053 
00054 void startMillis () {
00055     ticker.attach (millisTicker, 0.001);    
00056 }
00057 
00058 void stopMillis () {
00059     ticker.detach ();
00060 }
00061