summaryrefslogtreecommitdiffstatshomepage
path: root/stmhal
diff options
context:
space:
mode:
Diffstat (limited to 'stmhal')
-rw-r--r--stmhal/math.c51
-rw-r--r--stmhal/usbd_msc_storage.c2
2 files changed, 42 insertions, 11 deletions
diff --git a/stmhal/math.c b/stmhal/math.c
index cdb55a8ada..9197d850c8 100644
--- a/stmhal/math.c
+++ b/stmhal/math.c
@@ -1,18 +1,49 @@
#include <stdint.h>
-#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;
+typedef float float_t;
+typedef union {
+ float f;
+ struct {
+ uint64_t m : 23;
+ uint64_t e : 8;
+ uint64_t s : 1;
+ };
+} float_s_t;
+
+typedef union {
+ double d;
+ struct {
+ uint64_t m : 52;
+ uint64_t e : 11;
+ uint64_t s : 1;
+ };
+} double_s_t;
+
+double __attribute__((pcs("aapcs"))) __aeabi_f2d(float x) {
+ float_s_t fx={0};
+ double_s_t dx={0};
+
+ fx.f = x;
+ dx.s = (fx.s);
+ dx.e = (fx.e-127+1023) & 0x7FF;
+ dx.m = fx.m;
+ dx.m <<=(52-23); // left justify
+ return dx.d;
}
-float __aeabi_d2f(double x) {
- // TODO
- return 0.0;
+float __attribute__((pcs("aapcs"))) __aeabi_d2f(double x) {
+ float_s_t fx={0};
+ double_s_t dx={0};
+
+ dx.d = x;
+ fx.s = (dx.s);
+ fx.e = (dx.e-1023+127) & 0xFF;
+ fx.m = (dx.m>>(52-23)); // right justify
+ return fx.f;
}
+double __aeabi_dmul(double x , double y) {
+ return 0.0;
+}
/*
double sqrt(double x) {
// TODO
diff --git a/stmhal/usbd_msc_storage.c b/stmhal/usbd_msc_storage.c
index ce6d3a5608..1b4545cd30 100644
--- a/stmhal/usbd_msc_storage.c
+++ b/stmhal/usbd_msc_storage.c
@@ -41,7 +41,7 @@
static const int8_t FLASH_STORAGE_Inquirydata[] = { // 36 bytes
// LUN 0
0x00,
- 0x00, // 0x00 for a fixed drive, 0x80 for a removable drive
+ 0x80, // 0x00 for a fixed drive, 0x80 for a removable drive
0x02,
0x02,
(STANDARD_INQUIRY_DATA_LEN - 5),