GetTickCount.h@0:02022f4feae7, 2012-06-22 (annotated)
- Committer:
- PA
- Date:
- Fri Jun 22 02:56:17 2012 +0000
- Revision:
- 0:02022f4feae7
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
PA | 0:02022f4feae7 | 1 | /* mbed GetTickCount Library |
PA | 0:02022f4feae7 | 2 | * Copyright (c) 2010 Michael Wei |
PA | 0:02022f4feae7 | 3 | */ |
PA | 0:02022f4feae7 | 4 | |
PA | 0:02022f4feae7 | 5 | //shouldn't have to include, but fixes weird problems with defines |
PA | 0:02022f4feae7 | 6 | #include "LPC1768/LPC17xx.h" |
PA | 0:02022f4feae7 | 7 | |
PA | 0:02022f4feae7 | 8 | #ifndef MBED_TICKCOUNT_H |
PA | 0:02022f4feae7 | 9 | #define MBED_TICKCOUNT_H |
PA | 0:02022f4feae7 | 10 | extern volatile unsigned int TickCount; |
PA | 0:02022f4feae7 | 11 | |
PA | 0:02022f4feae7 | 12 | inline void GetTickCount_Start(void) { |
PA | 0:02022f4feae7 | 13 | //CMSIS SYSTICK Config |
PA | 0:02022f4feae7 | 14 | SysTick_Config(SystemCoreClock / 100); /* Generate interrupt every 10 ms */ |
PA | 0:02022f4feae7 | 15 | } |
PA | 0:02022f4feae7 | 16 | |
PA | 0:02022f4feae7 | 17 | inline void GetTickCount_Stop(void) { |
PA | 0:02022f4feae7 | 18 | SysTick->CTRL = (1 << SYSTICK_CLKSOURCE) | (0<<SYSTICK_ENABLE) | (0<<SYSTICK_TICKINT); /* Disable SysTick IRQ and SysTick Timer */ |
PA | 0:02022f4feae7 | 19 | } |
PA | 0:02022f4feae7 | 20 | |
PA | 0:02022f4feae7 | 21 | inline void GetTickCount_Reset(void) { |
PA | 0:02022f4feae7 | 22 | SysTick->CTRL = (1 << SYSTICK_CLKSOURCE) | (0<<SYSTICK_ENABLE) | (0<<SYSTICK_TICKINT); /* Disable SysTick IRQ and SysTick Timer */ |
PA | 0:02022f4feae7 | 23 | TickCount = 0; |
PA | 0:02022f4feae7 | 24 | SysTick->CTRL = (1 << SYSTICK_CLKSOURCE) | (1<<SYSTICK_ENABLE) | (1<<SYSTICK_TICKINT); /* Enable SysTick IRQ and SysTick Timer */ |
PA | 0:02022f4feae7 | 25 | } |
PA | 0:02022f4feae7 | 26 | |
PA | 0:02022f4feae7 | 27 | inline unsigned int GetTickCount(void) |
PA | 0:02022f4feae7 | 28 | { |
PA | 0:02022f4feae7 | 29 | return TickCount; |
PA | 0:02022f4feae7 | 30 | } |
PA | 0:02022f4feae7 | 31 | #endif |