// // Created by dell on 24-12-3. // #ifndef LDC1612_H #define LDC1612_H #include "gd32e23x_it.h" #include "gd32e23x.h" #include "systick.h" #include #include #include #include #include #include "board_config.h" #include "soft_i2c.h" #include "i2c.h" /***************************************************************************/ #define LDC1612_ADDR (0x2B << 1) /*Register Rddr*/ /***************************************************************************/ #define CONVERTION_RESULT_REG_START 0X00 #define SET_CONVERSION_TIME_REG_START 0X08 #define SET_CONVERSION_OFFSET_REG_START 0X0C #define SET_LC_STABILIZE_REG_START 0X10 #define SET_FREQ_REG_START 0X14 #define SENSOR_STATUS_REG 0X18 #define ERROR_CONFIG_REG 0X19 #define SENSOR_CONFIG_REG 0X1A #define MUL_CONFIG_REG 0X1B #define SENSOR_RESET_REG 0X1C #define SET_DRIVER_CURRENT_REG 0X1E #define READ_MANUFACTURER_ID 0X7E #define READ_DEVICE_ID 0X7F /******************************************************************************/ #define CHANNEL_0 0 #define CHANNEL_1 1 /******************************************************************************/ #define LDC1612_CONVERSION_TIME_CH0 0x0546 //0536 #define LDC1612_DRIVE_CURRENT 0xB000 //A000 #define LDC1612_MUX_CONFIG 0x020C // no auto scan and filter bandwidth 3.3MHz #define LDC1612_SENSOR_CONFIG 0x1601 #define LDC1612_ERROR_CONFIG 0x0000 #define LC_STABILIZE_TIME_CH0 0x001E //30 #define LDC1612_RESET_DEV 0x8000 //[15:0] 0b1000 0000 0000 0000 /******************************************************************************/ #define COIL_RP_KOM 15.727 #define COIL_L_UH 33 #define COIL_C_PF 150 #define COIL_Q_FACTOR 35.97 /******************************************************************************/ void ldc1612_set_conversion_time(uint8_t channel, uint16_t result); void ldc1612_set_conversion_offset(uint8_t channel, uint16_t result); void ldc1612_set_LC_stabilize_time(uint8_t channel, uint16_t result); void ldc1612_set_freq_divide(uint8_t channel); void ldc1612_set_error_config(uint16_t value); void ldc1612_set_mux_config(uint16_t value); void ldc1612_reset_sensor(void); void ldc1612_set_drive_current(uint8_t channel, uint16_t value); void ldc1612_set_sensor_config(uint16_t value); void ldc1612_single_ch0_config(void); void ldc1612_iic_get_sensor_infomation(void); uint16_t ldc1612_get_manufacturer_id(void); uint16_t ldc1612_get_deveice_id(void); uint32_t ldc1612_get_raw_channel_result(uint8_t channel); uint32_t ldc1612_parse_raw_result(uint32_t raw_result); #endif //LDC1612_H