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.
Fork of HardwareTimersLib by
Diff: Timer_LPTMR.cpp
- Revision:
- 9:dff7c891ec77
- Parent:
- 8:23c04123395c
- Child:
- 11:e0442c8b182b
diff -r 23c04123395c -r dff7c891ec77 Timer_LPTMR.cpp
--- a/Timer_LPTMR.cpp Tue Mar 11 02:42:03 2014 +0000
+++ b/Timer_LPTMR.cpp Tue Mar 11 03:56:01 2014 +0000
@@ -35,14 +35,15 @@
uint32_t Timer_LPTMR::getTick() {
if (!__valid)
return 0;
-
- // CRITICAL SECTION -- ALL INTERRUPTS MUST BE STOPPED!
- __disable_irq();
+
+ uint16_t ticks;
+ uint32_t count;
+
+ __disable_irq(); //CRITICAL SECTION -- ALL INTERRUPTS MUST BE STOPPED!
LPTMR0->CNR = 0; //need to write to the register in order to read it due to buffering
- uint16_t ticks = LPTMR0->CNR;
- uint32_t count = __count;
- __enable_irq();
- // END CRITICAL SECTION
+ ticks = (uint16_t) LPTMR0->CNR;
+ count = __count;
+ __enable_irq(); //END CRITICAL SECTION
//Convert to ticks
return (uint32_t) count * __rolloverValue + ticks;
