generated from hulk/gd32e23x_template
auto detect drive current function OK!!!
This commit is contained in:
24
src/main.c
24
src/main.c
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user