engine_control/source/firmware/kernel/driver/ds75.h

50 lines
1.5 KiB
C
Raw Normal View History

2016-07-23 05:59:54 +00:00
/*
* ds75.h
*
* Created on: Aug 1, 2012
* Author: tkl
*/
#ifndef DS75_H_
#define DS75_H_
#include <stdbool.h>
#include "i2c.h"
//-----------------------------------------------------------------------------
enum ds75_precision {
DS_75_PRECISION_9_BIT = 0,
DS_75_PRECISION_10_BIT,
DS_75_PRECISION_11_BIT,
DS_75_PRECISION_12_BIT,
DS_75_PRECISION_INVALID
};
//-----------------------------------------------------------------------------
//! \brief The ds75 driver object.
struct ds75 {
const struct i2c * i2c; //!< The i2c device the ds75 is connected to.
const char i2c_slave_addr; //!< The i2c slave address of the ds 75.
char *const config_value; //!< Config value.
};
//-----------------------------------------------------------------------------
//! \brief Data container for the ds 75 measurement result.
struct ds75_temperature {
short temperature; //!< Calculated temperature.
char raw[2]; //!< Raw i2c result.
bool valid; //!< Validity indicator.
};
//-----------------------------------------------------------------------------
int ds75_open(const struct ds75 *device);
int ds75_close(const struct ds75 *device);
int ds75_set_precision(const struct ds75 *device, enum ds75_precision precision);
enum ds75_precision ds_75_get_precision(const struct ds75 *device);
int ds_75_shut_down(const struct ds75 *device);
int ds_75_wakeup(const struct ds75 *device);
struct ds75_temperature ds_75_get_temperature(const struct ds75 *device);
#endif /* DS75_H_ */