UG103.13: RAIL Fundamentals (Rev. 1.0)

Silicon Labs 的 RAIL(Radio Abstraction Interface Layer,无线电抽象接口层)库提供了直观和易于自定义的无线电接口层,支持 proprietary 或 standards-based 无线协议。RAIL 旨在简化和缩短开发过程。开发者不再需要处理多个产品上的数百个寄存器,而可以依靠统一的软件 API。通过 Silicon Labs Flex SDK 提供的 RAIL 还使应用可跨 Silicon Labs 无线产品移植。

所有 EFR32FG 设备都支持 Proprietary。对于其他产品,请在 Ordering Information > Protocol Stack 下查看设备的数据手册,以了解是否支持 Proprietary。在 Proprietary SDK v2.7.n 中,EFR32xG22 不支持 Connect。

1. 引言

即使有许多可用的无线标准,专有(proprietary)无线仍然是与传统(legacy)专有网络通信的唯一选择。而且,使用无线标准始终是一个折衷方案 —— 为应用专门设计的协议可以针对能耗、数据吞吐量或范围进行更好的优化。

但是,专有协议的灵活性是有代价的。开发此类协议通常更加困难,并且它们通常与较新的基础设施不兼容。安全设计特别困难,在设计专有协议时必须考虑这一点。

要开发专有协议,您需要直接控制无线电硬件。但是,像 Wireless Gecko(EFR32™)这样具有多协议功能的无线电非常复杂,需要花费数月的时间才能理解。为了缩短此过程,Silicon Labs 提供了:

  • Radio Configurator,一个可以根据一些输入参数(如频率和比特率)生成无线电配置的工具。
  • RAIL,一个 C 库,它提供了一个更简单的接口来控制无线电。

Silicon Labs RAIL 是 Silicon Labs 内部以及公司客户和第三方合作伙伴内部开发的所有网络协议栈的最低层。RAIL 支持多种无线电配置和功能,并且是 Silicon Labs 无线产品的关键基础技术之一。

为了使软件可移植性尽可能简单,RAIL 的开发目标如下:

  • RAIL API 在主要版本中应向后兼容。为 RAIL 2.0 开发的代码应能够与最新版本的 RAIL 2.x 一起运行。
  • RAIL API 应该在支持的部件之间尽可能地兼容。尽管有一些 API 并非在所有部分上都可用,但是通用用法(例如接收、传输和状态转换)应该相同。

2. RAIL 概述

RAIL 库本身是通过 Gecko SDK Suite 提供的,但是支持工具和示例应用也是 Flex SDK 的一部分。在 Flex SDK 中,开发者可以开发直接与 RAIL 配合使用的协议,或基于 Silicon Labs Connect stack 配置应用。Silicon Lab Connect stack 提供了功能全面和易于定制的无线网络解决方案,该解决方案针对要求低功耗并用于简单网络拓扑的设备进行了优化。有关更多信息,请参见 UG103.12: Silicon Labs Connect Fundamentals

Flex SDK 中的 RAIL 组件包括:

  • RAIL 库:提供无线电功能的编程接口,如下图所示。
  • Radio Configurator:Simplicity Studio 的一部分,它是一个计算器和交互界面,使开发者可以配置无线电物理层的静态参数。详情参见 AN971: EFR32 Radio Configurator Guide for RAIL in Simplicity Studio v4AN1252: EFR32 Radio Configurator Guide for Simplicity Studio v5
  • RAILtest:一个示例应用,其中包含了每个 RAIL 库功能的串行命令,以允许进行脚本测试和临时实验。RAILtest 可以使用任何 PHY 构建,包括 802.15.4 和 Bluetooth Smart。许多 RAILtest 串行命令可用于实验室评估。RAILTest 也是测试各种 RAIL 功能的良好起点,并且可以用作许多 API 的参考实现。
  • 其他示例应用:可以按原样用于评估,也可以作为应用开发的起点。
  • 文档:通过 Simplicity Studio 交付。
  • 建立在 RAIL 之上的组件:提供基本功能,例如初始化、发送或接收。

有关使用 Flex SDK 中的示例应用开始进行 RAIL 开发的更多信息,请参阅 QSG138: Proprietary Flex SDK v2.x Quick Start GuideQSG168: Proprietary Flex SDK v3.x Quick Start Guide

尽管 RAIL 库支持完整的 EFR32 产品组合,但是 Radio Configurator 和 Flex SDK 示例仅在 EFR32FG 设备和其他具有 Proprietary 支持的 EFR 设备上可用。在 Ordering Information > Protocol Stack 下查看设备的数据手册,以查看是否支持 Proprietary。

Figure 2.1. RAIL-based Stack Structure

3. RAIL 库

RAIL 功能作为库提供,该库链接到开发者的应用。RAIL 库实现了配置和控制无线电所需的核心功能和运行时 API。

RAIL 库的工作原理是从 RAIL API 中获取直观且易于使用的命令,并将其转换为用于控制无线电和通信功能的寄存器级代码。API 命令在各 IC 之间保持不变。基础代码中的更改对开发者或系统测试人员透明。这也使开发者可以快速地为不同的产品创建多个协议栈,因为它们始终具有相似的软件无线电接口。RAIL 为开发者实现自己的 MAC 层和网络层功能提供了基础。

在可能的情况下,当前为 EFR32 实现的所有功能都将在将来的 IC 中实现,从而可以轻松迁移所有基于 RAIL 的应用。在 AN1244: EFR32 Migration Guide for Proprietary Applications 中,重点介绍了不同 EFR32 代间的主要区别。

RAIL API 是从命令和事件构建的。命令可用于从软件启动某些操作,而事件是由硬件生成的(通常是由中断产生),以使软件知道某些信息(如接收到的帧)。

RAIL 也用来实现同时支持多个协议栈。Silicon Labs 动态多协议解决方案是通过无线电调度程序实现的,该调度程序是抢占式优先级调度程序,可以在协议之间调度无线电硬件。对于单协议和多协议 RAIL,API 是相同的,但多协议 RAIL 应用的实现应有所不同。有关更多信息,请参见 UG305: Dynamic Multiprotocol User’s Guide

该库支持用于 ARM 的 GCC 和 IAR 编译器。

4. RAIL 特性

RAIL 在软件中包含以下特性,以及许多其他特性。

RAIL Highlights Description
Simple Transmit and Receive Both transmit and receive can be started with a single API. Finished transmission and received packets are signaled with RAIL events.
Automatic State Transitions Configurable transitions to go from one state to the next based on successful or unsuccessful transmit and receive operations. These support an optional delay as well to allow for consistent timings from one state to the next.
Frame Buffering Two configurable size frame buffers—one for receive and one for transmit—are available. Both can hold multiple frames.
Timekeeping, Timestamping, and Timers RAIL automatically maintains a RAIL timebase with µsec granularity. It can be used for:
  • Timestamping packets (enabled by default) at different packet positions
  • Scheduling receive and transmit operations
  • One general purpose timer with optional timer virtualization in RAIL (called MultiTimer)
  • Optional synchronization with RTC, to keep time and make scheduling possible from EM2 sleep mode
Scheduled Transmit Transmit at an absolute or relative time in the future.
Scheduled Receive Start receiving at an absolute or relative time in the future with an optional timeout after that start time.
CCA (Clear Channel Assessment) with Retransmission Supports two common medium access methodologies, which delays transmission until the channel is clear:
  • CSMA/CA (Carrier Sense Multiple Access with Collision Avoidance) — based on IEEE 802.15.4 specification.
  • LBT (Listen Before Talk) — based on ETSI EN 300 220-1 specification.
RSSI (Received Signal Strength Indicator) Read Ability to read instantaneous and average RSSI values from hardware. RSSI and Link Quality Indicator (LQI) measurements for each received frame is also available.
Address Filtering
  • Two address fields are supported (with fixed location), both maximum four bytes long.
  • Each field can filter for four addresses (for example, unicast and broadcast address).
Addresses can be enabled and configured at runtime.

For IEEE 802.15.4, this is handled specially, since it uses addresses with the location configured with the frame type.
Auto ACK Automatic transmission of a response packet after some delay to every successful receive. This can be a constant payload or dynamically loaded by the user any time before the transmission is supposed to begin.

For IEEE 802.15.4 this is handled automatically to improve performance.
IEEE 802.15.4 Helper Features These features include:
  • Address filtering (supporting three short address, long address and PAN ID)
  • Auto ACK
  • Event on Data Request command to set the frame pending bit
Note: To implement IEEE 802.15.4-based protocols, Silicon Labs recommends using the Connect stack’s MAC mode, which is a full IEEE 802.15.4 MAC layer implementation. For more information, see UG235.03: Architecture of the Silicon Labs Connect Stack v2.x or UG435.03: Architecture of the Silicon Labs Connect Stack v3.x.
Bluetooth LE and Z-Wave Helper APIs Helpers for implementing a Bluetooth LE or Z-Wave networking stack. These provide special modes and optimizations in hardware for these specific modes.
Multi-PHY Support The PHY configuration can be changed runtime. Also, RAIL can load PHY.
Multiprotocol Support Separate version of the RAIL library with a radio scheduler that can manage requests from different radio configurations on the same chip.
  • Supports time-slicing N different radio configurations where N >= 2.
  • Allows for different priority tasks from the different configurations and manages them so the highest priority is always completed.
  • Allows for tasks to be moved around if the timing isn’t critical, for most robust network.
Calibration Support Chip-specific calibrations. Commonly these include recalibrating for large temperature changes while in receive and image rejection calibration for increased sensitivity.
Stream Generation for RF Testing RAIL can generate Continuous Wave and PN9 pseudo-random modulated streams with any PHY for RF testing.
Receive Antenna Diversity Allows toggling between two antennas in receive mode and selecting the one with the stronger signal to improve sensitivity. Note that this is only supported on certain chips and PHY configurations.
RAIL API to Get Entropy from Radio Radio can be used to collect entropy from receive chain noise.
Power Manager Support When enabled, notifies the power manager component when the radio is on to prevent Energy Mode 2 (EM2) sleep.

5. RAIL 的主要更新

与 RAIL 1.x 相比,RAIL 2.x 添加了许多新功能,包括动态多协议,并提供了更简洁和更易理解的 API。详情参见 AN1113: Porting RAIL Applications to RAIL Version 2.x

Gecko SDK 3.x 仍然包含 RAIL 2.x,因此 API 保持向后兼容。新框架简化了项目迁移,并为初始化等常规任务提供了更多可重用的组件。但是,RAIL API 本身并没有发生变化。它仅添加了一些新功能。详情参见 AN1254: Transitioning from the v2.x to the v3.x Proprietary Flex SDK

6. 下一步

有关如何安装 Simplicity Studio 以及如何从 Flex SDK 开始使用 RAIL 的说明,请参阅 QSG138: Proprietary Flex SDK v2.x Quick Start GuideQSG168: Proprietary Flex SDK v3.x Quick Start Guide

要更熟悉 RAIL 中的软件开发,请参阅 API documentation 和 Silicon Labs RAIL tutorials