Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
10 years, 5 months ago.
Is this code compatible with Nucleo-L053R8 board? and ms58xx series sensors?
Hi, This is gandhi. I'm doing an internship. Here Can i use this code to run ms58xx series sensors? and also to Nucleo-L053R8 board. I'm getting errors like this: Error: Constant "PB_7" is not a type name in "ms5611.cpp", Line: 29, Col: 16 Error: Constant "PB_6" is not a type name in "ms5611.cpp", Line: 29, Col: 26
Question relating to:
1 Answer
10 years, 5 months ago.
Where does PB_6 and PB_7 come from? I2C for the L053R8 board is PB_8 and PB_9.
Try using the code example in the ms5611.h file. The MS5805 has a fixed I2C address of 0xEC, which is the same as the MS5611 with the CS pin tied high. Use the init line below:
ms5611 ms(PB_9, PB_8, ms5611::CSBpin_1); // if the above line doesn't work, try the following line instead // ms5611 ms(D14, D15, ms5611::CSBpin_1);
...kevin
show your code how you define ms5611 object
posted by Martin Kojtal 27 May 2015#include "mbed.h" #include "ms5611.h" double P; // compensated pressure value (mB) double T; // compensated temperature value (degC) double A; // altitude (ft) double S; // sea level barometer (mB) uint32_t C[8]; //coefficient storage //--------------------------------------------------------------------------------------------------------------------------------------// // Constructor and destructor - default to be compatible with legacy m5611 driver ms5611::ms5611(PB_7, PB_6) : _i2c(sda, scl) { _i2c.frequency(400000); _i2cWAddr = MS5611_ADDR_W; _i2cRAddr = MS5611_ADDR_R; } //--------------------------------------------------------------------------------------------------------------------------------------// // Constructor and destructor - new, to allow for user to select i2c address based on CSB pin ms5611::ms5611(PB_7, PB_6, CSBpolarity CSBpin) : _i2c(sda, scl) { _i2c.frequency(400000); _i2cWAddr = MS5611_ADDR_W; _i2cRAddr = MS5611_ADDR_R; if(CSBpin == CSBpin_1) { _i2cWAddr -= 2; _i2cRAddr -= 2; } } //******************************************************** //! @brief send I2C start condition and the address byte //! //! @return 0 //******************************************************** int ms5611::m_i2c_start(bool readMode) { int twst; _i2c.start(); if(readMode == true) { twst = m_i2c_write(_i2cRAddr); } else { twst = m_i2c_write(_i2cWAddr); } return(twst); } //******************************************************** //! @brief send I2C stop condition //! //! @return none //******************************************************** void ms5611::m_i2c_stop(void) { _i2c.stop(); } //******************************************************** //! @brief send I2C stop condition //! //! @return remote ack status //******************************************************** unsigned char ms5611::m_i2c_write(unsigned char data) { int twst = _i2c.write(data); return(twst); } //******************************************************** //! @brief read I2C byte with acknowledgment //! //! @return read byte //********************************************************