Skip to content

Commit af49f0c

Browse files
committed
app: init commit
0 parents  commit af49f0c

File tree

8 files changed

+139
-0
lines changed

8 files changed

+139
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
.*

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "esp-idf"]
2+
path = esp-idf
3+
url = https://github.com/espressif/esp-idf

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
cmake_minimum_required(VERSION 3.5)
2+
3+
set(SUPPORTED_TARGETS esp32)
4+
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
5+
project(bluetooth_uart_hci_controller)

README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
Bluetooth UART HCI Controller
2+
=============================
3+
4+
BTDM controller inside the ESP32 chip, use UART(H4) as HCI IO.
5+
6+
## Pinmap
7+
8+
| HCI IO | TX | RX | CTS | RTS |
9+
| :----: | -: | -: | --: | --: |
10+
| Pin | 5 | 18 | 19 | 23 |
11+
12+
## Preparing
13+
14+
### Obtain the Source
15+
16+
```
17+
git clone --recursive https://github.com/redchenjs/bluetooth_uart_hci_controller_esp32.git
18+
```
19+
20+
### Update an existing repository
21+
22+
```
23+
git pull
24+
git submodule update --init --recursive
25+
```
26+
27+
### Setup the Tools
28+
29+
```
30+
./esp-idf/install.sh
31+
```
32+
33+
## Building
34+
35+
### Setup the environment variables
36+
37+
```
38+
export IDF_PATH=$PWD/esp-idf
39+
source ./esp-idf/export.sh
40+
```
41+
42+
### Flash & Monitor
43+
44+
```
45+
idf.py flash monitor
46+
```

esp-idf

Submodule esp-idf added at f5b82c5

main/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
set(COMPONENT_SRCDIRS .)
2+
3+
register_component()

main/app_main.c

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* app_main.c
3+
*
4+
* Created on: 2020-02-01 23:25
5+
* Author: Jack Chen <redchenjs@live.com>
6+
*/
7+
8+
#include "esp_bt.h"
9+
#include "esp_log.h"
10+
11+
#include "nvs_flash.h"
12+
13+
#include "driver/uart.h"
14+
#include "soc/uhci_periph.h"
15+
#include "driver/periph_ctrl.h"
16+
17+
#define NVS_TAG "nvs"
18+
#define BT_TAG "bt"
19+
20+
int app_main(void)
21+
{
22+
esp_err_t ret = nvs_flash_init();
23+
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
24+
ESP_ERROR_CHECK(nvs_flash_erase());
25+
ret = nvs_flash_init();
26+
}
27+
ESP_ERROR_CHECK(ret);
28+
29+
ESP_LOGI(NVS_TAG, "initialized.");
30+
31+
periph_module_enable(PERIPH_UART1_MODULE);
32+
periph_module_enable(PERIPH_UHCI0_MODULE);
33+
34+
uart_set_pin(UART_NUM_1, 5, 18, 19, 23);
35+
36+
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
37+
ESP_ERROR_CHECK(esp_bt_controller_init(&bt_cfg));
38+
ESP_ERROR_CHECK(esp_bt_controller_enable(ESP_BT_MODE_BTDM));
39+
40+
ESP_LOGI(BT_TAG, "initialized, tx: 5, rx: 18, cts: 23, rts: 19");
41+
42+
return 0;
43+
}

sdkconfig.defaults

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#
2+
# Serial flasher config
3+
#
4+
CONFIG_ESPTOOLPY_FLASHMODE_QIO=y
5+
CONFIG_ESPTOOLPY_FLASHFREQ_80M=y
6+
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
7+
8+
#
9+
# Bluetooth
10+
#
11+
CONFIG_BT_ENABLED=y
12+
CONFIG_BTDM_CTRL_MODE_BTDM=y
13+
CONFIG_BTDM_CTRL_BR_EDR_SCO_DATA_PATH_HCI=y
14+
CONFIG_BTDM_CTRL_AUTO_LATENCY=y
15+
CONFIG_BTDM_CTRL_HCI_MODE_UART_H4=y
16+
17+
#
18+
# Compiler options
19+
#
20+
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
21+
22+
#
23+
# ESP32-specific
24+
#
25+
CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y
26+
27+
#
28+
# Power Management
29+
#
30+
CONFIG_PM_ENABLE=y
31+
CONFIG_PM_DFS_INIT_AUTO=y
32+
33+
#
34+
# Newlib
35+
#
36+
CONFIG_NEWLIB_NANO_FORMAT=y

0 commit comments

Comments
 (0)