diff options
author | Clyne Sullivan <clyne@bitgloo.com> | 2021-03-21 16:33:08 -0400 |
---|---|---|
committer | Clyne Sullivan <clyne@bitgloo.com> | 2021-03-21 16:33:08 -0400 |
commit | a4f1482a8b23d5f761f60d6f3821c84190d89e2f (patch) | |
tree | 746095fa69eccccdc1c2830fdd0c06bac01848f5 /source | |
parent | 1a7d45b9130251119874df8b15424ec41306d8f2 (diff) |
add pot. support; L4 trig; eagle schematic draft
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_ |