Add setAnalogRead type & command handler. Add core analogRead function.

This commit is contained in:
anecdata
2019-10-13 21:32:06 -05:00
parent b90bbd6349
commit 5687201ec9
3 changed files with 25 additions and 1 deletions

View File

@@ -18,6 +18,7 @@
*/
#include <driver/ledc.h>
#include <driver/adc.h>
#include "wiring_analog.h"
@@ -43,3 +44,11 @@ void analogWrite(uint32_t pin, uint32_t value)
};
ledc_channel_config(&ledc_conf);
}
int analogRead(uint32_t pin)
{
adc1_config_width(ADC_WIDTH_BIT_12);
adc1_config_channel_atten(pin,ADC_ATTEN_DB_11);
int val = adc1_get_raw(pin);
return val;
}

View File

@@ -28,6 +28,8 @@ extern "C" {
extern void analogWrite(uint32_t pin, uint32_t value);
extern int analogRead(uint32_t pin);
#ifdef __cplusplus
}
#endif