You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
100 lines
2.4 KiB
100 lines
2.4 KiB
#ifndef DS1624_H
|
|
#define DS1624_H
|
|
|
|
#include "../global.h"
|
|
#include "../configs/ds1624/ds1624.h"
|
|
|
|
#define DS1624_BASE_ADDR B01001000
|
|
#define DS1624_ADDR DS1624_BASE_ADDR | (DS1624_A0 * B00000001) | (DS1624_A1 * B00000010) | (DS1624_A2 * B00000100)
|
|
|
|
/**
|
|
* Sampling configurations
|
|
**/
|
|
#define DS1624_CONFIG_1SHOT B00000001
|
|
#define DS1624_CONFIG_CONT B00000000
|
|
|
|
// Select either 1shot or continous themometer mode
|
|
#define DS1624_CONFIGS DS1624_CONFIG_CONT
|
|
|
|
// DS1624 Commands
|
|
#define DS1624_CONFIG_ADDR 0xAC
|
|
#define DS1624_READ_TEMP 0xAA
|
|
#define DS1624_SMPL_START 0xEE
|
|
#define DS1624_SMPL_STOP 0x22
|
|
#define DS1624_ACCESS_MEM 0x17
|
|
|
|
// Bit masks
|
|
#define DS1624_CONFIG_DONE B10000000
|
|
|
|
// Size of the EEPROM memory in bytes
|
|
#define DS1624_EEPROM_SIZE 255 /* There are actually 256 bytes, but the twi functions only support reading 255 at a time!*/
|
|
#define DS1624_EEPROM_PAGE 8
|
|
|
|
class DS1624
|
|
{
|
|
public:
|
|
DS1624();
|
|
|
|
/**
|
|
* Init: runs the initializationr outine
|
|
**/
|
|
void Init(void);
|
|
|
|
/**
|
|
* readTemp: reads the temperature and returns
|
|
* a 16 byte integer in which the 2 highest bytes
|
|
* are used as (int8_t)degrees and the 2 lowest
|
|
* are used (uint8_t)decimals
|
|
**/
|
|
uint16_t readTemp(void);
|
|
|
|
/**
|
|
* Start conversion, used at startup in
|
|
* continous mode, or before a read
|
|
* in 1shot mode
|
|
**/
|
|
void startConversion(void);
|
|
|
|
/**
|
|
* stopConversion: stops the temperature acquisition
|
|
**/
|
|
void stopConversion(void);
|
|
/**
|
|
* EEPROM Support functions
|
|
**/
|
|
#ifdef DS1624_USE_EEPROM
|
|
/**
|
|
* writeData: writes data to the eeprom
|
|
* pass it an array of uint8_t containing the values to write,
|
|
* the start position (must be %8 == 0) and the length.
|
|
* The two last can be omnited.
|
|
**/
|
|
void writeData(uint8_t *, uint8_t, uint8_t);
|
|
void writeData(uint8_t *, uint8_t);
|
|
void writeData(uint8_t *);
|
|
|
|
/**
|
|
* writeData: writes data to the eeprom
|
|
* pass it an array of uint8_t to store the result,
|
|
* the start position and the length. The two last can be omnited
|
|
**/
|
|
void readData(uint8_t *, uint8_t, uint8_t);
|
|
void readData(uint8_t *, uint8_t);
|
|
void readData(uint8_t *);
|
|
#endif
|
|
private:
|
|
#ifdef DS1624_USE_EEPROM
|
|
/**
|
|
* writePage: writes a single page (or less) to the eeprom
|
|
* pass it an array of uint8_t to store the result,
|
|
* the start position and the length.
|
|
**/
|
|
void writePage(uint8_t *, uint8_t, uint8_t);
|
|
#endif
|
|
|
|
};
|
|
|
|
extern DS1624 TEMP;
|
|
|
|
#endif
|