Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
no2chem
Date:
Mon Jan 25 05:56:58 2010 +0000
Commit message:

Changed in this revision

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
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GetTickCount/GetTickCount.cpp	Mon Jan 25 05:56:58 2010 +0000
@@ -0,0 +1,5 @@
+volatile unsigned int TickCount;
+
+extern "C" void SysTick_Handler (void) {
+    TickCount+= 10;
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GetTickCount/GetTickCount.h	Mon Jan 25 05:56:58 2010 +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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Jan 25 05:56:58 2010 +0000
@@ -0,0 +1,15 @@
+#include "mbed.h"
+#include "GetTickCount/GetTickCount.h"
+
+int main() {
+    printf("GetTickCount() Demo App\r\n");
+    printf("Timer resolution is 10ms.\r\n");
+    printf("Sample will show the system timer every second.");
+    
+    GetTickCount_Start();
+    while(1) {
+        
+                printf("Ticks: %d\r\n", GetTickCount());
+                wait(1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Jan 25 05:56:58 2010 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/49a220cc26e0