RTL8733
Read time: 6 minute(s)
本章节讲解如何在 Luban-Lite 系统中配置 UART 接口的 RTL8733。
参数配置
Read time: 6 minute(s)
配置 Bluetooth 模组 Pinmux
根据原理图,配置对应的 Pinmux 功能引脚,以 D133CBV-QFN88 开发板为例,打开 target/d13x/demo88-nor/pinmux.c 文件,添加下列配置:
#ifdef AIC_USING_UART2
/* uart2 */
{5, PIN_PULL_DIS, 3, "PD.4"}, // BT_UART2_TX
{5, PIN_PULL_UP, 3, "PD.5"}, // BT_UART2_RX
{1, PIN_PULL_DIS, 3, "PD.6"}, // BT_PWR_ON
#endif
配置 UART 接口和 Bluetooth 模组
使用 UART 接口前,需将对应 UART 接口选中,以 D133CBV-QFN88 开发板为例,使用 scons
--meunconfig
命令配置所需的
UART 接口:
Board options
[*] Using Uart2 # 硬件连接哪个 UART 接口,选择哪个UART
UART2 Parameter --->
(48000000) UART2 clk frequence
(115200) UART2 baudrate
(8) UART2 data bits
(1) UART2 stop bits
(0) UART2 parity (0=none, 1=odd, 2=even)
UART2 protocol (RS232) --->
UART2 mode (RS232 normal) --->
[ ] Enable UART2 dma mode
Drivers options --->
Peripheral --->
[*] Using Realtek bt driver --->
realtek bluetooth Parameter --->
(PD.7) realtek bt power on gpio
(PD.6) realtek bt reset gpio
() realtek bt wake on gpio
配置 NimBLE
使用 scons --menuconfig
命令进入配置页面,配置如下:
Local packages options --->
Third-party packages options --->
[*] NimBLE:An open-source Bluetooth 5.0 stack porting on RT-Thread --->
Bluetooth Role support --->
[*] Peripheral Role support
[*] Central Role support
-*- Broadcaster Role support
-*- Observer Role support
Host Stack Configuration --->
[*] Bluetooth Host Stack support
(8192) The thread stack Size of Host Stack
(8) The thread priority of Host Stack
HCI Transport support --->
[*] HCI Transport using rt-thread uart
(uart2) The uart for HCI Transport
HCI Protocol support --->
Select HCI Protocol (HCI Protocol using H5) --->
NimBLE log level (info) --->
Bluetooth Samples (BLE peripheral heartrate sensor) --->
(1) Maximum number of concurrent connections
[*] Device Whitelist Support
(0) The number of multi-advertising instances
[ ] Extended Advertising Feature Support
Version (v1.8.0) --->
配置内核
使用下列代码设置 RT-Thread 内核的系统工作队列线程,包括使用系统默认的工作队列、指定工作队列线程的栈大小(8192)以及优先级(23):
Rt-Thread options --->
RT-Thread Components --->
Device Drivers --->
-*- Using system default workqueue
(8192) The stack size for system workqueue thread
(23) The priority level of system workqueue thread
警告:
- 完成上述配置后,如出现类似下面的提示,需要调整
OS 分区,并使用
mb
命令重新编译 BootLoader 和 RTT 即可: -
d13x_os.itb file_size: 0x216800 is over much than part_size: 0x200000
蓝牙 DEMO 使用说明
Read time: 6 minute(s)
心率测量 DEMO
Read time: 6 minute(s)
- 使用
scons --menuconfig
命令进入配置页面,开启心率测量 DEMO,配置如下:Local packages options ---> Third-party packages options ---> Bluetooth Samples (BLE config wifi) --->
- 配置完成后,保存退出,编译、烧录。
- 待系统启动后,可执行如下命令进行验证:
ble_hr
[I] realtek_bt_read_rom_version()163 rom version=2 [I] realtek_bt_download_firmware()185 download fw (0/157) [I] realtek_bt_download_firmware()185 download fw (1/157) [I] realtek_bt_download_firmware()185 download fw (2/157) ... [I] realtek_bt_download_firmware()185 download fw (156/157) [I] realtek_bt_read_local_version()144 examining hci_ver=0b hci_rev=d7b8 lmp_ver=0b lmp_subver=0da7 [I] realtek_bt_read_local_version()146 fw version 0xd7b80da7 Failed to restore IRKs from store; status=8 GAP procedure initiated: advertise; disc_mode=2 adv_channel_map=0 own_addr_type=0 adv_filter_policy=0 adv_itvl_min=0 adv_itvl_max=0
- 打开手机上的
BLE
调试软件 (nRF
Connect),找到
BLEHR_SENSOR 设备并连接。
连接设备后,即可看到下列 GATT 服务列表:
- 点击
Heart Rate 服务,并查看 Characteristic 列表,可以看到有一个名为 Heart Rate
Measurement 的特征值,其属性为 Notify。 点击右侧图标开启订阅,即可持续收到来自
blehr_sensor 传输的心率数据:
使能蓝牙配网 DEMO
Read time: 6 minute(s)
蓝牙配网需要使能 WiFi 相关配置,此处需要使用 RTT 自带的 LwIP,参考 AIC8800 调试指南进行配置。
- 使用
scons --menuconfig
命令进入配置页面,开启蓝牙配网 DEMO,配置如下:Local packages options ---> Third-party packages options ---> Bluetooth Samples (BLE config wifi) --->
- 配置完成后,保存退出,编译、烧录。
- 待系统启动后,可执行如下命令进行验证:
blufi
输出示例如下:registered service 0x1800 with handle=1registering characteristic 0x2a00 with def_handle=2 val_handle=3 registering characteristic 0x2a01 with def_handle=4 val_handle=5 registered service 0x1801 with handle=6registering characteristic 0x2a05 with def_handle=7 val_handle=8 registering characteristic 0x2b3a with def_handle=10 val_handle=11 registering characteristic 0x2b29 with def_handle=12 val_handle=13 registered service 0xffff with handle=14registering characteristic 0xff01 with def_handle=15 val_handle=16 registering characteristic 0xff02 with def_handle=17 val_handle=18 aic /> [I] realtek_bt_read_rom_version()163 rom version=2 [I] realtek_bt_download_firmware()185 download fw (0/157) [I] realtek_bt_download_firmware()185 download fw (1/157) [I] realtek_bt_download_firmware()185 download fw (2/157) ... [I] realtek_bt_download_firmware()185 download fw (155/157) [I] realtek_bt_download_firmware()185 download fw (156/157) [I] realtek_bt_read_local_version()144 examining hci_ver=0b hci_rev=d7b8 lmp_ver=0b lmp_subver=0da7 [I] realtek_bt_read_local_version()146 fw version 0xd7b80da7 [I/BLE/] BLUFI init finish GAP procedure initiated: advertise; disc_mode=2 adv_channel_map=0 own_addr_type=0 adv_filter_policy=0 adv_itvl_min=0 adv_itvl_max=0
- 完成上述操作后,打开手机上蓝牙配网软件
(EspBluFi),找到
BLUFI_DEVBICE 设备点击并连接,即可看到下列界面:
- 点击配网,设备模式选择 Station,选择 WiFi SSID,并输入密码后,点击确定,等待连接成功即可: