1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

cpu/esp32: add uart to ESP-IDF interface API

This commit is contained in:
Gunar Schorcht 2022-06-19 12:53:34 +02:00
parent d9fc082686
commit 81caeb1bb1
3 changed files with 87 additions and 1 deletions

View File

@ -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);
}

View File

@ -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 */

View File

@ -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