Andrew Boyson / clock

Dependents:   oldheating gps motorhome heating

Files at this revision

API Documentation at this revision

Comitter:
andrewboyson
Date:
Wed Jan 17 20:42:14 2018 +0000
Parent:
18:207dd1474cd9
Child:
20:62e0760cae13
Commit message:
Moved power enable out of init. Added timer functions.

Changed in this revision

clock.h Show annotated file Show diff for this revision Revisions of this file
tick.c Show annotated file Show diff for this revision Revisions of this file
tick.h Show annotated file Show diff for this revision Revisions of this file
--- a/clock.h	Tue Jan 16 17:38:12 2018 +0000
+++ b/clock.h	Wed Jan 17 20:42:14 2018 +0000
@@ -1,3 +1,4 @@
+#include <stdbool.h>
 #include <stdint.h>
 #include <time.h>
 
--- a/tick.c	Tue Jan 16 17:38:12 2018 +0000
+++ b/tick.c	Wed Jan 17 20:42:14 2018 +0000
@@ -112,7 +112,6 @@
     slew = 0;
     nsCountIsSet = false;
     
-    LPC_SC->PCONP    |=     4; //  4.8.9 Power Control for Peripherals register - Timer1 Power On
     LPC_TIM1->TCR     =     2; // 21.6.2 Timer Control Register - Reset TC and PC.
     LPC_TIM1->CTCR    =     0; // 21.6.3 Count Control Register - Timer mode
     LPC_TIM1->PR      =     0; // 21.6.5 Prescale register      - Don't prescale 96MHz clock (divide by PR+1).
@@ -126,3 +125,17 @@
     *pLastTime = thisTime;
     return elapsed;
 }
+uint32_t TickTimerStart()
+{
+    return LPC_TIM1->TC;
+}
+uint32_t TickTimerCount(uint32_t startCount)
+{
+    uint32_t thisCount = LPC_TIM1->TC;
+    return thisCount - startCount; 
+}
+uint32_t TickTimerMs(uint32_t startCount)
+{
+    uint32_t count = TickTimerCount(startCount);
+    return count / 96000;
+}
--- a/tick.h	Tue Jan 16 17:38:12 2018 +0000
+++ b/tick.h	Wed Jan 17 20:42:14 2018 +0000
@@ -10,7 +10,10 @@
 extern int32_t  TickGetPpb (void); extern void TickSetPpb (int32_t value); extern void TickAddPpb(int32_t value);
 extern bool     TickIsSet(void);
 
-extern uint32_t TickElapsed(uint32_t* pLastCount);
+extern uint32_t TickElapsed   (uint32_t* pLastCount);
+extern uint32_t TickTimerStart(void);
+extern uint32_t TickTimerCount(uint32_t startCount);
+extern uint32_t TickTimerMs   (uint32_t startCount);
 
 extern void     TickInit(void);
 extern void     TickMain(void);