?? gas_mon.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 + -