Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of MPL3115A2 by
Diff: MPL3115A2.h
- Revision:
- 2:a2fcfb7ff611
- Parent:
- 1:30a04f651efe
- Child:
- 3:a2f1752add9a
--- a/MPL3115A2.h Thu May 23 12:42:45 2013 +0000 +++ b/MPL3115A2.h Wed May 29 05:57:15 2013 +0000 @@ -55,101 +55,120 @@ class MPL3115A2 { public: -/** -* MPL3115A2 constructor -* -* @param sda SDA pin -* @param sdl SCL pin -* @param addr addr of the I2C peripheral -*/ -MPL3115A2(PinName sda, PinName scl, int addr); - -/** -* Get the value of the WHO_AM_I register -* -* @returns DEVICE_ID value == 0xC4 -*/ -uint8_t getDeviceID(); - -/** -* Return the STATUS register value -* -* @returns STATUS register value -*/ -unsigned char getStatus( void); - -/** -* Get the altimeter value -* -* @returns altimeter value as float -*/ -float getAltimeter( void); - -/** -* Get the pressure value -* -* @returns pressure value as float -*/ -float getPressure( void); + /** + * MPL3115A2 constructor + * + * @param sda SDA pin + * @param sdl SCL pin + * @param addr addr of the I2C peripheral + */ + MPL3115A2(PinName sda, PinName scl, int addr); + + /** + * Get the value of the WHO_AM_I register + * + * @returns DEVICE_ID value == 0xC4 + */ + uint8_t getDeviceID(); + + /** + * Return the STATUS register value + * + * @returns STATUS register value + */ + unsigned char getStatus( void); + + /** + * Get the altimeter value + * + * @returns altimeter value as float + */ + float getAltimeter( void); + + /** + * Get the pressure value + * + * @returns pressure value as float + */ + float getPressure( void); + + /** + * Get the temperature value + * + * @returns temperature value as float + */ + float getTemperature( void); + + /** + * Set the Altimeter Mode + * + * @returns none + */ + void Altimeter_Mode( void); + + /** + * Set the Barometric Mode + * + * @returns none + */ + void Barometric_Mode( void); + + /** + * Get the altimeter, pressure and temperature values + * + * @param array of float f[3] + * @returns none + */ + void getAllData( float *f); + + /** + * Return if there are date available + * + * @return 1 for data available, 0 for no data available + */ + unsigned int isDataAvailable( void); + + /** + * Set the oversampling rate value + * + * @param oversampling values. See MPL3115A2.h + * @return none + */ + void Oversample_Ratio( unsigned int ratio); -/** -* Get the temperature value -* -* @returns temperature value as float -*/ -float getTemperature( void); - -/** -* Set the Altimeter Mode -* -* @returns none -*/ -void Altimeter_Mode( void); - -/** -* Set the Barometric Mode -* -* @returns none -*/ -void Barometric_Mode( void); - -/** -* Get the altimeter, pressure and temperature values -* -* @param array of float f[3] -* @returns none -*/ -void getAllData( float *f); - -/** Return is there are date available -* -* @return 1 for data available, 0 for no data available -*/ -unsigned int isDataAvailable( void); - -/** Set the oversampling rate value -* -* @param oversampling values. See MPL3115A2.h -* @return none -*/ -void Oversample_Ratio( unsigned int ratio); + /** + * Configure the sensor to streaming data using Interrupt + * + * @param user functin callback, oversampling values. See MPL3115A2.h + * @return none + */ + void DataReady( void(*fptr)(void), unsigned char OS); + + /** + * Soft Reset + * + * @param none + * @return none + */ + void Reset( void); private: - I2C m_i2c; - int m_addr; - unsigned char MPL3115A2_mode; - unsigned char MPL3115A2_oversampling; - - /** Set the device in active mode - */ - void Active( void); - - /** Set the device in standby mode - */ - void Standby( void); - - void readRegs(int addr, uint8_t * data, int len); - void writeRegs(uint8_t * data, int len); + I2C m_i2c; + int m_addr; + unsigned char MPL3115A2_mode; + unsigned char MPL3115A2_oversampling; + void DataReady_IRQ( void); + + /** Set the device in active mode + */ + void Active( void); + + /** Set the device in standby mode + */ + void Standby( void); + + void readRegs(int addr, uint8_t * data, int len); + void writeRegs(uint8_t * data, int len); };