forked from donny681/ESP32_CAMERA_QR
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wiring.c
33 lines (29 loc) · 767 Bytes
/
wiring.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "wiring.h"
#include "soc/gpio_reg.h"
#include "soc/io_mux_reg.h"
#include "driver/gpio.h"
void pinMode(int pin, int mode) {
gpio_config_t conf = {0};
conf.pin_bit_mask = 1LL << pin;
if (mode == OUTPUT) {
conf.mode = GPIO_MODE_OUTPUT;
}
if (mode == INPUT || mode == INPUT_PULLUP) {
conf.mode = GPIO_MODE_INPUT;
}
if (mode == INPUT) {
conf.pull_down_en = GPIO_PULLDOWN_DISABLE;
conf.pull_up_en = GPIO_PULLUP_DISABLE;
}
else if (mode == INPUT_PULLUP) {
conf.pull_down_en = GPIO_PULLDOWN_DISABLE;
conf.pull_up_en = GPIO_PULLUP_ENABLE;
}
gpio_config(&conf);
}
void digitalWrite(int pin, int value) {
gpio_set_level(pin, (value)?1:0);
}
void delay(int millis) {
vTaskDelay(millis / portTICK_PERIOD_MS);
}