auto detect drive current function OK!!!

This commit is contained in:
yelvlab 2025-04-02 14:10:28 +08:00
parent da22e0eff9
commit 6c37fecd28
3 changed files with 22 additions and 6 deletions

View File

@ -5,7 +5,7 @@ project(xlsw_3dp_LDC1612)
set(VERSION_MAJOR 0)
set(VERSION_MINOR 2)
set(VERSION_PATCH 0)
set(VERSION_PATCH 1)
set(VERSION "V${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
string(TIMESTAMP CURRENT_DATE "%Y-%m-%d")
set(IIC_TYPE "SW-IIC")

View File

@ -48,7 +48,7 @@
/******************************************************************************/
#define LDC1612_CONVERSION_TIME_CH0 0x0546 //0536
#define LDC1612_DRIVE_CURRENT 0x9000 //A000
#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

View File

@ -33,14 +33,30 @@ int main(void) {
#endif
/* configure LDC1612 */
ldc1612_single_ch0_config();
// ldc1612_single_ch0_config();
/* Initialize watchdog */
watchdog_init();
// watchdog_init();
while (1) {
delay_ms(99);
fwdgt_counter_reload();
// delay_ms(10);
uint8_t data[2] = {0};
ldc1612_set_freq_divide(CHANNEL_0);
soft_i2c_read_16bits(LDC1612_ADDR, SENSOR_CONFIG_REG, data);
printf("SENSOR_CONFIG_REG: 0x%x\n", (data[0] << 8) | data[1]);
soft_i2c_write_16bits(LDC1612_ADDR, SENSOR_CONFIG_REG, (data[0] << 8) | data[1]);
ldc1612_set_sensor_config(LDC1612_SENSOR_CONFIG); //0x1A --0x1601
delay_ms(100);
soft_i2c_read_16bits(LDC1612_ADDR, SET_DRIVER_CURRENT_REG, data);
printf("sensor config: 0x%x\n", (data[0] << 8) | data[1]);
printf("sensor config: 0x%x\n", (((data[0] << 8) | data[1]) >> 6) & 0x1F);
printf("drive current value: 0x%x\n", (((((data[0] << 8) | data[1]) >> 6) & 0x1F) << 11) | 0x0000);
delay_ms(999);
// fwdgt_counter_reload();
}
}