summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2012-04-07 00:25:26 -0700
committerKeith Packard <keithp@keithp.com>2012-04-07 00:25:26 -0700
commitc7119405a3dd7128120374a2a001bc98ef523619 (patch)
tree2d945f9bca13dc441957619ee1cb12990c9689e5
parentd0d0d20c20e5eeacbc9a1ec1c93141a2044830fb (diff)
altos: Make ao_freq_to_set reentrant
Save a bunch of data space this way. Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r--src/core/ao.h2
-rw-r--r--src/core/ao_freq.c13
2 files changed, 10 insertions, 5 deletions
diff --git a/src/core/ao.h b/src/core/ao.h
index 67efa437..150c0817 100644
--- a/src/core/ao.h
+++ b/src/core/ao.h
@@ -1892,7 +1892,7 @@ ao_sqrt(uint32_t op);
* ao_freq.c
*/
-int32_t ao_freq_to_set(int32_t freq, int32_t cal);
+int32_t ao_freq_to_set(int32_t freq, int32_t cal) __reentrant;
#include <ao_arch_funcs.h>
diff --git a/src/core/ao_freq.c b/src/core/ao_freq.c
index 67b0b037..12496f6f 100644
--- a/src/core/ao_freq.c
+++ b/src/core/ao_freq.c
@@ -25,10 +25,15 @@
* frequency, and updating the radio setting along the way
*/
-int32_t ao_freq_to_set(int32_t freq, int32_t cal) {
- __pdata int32_t set = 0;
- uint8_t neg = 0;
- __pdata int32_t error = -434550 / 2;
+int32_t ao_freq_to_set(int32_t freq, int32_t cal) __reentrant
+{
+ static __pdata int32_t set;
+ static __pdata uint8_t neg;
+ static __pdata int32_t error;
+
+ set = 0;
+ neg = 0;
+ error = -434550 / 2;
if ((freq -= 434550) < 0) {
neg = 1;