Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpu/esp32: use ESP-IDF interrupt HAL for periph/uart #18274

Merged
merged 2 commits into from
Jul 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions cpu/esp32/esp-idf-api/uart.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (C) 2022 Gunar Schorcht
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/

/**
* @ingroup cpu_esp32_esp_idf_api
* @{
*
* @file
* @brief Interface for the ESP-IDF UART HAL API
*
* @author Gunar Schorcht <gunar@schorcht.net>
* @}
*/

#include <stdbool.h>
#include <stdint.h>

#include "driver/uart.h"
#include "hal/uart_hal.h"

#include "esp_idf_api/uart.h"

static uart_hal_context_t _uart_hal_ctx[] = {
#if UART_NUM_MAX >= 1
{
.dev = UART_LL_GET_HW(0),
},
#endif
#if UART_NUM_MAX >= 2
{
.dev = UART_LL_GET_HW(1),
},
#endif
#if UART_NUM_MAX >= 3
{
.dev = UART_LL_GET_HW(2),
},
#endif
};

void esp_idf_uart_set_wakeup_threshold(unsigned uart_num, uint32_t threshold)
{
assert(uart_num < ARRAY_SIZE(_uart_hal_ctx));
uart_hal_set_wakeup_thrd(&_uart_hal_ctx[uart_num], threshold);
}
36 changes: 36 additions & 0 deletions cpu/esp32/include/esp_idf_api/uart.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright (C) 2022 Gunar Schorcht
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/

/**
* @ingroup cpu_esp32_esp_idf_api
* @{
*
* @file
* @brief Interface for the ESP-IDF UART HAL API
*
* @author Gunar Schorcht <gunar@schorcht.net>
* @}
*/

#ifndef ESP_IDF_API_UART_H
#define ESP_IDF_API_UART_H

#ifndef DOXYGEN /* Hide implementation details from doxygen */

#ifdef __cplusplus
extern "C" {
#endif

void esp_idf_uart_set_wakeup_threshold(unsigned uart_num, uint32_t threshold);

#ifdef __cplusplus
}
#endif

#endif /* DOXYGEN */
#endif /* ESP_IDF_API_UART_H */
2 changes: 1 addition & 1 deletion cpu/esp32/include/periph_cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ typedef struct {
/**
* @brief Maximum number of UART interfaces
*/
#define UART_NUMOF_MAX (3)
#define UART_NUMOF_MAX (SOC_UART_NUM)
/** @} */

#ifdef MODULE_PERIPH_CAN
Expand Down
Loading