⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gas_mon.h

📁 DS2438 one wire (ow) battery monitor code for renesas M16c... (-:cool:-)
💻 H
字号:
//_____________________________________________________________________________
//_____________________________________________________________________________
//  gas_mon header file
//_____________________________________________________________________________
//_____________________________________________________________________________

//_____________________________________________________________________________
//  Header file for gas_mon.c
//_____________________________________________________________________________

#define gas_mon // at top of file to ensure that this file is only included once


// Includes
//_________

#ifndef general
    #define general
    #include "...\general.h" 
#endif


// Defines
//________

// the temperature is read a number of times and the average result taken 
// monitor temperature readings to average over
#define MON_TEMP_READINGS_TO_AVERAGE 5

// Application specific pin configuration for DS2438
#define DQ_PULL_UP pu10 // pullup for DQ line

#define DQ Gascell_Monitor_Data_p4_2 
#define DQ_DIRECTION pd_Gascell_Monitor_Data_p4_2

#define DQ_EXTRA_PULL_UP Gascell_Monitor_Data_p4_1 
#define DQ_EXTRA_PULL_UP_DIRECTION pd_Gascell_Monitor_Data_p4_1 

// DS2438 ROM function commands

#define READ_ROM 0x33
#define MATCH_ROM 0x55
#define SEARCH_ROM 0xF0
#define SKIP_ROM 0xCC

// DS2438 SRAM/EEPROM Memory function commands:
//  You can't read and write directly to the SRAM/EEPROM memory map.  
//  You can only directly read and alter the "shadow" or "scratch" page
//  of each of the registers.
//  However, the two high level commands readRegister(page, byte) and 
//  writeRegister(page, byte, data) overcome this limitation by carrying
//  out all the low level scratch pad copying automatically.
//
//  Exception: The data in the scratchpad of the status and threshold 
//             register will determine the operation of the device.
//
//  Writing to the SRAM/EEPROM memory map:-
//  To modify a memory location you have to "write" to the approproate scratch 
//  page and then "copy" that into SRAM/EEPROM.
//  
//  Reading from the SRAM/EEPROM memory map:-  
//  To read a memory location you have to "recall" that page to the approproate 
//  scratch page and then "read" that scratch page.
//  
#define WRITE_SP 0x4E // write to scratch page
#define READ_SP 0xBE // read the scratch page 

#define COPY_SP 0x48 // copy scratch page i.e. scratch page x -> SRAM/EEPROM page x
#define RECALL_MEMORY 0xB8 // read from scratch page i.e. -> SRAM/EEPROM page x-> scratch page x

// DS2438 register commands
#define CONVERT_T 0x44 // start temperature conversion
#define CONVERT_V 0xB4 // start voltage conversion

// Prototypes
//___________

// Initialisation
void gas_mon_initialise(void);
void gas_mon_setFullICA(void); 

// calibration
void gas_mon_calibrate_current(void); // zero's current offset register

// power up/down - saves around 20uA
void gas_mon_power_down(void);
void gas_mon_power_up(void);

// read measurements and data
word gas_mon_readROMserial(void);

float gas_mon_read_V_at_Vad_Pin(void); // (V)
float gas_mon_read_V_at_Vdd_Pin(void); // (V)

float gas_mon_readTemp(void); // (deg. C)

word gas_mon_readCurrentRegisterword(void); // raw register word
float gas_mon_readCurrent(void); // (mA)
float gas_mon_readCurrentAbs(void); // (mA) always positive

float gas_mon_getFullICA(void); //mAhr  - does not actually change the ICA
float gas_mon_readICA(void); // (mAhr)
byte gas_mon_readICA_Registerbyte(void);  // raw register byte

void gas_mon_load_ICA(void);

// high level IO
byte gas_mon_readRegister(byte page, byte byteToRead);
void gas_mon_writeRegister(byte page, byte byteToChange, byte data); 

// Current A/D control bit (IAD bit)
void gas_mon_setIAD(void);
void gas_mon_clearIAD(void);
byte gas_mon_getIAD(void);



// End of file: gas_mon.h 
//_____________________________________________________________________________

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -