Update ax5043.c

pull/6/head
alanbjohnston 7 years ago committed by GitHub
parent 2ae75ad8a7
commit 02133b00af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -616,6 +616,7 @@ int ax5043_autoranging(ax5043_conf_t *conf) {
val = BIT(4) | AX5043_VCOR_INIT; val = BIT(4) | AX5043_VCOR_INIT;
ret = ax5043_spi_write_8(conf, pllranging_reg, val); ret = ax5043_spi_write_8(conf, pllranging_reg, val);
if (ret) { if (ret) {
printf("ERROR: AX5043 Autoranging Write Failure\n\n");
return ret; return ret;
} }
@ -627,6 +628,7 @@ int ax5043_autoranging(ax5043_conf_t *conf) {
while (((val & BIT(4)) != 0) && !timeout ) { // changed to !=, since https://www.onsemi.com/pub/Collateral/AND9347-D.PDF says BIT(4) RNG START clears when autoranging done while (((val & BIT(4)) != 0) && !timeout ) { // changed to !=, since https://www.onsemi.com/pub/Collateral/AND9347-D.PDF says BIT(4) RNG START clears when autoranging done
ret = ax5043_spi_read_8(conf, &val, pllranging_reg); ret = ax5043_spi_read_8(conf, &val, pllranging_reg);
if (ret) { if (ret) {
printf("ERROR: AX5043 Autoranging Read Failure\n\n");
return ret; return ret;
} }
if ((clock() - start) > 500000) { if ((clock() - start) > 500000) {
@ -634,10 +636,13 @@ int ax5043_autoranging(ax5043_conf_t *conf) {
} }
} }
if ((val & BIT(5)) || timeout) { if (val & BIT(5)) {
printf("ERROR: AX5043 Autoranging Error\n\n");
return -PQWS_AX5043_AUTORANGING_ERROR; return -PQWS_AX5043_AUTORANGING_ERROR;
} else if (timeout) {
printf("ERROR: AX5043 Autoranging Timeout\n\n");
return -1;
} }
return PQWS_SUCCESS; return PQWS_SUCCESS;
} }

Loading…
Cancel
Save

Powered by TurnKey Linux.