D6F-PH MEMS Differential pressure Sensor User’s Manual (A288)
24
10. Sample Source Code
The following is a sample source code of the D6F-PH control in the case of using
STM32microcontroller. The I2C control unit will need to be adjusted to whatever microcontroller is
used.
10-1.
D6F_PH_Sample.h
/*=================================================*/
/* D6F-PH Digital Flow Sensor Header File (using STM32)
* :Copyright: (C) OMRON Corporation, Microdevice H.Q.
* :Auther :
* :Revision: $Rev$
* :Id: $Id$
* :Date: $Date$
*
* All Rights Reserved
* OMRON Proprietary Right
*=================================================*/
/*=======================*/
/* for General */
/*=======================*/
#define SA_7 0x6C // for 7bit Slave Address
//#define RANGE_MODE 100 // Full Range +/-50[Pa]
#define RANGE_MODE 250 // Full Range 0-250[Pa]
//#define RANGE_MODE 1000 // Full Range +/-500[Pa]
/*=======================*/
/* for Measure Mode */
/*=======================*/
#define P 1 // Pressure mode
#define T 2 // Temperature mode
/* Function prototypes -------------------------------------------------------*/
void Initialize( void );
short Press_meas( void );
short Temp_meas( void );
/* Private Functions --------------------------------------------------------*/
int I2C_WR(unsigned char add, char *dbuf, unsigned char n);
uint8_t I2C_RD_8(unsigned char add, char *dbuf, unsigned char n);
short I2C_RD_16(unsigned char add, char *dbuf, unsigned char n);
unsigned short I2C_RD_u16(unsigned char add, char *dbuf, unsigned char n);
void I2C1_Init(void);
void I2C1_Start(void);
void I2C1_MastrSel(uint8_t address, uint8_t rw);
void I2C1_AckEn(void);
void I2C1_AckDis(void);
void I2C1_Stop(void);
void I2C1_senddata(uint8_t data);
uint8_t I2C1_rcvdata(void);
Please change the RANGE_MODE
define for your target Product
Pressure range.