diff options
author | Daniel Palmer <danieruru@gmail.com> | 2014-05-22 11:27:48 +0900 |
---|---|---|
committer | Daniel Palmer <danieruru@gmail.com> | 2014-05-22 11:27:48 +0900 |
commit | 24319a175103ea760a6550cbc552720a6c08fe60 (patch) | |
tree | 42a21ac2ce89fd53982ffdb23e9908c0b8716fca | |
parent | c71117e33181ee72d44d7b9c379046d0f5d1f835 (diff) |
Copy some floats out into variables from the flash structure.INSTRUMENT_5_0_13
Workaround for aligned accesses
-rw-r--r-- | device-functions.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/device-functions.c b/device-functions.c index 2f4f2cf..f72b275 100644 --- a/device-functions.c +++ b/device-functions.c @@ -2826,11 +2826,18 @@ int Set_VI_Control(int parameter,int channel,float new_ampl,int *point_found,int +(*UseNegData)*max_points +(entry_i); - if ( (fabs(pwl_amp[index]-pwl_amp[index+1])>smallest_allowed_number) + // we copy these floats out into variables because anything that touches + // floats seems to generate instructions that can't work on unaligned + // data and these are unaligned. + float pwlamp1, pwlamp2; + memcpy(&pwlamp1, &pwl_amp[index], sizeof(pwlamp1)); + memcpy(&pwlamp2, &pwl_amp[index+1], sizeof(pwlamp2)); + + if ( (fabs(pwlamp1-pwlamp2)>smallest_allowed_number) && - ( ((tweaked_use_ampl>=pwl_amp[index]) && (tweaked_use_ampl<=pwl_amp[index+1])) + ( ((tweaked_use_ampl>=pwlamp1) && (tweaked_use_ampl<=pwlamp2)) || - (decreasing_values_allowed && (tweaked_use_ampl<=pwl_amp[index]) && (tweaked_use_ampl>=pwl_amp[index+1])) /* for OS only */ + (decreasing_values_allowed && (tweaked_use_ampl<=pwlamp1) && (tweaked_use_ampl>=pwlamp2)) /* for OS only */ ) ) { *point_found=1; @@ -2863,7 +2870,7 @@ int Set_VI_Control(int parameter,int channel,float new_ampl,int *point_found,int } } - fraction = (tweaked_use_ampl-pwl_amp[index]) / (pwl_amp[index] - pwl_amp[index+1]); + fraction = (tweaked_use_ampl-pwlamp1) / (pwlamp1 - pwlamp2); *relay_range=range_i; *entry=entry_i; |