#ifndef __ADS1220_H #define __ADS1220_H // #include "main.h" #include #include #include #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "esp_system.h" #include "driver/spi_master.h" #include "driver/gpio.h" typedef uint8_t u8; typedef uint32_t u32; typedef int32_t s32; #define LED1_GPIO_PIN 9 #define LED2_GPIO_PIN 10 #define GPIO_INPUT_IO_39 7 typedef struct { int ch0_4ma; int ch0_12ma; float ch0_4ma_yl; float ch0_12ma_yl; int ch1_4ma; int ch1_12ma; float ch1_4ma_yl; float ch1_12ma_yl; int ch2_4ma; int ch2_12ma; float ch2_4ma_yl; float ch2_12ma_yl; }ads_cali_t; //extern ads_cali_t ads_cali; uint32_t get_now_20us(void); int32_t tim_diff(uint32_t a,uint32_t b); int ADS1220_get_rate(void); void ADS1220_set_rate(int i); void ADS1220_Init(void); // ADS1220��ʼ�� void ADS1220_Config(void); // ADS1220���� void ADS1220_StartConv(u8 channal); // ADS1220����ת�� void ADS1220_Reset(void); // ADS1220��λ void ADS1220_PowerDown(void); // ADS1220�������ģʽ void ADS1220_PGASet(u8 gain); // ADS1220 PGA���� void ADS1220_WriteCommand(u8 cmd); // ADS1220д���� s32 ADS1220_ReadData(void); // ADS1220������ void ADS1220_WriteReg(u8 reg,u8 dat); // ADS1220д�Ĵ��� u8 ADS1220_ReadReg(u8 reg); // ADS1220���Ĵ��� u8 ADS1220_ReadWriteByte(u8 dat); // ��SPI������д��һ�ֽ� u32 ADS1220_ReadWrite24Bits(u32 dat); // ��ADS1220������д��24Bits int scale(int raw, int raw_min, int raw_max,int eng_min, int eng_max); #endif