pressure-wrapper: make p-w a separate project
This commit is contained in:
33
PressureWrapper/inc/I2C.h
Normal file
33
PressureWrapper/inc/I2C.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* I2C.h
|
||||
*
|
||||
* Created on: 21.2.2016
|
||||
* Author: krl
|
||||
*/
|
||||
|
||||
#ifndef I2C_H_
|
||||
#define I2C_H_
|
||||
|
||||
#include "chip.h"
|
||||
|
||||
struct I2C_config {
|
||||
unsigned int device_number;
|
||||
unsigned int speed;
|
||||
unsigned int clock_divider;
|
||||
unsigned int i2c_mode;
|
||||
I2C_config(): device_number(0), speed(100000), clock_divider(40), i2c_mode(IOCON_SFI2C_EN) {};
|
||||
};
|
||||
|
||||
class I2C {
|
||||
public:
|
||||
I2C(const I2C_config &cfg);
|
||||
virtual ~I2C();
|
||||
bool transaction(uint8_t devAddr, uint8_t *txBuffPtr, uint16_t txSize, uint8_t *rxBuffPtr, uint16_t rxSize);
|
||||
bool write(uint8_t devAddr, uint8_t *txBuffPtr, uint16_t txSize);
|
||||
bool read(uint8_t devAddr, uint8_t *rxBuffPtr, uint16_t rxSize);
|
||||
private:
|
||||
LPC_I2C_T *device;
|
||||
static uint32_t I2CM_XferBlocking(LPC_I2C_T *pI2C, I2CM_XFER_T *xfer);
|
||||
};
|
||||
|
||||
#endif /* I2C_H_ */
|
||||
43
PressureWrapper/inc/PressureWrapper.h
Normal file
43
PressureWrapper/inc/PressureWrapper.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* PressureWrapper.h
|
||||
*
|
||||
* Created on: 5 Oct 2022
|
||||
* Author: evgenymeshcheryakov
|
||||
*/
|
||||
|
||||
#ifndef PRESSUREWRAPPER_H_
|
||||
#define PRESSUREWRAPPER_H_
|
||||
|
||||
#include "I2C.h"
|
||||
#include <cstdio>
|
||||
|
||||
#define ADDRESS 0x40
|
||||
#define READADD 0x81
|
||||
#define WRITEADD 0x80
|
||||
|
||||
typedef struct _PRESSURE{
|
||||
uint8_t rBuffer[2];
|
||||
uint8_t crc;
|
||||
}PRESSURE_DATA;
|
||||
|
||||
class PressureWrapper
|
||||
{
|
||||
public:
|
||||
PressureWrapper ();
|
||||
/**
|
||||
* @brief Get the Status object
|
||||
*
|
||||
* @return true
|
||||
* @return false
|
||||
*/
|
||||
int getPressure ();
|
||||
|
||||
virtual ~PressureWrapper ();
|
||||
|
||||
private:
|
||||
I2C *i2c;
|
||||
PRESSURE_DATA data = {{0, 0}, 0};
|
||||
PRESSURE_DATA* getRawPressure ();
|
||||
};
|
||||
|
||||
#endif /* PRESSUREWRAPPER_H_ */
|
||||
Reference in New Issue
Block a user