Skip to content
Snippets Groups Projects
Commit 5325059a authored by swym's avatar swym
Browse files

analog pgio: lock ADC HW

parent c19f1153
Branches
No related tags found
No related merge requests found
Pipeline #3518 passed
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "adc.h" #include "adc.h"
#include "mxc_errors.h" #include "mxc_errors.h"
#include "modules/log.h" #include "modules/log.h"
#include "modules/modules.h"
/* /*
* Despite what the schematic (currently, 2019-08-18) says these are the correct * Despite what the schematic (currently, 2019-08-18) says these are the correct
...@@ -133,13 +134,18 @@ int epic_gpio_read_pin(uint8_t pin) ...@@ -133,13 +134,18 @@ int epic_gpio_read_pin(uint8_t pin)
} else if (cfg->func == GPIO_FUNC_IN) { } else if (cfg->func == GPIO_FUNC_IN) {
return GPIO_InGet(cfg) != 0; return GPIO_InGet(cfg) != 0;
} else if (cfg->func == GPIO_FUNC_ALT1) { } else if (cfg->func == GPIO_FUNC_ALT1) {
int rc = hwlock_acquire(HWLOCK_ADC, pdMS_TO_TICKS(10));
if (!rc) {
ADC_StartConvert(s_adc_channels[pin], 0, 0); ADC_StartConvert(s_adc_channels[pin], 0, 0);
uint16_t value; uint16_t value;
int rc = ADC_GetData(&value); int rc = ADC_GetData(&value);
hwlock_release(HWLOCK_ADC);
if (rc < 0) { if (rc < 0) {
return -EIO; return -EIO;
} }
return (int)value; return (int)value;
}
return rc;
} else { } else {
return -EINVAL; return -EINVAL;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment