mirror of
https://github.com/espressif/esp-idf.git
synced 2025-10-29 04:23:54 +00:00
controller_hci_uart: rename the example with suffix "_esp32"
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
# The following lines of boilerplate have to be in your project's CMakeLists
|
||||
# in this exact order for cmake to work correctly
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
project(controller_hci_uart)
|
||||
@@ -0,0 +1,8 @@
|
||||
#
|
||||
# This is a project Makefile. It is assumed the directory this Makefile resides in is a
|
||||
# project subdirectory.
|
||||
#
|
||||
|
||||
PROJECT_NAME := controller_hci_uart
|
||||
|
||||
include $(IDF_PATH)/make/project.mk
|
||||
10
examples/bluetooth/hci/controller_hci_uart_esp32/README.md
Normal file
10
examples/bluetooth/hci/controller_hci_uart_esp32/README.md
Normal file
@@ -0,0 +1,10 @@
|
||||
| Supported Targets | ESP32 |
|
||||
| ----------------- | ----- |
|
||||
|
||||
ESP-IDF UART HCI Controller
|
||||
===========================
|
||||
|
||||
This is a btdm controller use UART as HCI IO. This require the UART device support RTS/CTS mandatory.
|
||||
It can do the configuration of UART number and UART baudrate by menuconfig.
|
||||
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
idf_component_register(SRCS "controller_hci_uart_demo.c"
|
||||
INCLUDE_DIRS ".")
|
||||
@@ -0,0 +1,4 @@
|
||||
#
|
||||
# "main" pseudo-component makefile.
|
||||
#
|
||||
# (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.)
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
||||
|
||||
Unless required by applicable law or agreed to in writing, this
|
||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
||||
CONDITIONS OF ANY KIND, either express or implied.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "nvs_flash.h"
|
||||
#include "esp_bt.h"
|
||||
#include "soc/uhci_periph.h"
|
||||
#include "driver/uart.h"
|
||||
#include "driver/periph_ctrl.h"
|
||||
#include "esp_log.h"
|
||||
|
||||
static const char *tag = "CONTROLLER_UART_HCI";
|
||||
|
||||
static void uart_gpio_reset(void)
|
||||
{
|
||||
#if CONFIG_BTDM_CTRL_HCI_UART_NO == 1
|
||||
periph_module_enable(PERIPH_UART1_MODULE);
|
||||
#elif CONFIG_BTDM_CTRL_HCI_UART_NO == 2
|
||||
periph_module_enable(PERIPH_UART2_MODULE);
|
||||
#endif
|
||||
periph_module_enable(PERIPH_UHCI0_MODULE);
|
||||
|
||||
#ifdef CONFIG_BTDM_CTRL_HCI_UART_NO
|
||||
ESP_LOGI(tag, "HCI UART%d Pin select: TX 5, RX, 18, CTS 23, RTS 19", CONFIG_BTDM_CTRL_HCI_UART_NO);
|
||||
|
||||
uart_set_pin(CONFIG_BTDM_CTRL_HCI_UART_NO, 5, 18, 19, 23);
|
||||
#endif
|
||||
}
|
||||
|
||||
void app_main(void)
|
||||
{
|
||||
esp_err_t ret;
|
||||
|
||||
/* Initialize NVS — it is used to store PHY calibration data */
|
||||
ret = nvs_flash_init();
|
||||
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
|
||||
ESP_ERROR_CHECK(nvs_flash_erase());
|
||||
ret = nvs_flash_init();
|
||||
}
|
||||
ESP_ERROR_CHECK( ret );
|
||||
|
||||
|
||||
/* As the UART1/2 pin conflict with flash pin, so do matrix of the signal and pin */
|
||||
uart_gpio_reset();
|
||||
|
||||
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
|
||||
ret = esp_bt_controller_init(&bt_cfg);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(tag, "Bluetooth Controller initialize failed: %s", esp_err_to_name(ret));
|
||||
return;
|
||||
}
|
||||
|
||||
ret = esp_bt_controller_enable(ESP_BT_MODE_BTDM);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(tag, "Bluetooth Controller initialize failed: %s", esp_err_to_name(ret));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
# Override some defaults so BT stack is enabled
|
||||
# in this example
|
||||
|
||||
#
|
||||
# BT config
|
||||
#
|
||||
CONFIG_BT_ENABLED=y
|
||||
CONFIG_BTDM_CTRL_MODE_BLE_ONLY=n
|
||||
CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY=n
|
||||
CONFIG_BTDM_CTRL_MODE_BTDM=y
|
||||
CONFIG_BTDM_CTRL_BLE_MAX_CONN=9
|
||||
CONFIG_BTDM_CTRL_BR_EDR_MAX_ACL_CONN=7
|
||||
CONFIG_BTDM_CTRL_BR_EDR_MAX_SYNC_CONN=3
|
||||
CONFIG_BT_BLUEDROID_ENABLED=n
|
||||
CONFIG_BT_CONTROLLER_ONLY=y
|
||||
CONFIG_BTDM_CTRL_HCI_MODE_UART_H4=y
|
||||
CONFIG_BTDM_CTRL_HCI_UART_NO=1
|
||||
CONFIG_BTDM_CTRL_HCI_UART_BAUDRATE=921600
|
||||
CONFIG_BTDM_CTRL_MODEM_SLEEP=n
|
||||
Reference in New Issue
Block a user