Sigfox Communication library, allowing you to use any kind of UART able Sigfox Transmitter
Dependents: TestVirtualisation
millis.cpp@3:3ef537a95c15, 2019-01-15 (annotated)
- Committer:
- Sidibe
- Date:
- Tue Jan 15 15:18:38 2019 +0000
- Revision:
- 3:3ef537a95c15
- Parent:
- 0:996eb84c895e
bonjour
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
adrien3d | 0:996eb84c895e | 1 | /******************************************************************************* |
adrien3d | 0:996eb84c895e | 2 | * This file is part of the millis library. * |
adrien3d | 0:996eb84c895e | 3 | * * |
adrien3d | 0:996eb84c895e | 4 | * millis is free software: you can redistribute it and/or * |
adrien3d | 0:996eb84c895e | 5 | * modify it under the terms of the GNU General Public License as * |
adrien3d | 0:996eb84c895e | 6 | * published by the Free Software Foundation, either version 3 of * |
adrien3d | 0:996eb84c895e | 7 | * the License, or any later version. * |
adrien3d | 0:996eb84c895e | 8 | * * |
adrien3d | 0:996eb84c895e | 9 | * millis is distributed in the hope that it will be useful, * |
adrien3d | 0:996eb84c895e | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
adrien3d | 0:996eb84c895e | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
adrien3d | 0:996eb84c895e | 12 | * GNU Lesser General Public License for more details. * |
adrien3d | 0:996eb84c895e | 13 | * * |
adrien3d | 0:996eb84c895e | 14 | * millis is distributed in the hope that it will be useful, * |
adrien3d | 0:996eb84c895e | 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
adrien3d | 0:996eb84c895e | 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
adrien3d | 0:996eb84c895e | 17 | * GNU Lesser General Public License for more details. * |
adrien3d | 0:996eb84c895e | 18 | * * |
adrien3d | 0:996eb84c895e | 19 | * You should have received a copy of the GNU Lesser General Public * |
adrien3d | 0:996eb84c895e | 20 | * License along with millis. If not, see * |
adrien3d | 0:996eb84c895e | 21 | * <http://www.gnu.org/licenses/>. * |
adrien3d | 0:996eb84c895e | 22 | ******************************************************************************/ |
adrien3d | 0:996eb84c895e | 23 | |
adrien3d | 0:996eb84c895e | 24 | /* |
adrien3d | 0:996eb84c895e | 25 | * Copyright: DFRobot |
adrien3d | 0:996eb84c895e | 26 | * name: millis |
adrien3d | 0:996eb84c895e | 27 | * version: 1.0 |
adrien3d | 0:996eb84c895e | 28 | * Author: lisper (lisper.li@dfrobot.com) |
adrien3d | 0:996eb84c895e | 29 | * Date: 2014-10-30 |
adrien3d | 0:996eb84c895e | 30 | * Description: millis library for mbed |
adrien3d | 0:996eb84c895e | 31 | */ |
adrien3d | 0:996eb84c895e | 32 | |
adrien3d | 0:996eb84c895e | 33 | #include "mbed.h" |
adrien3d | 0:996eb84c895e | 34 | #include "millis.h" |
adrien3d | 0:996eb84c895e | 35 | |
adrien3d | 0:996eb84c895e | 36 | static volatile uint32_t millisValue = 0; |
adrien3d | 0:996eb84c895e | 37 | |
adrien3d | 0:996eb84c895e | 38 | static Ticker ticker; |
adrien3d | 0:996eb84c895e | 39 | |
adrien3d | 0:996eb84c895e | 40 | void millisTicker () |
adrien3d | 0:996eb84c895e | 41 | { |
adrien3d | 0:996eb84c895e | 42 | millisValue ++; |
adrien3d | 0:996eb84c895e | 43 | } |
adrien3d | 0:996eb84c895e | 44 | |
adrien3d | 0:996eb84c895e | 45 | uint32_t millis () |
adrien3d | 0:996eb84c895e | 46 | { |
adrien3d | 0:996eb84c895e | 47 | return millisValue; |
adrien3d | 0:996eb84c895e | 48 | } |
adrien3d | 0:996eb84c895e | 49 | |
adrien3d | 0:996eb84c895e | 50 | void setMillis (uint32_t theValue) { |
adrien3d | 0:996eb84c895e | 51 | millisValue = theValue; |
adrien3d | 0:996eb84c895e | 52 | } |
adrien3d | 0:996eb84c895e | 53 | |
adrien3d | 0:996eb84c895e | 54 | void startMillis () { |
adrien3d | 0:996eb84c895e | 55 | ticker.attach (millisTicker, 0.001); |
adrien3d | 0:996eb84c895e | 56 | } |
adrien3d | 0:996eb84c895e | 57 | |
adrien3d | 0:996eb84c895e | 58 | void stopMillis () { |
adrien3d | 0:996eb84c895e | 59 | ticker.detach (); |
adrien3d | 0:996eb84c895e | 60 | } |
adrien3d | 0:996eb84c895e | 61 |