Silicon Labs AN906, RF4CE ZRC User manual

AN906
RF4CE ZIGBEE REMOTE CONTROL FIRMWARE GUIDE
This document is intended f or firmware engineers working with Silicon Labs RF4CE ZRC (ZigBee Remote Control) Low Cost Remote and Full Feat ur ed Rem ote reference designs. It explains the m ain firmware structures and how to customize them.
New in This Revision
Initial release
Contents
Introduction ..................................................................................................................................................... 3
1
2 Remote Control Referenc e Desi gn Overview ................................................................................................... 3
3 Controller Im plem entation ............................................................................................................................... 4
3.1 Devices .................................................................................................................................................... 4
3.1.1 Pairing with Multiple Targets .............................................................................................................. 5
3.1.2 Using the TV Devic e for IR Cont r ol .................................................................................................... 5
3.2 Infrared Driver .......................................................................................................................................... 5
3.3 Accelerometer Motion Detection ............................................................................................................... 5
3.4 Voice Compression and St r eami ng .......................................................................................................... 5
3.4.1 Hardware Audio Codec ..................................................................................................................... 6
3.4.2 Software Audio Codec ....................................................................................................................... 7
3.5 Key Matrix Driver...................................................................................................................................... 8
3.5.1 Key Detection .................................................................................................................................... 9
3.5.2 Pin Sharing ....................................................................................................................................... 9
3.6 Identifi c ation Message.............................................................................................................................. 9
3.7 Action Mapping ........................................................................................................................................ 9
3.8 Storage .................................................................................................................................................... 9
3.9 Power Consumpti on ................................................................................................................................10
4 Target Implementati on ...................................................................................................................................10
5 Target-to-Host Protocol ..................................................................................................................................11
5.1 Protocol Layers .......................................................................................................................................11
5.2 Protocol Operation ..................................................................................................................................12
5.3 Presentation Layer ..................................................................................................................................12
5.3.1 Message Format ..............................................................................................................................12
5.3.2 Framing ...........................................................................................................................................12
Rev 0.1 Copyright © 2015 by Silicon Laboratories AN906
AN906
5.3.3 Checksum ........................................................................................................................................12
5.3.4 Escaping ..........................................................................................................................................12
5.3.5 Example ...........................................................................................................................................13
5.4 Application Layer ....................................................................................................................................13
5.4.1 Message Format ..............................................................................................................................13
5.5 Application Layer M essages Defined .......................................................................................................13
5.5.1 Message Payload .............................................................................................................................13
5.5.2 Message Id ......................................................................................................................................18
2 Rev. 0.1
AN906

1 Introduction

This applicati on note relates to the Low Cost Remote refer enc e design (RD43; Figure 1A) included in the EM34x Development Kit (EM34X-DEV), and the Full Featured Remote reference design (RD17; Figure 1B) included in the EM34x Voice Remote Control Development Kit (EM34X-VRDK) and the EM34x Voice Remote Control Evaluation Kit (EM34X-VREVK).
A) B)
Figure 1. A) Low Cost Remote Control; B) Full Featured Remote Con t rol
The following docum entation is recommended for firm ware engi neer s start ing with Silicon Labs ZigB ee Rem ote Control appli c ations:
UG103.10 Application Development Fundamentals: RF4CE QSG100 EM34x Development Kit Q uic k -Star t G uide UG113 EM34x Development Kit User Guide QSG103 EM341 Voice Remote Developm ent Kit Quick Start Guide QSG104 EM341 Voice Remote Evaluation K it Quick Start Guide

2 Remote Control Reference Design Overview

The Silicon Labs ZRC reference designs implement the followi ng t opology (Figure 2):
Controller: This is the hand-held wirel ess rem ote control device
Target: This devic e c ommunicates wirelessly with the Controller over the RF4CE network
Host: This device communicates with the Target over a wired serial connection using the target-to-host
protocol described in this document.
Rev. 0.1 3
AN906
Figure 2. RF4CE Remote Control System Topology
The Host is usually the main pr oc essor in a set-top box or other RF4CE-compliant equipment. In t his setting the Target device is the embedded processor insi de the set-top box. For the Silicon Labs remot e contr ol reference designs the Host devic e is a PC. T he Target device is a USB dongle or development kit that communic ates with the Host via a serial connection or USB. As the target-to-host protocol is implemented in the Target firmware using a UART or USB CDC connection, the target firmware can easily be reused in designs where the Target is embedded in a set-top box.
The Silicon Labs RF4CE ZRC Full Feat ur ed Controller and Low Cost Controll er support t he f ollowing features:
Key matrix scanning
ZRC 2.0 action commands sent ov er RF4CE when buttons are pushed
Infrared LED for cont r olling legacy equipment
Power button LED (dual c olor on Low Cost Controller and single color on Full Feat ur ed Controller)
Over-the-air action mapping to set actions for keys to user-defined ZRC2.0 action c ommands and/or IR
codes
Over-the-air identify message to l oc ate Controller via blinking LED
In addition, the Full Featured Controller includes the following features:
Buzzer to provide audio feedback
Backlight LEDs for key matrix
Accelerometer to turn on Backlight when controller is moved
Streaming voice audio to Target (and Host) when Voice button is pushed
Over-the-air identify message to locate Controller via buzzer sound

3 Controller Implementation

Firmware examples for the EM341 RF SoC in the Low Cost and Full Featured Controller s are included as RF4CE sample applic ations in the EmberZNet stack release.

3.1 Devices

Both of the remote contr ols support for two devices, called TV and STB . T he dev ic es are sel ec ted using the TV and the STB buttons on the controllers. The controller firmware is configured to support pai ri ng with up to two targets that can be mapped to the STB or TV devices. The targets do not necessarily have to be a television and a set-top box, even though t he text on the butt ons and t he dev ice names indicate this.
To pair a controller and target, first press the pairi ng butt on on the target (or host sending the Bind Request as described in section 5.5.1.8) to allow a controller to pair with it. T hen, while holding down the PAIRING/SET key on controller, press one of the device keys (TV or STB). The power button LED will be lit to indicate that a pairing is ongoing. When the tar get acc epts the pairing, the LED will be turned off. If the c ontroller does not find a target to pair with it will stop tryi ng after about 45 seconds and turn off the LED.
4 Rev. 0.1
AN906

3.1.1 Pairing with Multiple Targets

When the controller is paired with two targets, the user first selects the target to communicate with by pressing the associated devi c e butt on (TV or STB). W hen the user then pr es se s a key m apped to a specific ZRC 2.0 action command, this command is sent to the target paired as the selected devic e.
The first target t hat is pair ed to a controller is paired as both the TV and STB device. When the second target is paired, it is paired as the device corresponding to the button used in the pairing procedure.

3.1.2 Using the TV Device for IR Control

A common configuration is only to have one RF4CE-enabled device (e.g. set-top box) and a TV that only support s legacy IR signals. In such a configuration, the set-top box can be used to program the action mappings on the controller to allow it to send IR signals to the TV. In the referenc e firm ware, I R si gnals are only supported for the TV device. Both the T V and the STB device must be paired with the set-top box target to allow the set-top-box to update IR action mappings on the c ontroller.

3.2 Infrared Driver

The infrared driver incl uded in the reference firmware support s two IR dat abas e formats, the ZRC2.0 SIRD (Standard Infr ar ed Database) format and the UIRD (Universal Infrared Descriptor) format (both regular and encrypted). The IR codes can be transferred to the controller as acti on m apping updates matching the mappabl e actions that the controller supports. As SIRD codes are native to the ZRC2.0, this format is expected for IR descriptors unless a vendor ID is provided. For the UIRD codes the following dummy vendor IDs are used:
0x01: Regular UI RD
0x02: Encrypt ed UIRD
Note that the 32-bit encr y ption key must be obtained from the UIRD database prov ider and applied as a hash­define call ed UIRD_DECRY P TI ON_KEY. The encryption UIRD encryption algorithm is not available as source code, only as a pre-compiled library.

3.3 Accelerometer Motion Detection

The Full Featured Contr oller includes a 3-axis accel er om eter that is used to detect motion in any direction. The acceleromet er is programmed over I2C to sample the 3-axis acceler ation data every 50 ms and set the interrupt output to the EM341 if the accelerati on ex c eeds the c onfigured threshold. Aft er receiv ing an accelerometer interrupt output, the EM341 will t ur n on the eight key pad backlight LEDs and keep them on until the cont r oller has been still for at least 5 seconds.

3.4 Voice Compression and Streaming

The Full Featured Contr oller includes a digital PDM (pulse density modulation) microphone to record voice audio through an audio i nlet at the t op of the remote, between the POWER and SET buttons. The voic e system is designed for speech recognition to enable voice control of the host from the controller.
The digital PDM micr ophone c onv er ts the audio input to a 1-bit digital output in P DM format. In PDM format, the density of digital ones i nc r ease s or decr ease s with increased or decreased audio pressure into t he mi c r ophone. Since PDM is a digital f ormat, the microphone can be placed a reasonable distance from the hardware codec without impacting the audio performance, which might occur wit h an analog microphone.
The Full Featured Contr oller is implemented in two ver sions. The first uses a hardware codec for processing the microphone audi o before it is received by the EM341. The second does all of the audio processing internall y to the EM341. The software audi o c odec has the lowest B OM cost, but uses more EM341 CPU cycles than the hardware audio codec. The EM34X-VRDK inc ludes the hardware codec solution. For information on how to obtain the software codec, see www.silabs.com/zrctraining
.
Rev. 0.1 5
AN906
Bytes
Contents
7:1 (7 bytes)
MS ADPCM compressor state var iable

3.4.1 Hardware Audio Codec

The PDM 1-bit data stream is converted to a 16-bit PCM (pulse code modulation) by passing the PDM data through a decimation filter . To remove the microphone’s DC component , t he c odec ’s 1st order I IR filter is also configured as a high-pass filt er. To compensate the audio frequency response for artifacts induced by implemented plastics and audio waveguide, the codec ’s multiple IIR bi-quads can be configur ed as an equal izer. In the Full Featured Controller firmware, the codec’s IIR bi-quads are not enabled.
Figure 3 shows an overv iew of t he v oic e front -end.
Figure 3. Controller Hard Codec Voice Front -End
When the key matrix driver detects that the VOICE button is pressed, the audio streaming is set up by the following steps:
1. Key m atrix shared GPIOs are reconfigur ed for the hardware audio codec.
2. Hardwar e audio codec is powered up by asserti ng a GPIO.
3. Timer 2 (TIM2) is conf igured to drive the master clock to the hardware audio codec .
4. Ser ial Controller 1 (SC1) i s confi gur ed as an SPI slave to accept I2S mono audio.
5. Ser ial Controller 0 (SC0), alr eady in I 2C mode, is used to confi gur e the hardware codec.
Set up codec’s PLL and clock tree
Enable digit al P DM micr ophone oper ation
Set up decimation and digital filters
Set digital gain
Enable 16-bit (PCM) I 2S mono voic e audio data output @ 16 kSample/s.
6. T he filtered PDM to PCM I2S captured data is compressed and streamed to the paired target by the controller.
The controll er will c ontinue streaming voice data to the target that is paired with the current dev ic e sel ection (TV or STB) as long as the VOICE button is held down. The t arget dev ice receives the voice data and relays this to the host. When the VOI CE button is released:
1. T imer 2 (TIM2) is reset.
2. Key m atrix shared GPIOs are reconfigur ed for the key matrix.
3. Hardwar e audio codec is powered down by de-asserti ng a GPIO.
ZigBee (and RF4CE) has a max bitrate of 250 kbps. However, due to overhead and real-world RF interference, the highest practical sustained throughput with the EmberZNet stack is about 80 kbps. The v oic e audio is recorded as 16-bit samples @ 16 kSamples/s, which gives a bit rate of 256 kbps. To fit the audio within the allowed bit rate over ZigBee, a 4:1 MS ADPCM compression is appl ied, resulting in 64 kbps compressed voice data. The 64 kbps compressed voi c e data is then sent over RF4CE using a vendor-specific prof ile. This profile allows a voice payload of 103 bytes to be sent with each m essage. The payload consists of the following el em ents:
0
102 :8 (95 byt es) Comp ress ed audio
6 Rev. 0.1
Message sequence number (i ncrea sed f or each mess age up to 127 before wrapping to 0)
Loading...
+ 13 hidden pages