-
Notifications
You must be signed in to change notification settings - Fork 6
/
ESPEasySerialType.h
103 lines (83 loc) · 2.83 KB
/
ESPEasySerialType.h
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#ifndef ESPEASY_SERIAL_ESPEASYSERIALTYPE_H
#define ESPEASY_SERIAL_ESPEASYSERIALTYPE_H
#include "ESPEasySerialPort.h"
#ifdef ESP32
# ifndef SOC_UART_FIFO_LEN
# define SOC_UART_FIFO_LEN (128)
# endif // ifndef SOC_UART_FIFO_LEN
// Default pins taken from here:
// https://github.com/espressif/arduino-esp32/blob/3ec5f4efa1de4342aaab742008dc630091e5e035/cores/esp32/HardwareSerial.cpp#L24-L92
// Changed RX1 and TX1 for ESP32-classic, as the defaults chosen by Espressif are flash pins.
// Changed RX1 and TX1 for ESP32-C3 to lower pin nrs to have proper options for small boards.
# ifndef SOC_RX0
# if CONFIG_IDF_TARGET_ESP32
# define SOC_RX0 3
# elif CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
# define SOC_RX0 44
# elif CONFIG_IDF_TARGET_ESP32C3
# define SOC_RX0 20
# endif // if CONFIG_IDF_TARGET_ESP32
# endif // ifndef SOC_RX0
# ifndef SOC_TX0
# if CONFIG_IDF_TARGET_ESP32
# define SOC_TX0 1
# elif CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
# define SOC_TX0 43
# elif CONFIG_IDF_TARGET_ESP32C3
# define SOC_TX0 21
# endif // if CONFIG_IDF_TARGET_ESP32
# endif // ifndef SOC_TX0
# if SOC_UART_NUM > 1
# ifndef SOC_RX1
# if CONFIG_IDF_TARGET_ESP32
# define SOC_RX1 13
# elif CONFIG_IDF_TARGET_ESP32S2
# define SOC_RX1 18
# elif CONFIG_IDF_TARGET_ESP32C3
# define SOC_RX1 4
# elif CONFIG_IDF_TARGET_ESP32S3
# define SOC_RX1 15
# endif // if CONFIG_IDF_TARGET_ESP32
# endif // ifndef SOC_RX1
# ifndef SOC_TX1
# if CONFIG_IDF_TARGET_ESP32
# define SOC_TX1 15
# elif CONFIG_IDF_TARGET_ESP32S2
# define SOC_TX1 17
# elif CONFIG_IDF_TARGET_ESP32C3
# define SOC_TX1 5
# elif CONFIG_IDF_TARGET_ESP32S3
# define SOC_TX1 16
# endif // if CONFIG_IDF_TARGET_ESP32
# endif // ifndef SOC_TX1
# endif // if SOC_UART_NUM > 1
# if SOC_UART_NUM > 2
# ifndef SOC_RX2
# if CONFIG_IDF_TARGET_ESP32
# define SOC_RX2 16
# elif CONFIG_IDF_TARGET_ESP32S3
# define SOC_RX2 19
# else // if CONFIG_IDF_TARGET_ESP32
# define SOC_RX2 -1
# endif // if CONFIG_IDF_TARGET_ESP32
# endif // ifndef SOC_RX2
# ifndef SOC_TX2
# if CONFIG_IDF_TARGET_ESP32
# define SOC_TX2 17
# elif CONFIG_IDF_TARGET_ESP32S3
# define SOC_TX2 20
# else // if CONFIG_IDF_TARGET_ESP32
# define SOC_TX2 -1
# endif // if CONFIG_IDF_TARGET_ESP32
# endif // ifndef SOC_TX2
# endif // if SOC_UART_NUM > 2
#endif // ifdef ESP32
struct ESPeasySerialType {
static bool getSerialTypePins(ESPEasySerialPort serType,
int & rxPin,
int & txPin);
static ESPEasySerialPort getSerialType(ESPEasySerialPort typeHint,
int receivePin,
int transmitPin);
};
#endif // ifndef ESPEASY_SERIAL_ESPEASYSERIALTYPE_H