#ifndef _DRV_ADS8688_H_ #define _DRV_ADS8688_H_ #ifdef __cplusplus extern "C" { #endif #include #include "kit_macro.h" #include "gpio_manager.h" #include "drv_spi.h" /* kGpioType_ADC_Cs */ //Command Register #define NO_OP 0X0000 #define STDBY 0X8200 #define PWR_DN 0X8300 #define RST 0X8500 #define AUTO_RST 0XA000 #define MAN_Ch_0 0XC000 #define MAN_Ch_1 0XC400 #define MAN_Ch_2 0XC800 #define MAN_Ch_3 0XCC00 #define MAN_Ch_4 0XD000 #define MAN_Ch_5 0XD400 #define MAN_Ch_6 0XD800 #define MAN_Ch_7 0XDC00 #define MAN_AUX 0XE000 //Program Register #define AUTO_SEQ_EN 0x01 #define Channel_Power_Down 0X02 #define Feature_Select 0X03 #define Channel_0_Input_Range 0X05 #define Channel_1_Input_Range 0X06 #define Channel_2_Input_Range 0X07 #define Channel_3_Input_Range 0X08 #define Channel_4_Input_Range 0X09 #define Channel_5_Input_Range 0X0A #define Channel_6_Input_Range 0X0B #define Channel_7_Input_Range 0X0C #define Ch_0_Hysteresis 0X15 #define Ch_0_High_Threshold_MSB 0X16 #define Ch_0_High_Threshold_LSB 0X17 #define Ch_0_Low_Threshold_MSB 0X18 #define Ch_0_Low_Threshold_LSB 0X19 #define Ch_7_Hysteresis 0X38 #define Ch_7_High_Threshold_MSB 0X39 #define Ch_7_High_Threshold_LSB 0X3A #define Ch_7_Low_Threshold_MSB 0X3B #define Ch_7_Low_Threshold_LSB 0X3C #define Command_Read_Back 0X3F #define WRITE 1 #define READ 0 #define CH7_EN 0X80 #define CH6_EN 0X40 #define CH5_EN 0X20 #define CH4_EN 0X10 #define CH3_EN 0X08 #define CH2_EN 0X04 #define CH1_EN 0X02 #define CH0_EN 0x01 #define CH7_PD 0X80 #define CH6_PD 0X40 #define CH5_PD 0X20 #define CH4_PD 0X10 #define CH3_PD 0X08 #define CH2_PD 0X04 #define CH1_PD 0X02 #define CH0_PD 0x01 #define VREF_25_25 0X00 #define VREF_125_125 0x01 #define VREF_0625_0625 0X02 #define VREF_0_25 0X05 #define VREF_0_125 0X06 #define ADC_AUTO_MODE 0 typedef struct { uint8_t cs; SpiDev spi; }Ads8688Item; #define ADS8688_STATIC_INIT(_name, _spi, _cs) \ Ads8688Item _name = \ { \ .cs = _cs, \ .spi = _spi, \ } void drv_set_ads8688_cs(GpioStatus state); void drv_set_ads8688_rst(GpioStatus state); bool drv_ads8688_Init(void); void drv_ads8688_Reset(void); void drv_ads8688_pwrdn(void); void drv_ads8688_pwrup(void); void drv_reset_ads8688(void); void drv_enter_standby_mode (void); void drv_enter_pwrdn_mode (void); void drv_enter_auto_rst_mode(void); void drv_enter_auto_rst_mode_Data(uint16_t* outputdata, uint8_t chnum); void drv_ads8688_write_reg(uint8_t Addr,uint8_t data); uint16_t drv_ads8688_read_reg(uint8_t Addr); void drv_set_auto_scan_sequence(uint8_t seq); void drv_set_ch_pwrdn(uint8_t chn); void drv_set_ch_range(uint8_t ch,uint8_t range); void drv_ads8688_write_cmd_reg(uint16_t command); void drv_manual_chn_mode(uint16_t ch); uint16_t drv_manual_chn_mode_Data(void); uint16_t drv_get_ads8688_ch_data(uint16_t ch); int16_t drv_ads8688_value(uint16_t value); #ifdef __cplusplus } #endif #endif