Skip to content

Commit 3c8bc22

Browse files
committed
Merge branch 'feature/esp32c3_uart_add_wakeup_event_v4.4' into 'release/v4.4'
UART: add uart wakeup event for esp32c3 and esp32s3 (v4.4) See merge request espressif/esp-idf!22647
2 parents 188bb8d + ac67d5d commit 3c8bc22

File tree

11 files changed

+54
-79
lines changed

11 files changed

+54
-79
lines changed

components/driver/include/driver/uart.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -58,6 +58,9 @@ typedef enum {
5858
UART_PARITY_ERR, /*!< UART RX parity event*/
5959
UART_DATA_BREAK, /*!< UART TX data and break event*/
6060
UART_PATTERN_DET, /*!< UART pattern detected */
61+
#if SOC_UART_SUPPORT_WAKEUP_INT
62+
UART_WAKEUP, /*!< UART wakeup event */
63+
#endif
6164
UART_EVENT_MAX, /*!< UART event max index*/
6265
} uart_event_type_t;
6366

components/driver/uart.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -59,11 +59,20 @@ static const char *UART_TAG = "uart";
5959
#define UART_PATTERN_DET_QLEN_DEFAULT (10)
6060
#define UART_MIN_WAKEUP_THRESH (UART_LL_MIN_WAKEUP_THRESH)
6161

62+
#if SOC_UART_SUPPORT_WAKEUP_INT
63+
#define UART_INTR_CONFIG_FLAG ((UART_INTR_RXFIFO_FULL) \
64+
| (UART_INTR_RXFIFO_TOUT) \
65+
| (UART_INTR_RXFIFO_OVF) \
66+
| (UART_INTR_BRK_DET) \
67+
| (UART_INTR_PARITY_ERR)) \
68+
| (UART_INTR_WAKEUP)
69+
#else
6270
#define UART_INTR_CONFIG_FLAG ((UART_INTR_RXFIFO_FULL) \
6371
| (UART_INTR_RXFIFO_TOUT) \
6472
| (UART_INTR_RXFIFO_OVF) \
6573
| (UART_INTR_BRK_DET) \
6674
| (UART_INTR_PARITY_ERR))
75+
#endif
6776

6877

6978
#define UART_ENTER_CRITICAL_SAFE(mux) portENTER_CRITICAL_SAFE(mux)
@@ -1111,7 +1120,14 @@ static void UART_ISR_ATTR uart_rx_intr_handler_default(void *param)
11111120
UART_EXIT_CRITICAL_ISR(&(uart_context[uart_num].spinlock));
11121121
xSemaphoreGiveFromISR(p_uart_obj[uart_num]->tx_done_sem, &HPTaskAwoken);
11131122
}
1114-
} else {
1123+
}
1124+
#if SOC_UART_SUPPORT_WAKEUP_INT
1125+
else if (uart_intr_status & UART_INTR_WAKEUP) {
1126+
uart_hal_clr_intsts_mask(&(uart_context[uart_num].hal), UART_INTR_WAKEUP);
1127+
uart_event.type = UART_WAKEUP;
1128+
}
1129+
#endif
1130+
else {
11151131
uart_hal_clr_intsts_mask(&(uart_context[uart_num].hal), uart_intr_status); /*simply clear all other intr status*/
11161132
uart_event.type = UART_EVENT_MAX;
11171133
}

components/hal/esp32c3/include/hal/uart_ll.h

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
1-
// Copyright 2020 Espressif Systems (Shanghai) PTE LTD
2-
//
3-
// Licensed under the Apache License, Version 2.0 (the "License");
4-
// you may not use this file except in compliance with the License.
5-
// You may obtain a copy of the License at
6-
//
7-
// http://www.apache.org/licenses/LICENSE-2.0
8-
//
9-
// Unless required by applicable law or agreed to in writing, software
10-
// distributed under the License is distributed on an "AS IS" BASIS,
11-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
// See the License for the specific language governing permissions and
13-
// limitations under the License.
1+
/*
2+
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
146

157
// The LL layer for UART register operations.
168
// Note that most of the register operations in this layer are non-atomic operations.
@@ -59,6 +51,7 @@ typedef enum {
5951
UART_INTR_RS485_FRM_ERR = (0x1 << 16),
6052
UART_INTR_RS485_CLASH = (0x1 << 17),
6153
UART_INTR_CMD_CHAR_DET = (0x1 << 18),
54+
UART_INTR_WAKEUP = (0x1 << 19),
6255
} uart_intr_t;
6356

6457
static inline void uart_ll_set_reset_core(uart_dev_t *hw, bool core_rst_en) {

components/hal/esp32h2/include/hal/uart_ll.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ typedef enum {
5959
UART_INTR_RS485_FRM_ERR = (0x1 << 16),
6060
UART_INTR_RS485_CLASH = (0x1 << 17),
6161
UART_INTR_CMD_CHAR_DET = (0x1 << 18),
62+
UART_INTR_WAKEUP = (0x1 << 19),
6263
} uart_intr_t;
6364

6465
static inline void uart_ll_set_reset_core(uart_dev_t *hw, bool core_rst_en) {

components/hal/esp32s2/include/hal/uart_ll.h

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
1-
// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD
2-
//
3-
// Licensed under the Apache License, Version 2.0 (the "License");
4-
// you may not use this file except in compliance with the License.
5-
// You may obtain a copy of the License at
6-
//
7-
// http://www.apache.org/licenses/LICENSE-2.0
8-
//
9-
// Unless required by applicable law or agreed to in writing, software
10-
// distributed under the License is distributed on an "AS IS" BASIS,
11-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
// See the License for the specific language governing permissions and
13-
// limitations under the License.
1+
/*
2+
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
146

157
// The LL layer for UART register operations.
168
// Note that most of the register operations in this layer are non-atomic operations.
@@ -57,6 +49,7 @@ typedef enum {
5749
UART_INTR_RS485_FRM_ERR = (0x1<<16),
5850
UART_INTR_RS485_CLASH = (0x1<<17),
5951
UART_INTR_CMD_CHAR_DET = (0x1<<18),
52+
UART_INTR_WAKEUP = (0x1 << 19),
6053
} uart_intr_t;
6154

6255
/**

components/hal/esp32s3/include/hal/uart_ll.h

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
1-
// Copyright 2015-2020 Espressif Systems (Shanghai) PTE LTD
2-
//
3-
// Licensed under the Apache License, Version 2.0 (the "License");
4-
// you may not use this file except in compliance with the License.
5-
// You may obtain a copy of the License at
6-
//
7-
// http://www.apache.org/licenses/LICENSE-2.0
8-
//
9-
// Unless required by applicable law or agreed to in writing, software
10-
// distributed under the License is distributed on an "AS IS" BASIS,
11-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
// See the License for the specific language governing permissions and
13-
// limitations under the License.
1+
/*
2+
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
146

157
// The LL layer for UART register operations.
168
// Note that most of the register operations in this layer are non-atomic operations.
@@ -60,6 +52,7 @@ typedef enum {
6052
UART_INTR_RS485_FRM_ERR = (0x1 << 16),
6153
UART_INTR_RS485_CLASH = (0x1 << 17),
6254
UART_INTR_CMD_CHAR_DET = (0x1 << 18),
55+
UART_INTR_WAKEUP = (0x1 << 19),
6356
} uart_intr_t;
6457

6558
/**

components/soc/esp32c3/include/soc/soc_caps.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -277,6 +277,7 @@
277277

278278
#define SOC_UART_SUPPORT_RTC_CLK (1)
279279
#define SOC_UART_SUPPORT_XTAL_CLK (1)
280+
#define SOC_UART_SUPPORT_WAKEUP_INT (1) /*!< Support UART wakeup interrupt */
280281
#define SOC_UART_REQUIRE_CORE_RESET (1)
281282

282283
// UART has an extra TX_WAIT_SEND state when the FIFO is not empty and XOFF is enabled

components/soc/esp32h2/include/soc/soc_caps.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@
258258
#define SOC_UART_NUM (2)
259259
#define SOC_UART_FIFO_LEN (128) /*!< The UART hardware FIFO length */
260260
#define SOC_UART_BITRATE_MAX (5000000) /*!< Max bit rate supported by UART */
261-
261+
#define SOC_UART_SUPPORT_WAKEUP_INT (1) /*!< Support UART wakeup interrupt */
262262
#define SOC_UART_SUPPORT_RTC_CLK (1)
263263
#define SOC_UART_SUPPORT_XTAL_CLK (1)
264264

components/soc/esp32s2/include/soc/soc_caps.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -260,6 +260,7 @@
260260
/*-------------------------- UART CAPS ---------------------------------------*/
261261
// ESP32-S2 has 2 UART.
262262
#define SOC_UART_NUM (2)
263+
#define SOC_UART_SUPPORT_WAKEUP_INT (1) /*!< Support UART wakeup interrupt */
263264
#define SOC_UART_SUPPORT_REF_TICK (1) /*!< Support REF_TICK as the clock source */
264265
#define SOC_UART_FIFO_LEN (128) /*!< The UART hardware FIFO length */
265266
#define SOC_UART_BITRATE_MAX (5000000) /*!< Max bit rate supported by UART */

components/soc/esp32s3/include/soc/soc_caps.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -258,8 +258,13 @@
258258
#include "twai_caps.h"
259259

260260
/*-------------------------- UART CAPS ---------------------------------------*/
261-
#include "uart_caps.h"
262-
261+
// ESP32-S3 has 3 UARTs
262+
#define SOC_UART_NUM (3)
263+
#define SOC_UART_FIFO_LEN (128) /*!< The UART hardware FIFO length */
264+
#define SOC_UART_BITRATE_MAX (5000000) /*!< Max bit rate supported by UART */
265+
// UART has an extra TX_WAIT_SEND state when the FIFO is not empty and XOFF is enabled
266+
#define SOC_UART_SUPPORT_FSM_TX_WAIT_SEND (1)
267+
#define SOC_UART_SUPPORT_WAKEUP_INT (1) /*!< Support UART wakeup interrupt */
263268
#define SOC_UART_SUPPORT_RTC_CLK (1) /*!< Support RTC clock as the clock source */
264269
#define SOC_UART_SUPPORT_XTAL_CLK (1) /*!< Support XTAL clock as the clock source */
265270
#define SOC_UART_REQUIRE_CORE_RESET (1)

components/soc/esp32s3/include/soc/uart_caps.h

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)