Home

STM32W108xx ZigBee® RF4CE library

image

Contents

1. 7 1 2 Network layer 7 1 2 1 Node POS cs excu ea e EE dor epe E REM ERE UE eed 8 1 2 2 Network topology RR III 8 1 2 3 Frequency agility 20 0 eee 9 1 2 4 DISCOVOL S o Ree RE ERE wee eee eee 9 1 2 5 Paling xau DRM dE ee dams ERNIE 9 1 2 6 Message transmission and reception 10 1 2 7 SEGUY MEI 10 1 2 8 Power saving xxx a ei OUR Gre de 10 13 7 11 1 4 ZID application 11 2 Using the STRF4CE API 12 2 1 Programming 10 12 2 1 1 API to SAP mapping eee 12 2 2 ANZ aO au the UKE ENT Pe Re 13 2 2 1 Controller eek ee e Re oa bbe BA Gadde d e a E RR a 13 2 2 2 Target zx curse ewe nes aa Gade T oe ge dea eee ae Bee E RUE 13 2 3 Discovery 14 2 4 Paing er A ee ees ee 14 2 5 Message exchanges 15 26 SECUN Sere e oe eaa E 16 2 7 a A
2. 8 Power saving scheme 0 0 cee eer rr 11 RS 232 RC and target node 24 RF4CE Virtual RC and TV 0 eee eee ee eee nae 27 ST Virtual RC 2 eee eee sans 29 ST Virtual TV screenshot 0 eee eee eens 30 ST Virtual RC and Sony infrared 31 Host connection in SPI mode 42 Host connection in UART 43 Packet formatei anea ue sae BS du mcus eaeque ee a ee 43 Serial communication started by the host host side 46 Serial communication started by the host STM32W side 46 Callback response STM32W side 46 Doc ID 17097 Rev 4 ky UMO909 RF4CE protocol description 1 1 1 2 RF4CE protocol description Overview The ZigBee RF4CE standard was created by a consortium of companies with the objective to deliver a standardized specification for RF controlled home entertainment products RF radio frequency remote controls are faster more reliable and provide more freedom to operate devices from greater distances by removing the line of sight barrier found in today s IR infrared remote controls They also enable advanced features such as two way communication between the device and the remote control creating a
3. send the packet bytes through the serial channel status sendHostCmd cmd if status SUCCESS wait the command response status waitRspCmd rsp if status SUCCESS memcpy amp status amp rsp 2 4 return status j The first step is to format the command param structure into a byte array according to the packet format displayed above The sendHostCmd function sends the packet bytes using the UART or SPI protocol according to the serialrinit initialization function This function also manages the GPIO signals used to regulate the flow control before starting the communication see the figures in Section 7 5 Physical level protocol Every RFACE command returns a 4 byte response that indicates the command result The waitRspCmd function waits for the result from the coprocessor and returns the value to the application A library for STM32F devices that interface with the STM32W and RF4CE coprocessor firmware is provided as an example The library and the associated demo are intended to be run on an MB525 board fitted with an STM32F103VET6 microcontroller but can be customized and adapted to different boards and microcontrollers The 1f4ce_cmds c file manages all the RF4CE commands from the host side while the serial communication is managed by the stm32 sc c file The RF4CE API provided to the host is described in Document 5 Doc ID 17097 Rev 4 UMO0909 Using the STRF
4. 16 2 8 Power consumption 16 2 8 1 RF power down 2 2 29 e eh 16 2 8 2 SOC power down 16 2 8 8 standby 17 2 9 Non volatile memory 17 210 RF4CE stack 18 3 Designing an application using the RFACE library 20 2 53 Doc ID 17097 Rev 4 ky UMO909 Contents 4 ZRC demo application cuam coco boe e o atc a cn 22 4 1 Firmware common features 22 4 2 Building the firmware 23 4 3 Programming the firmware 23 4 4 RS 232 remote control and target applications 23 4 5 SI Virtual RC and DV ERBERETa eee ES UAE ER ad Memes 2r 4 5 1 ST Virtual BG d exar 28 4 5 2 ST Virt al TV a iude sted e hea ae eed 30 4 6 ST Virtual RC and Sony Infrared TV with an RFACE I R extender 31 5 ZID demonstration application 32 5 1 proJBG acce eii DAT DR Ee REA bet IR Eg 32 5 2 Jumper rax Rb ERO ERR Lobe Sees dea 32 5 8 Boards Supported ebd seven rebut KEEPER 33
5. UMO909 Using the STRF4CE library in Coprocessor mode 7 6 7 7 Serial communication packet format example The following examples show an example of byte sequences in packets during serial communication When the host launches a network init request nwk_Init Oxf 1 the packet has the following format CO 03 1A OF 01 FC Where OxCO command packet start byte 0x03 payload length 0x1A network init code OxOF node capabilities 0x01 force cold start OxFC end packet The STM32W executes the command and returns the following packet response C1 00 00 01 00 FC Where OxC1 command response start byte 0x00000100 command response RF4CE SAP pending OxFC end packet When the start confirm callback function is received the STM32W sends the following packet to the host MCU CO 05 14 00 00 00 00 FC Where OxCO command packet start byte 0x05 payload length 0x14 start confirm command code 0x00000000 status ok OxFC end packet Software code structure This section briefly describes the software structure for both communication sides the network coprocessor and the host processor The network coprocessor runs a stand alone application that basically consists of two state machines receiveStateMachine manages the RFACE commands received from the host processor translates the bytes and then calls the RFACE primit
6. Table 17 lists the signals and the corresponding pin numbers for an STM32W device Table 17 SPI signal and pin information Signal GPIO Direction ue i mna MISO PA1 Output 22 18 MOSI PAO Input 21 17 SCLK PA2 Input 24 20 nSSEL Input 25 21 nHwake PB3 Output 19 15 nSwake PB4 Input 20 16 nStop PA4 Output 26 22 Doc ID 17097 Rev 4 41 53 Using the STRF4CE library in Coprocessor mode UMO0909 Note 42 53 Figure 9 Host connection SPI mode MOSI MISO SCLK nSSEL STM32W nHwake A nStop A nSwake The STM3W SPI channel configured in slave mode can support a data transfer rate of up to 5 Mbps UART protocol The universal asynchronous receiver transmitter UART protocol uses the following signals to exchange data between the host MCU and the STM32W e TXD data transmission pin e RXD data reception pin In addition three other GPIO signals can be used to manage the flow control between the host MCU and the STM32W e nSwake to wake up the STM32W when the host wants to start a communication e nHwake to inform the host MCU that the STM32W has data available e nStop when asserted by the STM32W to signal to the host that it is busy for internal operation and that the host stops the data transmission The UART uses the following set 115200 8 None 1 None Table 18 lists the signals and the corresponding pin numbers
7. Table 14 Boards supported Board name Board revision ROLE STM32W108xB STM32W108CC A B HOST NA A B MOUSE_RC NA HOST X NA MB851 C MOUSE RC NA D HOST NA X D MOUSE RC NA A HOST NA A MOUSE RC NA B HOST X NA MB954 B MOUSE RC NA C HOST NA X C MOUSE RC NA HOST MB950A MB953 MB953A MOUSE RC X NA HOST MB950A MB953 MB953B MOUSE RC NA X A HOST X NA A MOUSE RC NA MB951 B HOST NA X B MOUSE RC NA X supported not supported NA not applicable Doc ID 17097 Rev 4 ZID ZRC demonsiration application UMO909 6 4 LED description MB950 M953 configured with ZigBee RF4CE 20 ZRC application Table 15 LED description LED Role STM32W108 RC Turned ON MOUSE Blinks each time a device does something and sends an RF packet RC Not used D3 MOUSE Not used 6 5 Button description MB950 M953 configured with ZigBee RF4CE 20 ZRC application Table 16 Button description Button Role STM32W108 Note B RC Volume Only related ZRC code is displayed 1 MOUSE Left key on mouse 62 RC Volume Only related ZRC code is displayed MOUSE Left key on mouse Bj RC Channel Only related ZRC code is displayed MOUSE Right key on mouse 5 Only related ZRC code is displayed 4 MOUSE Right key on mouse Switch device from LED D1 turned ON in RC mode 55 RC or MOUSE Mouse to
8. wv UMO909 Y User manual STM32W108xx ZigBee RF4CE library Introduction This document describes the ST RF4CE library and how to use it to develop RF4CE compliant applications on an STM32W device It describes the RF4CE protocol as defined by the ZigBee alliance and how the ST RF4CE library implements this protocol on STM32W devices This document applies to the following STM32W108xx kits STM32W108xx starter kit part number STM32W SK STM32W108xx extension kit part number STM32W EXT e STM32W108xx low cost RF control kit part number STM32W RFCKIT A description on how to perform common RF4CE operations as well as certain architecture dependent operations is also included Finally it describes reference applications for Target and Controller nodes as well as how to use an STM32W device with the ST RF4CE library alongside an external microcontroller Coprocessor mode The ZigBee RF4CE library is designed to run on STM32W108 engineering samples and on the STM32W108xBU63 microcontroller Table 1 lists the microcontrollers and tools concerned by this user manual Table 1 Applicable products and tools Type Part numbers product sub classes Microcontrollers STM32W108xx STM32W SK Evaluation tools to MCUs STM32W EXT STM32W RFCKIT August 2012 Doc ID 17097 Rev 4 1 53 www st com Contents UMO0909 Contents 1 RF4CE protocol description 7 1 1
9. CERC PAIR INDICATION END CERC RFACE COMM STATUS INDICATION Status 00000000 PairingRef 00 PANId FFFF Address 0080E1020000026C CERC RFACE COMM STATUS INDICATION END Target 0 gt Furthermore you can verify that the pairing operation is successful by checking the pairing table contents 1 2 Type the command p to verify that the devices are paired You can find below an example of the device paired The status must be 0x02 otherwise the discovery and pair procedure has failed for some reason Controller 0 gt lt CERC_PAIRING_TABLE gt status sNWK CH dstIEEEAddr dPAN dNWK frmcnt cp linkKey 0 02 A645 19 0080E10200000261 72FA E596 00000409 07 76ECD8D2C68C71800069D9B91B3667A7 1 FF FF PPPFFPFPEFPFPPFPPPF FREE FFPFEPFFRBF FF FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 2 FF FFFF FF FFFFFFFFFFFFFFFF FFFF FFFF FFFFFFFF FF FFFFFFPFFPPFFFPFFEFPFFPFFFPFPFFEFE 3 FF FFFF FF FFFFFFFFFFFFFFFF FFFF FFFF FF FFFFFFFFFFFFFFFFFFFFFFFFFFFFPFPFFP 4 FF FFFF FF FFFFFFFFFFFFFFFF FFFF FFFF FF FFFFFFFFFFFFFFFFFFFFFFFFFFFPFFPFFP You can now press keys on the controller and check that they are correctly received by the target 1 2 remote control Type commands Change channel keys 0 9 Volume up Volume down Channel up gt Channel down 2 1 target
10. The STM32W108 RF4CE ZRC firmware is the same in both RC and target devices and can be used in different scenarios according to Section 4 4 RS 232 remote control and target applications Section 4 5 ST Virtual RC and TV and Section 4 6 ST Virtual RC and Sony Infrared TV with an RF4CE I R extender This firmware can also be considered as a reference application for customers who want to implement a ZRC profile on top of the ZigBee RF4CE stack Firmware common features The RFACE ZRC firmware provides a user interface through an RS 232 interface with LEDs and push buttons When loaded on any board the firmware user interactions are those described in Table 5 Table 5 Firmware user interface User interface item Direction Description RS 232 via USB Input Output Command line interface see Section 4 4 Heartbeat LED should be flashing at all times except when LED D3 Yellow Output in Standby Doc ID 17097 Rev 4 ky UMO909 ZRC demo application 4 2 4 3 4 4 Table 5 Firmware user interface continued User interface item Direction Description ON RF4CE network initialized as target OFF RF4CE network layer not initialized or initialized as remote control LED D1 Green Output Blinks every sec RF4CE network layer cold start in progress Blinks every 0 2 sec RF4CE target node waiting for pairing from remote control LED D1 OFF Press to start the node as a tar
11. 0 val NIBAttributeValue STM32W Target Doc ID 17097 Rev 4 19 53 Designing an application using the RF4CE library UMO0909 3 20 53 Designing an application using the RFACE library The code below shows a skeleton application for implementing an RFACE target device finclude rf4ce h void NLDE DATA confirm NLDE DATA CONFIRM Type param lt Your code here gt void NLME_START_confirm uint32_t status printf RF4CE network started r n networkStarted TRUE void NLME AUTO DISCOVERY confirm NLME AUTO DISCOVERY CONFIRM Type param lt Your code here gt void NLME_DISCOVERY_confirm NLME_DISCOVERY_CONFIRM_Type param lt Your code here gt void NLME PAIR confirm NLME PAIR CONFIRM Type params lt Your code here gt void NLME_UNPATR_confirm NLME_UNPAIR_CONFIRM_Type param lt Your code here gt void NLDE DATA indication NLDE DATA INDICATION Type param lt Your code here gt void NLME DISCOVERY indication NLME DISCOVERY INDICATION Type param lt Your code here gt void NLME PAIR indication NLME PAIR INDICATION Type params lt Your code here gt void NLME COMM STATUS indication NLME COMM STATUS INDICATION Type params Doc ID 17097 Rev 4 ky UMO909 Designing an application using the RFACE library Your code here void NLME_UNPATR_indication uint8_t Pai
12. API to SAP mapping The API provided by the STRF4CE library defines a set of functions that implement SAP mapping according to Table 2 In the table the term F means that the SAP is implemented as a function call the term RF means that the SAP is implemented as a function return value and the term C means that the SAP is implemented as a function callback called in the context of NWK Tick and is provided by the user Each API returns the following values SUCCESS Operation completed successfully RFACE SAP PENDING Operation started and pending final result will be given by the matching callback RFACE BUSY Operation not started because the network layer is still performing some other operation or the network layer has not been initialized e Anyother value Error in the context of the specific operation Table 2 API to SAP mapping SAP Req Conf Ind Rsp AUTO DISC F C COMM STATUS C DISCOVERY F C C F GET SET F RF Doc ID 17097 Rev 4 UMO909 Using the STRF4CE API Table 2 API to SAP mapping continued SAP Req Conf Ind Rsp PAIR F C C F RESET F RF RX ENABLE F RF START F C UNPAIR F C UPDATE KEY F RF DATA F C C 2 2 Initialization The network layer is initialized by calling the NWK Init API The NWK Init API is used to initialize the network layer according to the following parameters 1 no
13. For each key pressed and released it receives two packets a One with payload 0x01 KEY PRESSED and containing an hex number 0x according to the following list KEY PRESSED plus 0x20 Channel 0 0x29 Channel 9 0x41 VolUp 0x42 VolDown I 3 Doc ID 17097 Rev 4 UMO909 ZRC demo application Note 4 5 Note 0x30 ChannelUp 0x31 ChannelDown b One with payload 0x03 KEY RELEASED If you keep the key pressed the ZRC profile sends a packet with payload 0x02 to indicate that the key is being repeated For each key received the infrared LED in the target emits a Sony RC compatible sequence This is useful for driving a Sony TV with an infrared remote control ST Virtual RC and TV This demo scenario uses two boards and two PC applets to emulate an RFACE remote control and an RFACE TV see Figure 5 The ST Virtual RC is a PC applet implementing a remote control driven through a PC GUI The ST Virtual TV is a PC applet implementing a TV driven through a PC GUI To start the demo please make sure you have two boards connected to the PC through the USB port and perform the following steps 1 Runthe ST Virtual RC and ST Virtual TV applications from the PCApplet folder 2 On Virtual RC application select a serial port from the drop down menu If the firmware is not present in the board it will be automatically downloaded by the ap
14. RC mode and LED D1 blinks each time the vice versa mouse does something 6 6 Set up MEMS mouse device RC platform 1 Download the zid zrc firmware on the selected board 2 CONFIGURE ZID RFACE MOUSE DEVICE AND DELETE THE PAIRING TABLE Reset the board with the button S1 pressed When you release the button S1 you can see the LED D1 green LED flash twice to indicate that the command was executed 3 PAIR MOUSE DEVICE WITH HOST DEVICE Press S1 Note The mouse and RC will go to deep sleep after five seconds of no movement or buttons events To wake up the mouse please press any buttons or reset 38 53 Doc ID 17097 Rev 4 UMO909 ZID ZRC demonstration application 6 7 6 8 Other button commands not normally needed 4 UNCONFIGURE ZID RFACE MOUSE DEVICE Reset the board with the button S1 pressed and keep the button S1 pressed for at least 5 seconds When you see the LED D1 flash twice you can release the button S1 At this step the board will be unconfigured 5 RESET the board f you reset the board without any button pressed the board will not lose its configuration Set up the HOST platform 1 Download the zid zrc firmware on the selected board 2 CONFIGURE ZID RFACE HOST After reset press the button S1 You can see the LED D1 flash every half second for 5 sec If the configuration ends with SUCCESS the LED D1 will remain on otherwise it will remain off
15. code 45 7 5 Physical level protocol 46 7 6 Serial communication packet format example 47 7 7 Software code structure 47 7 8 RF4CE network coprocessor demo 49 7 8 1 Building the firmware llle 49 7 8 2 Programming the firmware 49 7 8 3 Setting up the boards 0 ccc eens 49 8 Reference documents 50 9 Terms definitions 51 10 REVISION history 52 4 53 Doc ID 17097 Rev 4 ky UMO909 List of tables List of tables Table 1 Table 2 Table 3 Table 4 Table 5 Table 6 Table 7 Table 8 Table 9 Table 10 Table 11 Table 12 Table 13 Table 14 Table 15 Table 16 Table 17 Table 18 Table 19 Table 20 Table 21 Table 22 Table 23 Applicable products and tools 2 0 0 ce eh 1 API to SAP 000 cee teens 12 Configurable stack 18 ZigBee RF4CE ZRC demo applications 5 22 Firmware user interface 22 RS 232settings slisssssesseeeeeeee hh rn 24 Firmware commands sssseeeee
16. emulate the CH command Press button S3 to emulate the CH command Doc ID 17097 Rev 4 ky UMO0909 Using the STRF4CE library in Coprocessor mode 7 Using the STRFACE library in Coprocessor mode It is also possible to use an STM32W in an RFACE network as a slave device driven by an external microcontroller that acts as a host via a serial communication connection This Coprocessor mode is useful when the RFACE target is a device which already has a microcontroller For example a TV STB or DVD player 7 1 Serial protocols 7 1 1 SPI protocol The STM32W uses the Serial Peripheral Interface SPI for data communication as well as for handshake signaling using certain GPIOs The STM32W is configured as an SPI slave controller and uses four signals e MOSI Master Out Slave In input data from master e MISO Master In Slave Out output data sent to the master e SCLK Serial Clock clock data transfers on MOSI and MISO e nSSEL Slave Select the host uses this signal to enable serial communication with the slave In addition three GPIO signals are used to manage the flow control between the host MCU and the STM32W e nSwake used to wake up the STM32W when the host wants to start a communication e nHwake used to inform the host MCU that the STM32W has data available e nStop when asserted by the STM32W to signal to the host that it is busy for internal operations and that the host should stop the data transmission
17. for an STM32W device Table 18 UART signal and pin information Signal GPIO Direction nb bp TXD PB1 Output 30 25 RXD PB2 Input 31 26 nHwake PB3 Output 19 15 nSwake PB4 Input 20 16 nStop PA4 Output 26 22 Doc ID 17097 Rev 4 UMO0909 Using the STRF4CE library in Coprocessor mode Figure 10 Host connection in UART mode TXD RXD STM32W RXD TXD nHwake St B nStop nSwake 7 2 Packet format Figure 11 shows the packet format used to exchange information between the host MCU and the STM32W using the SPI or UART protocol Figure 11 Packet format Start Byte Length Byte Payload End Byte Where e Start Byte packet type command response 1 byte length Codes are 0 0 RF4CE command packet 0 1 RF4CE response packet e Length Byte payload length not including End Byte 1 byte length e Payload depends on the Start Byte it has the following format Command packet 0xCO The first byte is an RFACE instruction code Following bytes are instruction parameters if any The parameters are sent as a packed stream of bytes in little endian format Response packet 0xC1 All response bytes e Byte Packet end with code OxFC 1 byte length The maximum packet length is 200 bytes Therefore the maximum payload is 197 bytes including the 1 byte command packet and 196 bytes of parame
18. reserve the right to make changes corrections modifications or improvements to this document and the products and services described herein at any time without notice All ST products are sold pursuant to ST s terms and conditions of sale Purchasers are solely responsible for the choice selection and use of the ST products and services described herein and ST assumes no liability whatsoever relating to the choice selection or use of the ST products and services described herein No license express or implied by estoppel or otherwise to any intellectual property rights is granted under this document If any part of this document refers to any third party products or services it shall not be deemed a license grant by ST for the use of such third party products or services or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoever of such third party products or services or any intellectual property contained therein UNLESS OTHERWISE SET FORTH IN ST S TERMS AND CONDITIONS OF SALE ST DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY WITH RESPECT TO THE USE AND OR SALE OF ST PRODUCTS INCLUDING WITHOUT LIMITATION IMPLIED WARRANTIES OF MERCHANTABILITY FITNESS FOR A PARTICULAR PURPOSE AND THEIR EQUIVALENTS UNDER THE LAWS OF ANY JURISDICTION OR INFRINGEMENT OF ANY PATENT COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT UNLESS EXPRESSLY APPROVED IN WRITING BY TWO AUTHORIZED ST REPRESENTATIVES
19. richer experience for consumers The RF4CE standard defines a network layer plus two application profiles for consumer electronics ZRC and ZID The following sections provide more details on the network layer and the application profiles Network layer The RF4CE network stack is a thin flexible and future proof layer with the following features Based on 2 4 GHz MAC PHY IEEE 802 15 4 standard Co exists with other 2 4 GHz technologies Support for interoperability Support for secure communications Powersave mechanisms implemented in network layer Simple and intuitive pairing mechanism Allow for vendor specific applications and transactions Support for many different applications Figure 1 shows a layered representation of the RF4CE stack For more details about the network layer please refer to 1 Figure 1 RF4CE stack overview Application Layer OEM Application Framework ZigBee RF4CE Network and Profiles Power Save Management Security Networking Layer Channel Agility Fait MAC Layer IEEE 802 15 4 PHY Layer Ai15287 Doc ID 17097 Rev 4 7 53 RF4CE protocol description UMO0909 1 2 1 1 2 2 8 53 Node types The RF4CE standard defines only two node types with different roles e Target Node with the following capabilities Network Startup Full PAN capability Accepts or declines a pairing request A Makes decision on operating channel frequency agility e Co
20. the above code and its use is recommended The stack can be brought back to normal operation with a call to NLME RX ENABLE request With RxOnDuration parameters set to OxFFFFFF or using the helper function NWK PowerUp FALSE SOC power down For a maximum battery life in real life applications it could be useful to shut down the entire SOC In this case the sequence of operations should be as follows NWK PowerDown ATOMIC Configure RX TX pins to achieve minimum power consumption on MB851 Doc ID 17097 Rev 4 ky UMO909 Using the STRF4CE API 2 8 3 2 9 3 GPIOB gt ODR amp 1 lt lt 1 1 lt lt 2 halGpioConfig PORTB PIN 1 GPIO Mode IN PUD halGpioConfig PORTB PIN 2 GPIO Mode IN PUD halPowerDown halSleepWithOptions SLEEPMODE NOTIMER BUTTON S1 WAKE SOURCE UART RX WAKE SOURCE 0x20 DeepSleep 2 0x20 is to keep happy Primer 2 halPowerUp dee NWK_PowerUp TRUE uartInit RF standby RF4CE specifications define a mechanism used to reduce the power consumption using the NLME RX ENABLE request function with parameter RxOnDuration set to nwkActivePeriod A simple piece of code to activate standby is shown below uint32_t activePeriod NLME Get nwkActivePeriod ID 0 amp activePeriod NLME RX ENABLE request activePeriod Non volatile memory management The ST RF4CE stack contai
21. 3 PAIRING PROCEDURE Press the button 81 on the ZID RFACE Mouse board and on the 20 RF4CE Host board the LED D1 will start blinking during the pairing procedure If the procedure ends with SUCCESS the ZID RF4CE Host notifies the mouse device connected to the PC and you will be able to use the mouse board like a pointer with the right and left buttons Other button commands not normally needed 4 DELETE PAIRING TABLE ON ZID RF4CE HOST Press the S1 button for a couple of seconds When the LED D1 is off the device has the pairing table deleted How mouse and RC modes work Button S5 is used to switch from Mouse to RC mode and vice versa Mouse mode A mouse movement will be detected by the on board MEMS Tilt the mouse in a direction and the speed of the mouse will be proportional to the tilt angle In particular e Tilting towards the ground will move the mouse down e Tilting towards the ceiling will move the mouse up e Tilting left will move the mouse left e Tilting right will move the mouse right Press button S1 or S2 to emulate a click on the mouse left key Press button S3 or S4 to emulate a click on the mouse right key RC mode The following RC standard commands are emulated through the platform buttons Doc ID 17097 Rev 4 39 53 ZID ZRC demonstration application UMO0909 40 53 Press button S1 to emulate the VOL command Press button S2 to emulate the VOL command Press button S4 to
22. 4 15 53 Using the STRF4CE API UMO0909 2 6 2 7 2 8 2 8 1 2 8 2 16 53 multiple channel no channel designator vendor specific Status NLDE DATA request amp param Security The security is automatically activated by the stack when the node capabilities of paired nodes show that the node supports security see nodeCap parameters in Section 2 2 Even if the security is enabled over a couple of paired nodes the application has still the ability to select between secure and non secure communications when using the NLDE DATA request API If the security is not enabled only non secure communications are allowed Timer A simple timer API is used by the stack to handle timeouts and delays The timer has a resolution of 1 us An application can use both API TTME CurrentTime and TIME ELAPSED timers Power consumption The stack contains a built in mechanism to support power saving schemes RF power down The power down of the RF part is achieved through a call to NLME RX ENABLE request with RxOnDuration parameters set to 0 The stack confirms the power down of the RF part when the NWK Tick API return value has the bit RFACE STATE POWER DOWN set An example code for RF power down is NLME RX ENABLE request 0 while NWK Tick amp RFACE STATE POWER DOWN 0 A helper function Nwk_PowerDown is provided to implement
23. 4CE library in Coprocessor mode 7 8 RF4CE network coprocessor demo The software demo highlights the same functions as those described in Section 4 as well as how to work using an STM32W as the RF4CE network coprocessor The following boards are used to execute the demo e MB525 with STM32F103VET6 processor host board e MB851 or MB954 with the STM32W108 processor coprocessor board 7 8 1 Building the firmware The firmware for the MB525 board can be built from the IAR Embedded Workbench Sources using the related IAR project file Please note that the firmware on the host MCU will be built for the UART interface by default The firmware running on the coprocessor board is only provided prebuilt and can be found in the prebuilt directory 7 8 2 Programming the firmware To program the STM32F firmware you can use the IAR Embedded Workbench To program the STM32W prebuilt coprocessor firmware please use the stm32w_flasher exe file and follow the instructions provided in Section 4 3 7 8 3 Setting up the boards To run the demo additional wiring between the host and the RFACE coprocessor is required Table 21 provides information on the appropriate pins to connect on both boards If you use the default firmware on the host connect the pins marked Yes in the UART column Table 21 board to MB525 connection with UART and SPI mode Sina uam nHWake 5 PE10 Ye
24. 5 0x66 0x77 param LogicalChannel 15 param DstPANId 0x1234 memcpy param DstIEEEAddr dstLongAddr sizeof IEEEAddr param OrgAppCapabilities 0x13 param OrgDevTypeList 0 0x01 param OrgProfileIdList 0 0x01 param KeyExTransferCount 3 status NLME PAIR request amp param 2 5 Message exchanges 4 Messages are transmitted through the use of the NLDE_DATA_request and can be sent by both a controller node and a target node The RF4CE standard states that the following types of communication are possible e Controller to target e Targetto controller e Targetto target Messages can be exchanged only between nodes that have previously been paired that is a valid pairing entry exists in the pairing table In case of success the API returns RFACE SAP PENDING and the message transmission result is communicated through the call of NLDE DATA confirm Any other value returned by the API should be considered as an error condition Ij Message reception is indicated to the user application through the user defined callback NLDE DATA indication An example message exchange is uint32 t status NLDE DATA REQUEST Type param param nsduLength 1 param nsdu 0 0x11 param PairingRef 0 param ProfileId 0x01 Consumer Electronics Remote control param VendorId Oxfff1 Test vendor id 1 param TxOptions 0x4c Unicast nwk address ack security Doc ID 17097 Rev
25. 5 4 Seriall O 33 5 5 LED description 34 5 6 Buttons 34 5 7 Ecco eee Se eRe ee Bees 34 6 ZID ZRC demonstration application 36 6 1 IAR ice uh tan REFER tanned 36 6 2 JUMPEr settings ess oW MI E pa d he 37 6 3 Boards 37 6 4 LED MGSO Sed aa sta tracto a 38 6 5 Button description 38 6 6 Set up MEMS mouse device RC 38 6 7 Setup the HOST platform 39 6 8 mouse and RC modes 39 7 Using STRF4CE library in Coprocessor mode 41 7 1 27 10 perhe hice DR pd ERE PUR 41 7 1 1 SPI protoCol Re GE 3 ke seed 41 7 1 2 UART protocol 000 ce nn 42 7 2 Packet cna do vacua dR eesti Ee Rb E 43 Doc ID 17097 Rev 4 3 53 Contents 909 7 3 Serial RFACE command codes 44 7 4 RF4CE serial communication
26. 5 sec If the configuration is OK the LED D1 at the end is ON 2 Configure the HID mouse device by resetting the board by keeping the S1 button pressed for less than 5 seconds 3 Startthe pairing procedure by pressing the S1 button on both boards LED D1 blinks every 100 msec until the pairing procedure ends Both boards are now configured and paired and you should be able to use the mouse transmitter as a mouse for your PC Tilt the mouse transmitter in a direction and the speed of the mouse is proportional to the tilt angle e Tilting towards the ground will move the mouse down e Tilting towards the ceiling will move the mouse up e Tilting left will move the mouse left e Tilting right will move the mouse right The ZID RFACE demo puts the mouse device in deep sleep after 5 seconds of inactivity To wake up the mouse push any button ky Doc ID 17097 Rev 4 35 53 ZID ZRC demonsiration application UMO909 6 6 1 36 53 ZID ZRC demonstration application This is a demonstration application based on the RFACE ZRC amp ZID application profile It shows the coexistence between the two ZigBee RFACE ZRC and ZID application profiles Warning IAR project THIS APPLICATION SOFTWARE IS PROVIDED FOR INTERNAL DEMONSTRATION PURPOSE ONLY AND NO OTHER USE IS PERMITTED THIS APPLICATION IS PROVIDED ON AN AS IS BASIS WITHOUT WARRANTY OF ANY KIND EITHER STATUTORY EXPRESS OR IMPLIED INCLUDING WITHOUT LIMITATIO
27. COP NLME PAIR REQUEST OxOC Pair request function serial code NWKCOP NLME PAIR INDICATION OxOD Pair indication function serial code NWKCOP_NLME_PAIR_RESPONSE OxOE Pair response function serial code NWKCOP_NLME_PATR_CONFIRM OxOF Pair confirm function serial code NWKCOP_NLME_RESET 0x10 Reset request function serial code NWKCOP NLME RX ENABLE 0x11 RX enable request function serial code NWKCOP NLME SET 0x12 Set request function serial code NWKCOP NLME START REQUEST 0x13 Start request function serial code NWKCOP NLME START CONFIRM 0x14 Start confirm function serial code NWKCOP NLME UNPAIR REQUEST 0x15 Unpair request function serial code NWKCOP NLME UNPAIR INDICATION 0x16 Unpair indication function serial code NWKCOP_NLME_UNPAIR_RESPONSE 0x17 Unpair response function serial code NWKCOP NLME UNPAIR CONFIRM 0x18 Unpair confirm function serial code NWKCOP NLME UPDATE KEY 0x19 Update key request function serial code NWKCOP NWK INIT Ox1A Init the RF4CE network NWKCOP_MAC_GET_EUI64 Ox1B Get the IEEE Address 3 Doc ID 17097 Rev 4 UMO0909 Using the STRF4CE library in Coprocessor mode Table 19 RFACE coprocessor command codes continued Command Code Description Get the firmware version The information is 2 bytes Oxyz Okji where x y and z are the NWKCOP FIRMWARE VERSION 0 1 major minor and patch versions for the network cop
28. N WARRANTIES OF TITLE NON INFRINGEMENT MERCHANTABILITY SATISFACTORY QUALITY AND FITNESS FOR A PARTICULAR PURPOSE WITHOUT LIMITING THE GENERALITY OF THE FOREGOING ST EXPRESSLY DOES NOT WARRANT THE ACCURACY SAFETY OR USEFULNESS FOR ANY PURPOSE OF THE SOFTWARE APPLICATION ST HEREBY DISCLAIMS TO THE FULLEST EXTENT PERMITTED BY APPLICABLE MANDATORY LAW ANY AND ALL LIABILITY FOR THE USE OF THE SOFTWARE APPLICATION INCLUDING BUT NOT LIMITED TO ANY LIABILITY IN CONTRACT TORT OR OTHERWISE WHATEVER THE CAUSE THEREOF LIABILITY FOR ANY LOSS OF PROFIT BUSINESS OR GOODWILL OR ANY DIRECT INDIRECT SPECIAL CONSEQUENTIAL INCIDENTAL OR PUNITIVE COST DAMAGES OR EXPENSE OF ANY KIND HOWSOEVER ARISING UNDER OR IN CONNECTION WITH THIS USE This demonstration application shows the RFACE ZID and ZRC application profile merged features by using an HID device and a ZRC remote control It requires 2 platforms e one configured as ZID RF4CE MEMS mouse device and ZRC e configured as USB RF4CE ZID host The remote control only supports the channel and the volume This demonstration application is PC based Doc ID 17097 Rev 4 UMO909 ZID ZRC demonstration application 6 2 6 3 Jumper settings Table 13 Jumper settings Jumper name JP1 if available Role MOUSE RC STM32W108 Fitted HOST Does not matter MOUSE RC HOST MOUSE HOST 1 2 battery 5 6 USB Boards supported
29. OP WRONG LENGTH 0x1000 00C9 Serial communication error wrong parameters length NWKCOP END PACKET MISSING 0x1000 00C8 Serial communication error wrong parameters length end byte missing Doc ID 17097 Rev 4 These serial response codes are different from the return codes of the RFACE function calls 45 53 Using the STRF4CE library in Coprocessor mode UMO0909 7 5 46 53 Physical level protocol The following figures provide a graphical representation of a low level protocol They explain how signals are managed during communication Figure 12 shows an example of signal management during a serial communication started from the host side Figure 12 Serial communication started by the host host side nSwake mmm Ll E mmm wmm 0 Host Tx Host Rx Figure 13 shows the low level protocol from the STM32W side Figure 13 Serial communication started by the host STM32W side nSwake O nStop MEE f E STM32W Tx SnezwIR If the STM32W starts a serial communication following an interrupt for a packet received the low level protocol is as shown in Figure 14 Figure 14 Callback response STM32W side Clock mM M nHwake wn MM BU DU nSwake EM L ME BN nStop _ uM mm DU 0 STM32W Tx STM32W Rx Doc ID 17097 Rev 4
30. RFACE SAP PENDING meaning that network initialization will be completed with the call of the user defined callback NLME START confirm An example code for target initialization is void NLME START confirm uint32 t status Ly Doc ID 17097 Rev 4 13 53 Using the STRF4CE API UMO909 printf RF4C P network started r n networkStarted TRUE status NWK_Init 1 FALSE if status RF4CE_NVM_DATA INVALID T warm start fails status while networkStarted NWK Tick void 2 3 Discovery NWK_Init 1 try cold start TRUI my E FALSE A device discovery operation is started either a target or controller node with call to the P NLMI API returns the through the user defined callback NLME 1 DISCOVI ERY request API with the appropriate parameters In case of success the RFACE SAP PENDING value and the discovery result is communicated DISCOVERY confirm Only target nodes are notified of device discoveries by the user defined callback P NLME DISCOV ERY indication The target node can respond to a discovery indication D using NLME RFACE SAP P the user define SCOVERY response In case of success this API returns the ENDING value and the discovery response status is communicated through d callback COMM STATUS indication An ex
31. ST PRODUCTS ARE NOT RECOMMENDED AUTHORIZED OR WARRANTED FOR USE IN MILITARY AIR CRAFT SPACE LIFE SAVING OR LIFE SUSTAINING APPLICATIONS NOR IN PRODUCTS OR SYSTEMS WHERE FAILURE OR MALFUNCTION MAY RESULT IN PERSONAL INJURY DEATH OR SEVERE PROPERTY OR ENVIRONMENTAL DAMAGE ST PRODUCTS WHICH ARE NOT SPECIFIED AS AUTOMOTIVE GRADE MAY ONLY BE USED IN AUTOMOTIVE APPLICATIONS AT USER S OWN RISK Resale of ST products with provisions different from the statements and or technical features set forth in this document shall immediately void any warranty granted by ST for the ST product or service described herein and shall not create or extend in any manner whatsoever any liability of ST ST and the ST logo are trademarks or registered trademarks of ST in various countries Information in this document supersedes and replaces all information previously supplied The ST logo is a registered trademark of STMicroelectronics All other names are the property of their respective owners 2012 STMicroelectronics All rights reserved STMicroelectronics group of companies Australia Belgium Brazil Canada China Czech Republic Finland France Germany Hong Kong India Israel Italy Japan Malaysia Malta Morocco Philippines Singapore Spain Sweden Switzerland United Kingdom United States of America www st com ky Doc ID 17097 Rev 4 53 53
32. This is a mouse demonstration application based on the RFACE ZID application profile Warning IAR project THIS APPLICATION SOFTWARE IS PROVIDED FOR INTERNAL DEMONSTRATION PURPOSE ONLY AND NO OTHER USE IS PERMITTED THIS APPLICATION IS PROVIDED ON AN AS IS BASIS WITHOUT WARRANTY OF ANY KIND EITHER STATUTORY EXPRESS OR IMPLIED INCLUDING WITHOUT LIMITATION WARRANTIES OF TITLE NON INFRINGEMENT MERCHANTABILITY SATISFACTORY QUALITY AND FITNESS FOR A PARTICULAR PURPOSE WITHOUT LIMITING THE GENERALITY OF THE FOREGOING ST EXPRESSLY DOES NOT WARRANT THE ACCURACY SAFETY OR USEFULNESS FOR ANY PURPOSE OF THE SOFTWARE APPLICATION ST HEREBY DISCLAIMS TO THE FULLEST EXTENT PERMITTED BY APPLICABLE MANDATORY LAW ANY AND ALL LIABILITY FOR THE USE OF THE SOFTWARE APPLICATION INCLUDING BUT NOT LIMITED TO ANY LIABILITY IN CONTRACT TORT OR OTHERWISE WHATEVER THE CAUSE THEREOF LIABILITY FOR ANY LOSS OF PROFIT BUSINESS OR GOODWILL OR ANY DIRECT INDIRECT SPECIAL CONSEQUENTIAL INCIDENTAL OR PUNITIVE COST DAMAGES OR EXPENSE OF ANY KIND HOWSOEVER ARISING UNDER OR IN CONNECTION WITH THIS USE There is a single firmware image to perform the roles of mouse and dongle The mouse is the device acting as MEMS based mouse device which sends ZID RF4CE messages to the dongle The dongle is one of the supported ST boards connected to PC via USB and acting as an RFACE ZID Host adapter The firmware is not configured initially and users can c
33. ample code for device discovery is uin P NLM param param param param param param param param Discl N param status DISCOVERY DstPANId DstNwkAddr OrgAppCapabilities OrgDevTypeList 0 OrgProfileIdList 0 SearchDevType DiscProfileIdListSize DiscProfileIdList t32 t status EQUEST Type param OxFFFF OxFFFF 0x12 0x01 0x01 OxFF 0x01 0x01 00 0x0016e36 ERY request Duration DISCOV zH amp param 2 4 Pairing Device pairing pairing can be NLME PAIR P 14 53 is required prior to starting any communication with an RFACE node Device started either in a target or controller node with a call to the equest API with the appropriate parameters In case of success the API ky Doc ID 17097 Rev 4 UMO0909 Using the STRFACE API returns SAP PENDING and a pairing operation result is communicated through the callback NLME PAIR confirm The target node can respond to a pair indication using an NLME PAIR response API In case of success this API returns the value RFACE SAP PENDING and the pair response status is communicated through the user defined callback COMM STATUS indication An example code for device pairing is uint32 t status NLME PAIR REQUEST Type param IEEEAddr dstLongAddr 0x00 0 11 0x22 0x33 0x44 0x5
34. deCap the node capabilities as defined by RF4CE specifications 2 forceColdStart If set to True this boolean parameter allows the network layer to perform a cold start for example the first startup outside the factory Otherwise it will perform a warm start as defined by RFACE specifications In normal use scenarios the API should be called using the defined node capabilities and with forceColdStart to FALSE If there is a mismatch between the content of the NVM memory and the node capabilities the value RFACE DATA INVALID is returned meaning that the NVM data contains invalid data in this case an initialization with a forced cold start is required This is normally requested once when the device is first used outside the factory or in very special cases but not for example in the event of power loss such as a battery replacement 2 2 1 Controller The controller is initialized immediately and its status is returned accordingly If the call is successful the value SUCCESS is returned and the network layer is ready for communication An example code for controller initialization is status NWK Init 0 FALSE if status DATA INVALID If warm start fails try cold start status NWK Init 0 TRUE 2 2 2 Target The Network layer is initialized immediately in case of a warm start returning SUCCESS In case of a cold start the API will return
35. econfigurable platform ST RF4CE TV Select a Serial Port 4 30 53 Doc ID 17097 Rev 4 ky UMO909 ZRC demo application 4 6 Note ST Virtual RC and Sony Infrared TV with an RFACE I R extender This demo scenario targets a demo and an infrared TV supporting Sony codes see Figure 8 The RF4CE I R extender is an STM32W108 MB851 MB954 board which acts as an RFACE Infrared bridge between the ST Virtual RFACE RC and a Sony TV Please note that e rf4cefirmware is requested to be loaded in the STM32W108 MB851 MB954 board e Jumper JP1 should be fitted The Sony infrared TV is a normal TV supporting Sony I R codes as listed in Table 8 with the MB851 MB954 board placed close to the infrared receiver Figure8 ST Virtual RC and Sony infrared TV ff f Infrared Alf MB851 extender Sony I R TV ST Virtual RC The ST RF4CE I R extender supports the following features Network layer cold start by pressing button 51 when LED D1 is off e Pairing mode when LED 01 is on by pressing button S1 e Erase pairing table and bring to the unconfigured state when pressing button S1 for more than 2 seconds This demo can also run using the STM32 Primer2 with MB850 available only with the STM32W108B SK kit boards with STM32W108CB devices Doc ID 17097 Rev 4 31 53 ZID demonstration application UMO909 5 5 1 5 2 32 53 ZID demonstration application
36. ee eh rr 24 Button functions in ST Virtual RC 2 2 2 ren 28 Jumper settings rok ku ok kee e hi RA X HERD RO AGER AD Gui baw 32 Boards supported 1 0 eet rr 33 LED description si essa ke ae Se ee ee 34 Button description eee 34 Jumper settings sessi ee a ee be a ee E e 37 Boards supported 1 2 0 teens 37 LED description huc ark P PERE Tow eee RP d 38 Button description llis m re 38 SPI signal and pin information 0000 eee 41 UART signal and pin information 42 RF4CE coprocessor command codes 44 Serial communication error codes 45 Coprocessor board to MB525 connection with UART and SPI mode 49 List PC ead Se anit Wane AE REPE ie ee 51 Document revision history 52 Doc ID 17097 Rev 4 5 53 List of figures UMO0909 List of figures Figure 1 Figure 2 Figure 3 Figure 4 Figure 5 Figure 6 Figure 7 Figure 8 Figure 9 Figure 10 Figure 11 Figure 12 Figure 13 Figure 14 6 53 RF4CE stack 7 RF4CE multi PAN network
37. el Originator attempts transmission on the expected channel only e Multiple channel Originator attempts transmission using frequency re acquisition mechanism e Alldata can be sent secured or unsecured The options can be combined depending on the application for example e RCs typically use acknowledged unicast and multiple channel options e Target devices typically use unacknowledged unicast and single channel options Security Security is established when pairing nodes that support security in their node capabilities The security mechanism has the following features Utilizes AES 128 encryption Security mode ENC MIC 32 Data confidentiality via payload encryption Data authentication via Message Integrity Code Replay protection via frame counter Nodes use 128 bit link keys Keys are generated automatically if security is supported Keys are stored in the pairing table The application can decide which transmissions require the use of security Power saving The RFACE specification defines a 2 state power saving scheme Active and Standby In normal use cases RCs simply power off when no buttons are being pressed while target devices must also use power saving techniques when in Standby Targets must also ensure a reasonable human reaction time to exit from Standby Doc ID 17097 Rev 4 ky UMO909 RF4CE protocol description 1 3 1 4 To achieve this power saving techniques use an active peri
38. ent ZigBee RF4CE ZID Profile version 0 9 ZigBee Alliance document 105557r11cZB March 8th 2011 Doc ID 17097 Rev 4 ky UMO909 Terms and definitions 9 3 Terms and definitions Table 22 List of terms Term Meaning lack Acmowedgmen API Application programming interfaces ZRC ZigBee Remote Control HDMI High Definition Multimedia Interface MAC Medium Access Control NLDE Network layer data entity NLME Network layer management entity NVM Non volatile memory PAN Personal Area Network PHY Physical layer RC Remote control device RF4CE Radio Frequency for Consumer Electronics SAP Service Access Point ZID ZigBee Input Device Doc ID 17097 Rev 4 51 53 Revision history UMO0909 10 Revision history Table 23 Document revision history Date Revision Changes 19 Feb 2010 1 Initial release 31 Aug 2010 2 Added Section 7 Using the STRF4CE library in Coprocessor mode 12 May 2011 3 Added Section 5 ZID demonstration application Updated User Manual for new ZigBee RFACE release including replacement of Figure 7 and Figure 8 update of Table 11 add up of Section 6 ZID ZRC demonstration application 31 Aug 2012 4 3 52 53 Doc ID 17097 Rev 4 UMO909 Please Read Carefully Information in this document is provided solely in connection with ST products STMicroelectronics NV and its subsidiaries ST
39. g p3 MOUSE DONGLE OFF when in deep sleep 5 6 Buttons description Table 12 Button description Button Role Paired STM32W108 If held down while resetting for less than 5 NONE N A seconds configured as a mouse If pressed after reset configured as dongle If held down while resetting for more than MOUSE No 5 seconds delete configuration as mouse Si If pressed start pairing If held down while resetting for more than MOUSE Yes 5 seconds delete configuration as mouse If pressed left click wakeup If pressed for more than 2 seconds reset DONGLE Does not matter pairing table If pressed shortly start pairing S2 if available MOUSE Yes Left click wakeup S3 if available MOUSE Yes Right click wakeup S4 if available MOUSE Yes Right click wakeup S5 if available MOUSE Yes Wakeup 5 7 Usage The RF4CE ZID demo is based on the application profile version 0 9 08 March 2011 It demonstrates the basic steps to configure two boards one as a HID device and the other as a HID USB adaptor The HID device is a mouse which is based on the detection of the MEMS axis accelerations that translate to mouse movements and are sent to the receiver attached to the PC Please flash the supported boards with hid rf4ce image start up the demo follow the steps below 34 53 Doc ID 17097 Rev 4 ky UMO0909 ZID demonstration application 1 Connect the HID USB dongle to the PC and press the S1 button The LED D1 blinks every half second for
40. get Push button S1 Input LED D1 ON Press to enable pairing LED D1 ON Press for more than 2 seconds to bring the RF4CE node to unconfigured state The following subsection provides a description of the building and running steps of the demonstration applications using the IAR projects delivered within the RF4CE software library package as a reference The available workspaces provide reference examples for the STM32W108CC boards Building the firmware The firmware can be built from the IAR Embedded Workbench sources using the related IAR project file Programming the firmware The firmware can be programmed in the boards using the Embedded Workbench using the stm32w_flasher utility For information on how to use the stm32w flasher utility refer to the STM32W SK and STM32W EXT starter and extension kits for STM32W108xx user manual reference UM0894 RS 232 remote control and target applications In this demo scenario the user interacts with the boards using a PC HyperTerminal and the user can set a node as an RF4CE target or as an RF4CE controller Figure 4 This demo scenario uses two boards and it can be run even on a single PC The RS 232 port in the PC should be set according to the values shown in Table 6 Doc ID 17097 Rev 4 23 53 ZRC demo application UMO0909 Table 6 RS 232 settings Parameter Setting Baud rate 115200 Data bits 8 Parity None Stop bi
41. he profile defines two types of device a HID class device and a HID adaptor The HID class device can be used to support devices such as keyboards mice or touchpads and the HID adaptor can be used to communicate through a HID class driver to some PC or other embedded host Doc ID 17097 Rev 4 11 53 Using the STRF4CE API UMO0909 2 2 1 12 53 Using the STRFACE API Programming model The STRF4CE library is a very efficient implementation based on a MAC PHY layer specifically tailored for RFACE applications It features a simple and efficient NVM management system that stores non volatile data and preserves the network layer state using power cycling methods An RF4CE API also implements power management functions only for the radio part in compliance with RFACE specifications The same code base is used for both the target and controller node types The API is defined with a map close to the SAP defined in the specification The API is designed and implemented to be non blocking that is the network layer operations will give back control to the application when waiting for an event The core of an RFACE compliant application is implemented through a never ending loop where the network layer state machine and application state machine are run while 1 Non blocking call to run the application state machine ApplicationTick Non blocking call to run the network layer state machine void NWK Tick
42. he stack Do not change this but use nwkcNodeCapabilities Not specified NWK Init to set the node capabilities nwkcVendorIdentifier 16 bit value OxFFF1 Vendor ID please use NWK_Config to change it nwkcVendorString 7 character string ST Vendor string please use NWK_Config to change it For a complete description of the parameters please refer to documents 1 2 and 6 The stack configuration is required prior to cold starting the stack using NWK_Init it is stored in the non volatile memory The following code shows how to configure the stack using NWK_Config void NLME START confirm printf RF4CE network networkStarted TRUE uint32_t status started r n status NWK_Init 0 FALSE if status RF4CE_NVM_ warm start fails uint16_t myVendorId DATA_INVALID Oxabcd try cold start NWK Config nwkcVendorIdentifier ID amp myVendorId NWK Config nwkcVendorString ID Vendor status NWK Init 1 TRUE while networkStarted FALSE void NWK Tick 1 All other network parameters can be modified using the NLME_Set API Below is an example of how to set up the nwkUserString parameter This should be done only once after a cold start NLME_SET_Type val 18 53 Doc ID 17097 Rev 4 ky UMO909 Using the STRF4CE API 4 val NIBAttribute nwkUserString_ID val NIBAttributeIndex
43. ive sendStateMachine manages the response command packets to send to the network coprocessor It also picks up the messages received from the air and translates them as a byte sequence to send to the host processor using a serial connection Doc ID 17097 Rev 4 47 53 Using the STRF4CE library in Coprocessor mode UMO0909 48 53 As explained above the network coprocessor can manage two different types of serial communications SPI or UART The user selects the SPI or UART interface during the compilation time using a special preprocessor define If the user declares the preprocessor define SC SPI the network coprocessor manages the serial communication using the SPI channel in slave mode Otherwise if the preprocessor variable is not defined the coprocessor uses the UART channel by default The host processor firmware is the interface between the user application and the network coprocessor It manages RF4CE requests from the user application and translates them as a byte array to be sent through the serial channel The first step to execute in the main is to initialize the serial communication UART or SPI using the command hostSerialInit After this initialization the user application can execute the RFACE commands Every RFACE command is implemented using the following structure rf4ce command param function to copy the rf4ce param values inside a byte array cmd create_array_byte_from_param param
44. lume up button 4 0 42 0x13 Volume down button 0x40 0x15 Standby button 4 0x30 0x10 Channel up button 0x31 0x11 Channel down button 0 44 Ox1A Play button tn 0x46 0x19 Pause button t 0x69 0x25 AV button 0 20 0 29 Digit button 0 35 Info button np 0x09 0x60 Menu button JI 0x01 0x74 Up button 0 02 0 75 Down button gt 0x04 0x33 Right button lt 0x03 0x34 Left button J 0x00 0x65 Select OK button x N A N A Cancel all paired devices Doc ID 17097 Rev 4 UMO0909 ZRC demo application Table 8 Button functions in ST Virtual RC continued Key label ZRC code Infrared code Description Show the list of paired devices amp Search and pair RF4CE target Figure 6 shows a snapshot of the ST Virtual RC application Figure 6 ST Virtual RC RFACE RC Select a Serial E zi gt 90 Z E lt o n ch A E ky Doc ID 17097 Rev 4 29 53 ZRC demo application UMO0909 4 5 2 ST Virtual TV The ST Virtual TV is a PC GUI application that emulates an RFACE TV and supports the following features e 12 channels playing video from files Volume control Mute Channel change Play Pause Pair button Erase pairing table button Paired devices information Figure7 ST Virtual TV screenshot AT RFACE TV Open flexible r
45. mand sequences 1 1 2 If the devices are not configured the prompt is Unconfig gt Otherwise type to cancel any previous configuration 2 1 Type command T to configure the target Wait approximately 5 seconds to end the RF4CE network initialization If the initialization is correct the prompt will be Target 1 gt 1 indicates that the device is not paired 3 2 Type command c to configure the controller remote control If the initialization is correct the prompt is Controller 1 gt 1 indicates that the device is not paired 4 1 2 Type command and wait for the confirm messages on both boards Below is an example of a log of discovery and pair messages with status OK CONTROLLER Controller 1 D CERC DSC PAIR Status 00000100 CERC DSC PAIR END Controller 1 CERC PAIR CONFIRM Status 00000000 PairingRef 00 Vendorld FFF2 VendorString Vendor AppCapabilities 13 UserString STM32W Target DevTypeList 02 CERC PAIR CONFIRM END Controller 0 TARGET Target 1 gt D lt CERC_DSC_PAIR gt Status 00000100 lt CERC_DSC_PATR_END gt Target 1 gt lt CERC_PAIR_INDICATION gt Status 00000000 PairingRef 00 VendorlId FFF1 VendorString ST AppCapabilities 13 UserString STM32W RC DevTypeList 01 Doc ID 17097 Rev 4 25 53 ZRC demo application UMO0909 26 53 PANId FFFF Address 0080E1020000026C
46. ns a module used to manage NVM storage using 1 Kbyte of Flash memory NVM usage is transparent to the user but some interaction with the application is required to limit Flash wearing Flash wearing is limited using a cache of the NVM data in RAM This cache needs to be flushed into the actual flash periodically so that it is not lost in case of a power failure The following code provides an example of how to flush the NVM cache retVal NWK Tick Check whether cache flush is required if retVal amp RFACE STATE NEED CACHE FLUSH NWK Flush j The NWK Tick return value gives an indication when cache and NVM are not consistent A call to NWK Flush is not mandatory and can be delayed if necessary since the NWK Flush operation requires about 40 ms to complete The application can choose when itis more appropriate to call it and how often Doc ID 17097 Rev 4 17 53 Using the STRF4CE API UMO909 2 10 RF4CE stack configuration The ST RF4CE library allows the configuration of certain stack parameters at run time These stack parameters Table 3 are according to the specification constants but implementation dependent Table 3 Configurable stack parameters Name Valid range berau Description value nwkcMaxNodeDescListSize Not specified 3 Not changeable without recompiling the stack nwkcMaxPairingTableEntries Not specified 5 Mot changeable without recompiling t
47. ntroller Node with the following capabilities Initiates pairing and discovery process with Target nodes Implements frequency agility On demand communication Network topology ZigBee RF4CE PANS are essentially point to point or star topologies with a single node acting as the target device and one or many nodes acting as remote controls No routing is allowed and communication happens between nodes within RF range The ZigBee RFACE network also supports multiple PANs and participation in multiple networks Figure 2 Figure 2 RFACE multi PAN network PAN 1 Target Controller node node Figure 2 illustrates an example ZigBee RFACE topology which includes three target nodes a TV a DVD and a CD player where each target node creates its own RC PAN The TV DVD and CD player also have dedicated remote controls which are paired to each appropriate target node A multi function remote control capable of controlling all three target nodes itself is added to the network by successively pairing to the desired target nodes The DVD is also paired with the TV so that an external channel can be selected on the TV when a DVD is played As a consequence this remote control network consists of three separate remote control PANs one managed by the TV PAN 1 containing the TV remote control the multi function Doc ID 17097 Rev 4 ky UMO909 RF4CE protocol description 1 2 3 1 2 4 1 2 5 remote contr
48. od during which the target wakes up and a duty cycle after which the device repeats the active period as shown in Figure 3 Figure 3 Power saving scheme nwkDufyCycle no more than f sec nwkActivePrenad min of 16 8 msec Rx on ZRC application profile The ZRC application profile is the first application profile defined for the RF4CE protocol It aims at replacing remote controls that use traditional infrared technology It defines a very simple push button pairing process between the remote control and the target device The mechanism works in conjunction with existing ZigBee RF4CE discovery and pairing mechanisms Discovery pairing and security optional all take place at a single press of a button This application profile also defines a set of commands for basic CE device control such as remote control pressed remote control repeated and remote control released Refer to Document 8 for a description of these embedded HDMI CEC commanas The ZRC also provides support for manufacturer specific commands ZID application profile The ZID application profile is the second application profile defined for the RF4CE protocol It defines commands and procedures to enable devices such as mice touchpads keyboards wands Riva wheels or RC pointers The RF4CE ZID profile defines the over air commands and mechanisms required to allow a Human interface device HID class device to communicate with a host T
49. ol and the DVD a second managed by the CD player PAN 2 containing the CD remote control and the multi function remote control and a third managed by the DVD PAN3 containing the DVD remote control multi function remote control and the TV Frequency agility ZigBee RF4CE networks operate on the following IEEE 802 15 4 channels e Channel 15 2 425 GHz e Channel 20 2 450 GHz e Channel25 2 475 GHz Both target and controller node types support frequency agility Target nodes specify the PAN base frequency and can decide to switch frequencies on adverse channel conditions The detection of a channel busy condition is implementation dependent Frequency reacquisition is achieved through a mechanism that allows other nodes by trying each frequency and once found the new channel information is stored for future communications Discovery The discovery procedure builds a list of devices in the RF vicinity Discovery requests are sent by the originating device for example a RC and use a broadcast multi channel service so that multiple devices can respond The discovery request also contains originator information to allow the device to respond When a discovery request is received recipient devices normally inform the application of the event The application decides whether or not to respond to the discovery request The recipient device for example a television sends a discovery response directly back to the originator fo
50. onfigure it using button press combinations see Table 12 Button description Jumper settings Table 9 Jumper settings Jumper name Role STM32W108 MOUSE Fitted JP1 if available DONGLE Does not matter MOUSE DONGLE 1 2 battery 5 6 USB Doc ID 17097 Rev 4 ky UMO0909 ZID demonstration application 5 3 Boards supported Table 10 Boards supported Board name Board revision Role STM32W108xB STM32W108CC A B MOUSE X NA A B DONGLE NA MB851 C MOUSE DONGLE X NA D MOUSE DONGLE NA X A MOUSE X NA A DONGLE NA MB954 B MOUSE DONGLE X NA C MOUSE DONGLE NA X MB953A MOUSE DONGLE X NA MB950A MB953 MB953B MOUSE DONGLE NA X A MOUSE NA A DONGLE X NA MB951 B MOUSE NA B DONGLE NA X X supported not supported NA not applicable 5 4 Serial I O Debug info only in case of errors ky Doc ID 17097 Rev 4 33 53 ZID demonstration application UMO0909 5 5 LED description Table 11 LED description LED Role STM32W108 OFF NOME Blinks twice if configured as a mouse ON only when an transmission is taking place MOUSE Blinks every 0 1 second while pairing Df Blinks twice if the configuration is deleted ON during normal operation DONGLE Blinks every 0 5 seconds while network startup Blinks every 0 1 second while pairing Flashin
51. plication Wait for the initialization procedure to complete ST RFACE RC Ready message is displayed 3 Onthe Virtual TV application select a serial port from the drop down menu If the firmware is not present in the board it will be automatically downloaded by the application Wait for the initialization procedure to complete ST RFACE TV Ready message is displayed 4 Virtual RC application select lt 5 Virtual TV application select ES to start the pairing procedure to start the pairing procedure 6 If everything is OK the message Paired is displayed on the TV and a confirmation message with technical details is displayed on the RC after a few seconds 7 The demo is now operational and the key presses on the virtual RC will perform the requested action on the virtual TV as specified in Table 8 If you run again the demo with the same boards as RC and TV the devices are already paired and steps 4 5 and 6 are not necessary Figure 5 RFACE Virtual RC and TV 5 f Doc ID 17097 Rev 4 27 53 ZRC demo application UMO909 4 5 1 28 53 ST Virtual RC The ST Virtual RC is a PC GUI application that emulates an RFACE RC and supports the commands listed in Table 8 Table 8 Button functions in ST Virtual RC Key label ZRC code Infrared code Description qo 0x43 0x14 Mute button a 0x41 0x12 Vo
52. r example a RC using a unicast service The discovery response contains recipient information When the discovery procedure is completed originator devices inform the application of all discovery information The application then decides whether to pair with a particular device Pairing Pairing is a procedure required to establish a link between two devices in radio range that wish to communicate Pairing is required prior to device communications and it is performed only once Pairing information is stored in non volatile memory so that it can be retrieved after power cycling Pairing is similar to discovery where originator and recipient information is exchanged and the application has full control of whether to accept or not Both originator and recipient devices create pairing table entries that contain addressing information and security information if applicable The application uses these entries via a reference index Doc ID 17097 Rev 4 9 53 RF4CE protocol description UMO0909 1 2 6 1 2 7 1 2 8 10 53 Message transmission and reception Message exchanges are supported between paired devices only Transmission options include Acknowledged Originator data is confirmed by the recipient e Unacknowledged Originator data is not confirmed by the recipient e Unicast Originator data is sent to a specific recipient e Broadcast Originator data is sent to all recipients e Single chann
53. ringRef lt Your code here gt j int main void Initialization phase init serial Initialize serial interface status NWK_Init 1 FALSE f if status RFACE NVM DATA INVALID If warm start fails try cold start uinti16 t myVendorId NWK Config nwkcVendor NWK Config nwkcVendor status NWK Init 1 while networkStarted void NWK Tick while 1 Non blocking call to ApplicationTick Non blocking call to void NWK Tick 4 Identifier ID amp myVendorId String_ID TRUE FALSE advance application state machine advance network layer state machine Doc ID 17097 Rev 4 21 53 ZRC demo application UMO0909 4 4 1 22 53 ZRC demo application The ZigBee RFACE demo applications target the ZigBee RFACE ZRC Consumer electronic remote control profile for remote control and target devices for the scenarios listed in Table 4 Table 4 ZigBee RFACE ZRC demo applications scenarios RF4CE remote control RFACE target device RS232 RC RS232 Target ST Virtual RC ST Virtual TV ST Virtual RC Sony infrared TV All combinations between RCs and targets are supported These scenarios demonstrate simple RFACE interactions between an RC and a target device with e Discovery and pairing e Secure communications e Datatransmission e Power management
54. rocessor firmware and i are the major minor and patch versions for RF4CE library NWKCOP POWER DOWN Ox1D Power down request for STM32W coprocessor NWKCOP_POWER_UP Ox1E Power up request for STM32W coprocessor Helper function request to configure RF4CE NWKCOP_NWK_CONFIG Ox1F network coprocessor layer prior to cold start initialization NWECOP KUM ERASE 0x20 Support function call to erase the RF4CE NVM network coprocessor memory NWKCOP MAC SET EUIG4 0x21 Set the IEEE Address only for test not available for normal use All the commands have a 4 byte response code to indicate the command outcome 7 4 RF4CE serial communication code 4 Table 20 Serial communication error codes The serial communication code is a byte sent after each communication which allows the host microcontroller and STM32W to check for errors during the last transaction The codes are described in Table 20 Command NWKCOP_PACK ET TOO LONG Code 0x1000 00DA Description Serial communication error packet too long Serial communication error packet NWKCOP PACKET DAMAGED 0x1000 00DB damaged NWKCOP BUSY 0x1000 00DE Serial communication error STM32W is busy form more than a timeout NWKCOP UNKNOWN CO 0x1000 00CB Serial communication error unknown command NWKCOP UNKNOWN PACKET TYPE 0 1000 00CA Serial communication error unknown packet type start byte unknown NWKC
55. s Yes nSWake 6 PE11 Yes Yes nStop 10 PE12 Yes Yes MOSI 7 PB15 No Yes MISO 8 PB14 No Yes SCLK 9 PB13 No Yes nSSEL 11 PE13 No Yes UART RX 16 PD5 Yes No UART TX 15 PD6 Yes No GND 22 GND Yes Yes The demo uses the MB525 USART1 with settings as specified in Table 6 The LEDS on the MB525 is the heartbeat LED and it blinks every half second Doc ID 17097 Rev 4 49 53 Reference documents UM0909 50 53 The LED1 is an application LED with the following meaning ON demo configured as TARGET OFF demo configured as CONTROLLER or UNCONFIGURED BLINKING every half second the board is initialized as TARGET and executing the energy scan and active scan to select the channel and the PANID respectively BLINKING every 100 msec the device is executing a Discovery amp Pair procedure An IAR project is provided to show the network coprocessor reference code for the host side See Section 4 4 for details on how to operate the demo Reference documents 1 2 3 4 5 6 c c ZigBee RF4CE Specification ZigBee Alliance document 094945r00ZB Version 1 00 March 17th 2009 ZigBee RF4CE CERC Profile Specification ZigBee Alliance document 094946r00ZB March 17th 2009 High Definition Multimedia Interface Specification HDMI Licensing LLC Version 1 3a 5 November 10 2006 STMicroelectronics STM32W108HB datasheet Doc ID 16252 Rev 3 December 2009 ST RF4CE API Reference Guide HTML docum
56. ters Doc ID 17097 Rev 4 43 53 Using the STRF4CE library in Coprocessor mode UMO0909 7 3 44 53 Serial RF4CE command codes Table 19 lists all the RF4CE command codes used in the serial packet during communication Table 19 RF4CE coprocessor command codes Command Code Description NWKCOP_NOP 0x00 Nop instruction NWKCOP NLDE DATA REQUEST 0x01 Data request function serial code NWKCOP NLDE DATA INDICATION 0x02 Data indication function serial code NWKCOP_NLDE_DATA_CONFIRM 0x03 Data confirm function serial code NWKCOP NLME AUTO DISCOVERY REQUEST 0x04 Auto discovery request function serial code NWKCOP NLME AUTO DISCOVERY CONFIRM 0x05 Auto discovery confirm function serial code NWKCOP NLME COMM STATUS INDICATION 0x06 Comm status indication function serial code NWKCOP_NLME_DISCOVERY_REQUEST 0x07 Discovery request function serial code NWKCOP_NLME_DISCOVERY_INDICATION 0x08 Discovery indication function serial code NWKCOP_NLME_DISCOVERY_RESPONSE 0x09 Discovery response function serial code NWKCOP NLME DISCOVERY CONFIRM OxOA Discovery confirm function serial code NWKCOP NLME GET OxOB Get request function serial code NWK
57. ts 1 Flow control Xon Xoff Figure 4 RS 232 RC and target node The demo supports the commands case sensitive as shown in Table 7 over the HyperTerminal The two devices are named 1 and 2 in reference to the STM32W108 boards and are both loaded with the rf4ce firmware image Table 7 Firmware commands Command Description T Configure the node as the target Configure the node as the controller D Discovery amp pair procedure Z Discovery amp pair procedure from a target p Dump pairing table R Device software reset e Clear pairing table E Erase the NVM storage S Enable the power save A Disable the power save Update the remote control firmware over the air from the target The firmware sent is the target Flash image Note the remote control and the target should contain the bootloader code iap_bootloader s37 at the bottom of the Flash memory space Print Help menu Send command key pressed volume up Send command key pressed volume down Send command key pressed channel up Send command key pressed channel down 24 53 3 Doc ID 17097 Rev 4 UMO909 ZRC demo application 4 Table 7 Firmware commands continued Command Description 0 9 Send command key pressed channel 0 9 ESC Enter the string command mode To run the demo applications type the following com

Download Pdf Manuals

image

Related Search

Related Contents

La faisabilité économique des projets d`économie sociale  - NEC Display Solutions Europe  Manual do usuário  Targus 3D Protection  Whirlpool 3SLSR6233MQ0 Washer/Dryer User Manual    Samsung Galaxy Tab E T377R4 User Manual  BFB-1307Z  VFP-10JD  User Manual - Skope Industries  

Copyright © All rights reserved.
Failed to retrieve file