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_TPM.cpp
- Revision:
- 9:dff7c891ec77
- Parent:
- 8:23c04123395c
- Child:
- 10:12c1c5cef918
diff -r 23c04123395c -r dff7c891ec77 Timer_TPM.cpp
--- a/Timer_TPM.cpp Tue Mar 11 02:42:03 2014 +0000
+++ b/Timer_TPM.cpp Tue Mar 11 03:56:01 2014 +0000
@@ -35,16 +35,17 @@
if (!__valid)
return 0;
- // CRITICAL SECTION -- ALL INTERRUPTS MUST BE STOPPED!
- __disable_irq();
+ uint16_t tick;
+ uint32_t count;
+
+ __disable_irq(); //CRITICAL SECTION -- ALL INTERRUPTS MUST BE STOPPED!
TPM0->CNT = 0; //Need to write to the TPM CNT register in order to read it (buffering)
- uint16_t tick = TPM0->CNT;
- uint32_t count = __count;
- __enable_irq();
- // END CRITICAL SECTION
+ tick = (uint16_t) TPM0->CNT;
+ count = __count;
+ __enable_irq(); //END CRITICAL SECTION
//Convert to ticks
- return (uint32_t) count * __rolloverValue + tick;
+ return count * __rolloverValue + (uint32_t) tick;
}
void Timer_TPM::__init_timer() {
