auto detect drive current function OK!!!

This commit is contained in:
yelvlab 2025-04-02 14:15:48 +08:00
parent 2a0e0b40b6
commit db780ba529
2 changed files with 20 additions and 7 deletions

View File

@ -4,11 +4,11 @@ include(cmake/toolchain.cmake)
project(xlsw_3dp_LDC1612)
set(VERSION_MAJOR 0)
set(VERSION_MINOR 2)
set(VERSION_PATCH 0)
set(VERSION_MINOR F)
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")
set(IIC_TYPE "AutoDetectDriveCurrent")
#set(IIC_TYPE "HW-IIC")
enable_language(C)

View File

@ -33,14 +33,27 @@ 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();
}
}