Sam
millis.cpp@2:611a5eb132a1, 2020-09-13 (annotated)
- Committer:
- s0313045
- Date:
- Sun Sep 13 04:30:54 2020 +0000
- Revision:
- 2:611a5eb132a1
- Parent:
- 0:502b364c9f1d
by Sam
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
s0313045 | 0:502b364c9f1d | 1 | #include "mbed.h" |
s0313045 | 0:502b364c9f1d | 2 | #include "millis.h" |
s0313045 | 0:502b364c9f1d | 3 | /* |
s0313045 | 0:502b364c9f1d | 4 | millis.cpp |
s0313045 | 0:502b364c9f1d | 5 | Copyright (c) 2016 Zoltan Hudak <hudakz@inbox.com> |
s0313045 | 0:502b364c9f1d | 6 | All rights reserved. |
s0313045 | 0:502b364c9f1d | 7 | |
s0313045 | 0:502b364c9f1d | 8 | This program is free software: you can redistribute it and/or modify |
s0313045 | 0:502b364c9f1d | 9 | it under the terms of the GNU General Public License as published by |
s0313045 | 0:502b364c9f1d | 10 | the Free Software Foundation, either version 3 of the License, or |
s0313045 | 0:502b364c9f1d | 11 | (at your option) any later version. |
s0313045 | 0:502b364c9f1d | 12 | |
s0313045 | 0:502b364c9f1d | 13 | This program is distributed in the hope that it will be useful, |
s0313045 | 0:502b364c9f1d | 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
s0313045 | 0:502b364c9f1d | 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
s0313045 | 0:502b364c9f1d | 16 | GNU General Public License for more details. |
s0313045 | 0:502b364c9f1d | 17 | |
s0313045 | 0:502b364c9f1d | 18 | You should have received a copy of the GNU General Public License |
s0313045 | 0:502b364c9f1d | 19 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
s0313045 | 0:502b364c9f1d | 20 | */ |
s0313045 | 0:502b364c9f1d | 21 | |
s0313045 | 0:502b364c9f1d | 22 | volatile unsigned long _millis; |
s0313045 | 0:502b364c9f1d | 23 | |
s0313045 | 0:502b364c9f1d | 24 | void millisStart(void) { |
s0313045 | 0:502b364c9f1d | 25 | SysTick_Config(SystemCoreClock / 1000); |
s0313045 | 0:502b364c9f1d | 26 | } |
s0313045 | 0:502b364c9f1d | 27 | |
s0313045 | 0:502b364c9f1d | 28 | extern "C" void SysTick_Handler(void) { |
s0313045 | 0:502b364c9f1d | 29 | _millis++; |
s0313045 | 0:502b364c9f1d | 30 | } |
s0313045 | 0:502b364c9f1d | 31 | |
s0313045 | 0:502b364c9f1d | 32 | unsigned long millis(void) { |
s0313045 | 0:502b364c9f1d | 33 | return _millis; |
s0313045 | 0:502b364c9f1d | 34 | } |
s0313045 | 0:502b364c9f1d | 35 | |
s0313045 | 0:502b364c9f1d | 36 |