pressure-wrapper: add structure for pressure_data
This commit is contained in:
parent
1524171e31
commit
98ae07bc18
@ -15,10 +15,15 @@
|
||||
#define READADD 0x81
|
||||
#define WRITEADD 0x80
|
||||
|
||||
typedef struct _PRESSURE{
|
||||
uint8_t rBuffer[2];
|
||||
uint8_t crc;
|
||||
}PRESSURE_DATA;
|
||||
|
||||
class PressureWrapper
|
||||
{
|
||||
public:
|
||||
PressureWrapper ();
|
||||
PressureWrapper (I2C *i2c);
|
||||
/**
|
||||
* @brief Get the Status object
|
||||
*
|
||||
@ -26,12 +31,13 @@ public:
|
||||
* @return false
|
||||
*/
|
||||
bool getStatus ();
|
||||
int16_t getPressure ();
|
||||
PRESSURE_DATA* getPressure ();
|
||||
|
||||
virtual ~PressureWrapper ();
|
||||
|
||||
private:
|
||||
I2C *i2c;
|
||||
PRESSURE_DATA data = {{0, 0}, 0};
|
||||
};
|
||||
|
||||
#endif /* PRESSUREWRAPPER_H_ */
|
||||
|
||||
@ -7,12 +7,25 @@
|
||||
|
||||
#include <PressureWrapper.h>
|
||||
|
||||
PressureWrapper::PressureWrapper ()
|
||||
PressureWrapper::PressureWrapper (I2C *i2c) : i2c(i2c)
|
||||
{
|
||||
// TODO Auto-generated constructor stub
|
||||
|
||||
}
|
||||
|
||||
PressureWrapper::~PressureWrapper ()
|
||||
{
|
||||
// TODO Auto-generated destructor stub
|
||||
}
|
||||
|
||||
bool PressureWrapper::getStatus() {
|
||||
uint8_t control_register = 0x01;
|
||||
uint8_t status = 0;
|
||||
i2c->transaction(ADDRESS, &control_register, 1, &status, 1);
|
||||
}
|
||||
|
||||
PRESSURE_DATA* PressureWrapper::getPressure () {
|
||||
uint8_t getMeasurementComm = 0xF1;
|
||||
i2c->transaction(ADDRESS, &getMeasurementComm, 1, data.rBuffer, 3);
|
||||
//i2c->transaction(ADDRESS, &getMeasurementComm, 1, data.crc, 1);
|
||||
return &data;
|
||||
}
|
||||
|
||||
@ -46,6 +46,7 @@
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/I2C/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/StateHandler/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/Timer/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/PressureWrapper/inc}""/>
|
||||
</option>
|
||||
<option id="com.crt.advproject.cpp.misc.dialect.1893636131" name="Language standard" superClass="com.crt.advproject.cpp.misc.dialect" useByScannerDiscovery="true" value="com.crt.advproject.misc.dialect.c++11" valueType="enumerated"/>
|
||||
<inputType id="com.crt.advproject.compiler.cpp.input.1024506123" superClass="com.crt.advproject.compiler.cpp.input"/>
|
||||
@ -75,6 +76,7 @@
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/I2C/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/StateHandler/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/Timer/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/PressureWrapper/inc}""/>
|
||||
</option>
|
||||
<option id="com.crt.advproject.c.misc.dialect.1885316467" name="Language standard" superClass="com.crt.advproject.c.misc.dialect" useByScannerDiscovery="true" value="com.crt.advproject.misc.dialect.c11" valueType="enumerated"/>
|
||||
<inputType id="com.crt.advproject.compiler.input.1491212950" superClass="com.crt.advproject.compiler.input"/>
|
||||
@ -94,6 +96,7 @@
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/I2C/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/StateHandler/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/Timer/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/PressureWrapper/inc}""/>
|
||||
</option>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.486566022" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
||||
<inputType id="com.crt.advproject.assembler.input.255980151" name="Additional Assembly Source Files" superClass="com.crt.advproject.assembler.input"/>
|
||||
@ -126,6 +129,7 @@
|
||||
<listOptionValue builtIn="false" value="I2C"/>
|
||||
<listOptionValue builtIn="false" value="StateHandler"/>
|
||||
<listOptionValue builtIn="false" value="Timer"/>
|
||||
<listOptionValue builtIn="false" value="PressureWrapper"/>
|
||||
</option>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.cpp.link.option.paths.804461696" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/lpc_board_nxp_lpcxpresso_1549/Debug}""/>
|
||||
@ -135,6 +139,7 @@
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/I2C/Debug}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/StateHandler/Debug}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/Timer/Debug}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/PressureWrapper/Debug}""/>
|
||||
</option>
|
||||
<option id="com.crt.advproject.link.cpp.crpenable.8641361" name="Enable automatic placement of Code Read Protection field in image" superClass="com.crt.advproject.link.cpp.crpenable"/>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.849613399" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
|
||||
@ -200,6 +205,7 @@
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/I2C/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/StateHandler/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/Timer/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/PressureWrapper/inc}""/>
|
||||
</option>
|
||||
<option id="com.crt.advproject.cpp.misc.dialect.1640449237" name="Language standard" superClass="com.crt.advproject.cpp.misc.dialect" useByScannerDiscovery="true" value="com.crt.advproject.misc.dialect.c++11" valueType="enumerated"/>
|
||||
<inputType id="com.crt.advproject.compiler.cpp.input.812988440" superClass="com.crt.advproject.compiler.cpp.input"/>
|
||||
@ -229,6 +235,7 @@
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/I2C/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/StateHandler/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/Timer/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/PressureWrapper/inc}""/>
|
||||
</option>
|
||||
<option id="com.crt.advproject.c.misc.dialect.1383624929" name="Language standard" superClass="com.crt.advproject.c.misc.dialect" useByScannerDiscovery="true" value="com.crt.advproject.misc.dialect.c11" valueType="enumerated"/>
|
||||
<inputType id="com.crt.advproject.compiler.input.391538574" superClass="com.crt.advproject.compiler.input"/>
|
||||
@ -248,6 +255,7 @@
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/I2C/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/StateHandler/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/Timer/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/PressureWrapper/inc}""/>
|
||||
</option>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1169670567" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
||||
<inputType id="com.crt.advproject.assembler.input.956763731" name="Additional Assembly Source Files" superClass="com.crt.advproject.assembler.input"/>
|
||||
@ -280,6 +288,7 @@
|
||||
<listOptionValue builtIn="false" value="I2C"/>
|
||||
<listOptionValue builtIn="false" value="StateHandler"/>
|
||||
<listOptionValue builtIn="false" value="Timer"/>
|
||||
<listOptionValue builtIn="false" value="PressureWrapper"/>
|
||||
</option>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.cpp.link.option.paths.245096214" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/lpc_board_nxp_lpcxpresso_1549/Release}""/>
|
||||
@ -289,6 +298,7 @@
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/I2C/Release}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/StateHandler/Release}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/Timer/Release}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/PressureWrapper/Release}""/>
|
||||
</option>
|
||||
<option id="com.crt.advproject.link.cpp.crpenable.209534913" name="Enable automatic placement of Code Read Protection field in image" superClass="com.crt.advproject.link.cpp.crpenable"/>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.1513506142" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
<project>I2C</project>
|
||||
<project>StateHandler</project>
|
||||
<project>Timer</project>
|
||||
<project>PressureWrapper</project>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
|
||||
@ -20,6 +20,8 @@
|
||||
#include "LiquidCrystal.h"
|
||||
#include "StateHandler.h"
|
||||
#include "Timer.h"
|
||||
#include "PressureWrapper.h"
|
||||
#include "I2C.h"
|
||||
|
||||
#include <cr_section_macros.h>
|
||||
|
||||
@ -64,7 +66,14 @@ main (void)
|
||||
DigitalIoPin b_toggle (0, 5, true, true, true); // A3
|
||||
bool b_toggle_state = false;
|
||||
|
||||
int16_t pressure = 1;
|
||||
// NVIC_DisableIRQ(I2C0_IRQn);
|
||||
|
||||
I2C_config config;
|
||||
I2C i2c(config);
|
||||
PressureWrapper sens(&i2c);
|
||||
|
||||
PRESSURE_DATA *pressure;
|
||||
pressure = sens.getPressure();
|
||||
|
||||
Timer glob_time;
|
||||
|
||||
@ -103,7 +112,7 @@ main (void)
|
||||
* TODO:
|
||||
* - Update current pressure to eTick
|
||||
*/
|
||||
ventMachine.HandleState (Event (Event::eTick, pressure));
|
||||
ventMachine.HandleState (Event (Event::eTick, pressure->rBuffer[1]));
|
||||
glob_time.tickCounter(1);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user