71 lines
1.9 KiB
C
71 lines
1.9 KiB
C
#ifndef __ADS1220_H
|
|
#define __ADS1220_H
|
|
|
|
#include <stdint.h>
|
|
#include "freertos/queue.h"
|
|
|
|
#define ADS1220_DRDY_IO 7
|
|
#define SPI2_PIN_NUM_MISO 6
|
|
#define SPI2_PIN_NUM_MOSI 5
|
|
#define SPI2_PIN_NUM_CLK 16
|
|
#define SPI2_PIN_NUM_CS 15
|
|
#define ADS1220_HOST SPI2_HOST
|
|
#define PARALLEL_LINES 16
|
|
|
|
|
|
#define ADS1220_nCS_HIGH() gpio_set_level(GPIO_NUM_38, 1)
|
|
#define ADS1220_nCS_LOW() gpio_set_level(GPIO_NUM_38, 0)
|
|
|
|
#define ADS1220_CMD_WREG 0x40
|
|
#define ADS1220_CMD_RREG 0x20
|
|
#define ADS1220_CMD_RESET 0x06
|
|
#define ADS1220_CMD_START 0x08
|
|
#define ADS1220_CMD_POWERDOWN 0x02
|
|
#define ADS1220_CMD_RDATA 0x10
|
|
|
|
#define Channal1 0x00
|
|
#define Channal2 0x10
|
|
#define Channal3 0x20
|
|
#define Channal4 0x30
|
|
|
|
#define ADS1220_REG0 0x00
|
|
#define ADS1220_REG1 0x01
|
|
#define ADS1220_REG2 0x02
|
|
#define ADS1220_REG3 0x03
|
|
|
|
#define PGAGain1 0x00
|
|
#define PGAGain2 0x02
|
|
#define PGAGain4 0x04
|
|
#define PGAGain8 0x06
|
|
#define PGAGain16 0x08
|
|
#define PGAGain32 0x0A
|
|
#define PGAGain64 0x0C
|
|
#define PGAGain128 0x0E
|
|
|
|
#define ADS1220_Standby 0
|
|
#define ADS1220_ConvStart 1
|
|
#define ADS1220_ConvFinish 2
|
|
|
|
#define ADS1220_Channal1 0
|
|
#define ADS1220_Channal2 1
|
|
#define ADS1220_Channal3 2
|
|
#define ADS1220_Channal4 3
|
|
|
|
int ADS1220_get_rate(void);
|
|
void ADS1220_set_rate(int i);
|
|
void ADS1220_Config(void);
|
|
void ADS1220_StartConv(uint8_t channal);
|
|
void ADS1220_Reset(void);
|
|
void ADS1220_PowerDown(void);
|
|
void ADS1220_PGASet(uint8_t gain);
|
|
void ADS1220_WriteCommand(uint8_t cmd);
|
|
int32_t ADS1220_ReadData(void);
|
|
void ADS1220_WriteReg(uint8_t reg,uint8_t dat);
|
|
uint8_t ADS1220_ReadReg(uint8_t reg);
|
|
uint8_t ADS1220_ReadWriteByte(uint8_t dat);
|
|
|
|
void ads1220_init(void);
|
|
int ads1220_read_flow(int32_t *ad_raw_p, int *ad_ch_p, uint32_t *ad_update_time_p);
|
|
|
|
#endif
|