diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/cordic.cpp | 17 | ||||
-rw-r--r-- | source/cordic.hpp | 8 |
2 files changed, 19 insertions, 6 deletions
diff --git a/source/cordic.cpp b/source/cordic.cpp index d2997f2..29ee068 100644 --- a/source/cordic.cpp +++ b/source/cordic.cpp @@ -1,8 +1,8 @@ #include "cordic.hpp" #include "hal.h" -namespace cordic { #if !defined(TARGET_PLATFORM_L4) +namespace cordic { void init() { @@ -93,16 +93,21 @@ double tan(double x) { return tanx; } +} #else // L4 +#include <cmath> +namespace cordic { void init() {} -double mod(double, double) { return 0; } +float mod(float a, float b) { + return a - (b * std::floor(a / b)); +} -double cos(double) { return 0; } -double sin(double) { return 0; } -double tan(double) { return 0; } +float cos(float x) { return std::cos(x); } +float sin(float x) { return std::sin(x); } +float tan(float x) { return std::tan(x); } -#endif } +#endif diff --git a/source/cordic.hpp b/source/cordic.hpp index 5c52fe4..5d640cc 100644 --- a/source/cordic.hpp +++ b/source/cordic.hpp @@ -6,11 +6,19 @@ namespace cordic { void init(); +#if !defined(TARGET_PLATFORM_L4) double mod(double n, double d); double cos(double x); double sin(double x); double tan(double x); +#else + float mod(float n, float d); + + float cos(float x); + float sin(float x); + float tan(float x); +#endif } #endif // CORDIC_HPP_ |