From 24319a175103ea760a6550cbc552720a6c08fe60 Mon Sep 17 00:00:00 2001 From: Daniel Palmer Date: Thu, 22 May 2014 11:27:48 +0900 Subject: Copy some floats out into variables from the flash structure. Workaround for aligned accesses --- device-functions.c | 15 +++++++++++---- 1 file 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; -- cgit