Added INPUT_PULLUP support and let analog write use full PWM range

This commit is contained in:
ZodiusInfuser
2021-03-22 16:52:06 +00:00
parent f2a0e601b2
commit d0074840ab
7 changed files with 15 additions and 4 deletions

View File

@@ -38,7 +38,7 @@ void analogWrite(uint32_t pin, uint32_t value)
ledc_channel_config_t ledc_conf = {
.channel = (pin % 7),
.duty = (value << 2),
.duty = (value << 2) | ((value & 0xC0) >> 6),
.gpio_num = pin,
.intr_type = LEDC_INTR_DISABLE,
.speed_mode = LEDC_HIGH_SPEED_MODE,

View File

@@ -33,6 +33,11 @@ void pinMode(uint32_t pin, uint32_t mode)
gpio_set_direction((gpio_num_t)pin, GPIO_MODE_OUTPUT);
gpio_set_pull_mode((gpio_num_t)pin, GPIO_FLOATING);
break;
case INPUT_PULLUP:
gpio_set_direction((gpio_num_t)pin, GPIO_MODE_INPUT);
gpio_set_pull_mode((gpio_num_t)pin, GPIO_PULLUP_ONLY);
break;
}
PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[pin], PIN_FUNC_GPIO);

View File

@@ -31,6 +31,7 @@ extern "C" {
#define INPUT 0x00
#define OUTPUT 0x01
#define INPUT_PULLUP 0x02
extern void pinMode(uint32_t pin, uint32_t mode);