Omron D6F-PH User Manual page 29

Mems differential pressure sensor
Table of Contents

Advertisement

/*
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();
I2C1_MastrSel(add, 0);
while (n_w--) {
I2C1_senddata(dbuf[i]); /* Send Data
i++;
}
I2C1_Stop();
/* I2C RD Access */
I2C1_Start();
I2C1_MastrSel(add, 0);
I2C1_senddata(dbuf[n-1]); /* Word Address
I2C1_Start();
I2C1_MastrSel(add, 1);
I2C1_AckDis();
I2C1_Stop();
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();
I2C1_MastrSel(add, 0);
while (n_w--) {
I2C1_senddata(dbuf[i]);
D6F-PH MEMS Differential pressure Sensor User's Manual (A288)
/* Start condition */
/* Slave Address 7bit => 8bit */
/* Stop condition */
/* Start condition */
/* Slave Address 7bit => 8bit */
/* Re-Start condition */
/* Slave 7bit => 8bit for RD */
/* ack diable for 1 byte */
/* Stop condition send */
/* Start condition */
/* Slave Address 7bit => 8bit */
/* Send Data
*/
*/
*/
*/
*/
*/
*/
*/
*/
28

Advertisement

Table of Contents
loading

Table of Contents