D6F-PH MEMS Differential pressure Sensor User’s Manual (A288)
28
/* unsigned char n (Number of bytes)*/
/* Return value : 8bit Read result */
/*=================================================*/
uint8_t I2C_RD_8 (unsigned char add, char *dbuf, unsigned char n) {
int i= 0;
char n_w;
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 */
/* I2C RD Access */
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_AckDis(); /* ack diable for 1 byte */
I2C1_Stop(); /* Stop condition send */
RD_REG = I2C1_rcvdata(); /* Read Data */
return RD_REG;
}
/*=================================================*/
/* I2C Read command */
/* Usage : I2C_RD_16() */
/* Argument : char add (7bit Slave Address) */
/* char *dbuf (Write data) */
/* unsigned char n (Number of bytes)*/
/* Return value : 16bit Read result */
/*=================================================*/
short I2C_RD_16 (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 */
Summary of Contents for D6F-PH
Page 35: ......