notaz.gp2x.de
/
teensytas.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
de20174
)
micros() implementation without irq disable
author
notaz
<notasas@gmail.com>
Sat, 25 Oct 2014 22:14:39 +0000
(
01:14
+0300)
committer
notaz
<notasas@gmail.com>
Sat, 25 Oct 2014 22:14:39 +0000
(
01:14
+0300)
teensy3/pins_teensy.c
patch
|
blob
|
blame
|
history
diff --git
a/teensy3/pins_teensy.c
b/teensy3/pins_teensy.c
index
1c81ee9
..
52df777
100644
(file)
--- a/
teensy3/pins_teensy.c
+++ b/
teensy3/pins_teensy.c
@@
-690,7
+690,7
@@
volatile uint32_t systick_millis_count = 0;
//uint32_t systick_current, systick_count, systick_istatus; // testing only
//uint32_t systick_current, systick_count, systick_istatus; // testing only
-
uint32_t micros
(void)
+
static uint32_t micros_mask
(void)
{
uint32_t count, current, istatus;
{
uint32_t count, current, istatus;
@@
-707,6
+707,24
@@
uint32_t micros(void)
return count * 1000 + current / (F_CPU / 1000000);
}
return count * 1000 + current / (F_CPU / 1000000);
}
+uint32_t micros(void)
+{
+ uint32_t count, current, istatus;
+
+ if (nvic_execution_priority() <= (SCB_SHPR3 >> 24))
+ return micros_mask();
+
+ do {
+ current = SYST_CVR;
+ count = systick_millis_count;
+ istatus = SCB_ICSR; // bit 26 indicates if systick exception pending
+ }
+ while (istatus & SCB_ICSR_PENDSTSET);
+
+ current = ((F_CPU / 1000) - 1) - current;
+ return count * 1000 + current / (F_CPU / 1000000);
+}
+
void delay(uint32_t ms)
{
uint32_t start = micros();
void delay(uint32_t ms)
{
uint32_t start = micros();