Samp_I2Cのソース変更部分
大気圧センサー対応のための追加部分を以下に示します。
static void vHandleSerialInput(void)
case 'f':
vfPrintf(&sSerStream, "LPS331A-TEST\r\n");
uint8 u8Address=0x0f;
uint8 pu8Dest[8];
uint8 u8Length=1;
bool_t bOk = TRUE;
bOk &= bSMBusWrite(0x5D, u8Address, 0, NULL);
bOk &= bSMBusSequentialRead(0x5D, u8Length, pu8Dest);
vfPrintf(&sSerStream, "0x0F=%x ",pu8Dest[0]);
uint8 pu8Data[8];
volatile long x;
pu8Data[0]=0x90;
u8Length=1;
u8Address=0x20;
bOk &= bSMBusWrite(0x5D, u8Address, 1, pu8Data);
for(x = 0; x < 160000; x++){;}
bOk &= bSMBusWrite(0x5D, u8Address, 0, NULL);
bOk &= bSMBusSequentialRead(0x5D, u8Length, pu8Dest);
vfPrintf(&sSerStream, "0x20=%x\r\n",pu8Dest[0]);
u8Address=0x28;
u8Length=1;
bOk &= bSMBusWrite(0x5D, u8Address, 0, NULL);
bOk &= bSMBusSequentialRead(0x5D, u8Length, pu8Dest);
vfPrintf(&sSerStream, "%x ",pu8Dest[0]);
pu8Dest[1]=pu8Dest[0];
u8Address=0x29;
bOk &= bSMBusWrite(0x5D, u8Address, 0, NULL);
bOk &= bSMBusSequentialRead(0x5D, u8Length, pu8Dest);
vfPrintf(&sSerStream, "%x ",pu8Dest[0]);
pu8Dest[2]=pu8Dest[0];
u8Address=0x2A;
bOk &= bSMBusWrite(0x5D, u8Address, 0, NULL);
bOk &= bSMBusSequentialRead(0x5D, u8Length, pu8Dest);
vfPrintf(&sSerStream, "%x ",pu8Dest[0]);
pu8Dest[3]=pu8Dest[0];
u8Address=0x2B;
bOk &= bSMBusWrite(0x5D, u8Address, 0, NULL);
bOk &= bSMBusSequentialRead(0x5D, u8Length, pu8Dest);
vfPrintf(&sSerStream, "%x ",pu8Dest[0]);
pu8Dest[4]=pu8Dest[0];
u8Address=0x2C;
bOk &= bSMBusWrite(0x5D, u8Address, 0, NULL);
bOk &= bSMBusSequentialRead(0x5D, u8Length, pu8Dest);
vfPrintf(&sSerStream, "%x\r\n",pu8Dest[0]);
pu8Dest[5]=pu8Dest[0];
long PD=(pu8Dest[3]*256*256+pu8Dest[2]*256+pu8Dest[1])*10/4096;
long TD=pu8Dest[5]*256+pu8Dest[4];
if(TD >= 128)
{
TD=425+((double)TD-256*256)/48;
}
else
{
TD=425+(double)TD/48;
}
vfPrintf(&sSerStream, "Pressure(x0.1hPa)=%d\r\n",PD);
vfPrintf(&sSerStream, "Temperature(x0.1Degree)=%d\r\n",TD);
break;