|
@ -241,12 +241,14 @@ mp_obj_t mp_binary_get_val(char struct_type, char val_type, byte *p_base, byte * |
|
|
return mp_obj_new_str(s_val, strlen(s_val)); |
|
|
return mp_obj_new_str(s_val, strlen(s_val)); |
|
|
#if MICROPY_PY_BUILTINS_FLOAT |
|
|
#if MICROPY_PY_BUILTINS_FLOAT |
|
|
} else if (val_type == 'f') { |
|
|
} else if (val_type == 'f') { |
|
|
union { uint32_t i; |
|
|
union { |
|
|
|
|
|
uint32_t i; |
|
|
float f; |
|
|
float f; |
|
|
} fpu = {val}; |
|
|
} fpu = {val}; |
|
|
return mp_obj_new_float_from_f(fpu.f); |
|
|
return mp_obj_new_float_from_f(fpu.f); |
|
|
} else if (val_type == 'd') { |
|
|
} else if (val_type == 'd') { |
|
|
union { uint64_t i; |
|
|
union { |
|
|
|
|
|
uint64_t i; |
|
|
double f; |
|
|
double f; |
|
|
} fpu = {val}; |
|
|
} fpu = {val}; |
|
|
return mp_obj_new_float_from_d(fpu.f); |
|
|
return mp_obj_new_float_from_d(fpu.f); |
|
@ -308,7 +310,8 @@ void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in, byte *p |
|
|
break; |
|
|
break; |
|
|
#if MICROPY_PY_BUILTINS_FLOAT |
|
|
#if MICROPY_PY_BUILTINS_FLOAT |
|
|
case 'f': { |
|
|
case 'f': { |
|
|
union { uint32_t i; |
|
|
union { |
|
|
|
|
|
uint32_t i; |
|
|
float f; |
|
|
float f; |
|
|
} fp_sp; |
|
|
} fp_sp; |
|
|
fp_sp.f = mp_obj_get_float_to_f(val_in); |
|
|
fp_sp.f = mp_obj_get_float_to_f(val_in); |
|
@ -316,7 +319,8 @@ void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in, byte *p |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
case 'd': { |
|
|
case 'd': { |
|
|
union { uint64_t i64; |
|
|
union { |
|
|
|
|
|
uint64_t i64; |
|
|
uint32_t i32[2]; |
|
|
uint32_t i32[2]; |
|
|
double f; |
|
|
double f; |
|
|
} fp_dp; |
|
|
} fp_dp; |
|
|