
29
D6F-PH MEMS Differential pressure Sensor User’s Manual (A288)
i++;
}
I2C1_Stop(); /* Stop condition */
adc_wait(5); /* 5msec wait */
I2C1_Start(); /* Start condition */
I2C1_MastrSel(add, 0); /* Slave Address 7bit => 8bit */
I2C1_senddata(dbuf[n-1]); /* Word Address */
I2C1_Start(); /* Re-Start condition */
I2C1_MastrSel(add, 1); /* Slave 7bit => 8bit for RD */
I2C1_AckEn(); /* ack enable send after MSB 1 byte read */
rd_fifo[0] = I2C1_rcvdata(); /* Read Data */
I2C1_AckDis(); /* ack diable send after LSB 1 byte read */
I2C1_Stop(); /* Stop condition send */
rd_fifo[1] = I2C1_rcvdata(); /* Read Data */
RD_FIFO = ((rd_fifo[0] << 8) | rd_fifo[1]);
return RD_FIFO;
}
/*=================================================*/
/* I2C Read command */
/* Usage : I2C_RD_u16() */
/* Argument : char add (7bit Slave Address) */
/* char *dbuf (Write data) */
/* unsigned char n (Number of bytes)*/
/* Return value : 16bit Read result */
/*=================================================*/
unsigned short I2C_RD_u16 (unsigned char add, char *dbuf, unsigned char n) {
int i= 0;
char n_w;
uint8_t rd_fifo[2] = {0, 0};
n_w = n - 1;
/* I2C Pre-WR Access */
I2C1_Start(); /* Start condition */
I2C1_MastrSel(add, 0); /* Slave Address 7bit => 8bit */
while (n_w--) {
I2C1_senddata(dbuf[i]); /* Send Data */
i++;
}
I2C1_Stop(); /* Stop condition */
adc_wait(5); /* 5msec wait */
I2C1_Start(); /* Start condition */
I2C1_MastrSel(add, 0); /* Slave Address 7bit => 8bit */
I2C1_senddata(dbuf[n-1]); /* Word Address */
Summary of Contents for D6F-PH
Page 35: ......