jianghuai/SYSTEM/ads1015.h
2024-05-07 09:36:09 +08:00

61 lines
2.0 KiB
C

#ifndef _ADS1015_H_
#define _ADS1015_H_
#include "stm32f10x.h"
#define ADS1015_IIC_SCL_ GPIO_Pin_6
#define ADS1015_IIC_SDA_ GPIO_Pin_7
/***************************************************************************************
*??:??????????????,?????????????????(???????)
* ??????????????,????????????????????
****************************************************************************************/
#define SDA_A1 PBout(7)=1 //SDA??
#define SDA_A0 PBout(7)=0
#define SCL_A1 PBout(6)=1 //SCL
#define SCL_A0 PBout(6)=0
#define SDA_AI PBin(7) //SDA??
//I2C
#define WR_REG 0x90 //????
#define RE_REG 0x91 //????
/***********************************??????**********************************************/
#define DATA_REG 0x00 //???????
#define CONF_REG 0x01 //????????
#define LOTH_REG 0x02 //???????
#define HITH_REG 0x03 //???????
#define ch0 0xc0 //??0
#define ch1 0xd0 //??1
#define ch2 0xe0 //??2
#define ch3 0xf0 //??3
/***********************?????*************************************************************
*| OS | MUX2 | MUX1 | MUX0 | PGA2 | PGA1 | PGA0 | MODE |------HCMD
*| DR2| DR1 | DR0 | COMP_MODE | COMP_POL | COMP_LAT | COMP_QUE1 | COMP_QUE0 |-----LCMD
***********************************************************************************************/
#define HCMD1 0x64 //AIN0???? +-4.096?? ???? 01000100b
#define LCMD1 0xf0 //860sps ??????? ????? ??????? ??????? 11110000b
/************************????****************************/
static void ADS1115_delay(u16 D);
void delay_nms(u16 ms);
void delay_nus(u16 us);
void ADS1115_Init(void);
void I2CStart_A(void);
void I2CStop_A(void);
void I2CWriteByte_A(u8 DATA);
u8 I2CReadByte_A(void);
void ADS1115Config_A(u8 LCMD,u8 HCMD);
void SetThresHold_A(u16 L_TH,u16 H_TH); //??????
u16 ReadAD_A(void);
u16 getad(u8 LCMD,u8 HCMD);
u16 lvbo(u8 LCMD,u8 HCMD);
float GetSampleVolt(u8 key);
#endif