skeleton code for WES237B lab2

Dependencies:   mbed

Fork of ClockControl by Michael Wei

Files at this revision

API Documentation at this revision

Comitter:
mbed36372
Date:
Fri Apr 18 01:26:02 2014 +0000
Parent:
1:5dd5b87217e5
Commit message:
change getTickCount in folder;

Changed in this revision

GetTickCount.lib Show diff for this revision Revisions of this file
GetTickCount/GetTickCount.cpp Show annotated file Show diff for this revision Revisions of this file
GetTickCount/GetTickCount.h Show annotated file Show diff for this revision Revisions of this file
diff -r 5dd5b87217e5 -r 53ed37115187 GetTickCount.lib
--- a/GetTickCount.lib	Fri Apr 18 01:19:42 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/PA/code/GetTickCount/#02022f4feae7
diff -r 5dd5b87217e5 -r 53ed37115187 GetTickCount/GetTickCount.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GetTickCount/GetTickCount.cpp	Fri Apr 18 01:26:02 2014 +0000
@@ -0,0 +1,5 @@
+volatile unsigned int TickCount;
+
+extern "C" void SysTick_Handler (void) {
+    TickCount+= 10;
+}
\ No newline at end of file
diff -r 5dd5b87217e5 -r 53ed37115187 GetTickCount/GetTickCount.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GetTickCount/GetTickCount.h	Fri Apr 18 01:26:02 2014 +0000
@@ -0,0 +1,31 @@
+/* mbed GetTickCount Library
+  * Copyright (c) 2010 Michael Wei
+  */ 
+  
+//shouldn't have to include, but fixes weird problems with defines
+#include "LPC1768/LPC17xx.h"
+
+#ifndef MBED_TICKCOUNT_H 
+#define MBED_TICKCOUNT_H 
+extern volatile unsigned int TickCount;
+
+inline void GetTickCount_Start(void) {
+    //CMSIS SYSTICK Config
+    SysTick_Config(SystemCoreClock / 100);               /* Generate interrupt every 10 ms */
+}
+
+inline void GetTickCount_Stop(void) {
+    SysTick->CTRL = (1 << SYSTICK_CLKSOURCE) | (0<<SYSTICK_ENABLE) | (0<<SYSTICK_TICKINT);    /* Disable SysTick IRQ and SysTick Timer */
+}
+
+inline void GetTickCount_Reset(void) {
+     SysTick->CTRL = (1 << SYSTICK_CLKSOURCE) | (0<<SYSTICK_ENABLE) | (0<<SYSTICK_TICKINT);    /* Disable SysTick IRQ and SysTick Timer */
+     TickCount = 0;
+     SysTick->CTRL = (1 << SYSTICK_CLKSOURCE) | (1<<SYSTICK_ENABLE) | (1<<SYSTICK_TICKINT);    /* Enable SysTick IRQ and SysTick Timer */
+}
+
+inline unsigned int GetTickCount(void)
+{
+    return TickCount;
+}
+#endif
\ No newline at end of file