Samp_I2Cのソース変更部分
温湿度センサー対応のための追加部分を以下に示します。
static void vHandleSerialInput(void)
uint8 u8Address;
uint8 pu8Dest[256];
uint8 u8Length=1;
bool_t bOk = TRUE;
uint8 pu8Data[256];
long TD;
long PD;
long HD;
volatile long x;
case 'g':
vfPrintf(&sSerStream, "AM2321A-TEST\r\n");
bOk &= bSMBusWrite(0x5C, 0, 0, NULL);
for(x = 0; x < 1600; x++){;}
u8Address=0x03;
u8Length=2;
pu8Data[0]=0x00;
pu8Data[1]=0x04;
bOk &= bSMBusWrite(0x5C, u8Address, u8Length, pu8Data);
for(x = 0; x < 1600; x++){;}
u8Length=8;
bOk &= bSMBusSequentialRead(0x5C, u8Length, pu8Dest);
for(x = 0; x < 8; x++)
{vfPrintf(&sSerStream, "%02x ",pu8Dest[x]);}
vfPrintf(&sSerStream, "\r\n");
HD=pu8Dest[2]*256+pu8Dest[3];
vfPrintf(&sSerStream, "Humidity(x0.1%%)=%d\r\n",HD);
TD=pu8Dest[4]*256+pu8Dest[5];
vfPrintf(&sSerStream, "Temperature(x0.1Degree)=%d\r\n",TD);
break;