当前位置: 首页>>代码示例>>C#>>正文


C# SPI.Dispose方法代码示例

本文整理汇总了C#中Microsoft.SPOT.Hardware.SPI.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# SPI.Dispose方法的具体用法?C# SPI.Dispose怎么用?C# SPI.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.SPOT.Hardware.SPI的用法示例。


在下文中一共展示了SPI.Dispose方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: calculatePressure


//.........这里部分代码省略.........
            //
            //Variable sizes:
            //For placing high and low bytes of the Memory addresses for each of the 6 coefficients:
            //signed char (S8) sia0MSB, sia0LSB, sib1MSB,sib1LSB, sib2MSB,sib2LSB, sic12MSB,sic12LSB, sic11MSB,sic11LSB, sic22MSB,sic22LSB; //
            //Variable for use in the compensation, this is the 6 coefficients in 16bit form, MSB+LSB.
            //signed int (S16) sia0, sib1, sib2, sic12, sic11, sic22;
            //
            //Variable used to do large calculation as 3 temp variables in the process below
            //signed long (S32) lt1, lt2, lt3;
            //
            //Variables used for Pressure and Temperature Raw.
            //unsigned int (U16) uiPadc, uiTadc.
            //signed (N=number of bits in coefficient, F-fractional bits) //s(N,F)
            //The below Pressure and Temp or uiPadc and uiTadc are shifted from the MSB+LSB values to remove the zeros in the LSB since this
            // 10bit number is stored in 16 bits. i.e 0123456789XXXXXX becomes 0000000123456789

            uiPadc = uiPadc >> 6; //Note that the PressCntdec is the raw value from the MPL115A data address. Its shifted >>6 since its 10 bit.
            uiTadc = uiTadc >> 6; //Note that the TempCntdec is the raw value from the MPL115A data address. Its shifted >>6 since its 10 bit.

            //******* STEP 1 c11x1= c11 * Padc
            lt1 = (long)sic11;    // s(16,27) s(N,F+zeropad) goes from s(11,10)+11ZeroPad = s(11,22) => Left Justified = s(16,27)
            lt2 = (long)uiPadc;   // u(10,0) s(N,F)
            lt3 = lt1 * lt2;      // s(26,27) /c11*Padc
            si_c11x1 = (long)lt3; // s(26,27)- EQ 1 =c11x1 /checked

            //divide this hex number by 2^30 to get the correct decimal value.
            //b1 =s(14,11) => s(16,13) Left justified

            //******* STEP 2 a11= b1 + c11x1
            lt1 = ((long)sib1) << 14;   // s(30,27) b1=s(16,13) Shift b1 so that the F matches c11x1(shift by 14)
            lt2 = (long)si_c11x1;       // s(26,27) //ensure fractional bits are compatible
            lt3 = lt1 + lt2;            // s(30,27) /b1+c11x1
            si_a11 = (long)(lt3 >> 14); // s(16,13) - EQ 2 =a11 Convert this block back to s(16,X)

            //******* STEP 3 c12x2= c12 * Tadc
            // sic12 is s(14,13)+9zero pad = s(16,15)+9 => s(16,24) left justified
            lt1 = (long)sic12;    // s(16,24)
            lt2 = (long)uiTadc;   // u(10,0)
            lt3 = lt1 * lt2;      // s(26,24)
            si_c12x2 = (long)lt3; // s(26,24) - EQ 3 =c12x2 /checked

            //******* STEP 4 a1= a11 + c12x2
            lt1 = ((long)si_a11 << 11); // s(27,24) This is done by s(16,13) <<11 goes to s(27,24) to match c12x2's F part
            lt2 = (long)si_c12x2;       // s(26,24)
            lt3 = lt1 + lt2;            // s(27,24) /a11+c12x2
            si_a1 = (long)lt3 >> 11;    // s(16,13) - EQ 4 =a1 /check

            //******* STEP 5 c22x2= c22 * Tadc
            // c22 is s(11,10)+9zero pad = s(11,19) => s(16,24) left justified
            lt1 = (long)sic22;      // s(16,30) This is done by s(11,10) + 15 zero pad goes to s(16,15)+15, to s(16,30)
            lt2 = (long)uiTadc;     // u(10,0)
            lt3 = lt1 * lt2;        // s(26,30) /c22*Tadc
            si_c22x2 = (long)(lt3); // s(26,30) - EQ 5 /=c22x2

            //******* STEP 6 a2= b2 + c22x2
            //WORKS and loses the least in data. One extra execution. Note how the 31 is really a 32 due to possible overflow.
            // b2 is s(16,14) User shifted left to => s(31,29) to match c22x2 F value
            lt1 = ((long)sib2 << 15);    //s(31,29)
            lt2 = ((long)si_c22x2 >> 1); //s(25,29) s(26,30) goes to >>16 s(10,14) to match F from sib2
            lt3 = lt1 + lt2;             //s(32,29) but really is a s(31,29) due to overflow the 31 becomes a 32.
            si_a2 = ((long)lt3 >> 16);   //s(16,13)

            //******* STEP 7 a1x1= a1 * Padc
            lt1 = (long)si_a1;      // s(16,13)
            lt2 = (long)uiPadc;     // u(10,0)
            lt3 = lt1 * lt2;        // s(26,13) /a1*Padc
            si_a1x1 = (long)(lt3);  // s(26,13) - EQ 7 /=a1x1 /check

            //******* STEP 8 y1= a0 + a1x1
            // a0 = s(16,3)
            lt1 = ((long)sia0 << 10);  // s(26,13) This is done since has to match a1x1 F value to add. So S(16,3) <<10 = S(26,13)
            lt2 = (long)si_a1x1;       // s(26,13)
            lt3 = lt1 + lt2;           // s(26,13) /a0+a1x1
            si_y1 = ((long)lt3 >> 10); // s(16,3) - EQ 8 /=y1 /check

            //******* STEP 9 a2x2= a2 *Tadc
            lt1 = (long)si_a2;      // s(16,13)
            lt2 = (long)uiTadc;     // u(10,0)
            lt3 = lt1 * lt2;        // s(26,13) /a2*Tadc
            si_a2x2 = (long)(lt3);  // s(26,13) - EQ 9 /=a2x2

            //******* STEP 10 pComp = y1 +a2x2
            // y1= s(16,3)
            lt1 = ((long)si_y1 << 10); // s(26,13) This is done to match a2x2 F value so addition can match. s(16,3) <<10
            lt2 = (long)si_a2x2;       // s(26,13)
            lt3 = lt1 + lt2;           // s(26,13) /y1+a2x2

            // FIXED POINT RESULT WITH ROUNDING:
            siPcomp = (long)lt3 >> 13; // goes to no fractional parts since this is an ADC count.

            //decPcomp is defined as a floating point number.
            //Conversion to Decimal value from 1023 ADC count value. ADC counts are 0 to 1023. Pressure is 50 to 115kPa correspondingly.
            var decPcomp = (double)((65.0 / 1023.0) * siPcomp) + 50;
            var decPcompHg = decPcomp*0.295300586466965;
            decPcomp_out = decPcomp.ToString();
            Debug.Print("decPcomp: " + decPcomp_out + " millibars: " + decPcompHg);

            SPI_Out.Dispose();
            return decPcompHg;
        }
开发者ID:zgramana,项目名称:WeatherStation,代码行数:101,代码来源:PressureSensor.cs


注:本文中的Microsoft.SPOT.Hardware.SPI.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。