diff options
Diffstat (limited to 'stm')
| -rw-r--r-- | stm/Makefile | 1 | ||||
| -rw-r--r-- | stm/main.c | 25 | ||||
| -rw-r--r-- | stm/math.c | 48 | ||||
| -rw-r--r-- | stm/mpconfigport.h | 5 |
4 files changed, 50 insertions, 29 deletions
diff --git a/stm/Makefile b/stm/Makefile index cc16eda43..1675c22ab 100644 --- a/stm/Makefile +++ b/stm/Makefile @@ -47,6 +47,7 @@ LIBS = SRC_C = \ main.c \ printf.c \ + math.c \ system_stm32f4xx.c \ stm32fxxx_it.c \ string0.c \ diff --git a/stm/main.c b/stm/main.c index e5f5d4e76..bab8933b1 100644 --- a/stm/main.c +++ b/stm/main.c @@ -666,28 +666,3 @@ soft_reset: first_soft_reset = false; goto soft_reset; } - -// these 2 functions seem to actually work... no idea why -// replacing with libgcc does not work (probably due to wrong calling conventions) -double __aeabi_f2d(float x) { - // TODO - return 0.0; -} - -float __aeabi_d2f(double x) { - // TODO - return 0.0; -} - -double sqrt(double x) { - // TODO - return 0.0; -} - -machine_float_t machine_sqrt(machine_float_t x) { - asm volatile ( - "vsqrt.f32 %[r], %[x]\n" - : [r] "=t" (x) - : [x] "t" (x)); - return x; -} diff --git a/stm/math.c b/stm/math.c new file mode 100644 index 000000000..ac680f6b7 --- /dev/null +++ b/stm/math.c @@ -0,0 +1,48 @@ +#include <math.h> + +// these 2 functions seem to actually work... no idea why +// replacing with libgcc does not work (probably due to wrong calling conventions) +double __aeabi_f2d(float x) { + // TODO + return 0.0; +} + +float __aeabi_d2f(double x) { + // TODO + return 0.0; +} + +/* +double sqrt(double x) { + // TODO + return 0.0; +} +*/ + +float sqrtf(float x) { + asm volatile ( + "vsqrt.f32 %[r], %[x]\n" + : [r] "=t" (x) + : [x] "t" (x)); + return x; +} + +// TODO we need import these functions from some library (eg musl or newlib) +float powf(float x, float y) { return 0.0; } +float expf(float x) { return 0.0; } +float logf(float x) { return 0.0; } +float log2f(float x) { return 0.0; } +float log10f(float x) { return 0.0; } +float coshf(float x) { return 0.0; } +float sinhf(float x) { return 0.0; } +float tanhf(float x) { return 0.0; } +float acoshf(float x) { return 0.0; } +float asinhf(float x) { return 0.0; } +float atanhf(float x) { return 0.0; } +float cosf(float x) { return 0.0; } +float sinf(float x) { return 0.0; } +float tanf(float x) { return 0.0; } +float acosf(float x) { return 0.0; } +float asinf(float x) { return 0.0; } +float atanf(float x) { return 0.0; } +float atan2f(float x, float y) { return 0.0; } diff --git a/stm/mpconfigport.h b/stm/mpconfigport.h index 9cbda9c6c..3f48c43f0 100644 --- a/stm/mpconfigport.h +++ b/stm/mpconfigport.h @@ -6,8 +6,8 @@ #define MICROPY_EMIT_INLINE_THUMB (1) #define MICROPY_ENABLE_GC (1) #define MICROPY_ENABLE_REPL_HELPERS (1) -#define MICROPY_ENABLE_FLOAT (1) #define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ) +#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT) #define MICROPY_PATH_MAX (128) /* Enable FatFS LFNs 0: Disable LFN feature. @@ -29,9 +29,6 @@ typedef int32_t machine_int_t; // must be pointer size typedef uint32_t machine_uint_t; // must be pointer size typedef void *machine_ptr_t; // must be of pointer size typedef const void *machine_const_ptr_t; // must be of pointer size -typedef float machine_float_t; - -machine_float_t machine_sqrt(machine_float_t x); // There is no classical C heap in bare-metal ports, only Python // garbage-collected heap. For completeness, emulate C heap via |
