Example #1
0
 public static bool IsBitSet(this StatusRegisterBit bit, StatusRegister reg, RegisterFeedback feedback)
 {
     if (reg.SignednessType == Signedness.Signed)
     {
         var val = feedback.getSignedValue();
         return isBitSet(val, bit.Bit);
     }
     else if (reg.SignednessType == Signedness.Unsigned)
     {
         var val = feedback.getUnsignedValue();
         return isBitSet(val, bit.Bit);
     }
     throw new Exception("unknown signedness");
 }
Example #2
0
 public static float BuildScaledValue(this AnalogRegister reg, RegisterFeedback feedback)
 {
     if (reg.SignednessType == Signedness.Signed)
     {
         var val = feedback.getSignedValue();
         return reg.ScalingFactor * val;
     }
     else if (reg.SignednessType == Signedness.Unsigned)
     {
         var val = feedback.getUnsignedValue();
         return reg.ScalingFactor * val;
     }
     else
     {
         throw new Exception("Unknown data type");
     }
 }