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