pile_com_stm32/main/stm32/ads1220.h

62 lines
1.7 KiB
C
Raw Normal View History

2023-07-20 10:17:11 +08:00
#ifndef __ADS1220_H
#define __ADS1220_H
// #include "main.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#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
2023-07-20 10:17:11 +08:00
#define GPIO_INPUT_IO_39 7
2023-07-20 10:17:11 +08:00
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<32><30>ʼ<EFBFBD><CABC>
void ADS1220_Config(void); // ADS1220<32><30><EFBFBD><EFBFBD>
void ADS1220_StartConv(u8 channal); // ADS1220<32><30><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>
void ADS1220_Reset(void); // ADS1220<32><30>λ
void ADS1220_PowerDown(void); // ADS1220<32><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ
void ADS1220_PGASet(u8 gain); // ADS1220 PGA<47><41><EFBFBD><EFBFBD>
void ADS1220_WriteCommand(u8 cmd); // ADS1220д<30><D0B4><EFBFBD><EFBFBD>
s32 ADS1220_ReadData(void); // ADS1220<32><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void ADS1220_WriteReg(u8 reg,u8 dat); // ADS1220д<30>Ĵ<EFBFBD><C4B4><EFBFBD>
u8 ADS1220_ReadReg(u8 reg); // ADS1220<32><30><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD>
u8 ADS1220_ReadWriteByte(u8 dat); // <20><>SPI<50><49><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4>һ<EFBFBD>ֽ<EFBFBD>
u32 ADS1220_ReadWrite24Bits(u32 dat); // <20><>ADS1220<32><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4>24Bits
int scale(int raw, int raw_min, int raw_max,int eng_min, int eng_max);
#endif