Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: oldheating gps motorhome heating
Diff: timer/timer.c
- Revision:
- 40:53666b1a5848
- Parent:
- 39:5b594b1b6a0a
- Child:
- 41:8cd859cd1475
--- a/timer/timer.c Mon Dec 03 12:50:10 2018 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-#include <stdint.h>
-#include <stdbool.h>
-
-#include "timer.h"
-
-#define TCR (*((volatile unsigned *) 0x40004004))
-#define TC (*((volatile unsigned *) 0x40004008))
-#define PR (*((volatile unsigned *) 0x4000400C))
-#define MCR (*((volatile unsigned *) 0x40004014))
-#define CTCR (*((volatile unsigned *) 0x40004070))
-
-uint32_t TimerCount()
-{
- return TC;
-}
-uint32_t TimerSinceRepetitive(uint32_t* pLastCount)
-{
- uint32_t thisCount = TC;
- uint32_t period = thisCount - *pLastCount;
- *pLastCount = thisCount;
- return period;
-}
-uint32_t TimerSinceCount(uint32_t lastCount)
-{
- return TC - lastCount;
-}
-uint32_t TimerSinceMs(uint32_t lastCount)
-{
- uint32_t count = TC - lastCount;
- return count / TIMER_COUNT_PER_MS;
-}
-
-bool TimerRepetitiveTick(uint32_t* pLastCount, uint32_t interval)
-{
- if (TC - *pLastCount >= interval) //All unsigned wrap around arithmetic
- {
- *pLastCount += interval;
- return true;
- }
- return false;
-}
-
-int32_t TimerMultiplyFractionalPart(int32_t value, uint32_t countSinceLast, uint32_t interval)
-{
- int64_t fraction;
-
- fraction = countSinceLast;
- fraction <<= 32;
- fraction /= interval;
-
- return (value * fraction) >> 32;
-}
-
-void TimerInit()
-{
- TCR = 2; // 21.6.2 Timer Control Register - Reset TC and PC.
- CTCR = 0; // 21.6.3 Count Control Register - Timer mode
- PR = 0; // 21.6.5 Prescale register - Don't prescale 96MHz clock (divide by PR+1).
- MCR = 0; // 21.6.8 Match Control Register - no interrupt or reset
- TCR = 1; // 21.6.2 Timer Control Register - Enable TC and PC
-}