Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_43676597
arduino-esp32
提交
371f382d
A
arduino-esp32
项目概览
weixin_43676597
/
arduino-esp32
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
arduino-esp32
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
371f382d
编写于
4月 08, 2021
作者:
M
me-no-dev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix Serial RX and add option for FIFO Full Threshold in Serial.begin
Fixes:
https://github.com/espressif/arduino-esp32/issues/5005
上级
425619df
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
25 addition
and
18 deletion
+25
-18
cores/esp32/HardwareSerial.cpp
cores/esp32/HardwareSerial.cpp
+3
-3
cores/esp32/HardwareSerial.h
cores/esp32/HardwareSerial.h
+1
-1
cores/esp32/esp32-hal-tinyusb.c
cores/esp32/esp32-hal-tinyusb.c
+0
-3
cores/esp32/esp32-hal-uart.c
cores/esp32/esp32-hal-uart.c
+20
-10
cores/esp32/esp32-hal-uart.h
cores/esp32/esp32-hal-uart.h
+1
-1
未找到文件。
cores/esp32/HardwareSerial.cpp
浏览文件 @
371f382d
...
...
@@ -50,7 +50,7 @@ HardwareSerial Serial2(2);
HardwareSerial
::
HardwareSerial
(
int
uart_nr
)
:
_uart_nr
(
uart_nr
),
_uart
(
NULL
)
{}
void
HardwareSerial
::
begin
(
unsigned
long
baud
,
uint32_t
config
,
int8_t
rxPin
,
int8_t
txPin
,
bool
invert
,
unsigned
long
timeout_ms
)
void
HardwareSerial
::
begin
(
unsigned
long
baud
,
uint32_t
config
,
int8_t
rxPin
,
int8_t
txPin
,
bool
invert
,
unsigned
long
timeout_ms
,
uint8_t
rxfifo_full_thrhd
)
{
if
(
0
>
_uart_nr
||
_uart_nr
>
2
)
{
log_e
(
"Serial number is invalid, please use 0, 1 or 2"
);
...
...
@@ -78,7 +78,7 @@ void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, in
txPin
=
TX2
;
}
#endif
_uart
=
uartBegin
(
_uart_nr
,
baud
?
baud
:
9600
,
config
,
rxPin
,
txPin
,
256
,
invert
);
_uart
=
uartBegin
(
_uart_nr
,
baud
?
baud
:
9600
,
config
,
rxPin
,
txPin
,
256
,
invert
,
rxfifo_full_thrhd
);
_tx_pin
=
txPin
;
_rx_pin
=
rxPin
;
...
...
@@ -94,7 +94,7 @@ void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, in
if
(
detectedBaudRate
)
{
delay
(
100
);
// Give some time...
_uart
=
uartBegin
(
_uart_nr
,
detectedBaudRate
,
config
,
rxPin
,
txPin
,
256
,
invert
);
_uart
=
uartBegin
(
_uart_nr
,
detectedBaudRate
,
config
,
rxPin
,
txPin
,
256
,
invert
,
rxfifo_full_thrhd
);
}
else
{
log_e
(
"Could not detect baudrate. Serial data at the port must be present within the timeout for detection to be possible"
);
_uart
=
NULL
;
...
...
cores/esp32/HardwareSerial.h
浏览文件 @
371f382d
...
...
@@ -55,7 +55,7 @@ class HardwareSerial: public Stream
public:
HardwareSerial
(
int
uart_nr
);
void
begin
(
unsigned
long
baud
,
uint32_t
config
=
SERIAL_8N1
,
int8_t
rxPin
=-
1
,
int8_t
txPin
=-
1
,
bool
invert
=
false
,
unsigned
long
timeout_ms
=
20000UL
);
void
begin
(
unsigned
long
baud
,
uint32_t
config
=
SERIAL_8N1
,
int8_t
rxPin
=-
1
,
int8_t
txPin
=-
1
,
bool
invert
=
false
,
unsigned
long
timeout_ms
=
20000UL
,
uint8_t
rxfifo_full_thrhd
=
112
);
void
end
();
void
updateBaudRate
(
unsigned
long
baud
);
int
available
(
void
);
...
...
cores/esp32/esp32-hal-tinyusb.c
浏览文件 @
371f382d
...
...
@@ -48,8 +48,6 @@ typedef struct {
bool
external_phy
;
}
tinyusb_config_t
;
static
TaskHandle_t
s_tusb_tskh
;
static
void
configure_pins
(
usb_hal_context_t
*
usb
)
{
for
(
const
usb_iopin_dsc_t
*
iopin
=
usb_periph_iopins
;
iopin
->
pin
!=
-
1
;
++
iopin
)
{
...
...
@@ -74,7 +72,6 @@ static void configure_pins(usb_hal_context_t *usb)
esp_err_t
tinyusb_driver_install
(
const
tinyusb_config_t
*
config
)
{
int
res
;
log_i
(
"Driver installation..."
);
// Hal init
...
...
cores/esp32/esp32-hal-uart.c
浏览文件 @
371f382d
...
...
@@ -130,10 +130,10 @@ static void ARDUINO_ISR_ATTR _uart_isr(void *arg)
}
}
void
uartEnableInterrupt
(
uart_t
*
uart
)
static
void
uartEnableInterrupt
(
uart_t
*
uart
,
uint8_t
rxfifo_full_thrhd
)
{
UART_MUTEX_LOCK
();
uart
->
dev
->
conf1
.
rxfifo_full_thrhd
=
112
;
uart
->
dev
->
conf1
.
rxfifo_full_thrhd
=
rxfifo_full_thrhd
;
#if CONFIG_IDF_TARGET_ESP32
uart
->
dev
->
conf1
.
rx_tout_thrhd
=
2
;
#else
...
...
@@ -149,7 +149,7 @@ void uartEnableInterrupt(uart_t* uart)
UART_MUTEX_UNLOCK
();
}
void
uartDisableInterrupt
(
uart_t
*
uart
)
static
void
uartDisableInterrupt
(
uart_t
*
uart
)
{
UART_MUTEX_LOCK
();
uart
->
dev
->
conf1
.
val
=
0
;
...
...
@@ -162,7 +162,7 @@ void uartDisableInterrupt(uart_t* uart)
UART_MUTEX_UNLOCK
();
}
void
uartDetachRx
(
uart_t
*
uart
,
uint8_t
rxPin
)
static
void
uartDetachRx
(
uart_t
*
uart
,
uint8_t
rxPin
)
{
if
(
uart
==
NULL
)
{
return
;
...
...
@@ -171,7 +171,7 @@ void uartDetachRx(uart_t* uart, uint8_t rxPin)
uartDisableInterrupt
(
uart
);
}
void
uartDetachTx
(
uart_t
*
uart
,
uint8_t
txPin
)
static
void
uartDetachTx
(
uart_t
*
uart
,
uint8_t
txPin
)
{
if
(
uart
==
NULL
)
{
return
;
...
...
@@ -179,17 +179,17 @@ void uartDetachTx(uart_t* uart, uint8_t txPin)
pinMatrixOutDetach
(
txPin
,
false
,
false
);
}
void
uartAttachRx
(
uart_t
*
uart
,
uint8_t
rxPin
,
bool
inverte
d
)
static
void
uartAttachRx
(
uart_t
*
uart
,
uint8_t
rxPin
,
bool
inverted
,
uint8_t
rxfifo_full_thrh
d
)
{
if
(
uart
==
NULL
||
rxPin
>=
GPIO_PIN_COUNT
)
{
return
;
}
pinMode
(
rxPin
,
INPUT
);
uartEnableInterrupt
(
uart
);
uartEnableInterrupt
(
uart
,
rxfifo_full_thrhd
);
pinMatrixInAttach
(
rxPin
,
UART_RXD_IDX
(
uart
->
num
),
inverted
);
}
void
uartAttachTx
(
uart_t
*
uart
,
uint8_t
txPin
,
bool
inverted
)
static
void
uartAttachTx
(
uart_t
*
uart
,
uint8_t
txPin
,
bool
inverted
)
{
if
(
uart
==
NULL
||
txPin
>=
GPIO_PIN_COUNT
)
{
return
;
...
...
@@ -198,7 +198,7 @@ void uartAttachTx(uart_t* uart, uint8_t txPin, bool inverted)
pinMatrixOutAttach
(
txPin
,
UART_TXD_IDX
(
uart
->
num
),
inverted
,
false
);
}
uart_t
*
uartBegin
(
uint8_t
uart_nr
,
uint32_t
baudrate
,
uint32_t
config
,
int8_t
rxPin
,
int8_t
txPin
,
uint16_t
queueLen
,
bool
inverted
)
uart_t
*
uartBegin
(
uint8_t
uart_nr
,
uint32_t
baudrate
,
uint32_t
config
,
int8_t
rxPin
,
int8_t
txPin
,
uint16_t
queueLen
,
bool
inverted
,
uint8_t
rxfifo_full_thrhd
)
{
if
(
uart_nr
>=
UART_PORTS_NUM
)
{
return
NULL
;
...
...
@@ -256,7 +256,7 @@ uart_t* uartBegin(uint8_t uart_nr, uint32_t baudrate, uint32_t config, int8_t rx
UART_MUTEX_UNLOCK
();
if
(
rxPin
!=
-
1
)
{
uartAttachRx
(
uart
,
rxPin
,
inverted
);
uartAttachRx
(
uart
,
rxPin
,
inverted
,
rxfifo_full_thrhd
);
}
if
(
txPin
!=
-
1
)
{
...
...
@@ -322,7 +322,11 @@ uint32_t uartAvailable(uart_t* uart)
if
(
uart
==
NULL
||
uart
->
queue
==
NULL
)
{
return
0
;
}
#ifdef UART_READ_RX_FIFO
return
(
uxQueueMessagesWaiting
(
uart
->
queue
)
+
uart
->
dev
->
status
.
rxfifo_cnt
)
;
#else
return
uxQueueMessagesWaiting
(
uart
->
queue
);
#endif
}
uint32_t
uartAvailableForWrite
(
uart_t
*
uart
)
...
...
@@ -333,6 +337,7 @@ uint32_t uartAvailableForWrite(uart_t* uart)
return
0x7f
-
uart
->
dev
->
status
.
txfifo_cnt
;
}
#ifdef UART_READ_RX_FIFO
void
uartRxFifoToQueue
(
uart_t
*
uart
)
{
uint8_t
c
;
...
...
@@ -357,6 +362,7 @@ void uartRxFifoToQueue(uart_t* uart)
uart
->
dev
->
int_clr
.
val
=
0xffffffff
;
UART_MUTEX_UNLOCK
();
}
#endif
uint8_t
uartRead
(
uart_t
*
uart
)
{
...
...
@@ -364,10 +370,12 @@ uint8_t uartRead(uart_t* uart)
return
0
;
}
uint8_t
c
;
#ifdef UART_READ_RX_FIFO
if
((
uxQueueMessagesWaiting
(
uart
->
queue
)
==
0
)
&&
(
uart
->
dev
->
status
.
rxfifo_cnt
>
0
))
{
uartRxFifoToQueue
(
uart
);
}
#endif
if
(
xQueueReceive
(
uart
->
queue
,
&
c
,
0
))
{
return
c
;
}
...
...
@@ -380,10 +388,12 @@ uint8_t uartPeek(uart_t* uart)
return
0
;
}
uint8_t
c
;
#ifdef UART_READ_RX_FIFO
if
((
uxQueueMessagesWaiting
(
uart
->
queue
)
==
0
)
&&
(
uart
->
dev
->
status
.
rxfifo_cnt
>
0
))
{
uartRxFifoToQueue
(
uart
);
}
#endif
if
(
xQueuePeek
(
uart
->
queue
,
&
c
,
0
))
{
return
c
;
}
...
...
cores/esp32/esp32-hal-uart.h
浏览文件 @
371f382d
...
...
@@ -51,7 +51,7 @@ extern "C" {
struct
uart_struct_t
;
typedef
struct
uart_struct_t
uart_t
;
uart_t
*
uartBegin
(
uint8_t
uart_nr
,
uint32_t
baudrate
,
uint32_t
config
,
int8_t
rxPin
,
int8_t
txPin
,
uint16_t
queueLen
,
bool
inverted
);
uart_t
*
uartBegin
(
uint8_t
uart_nr
,
uint32_t
baudrate
,
uint32_t
config
,
int8_t
rxPin
,
int8_t
txPin
,
uint16_t
queueLen
,
bool
inverted
,
uint8_t
rxfifo_full_thrhd
);
void
uartEnd
(
uart_t
*
uart
,
uint8_t
rxPin
,
uint8_t
txPin
);
uint32_t
uartAvailable
(
uart_t
*
uart
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录