Commit faff5c5e authored by Jeroen Vreeken's avatar Jeroen Vreeken
Browse files

Change am335x adc programming to use more time if available.

More retries in the same time for vesp commands.
parent 28f20769
...@@ -177,17 +177,25 @@ static struct controller_block * block_am335x_adc_create(char *name, int argc, v ...@@ -177,17 +177,25 @@ static struct controller_block * block_am335x_adc_create(char *name, int argc, v
factor = 200000 / frequency; factor = 200000 / frequency;
if (factor > 16) { if (factor > 16) {
avg = AM335X_ADC_STEPCONFIG_AVERAGE_16; avg = AM335X_ADC_STEPCONFIG_AVERAGE_16;
factor /= 16;
} else if (factor > 8) { } else if (factor > 8) {
avg = AM335X_ADC_STEPCONFIG_AVERAGE_8; avg = AM335X_ADC_STEPCONFIG_AVERAGE_8;
factor /= 8;
} else if (factor > 4) { } else if (factor > 4) {
avg = AM335X_ADC_STEPCONFIG_AVERAGE_4; avg = AM335X_ADC_STEPCONFIG_AVERAGE_4;
factor /= 4;
} else if (factor > 2) { } else if (factor > 2) {
avg = AM335X_ADC_STEPCONFIG_AVERAGE_2; avg = AM335X_ADC_STEPCONFIG_AVERAGE_2;
factor /= 2;
} else { } else {
avg = AM335X_ADC_STEPCONFIG_AVERAGE_1; avg = AM335X_ADC_STEPCONFIG_AVERAGE_1;
} }
factor /= 100;
if (!factor)
factor = 1;
log_send(LOG_T_DEBUG, "%s: factor: %d", name, factor);
am335x_write32(base, AM335X_ADC_REG_ADC_CLKDIV, 0); am335x_write32(base, AM335X_ADC_REG_ADC_CLKDIV, factor - 1);
am335x_write32(base, AM335X_ADC_REG_IDLECONFIG, 0); am335x_write32(base, AM335X_ADC_REG_IDLECONFIG, 0);
am335x_write32(base, AM335X_ADC_REG_TS_CHARGE_DELAY, 1); am335x_write32(base, AM335X_ADC_REG_TS_CHARGE_DELAY, 1);
......
...@@ -353,7 +353,11 @@ ssize_t vesp_command_real(struct controller_bus *bus, ...@@ -353,7 +353,11 @@ ssize_t vesp_command_real(struct controller_bus *bus,
struct timespec t_timeout; struct timespec t_timeout;
clock_gettime(CLOCK_MONOTONIC, &t_timeout); clock_gettime(CLOCK_MONOTONIC, &t_timeout);
t_timeout.tv_sec += 1; t_timeout.tv_nsec += 100000000;
if (t_timeout.tv_nsec > 1000000000) {
t_timeout.tv_nsec -= 1000000000;
t_timeout.tv_sec++;
}
while (1) { while (1) {
struct timespec timeout, t_now; struct timespec timeout, t_now;
...@@ -418,7 +422,7 @@ ssize_t vesp_command(struct controller_bus *bus, ...@@ -418,7 +422,7 @@ ssize_t vesp_command(struct controller_bus *bus,
void *res, size_t res_size) void *res, size_t res_size)
{ {
struct command_data data; struct command_data data;
int retries = 3; int retries = 30;
do { do {
data.bus = bus; data.bus = bus;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment