Home
CC USB Software Examples User`s Guide
Contents
1. 12 22 12 A TEXAS Ai INSTRUMENTS swru222 5 4 USB RF Modem Example rf modem This application example is a wireless USB to serial port RS232 converter It creates a virtual serial port on the host operating system Data sent to this virtual serial port will be transferred to the USB device over the PC s USB hub then over the air to the CC1110 CC2510 CC2530EM and finally to a PC serial port via the SmartRFO4EB SmartRFO5EB Hardware flow control for RTS is implemented CTS is not supported directly by the CDC driver but is indirectly implemented by stopping the processing of USB requests when the RF modem is busy with processing the RF traffic The radio link has CRC check and automatic retransmission for error free operation Note The application has been tested on Windows XP SP2 Windows XP SP3 Windows Vista SP1 and GNU Linux Ubuntu 9 04 For other operating systems a suitable drivers may have to be found or created This application example uses the USB framework found in the USB firmware library to configure the USB Dongle and to handle all USB standard requests In addition the class requests required by the CDC device class are implemented in a separate file The radio communication between CC2530EM and the USB Dongle is done using the MRFI protocol Please see 10 for more information about the CDC class 5 4 1 Software Components The executables for the applications are located as follows
2. rf modem hex The file is located in ide rfusb_cc1111 iar ide rfusb cc2511 iar ide rfusb cc2531 iar ide srf04_cc1110 iar ide srf04_cc2511 iar or ide srf05 cc2531 iar depending on the intended target device In addition a setup information file usb cdc_driver_ccxxxx inf will be needed on Windows operating systems to associate the device with the operating system s driver for USB CDC ACM class usbser sys There are three files one per USB dongle located in the driver folder Note The 64 bit edition of Microsoft Windows Vista only accepts digitally signed driver installation files This driver files in this software package are not signed and will not be accepted They can however be used on 32 bit edition of Windows Vista 5 4 2 Installing the Application CC 1111 CC2511 e Attach the CC1110EM CC2510EM to the SmartRFO4EB and program it with the flash image rf modem hex using IAR Embedded Workbench or the SmartRF Flash Programmer See 1 for more information e Connect the USB Dongle to the other SmartRFO4EB through the SOC_DEM and program it with the flash image rf_modem hex using IAR Embedded Workbench or the SmartRF Flash Programmer See 1 for more information 5 4 3 Installing the Application CC2531 e Attach CC2531EM to the SmartRFO5EB and program it with the flash image rf_modem hex using IAR Embedded Workbench or the SmartRF Flash Programmer See 1 for more information 13 22 13 13 TEXAS INSTRUM
3. logical channels This is available from the following definition in mrfi h e MRFI_NUM_LOGICAL_CHANS The discipline to accomplish the channel change such as perhaps changing the radio through the correct state transitions is owned by MRFI and is not a concern of the caller 8 22 8 13 TEXAS INSTRUMENTS swru222 uint8_t MRFI_SetRxAddrFilter uint8_t This function sets the address to be used as a filter value Depending on the radio not all the bytes may be used as part of the native hardware filtering capabilities Some of the actual filtering implementation may be in software MRFI hides this partition and the caller does not know how the actual filtering is accomplished void MRFI_EnableRxAddrFilter void When this call is made MRFI will subsequently filter out all received packets that do not match the address previously set Broadcast packets are always received regardless of filter setting void MRFI_Sleep void This call puts the radio into the sleep state The call is synchronous in the sense that when it returns the radio in SLEEP state To ensure reliable operation this function must never be called from interrupt context void MRFI_WakeUp void This call takes the radio out of SLEEP state into IDLE state The call is synchronous in the sense that when it returns the radio in IDLE state 5 2 3 Packet Sniffer Capture The Texas Instruments Packet Sniffer is an indispensable tool when developing RF based applic
4. Frame Check 11 bytes 1 byte 1 byte O 44 bytes 1 byte Table 3 Frame format 5 2 2 MRFIAPI MRFI is the lowest software layer of the SimpliciTl protocol and is used in these application examples without the rest of SimpliciTl It implements a common API for all supported RF devices hiding the implementation details from the application It is a pure radio interface not to be confused with a more generic HAL This section is limited to a brief overview of the API as this document focuses on the applications and the USB Firmware Library Only the API calls which are used by the examples are mentioned here For a complete overview of the MRFI API please refer to the MRFI interface header mrfi h located in source components simpliciTl mrfi and the various implementations found in mrfi_radio c source components simpliciTl mrfi radios familyXX The relevant sub folders are family6 CC2530 31 and family2 CC1110 1111 2510 251 1 All references to MRFI are contained in a single source file which is common to both examples source apps common mrfi_link c void MRFI_Init void This function must be called before any other MRFI calls uint8_t MRFI_Transmit mrfiPacket_t uint8_t This call supplies a pointer to a mrfiPacket_t object whose frame element has been populated with the payload The implementation populating the payload portion of the frame should use the MRFI macro MRFI_P_PAYLOAD p defined in mrfi h to obtain a pointer to the
5. byte 6 axis The frames with 2 byte payloads are application ACK frames 11 22 11 13 TEXAS INSTRUMENTS swru222 MAC Payload Byte ETA Frame tyoe DATA Mouse DATA ID fixed 1 Button activity Mouse X movement Mouse Y movement 6 Mouse Z movement Scroll wheel Table 5 Mouse Mode Payload Address P nbr Time us Length Frame control field Sequence Dest Dest Source FCS Rx 0 Type Sec Pod Ack req PAN compr number PAH Address PAH 1 0 20 DATA 0 D 0x03 Ox2007 Ox25DE 0x2007 Ox25EB DE P nbr Time us Length Frame control field Sequence Dest Dest Source Source Lol los EX 1795 Type Sec Pod Ack req PAN compr number PAH Address PAI Address 2 1795 15 DATA 0 0 D 0x63 Ox2007 Ox25EB 0x2007 Ox25DE 132 DE P nbr Time us Lomat Frame control field Sequence Dest Dest Source Source Lol l Fes EX 2555 Type Sec Pod Ack req PAN compr number FAH Address PAH Address 3 4150 20 DATA 0 0 D 0x04 Ox2007 Ox25DE 02007 OxZ25EE 136 DE P nbr Time us Length Frame control field Sequence Dest Dest Source Source Lol lFcs EX 1793 Type Sec Pod Ack rec PAN compr number FAH Address PAI Address 4 5945 15 DATA 0 D 0x6 Ox2007 Ox25EB 02007 Ox25DE 144 DE Figure 8 Mouse Left Movement Source The keyboard mode payload is decoded as shown in Table 6 An example of a keyboard frame is shown in Figure 9 Byte 4 of the MAC payload
6. can be used as any standard serial port Note that the control line CTS Clear To Send will not be visible in terminal emulators or analysis tools which shows the state of this line the CDC class does not make use of this feature The green LED on the dongle is lit only when the PC asserts the RTS signal in HyperTerminal this is equivalent to connecting Note Make sure that the PC application e g HyperTerminal is disconnected before physically unplugging and inserting the USB dongle Leaving HyperTerminal connected may cause the USB dongle to fail during enumeration due to being flooded by requests by a PC application which thinks it is still connected 5 4 5 Running the EB Application Connect the CC2510 CC1100EM to the SmartRF04EB and power it OR connect the CC2530EM to a SmartRFO5EB and apply power Select Device 1 by pushing button S1 LCD will then display Device 1 ready Connect an RS232 NULL modem cable between a COM port on the PC and the 16 22 16 A TEXAS INSTRUMENTS swru222 serial port on the SmartRFO4B SmartRFO5EB Connect one HyperTerminal window to the Virtual COM port and another HyperTerminal window to the COM port connected to the evaluation board The port settings should be 38400 baud 8 bits 1 stop bit no parity Hardware handshaking must be enabled You should observe text written in one HyperTerminal window appearing in the other as shown in Figure 16 and Figure 17 3 00M9 38400 HyperTer
7. ide just below the root of the installation The file is named usb_app_ex eww Figure 3 Folders E E Temp _jrfusb_cc1111 File Folder GS docs jrfusb_cc 511 File Folder e Srfusb_cc2531 File Folder TE C srf04_cc1110 File Folder Ao O srf04_ cc2510 File Folder ip O srf05_ec2530 File Folder E ES rfusb_cc2511 Edjusb_app_ex eww SKB IAR IDE Workspace fan lar E 5 rfusb_cc2531 3 iar E C srf04_cc1110 m iar E 5 srf04 cc2510 3 iar E C srf0S_cc2530 3 iar source E apps common 9 rf modern 22 simple_hid 3 components Figure 3 Directory Structure 5 22 5 A TEXAS INSTRUMENTS swru222 After opening the IAR workspace all the examples can be built in one operation by hitting the F8 key Downloading to the target can be done using the keyboard shortcut CTRL D alternatively Project gt Debug as shown in Figure 4 By X IAR Embedded Workbench IDE E File Edit View Project Tools Window Help Add Files Add Group Import File List Edit Configurations Remove E Blusb_apt rf_mo Create New Project Y rf_mo Add Existing Project v rf_mo Options ALT F7 v E r _mo v E rf mo Source Code Control v agr MO Make E7 v P simpli Compile CTRL F7 a La E simpli Rebuild All vY Ha E simpl Gen v Ha E simpli Batch build Fa Y aap Gai Stop Build GTRL Break Q Debug Make amp Restart Vaii simple hid mouse c E 4 Lau
8. it with the flash image simple_hid_dongle hex using IAR Embedded Workbench or the SmartRF Flash Programmer See 1 for more information 5 3 3 Installing the Application CC2531 e Attach the CC2530EM to the SmartRFO5EB and program it with the flash image simple_hid_eb hex using IAR Embedded Workbench or the SmartRF Flash Programmer See 1 for more information e Connect the the CC2531 USB dongle to the other SmartRFO5EB and program it with the flash image simple_hid_dongle hex using IAR Embedded Workbench or the SmartRF Flash Programmer See 1 for more information It is also possible to use the CC Debugger for this purpose 5 3 4 Running the Application Insert USB Dongle into a free USB pori The firmware will identify the USB Dongle as a composite HID with a keyboard and mouse On most operating systems no extra driver is necessary the OS will automatically load a standard driver for HID devices Select the operating mode Mouse or Keyboard by operating the joystick left right and confirm the selection using the S1 button see Figure 7 10 22 10 I TEXAS INSTRUMENTS swru222 AA gt mi AIIN RS Y ALDI D7 U NA Be POTME TEA Rei A235 E Figure 7 Selecting Mouse Keyboard Mode SmartRFO5EB Mouse Mode In mouse mode the joystick on the SmartRFO4EB SmartRFO5EB can be used as a mouse Push the joystick up down left right to emulate mouse movement The button S1 emulates the ri
9. to the next step Select Search for the best driver in these locations as shown in Figure 12 Make sure that the wizard searches the driver directory one level below the installation root It is also possible to install the driver manually This is quicker but the user runs the risk of installing the wrong driver 14 22 14 13 TEXAS INSTRUMENTS swru222 Found New Hardware Wizard Please choose your search and installation options i Search for the best driver in these locations Use the check boses below to limit or expand the default search which includes local paths and removable media The best driver found will be installed Search removable media floppy CD ROM he Include this location in the search C usb_app_ex dhiver Don t search will choose the driver ta install Choose this option to select the device driver from a list Windows does not guarantee that the driver you choose will be the best match for your hardware Back Hest gt Cancel Figure 12 Driver Installation Step 2 Click Next to advance to the next step Windows will now search for the driver which may take some time see Figure 13 Found New Hardware Wizard Please wait while the wizard searches y 11002511 Low Power RF to USB CDC Serial Port i Figure 13 Driver Installation Step 3 15 22 15 13 TEXAS INSTRUMENTS swru222 You are now likely to encounter the warning dialog shown in Figur
10. 12 TEXAS INSTRUMENTS CC USB Software Examples User s Guide swru222 I TEXAS INSTRUMENTS swru222 Table of Contents 9 INFOdU CIO Nai 2 About TIS Manllal coin 2 ACTODYM S oiia e et ot tat ia sti dieta oa iii ai alt i na i i 2 Getting Stailed 2 asecii 0 iza a 3 4 E A A aia 00 tat 3 Be MACON Al AOC ICS tas a ie ia apa 3 AO IMOWINETODIE NS ana iio a dat 3 USB Application Examples iia 5 5 1 sBUNGIIO ANG TAUNDING MO Example Soressi A AA 9003 a al ae 5 HE AFTO hacia Dace Podio 7 5 2 1 WIP aime OT 7 5 2 2 ARE PP cc ct ie tant oase ic aa ca A issue anni Geet seek tea tac seat a 7 5 2 3 ME sasoie II AN 9 59 USB Example SENDO AMOS o 10 5 3 1 SOWAS COMPONEN SE seia a o Tate o eet 10 5 3 2 Installing the Application CC1111 CC2511 eee nnnaaaaa 10 5 3 3 Installing the Application CC253 Tosse loep eane dala it anu et to daia mele da a a o ta 10 5 3 4 RUARIRO the ADICON citric sii o A STA aa AAA AAA AAA AA ERA AA AA i 10 5 3 5 Packe Onne Capra e scoici iata et cates N ds a et oe 11 54 USBRF Modem Example T Mod rn iii ede a a eee 13 5 4 1 SOMWarerG OM A A A 13 5 4 2 Installing theApplicationy COITO oes e coase pas De aaa Da aaa Da Ile al DONA iul Dee Ge 13 5 4 3 lnstalling the Application CC253 1 scczcecccetoct seca aut cee 0089520050 eat coca sees anaes setae ALLEN mau eee ia GET 13 5 4 4 Running the USB APP AMO ata Aaa 14 5 4 5 RUARIDO the EB ADOC AO aia a A 16 5 4 6 Paciente Caplio ac aac sc dats antics act nck
11. 6 7 8 9 10 11 CC1110 CC1111DK CC2510 CC2511DK Development Kit User Manual swru1 34 CC2530DK Development Kit User Manual swru208 Texas Instruments SmartRF Studio swrc046 Texas Instruments SmartRF Flash Programmer swrc044 CC USB Firmware Library and Examples swrc088 Texas Instruments Packet Sniffer swrc045 CC1111 CC2511 USB Hardware User s Manual swrc082 CC2531 USB Hardware User s Manual swrc221 Device Class Definition for HID 1 11 US IF Inc 2001 http www usb org developers devclass_docs HID1_11 paf USB Class Definitions for Communication Devices 1 1 USB IF Inc 1999 http www usb org developers devclass_docs usbcadc1 1 pdf SimpliciT Installer simpliciti html 7 General Information 7 1 Document History Revision Date Description Changes SWRU222 2009 05 08 Initial release 21 22 21
12. EE ERATE RETA EER ERATE EE INCLUDES wy include hal _defs h include common mrfi_link h include hal board h include hal _button h Tats Messages File Line JE x Errors 0 Warnings 0 in 18 Col 11 gS SS Figure 5 usb _app_ex eww Workspace Alternatively the generated HEX file can be downloaded to the target using the SmartRF Flash programmer 6 22 6 A TEXAS Ai INSTRUMENTS swru222 5 2 RF Protocol Both examples use MRFI as the basic protocol for RF communication On top of MRFI there is a minimal network layer which adds retransmission and acknowledge The application layer uses two frame types DATA and ACK The latter is used to indicate to the sender that the receiver is busy The RF channel is fixed to MRFI logical channel 0 defined as shown in Table 2 Please refer to the document SimpliciT Channel Table Information pdf contained in the SimpliciTl installer for details on the channel allocation 21 Frequency MHZ E RR IE eT CC2511 2425 7 CC2531 2425 Table 2 MRFI Channel 0 Frequencies 5 2 1 MRFI Frame Format The MRFI frame format is identical to SimpliciTl apart from the NWK payload which is this example has been replaced by a two byte header and the application payload The MRFI SimpliciTl header varies slightly between IEEE 802 15 4 compliant devices CC2531 and CC1111 CC2511 please refer to 11 for details Sequence Number Frame Type Payload
13. ENTS swru222 e Connect the CC2531 USB Dongle to the other SmartRFO5EB and program it with the flash image rf_modem hex using IAR Embedded Workbench or the SmartRF Flash Programmer See 1 for more information It is also possible to use the CC Debugger for this purpose 5 4 4 Running the USB Application e Disconnect the programmed USB Dongle from the SmartRFEB Programmer and plug it into a free USB port on the PC e f using Microsoft Windows the operating system will ask for a driver Point to the file driver folder containing the usb _cdc_driver_ccxxxx inf setup information files When the USB dongle is plugged in first time it will appear in Windows XP as in Figure 10 i Found New Hardware x Clos USB COC eea Some za Figure 10 Plugging in the USB Dongle First Time The Windows installation Wizard will now start and guide the user through the driver installation procedure Please select Install from a list or specific location as shown in Figure 11 Found New Hardware Wizard Welcome to the Found New Hardware Wizard This wizard helps you install software for TI C2511 Low Power AF to USB COC Serial Port If your hardware came with an installation CD 182 or Floppy disk insert it now what do pon want the wizard to do Install the software automatically Recommended Click Next to continue Back Lancel Figure 11 Driver Installation Step 1 Click Next to advance
14. SoC Debug Flash connector on SmartRFO4EB is more stable when the voltage differs on the SmartRFO4EB and the target board If problems are still experienced when using SOC_DEM make sure that the 10 pin flat cable used to connect the RF USB Dongle to the SmartRFO4EB is as short as possible Next it might be necessary to reduce the debug interface speed in order to achieve stable operation In the IAR workbench do the following Highlight the project name by clicking on it in the Files window see Figure 1 Go to Project gt Options Select the Category Texas Instruments Click on the Target tab 3 22 3 A TEXAS INSTRUMENTS swru222 Check the Reduce interface speed option see Figure 2 El simple_hid_donale fush_cc2531 ye Ha El simple_hid_eb sr04_cc2510 v a El simple_hid_eb st04_cc1110 T MERTE impie hid eb srf0s cc2530 v project name La Caa aia aplica a G hal a Ca mor Ha Ca utilities a 9 Output Figure 1 Selecting Project Options for node simple_hid_eb x Category General Options Cic Compiler Assembler Custom Build Download Target Build Actions Linker Debugger W Enable stack overflow warning idl Part Driver Number of banks 4 Check the Reduce interface speed option Texas instrument Infineon ROM Monitor Analog Devices Silabs Simulator T Log communication communication log EI OF Ca
15. any number of configurations interfaces and alternate settings The following features are provided e Initialization of the USB peripheral unit and response to reset signaling on the bus e Automated response to almost all standard requests based on data from the USB descriptor set the SYNCH_FRAME and SET DESCRIPTOR requests must be handled by the application e Automated setup of endpoint control registers depending on the selected configuration and interface alternate settings e All endpoint types are supported Setup bulk interrupt and isochronous e An interface for responding to class and vendor requests Both automated and manual data transfer is supported e Endpoint access via a simple set of macros and functions e Support for suspend mode and remote wake up e A function hook and event based interface allows for the framework to run from main the USB interrupt or a combination of both The library is generic However it does require some knowledge of the USB specification including the concepts of configurations interfaces and endpoints different endpoint types standard vendor and class requests and USB descriptor sets Figure 19 shows how the USB firmware library is organized use mena Framework USB Suspend USB Suspend Usar software USB Standard Request Processing a MS Interrupt USB Fw Library USB Hardware USB Descriptor Parser USB Register Interface USB Interface Serial Engine Figur
16. ations Using it for sniffing on IEEE 802 15 4 compliant devices like the CC2531 is straightforward as no configuration file is required Simply select Channel 15 OxF and start Sniffing on the CC1111 and CC2511 can be done by selecting the SimpliciT protocol and selecting logical channel 0 P nbr Time us Length Frame control field Sequence Dest Dest Source f Source Lol rcs Rx 0 Type Sec Pnd Ack req PAN compr f number PAI Address PAN Address 1 16 DATA 0 oO l Dx 78 Dx 2007 Ox25DE 0x2007 Oxz5EB 100 f OE P nbr Time us Length Frame control fielcl Sequence Dest Dest Source Source Lol lFes Rx 2755 Type Sec Pnd Ack req PAN compr number PAI Address PAN Address 2 2755 15 DATA 0 oO l D D857 Dx 200 Ox25EB 02007 Ox25DE sd DE P nbr Time us Length Frame control fiekl Sequence Dest Dest Source Source Lol lFes PX 4544429 Type Sec Pnd Ack req PAN compr number PAN Address PAN Address 3 547154 16 DATA 0 o l D Dx 72 Dx 2007 O225DE 022007 0x25EB 96 OE P nbr Time us Length Frame control field Sequence Dest Dest Source Source Lol Fes EX 2754 Type Sec Pnd Ack req PAN compr number PAH Address PAI Address 4 549938 15 DATA O 0 Oo 0 Dx 88 Dx 2007 OxZ25EB 02007 Ox25DE 64 OE Figure 6 Screenshot of the Texas Instruments General Packet Sniffer 9 22 9 ve TEXAS INSTRUMENTS swru222 5 3 USB HID Example simple_hid This applicat
17. e 14 If that s the case you can safely click Continue anyway and the driver installation will be complete Hardware Installation A The software you are installing for this hardware TL AF USB to Serial haz not passed Windows Logo testing to verifp its compatibility with Windows lt P Tell me why this testing iz important Continuing your installation of this software may impair or destabilize the correct operation of pour system either immediately or in the future Microsoft strongly recommends that you stop this installation now and contact the hardware vendor for software that has passed Windows Logo testing Continue Anyway Figure 14 Driver Signature Warning When Windows have finished installing the device a new serial port will show in the device manager in Windows See Figure 15 iol x File Action View Help e 8 4 2 2 H E Monitors EH Multifunction adapters ee Network adapters eg PCMCIA adapters Elf Ports COM amp LPT i 4 Communications Port COM13 oo ECP Printer Port LPT1 i ai High Speed Communications Port COM Ss zes Figure 15 Virtual COM Port in Windows Device Manager Note The port number assigned to the USB Virtual Serial port is arbitrary You may change it to an alternative port number as follows Right click on the port in the device manager and choose Properties gt Port settings gt Advanced to change The Virtual COM port is now ready and
18. e 19 USB Firmware Library Structure As shown in Figure 19 the USB library is divided into five modules The USB Firmware Library contains all USB status information and functions for initialization device reset handling and transfers on endpoint O lt also contains basic macros and functions for endpoint control and FIFO access Vendor and class requests are passed up to the application and standard requests further down for internal processing The USB Standard Requests usbsr module contains automated processing functions for almost all standard requests The automated handling and endpoint configuration relies on the USB descriptor set and two look up tables Requests that are not supported SYNCH FRAME and SET DESCRIPTOR or requests that are class specific are passed up to the application The application is also notified upon important events such as change in endpoint status or interface alternate settings The USB Descriptor Parser usbdp module provides a mechanism for locating standard formatted USB descriptors The user must provide a USB descriptor set and two simple lookup tables one for locating other descriptor formats and another for setting up endpoint double buffering The necessary 18 22 18 19 TEXAS INSTRUMENTS swru222 constant and structure definitions and guidelines for writing compatible descriptor sets are found in the USB Descriptor module The USB Suspend usbsusp module provides easy to use fully automat
19. ed support for USB suspend USB resume and USB remote wakeup functionality To implement USB suspend and USB resume the user only need to add a short piece of code to the main loop USB remote wakeup is performed by a single function call 5 6 USB Source Code Organization Figure 20 shows how the source code of the USB firmware library is organized The common code is kept in the library directory and the device dependent code is place in sub folders one for each device Note that the code for the CC1111 and CC2511 is identical the device dependent code is shared in the folder CCxx11 9 driver ecza 3 ide Dret E Ga source n usb_descriptar h Ga apps cl Usb descriptor_parser c E GS components h usb_descriptor_parser h 5 assembly e usb Framenork c S common n usb Framework h radios h usb Framework structs h h usb_interrupt h h usb_reg h el usb_standard_requests c 2 simpliciti 2 targets E 5 usb 9 class_cdc h usb_standard_requests h lu ass id h usb_suspend h 3 cc 531 IE coxx11 utils Figure 20 USB Firmware Library Directory Structure The complete documentation of USB Firmware Library is available as a compressed HTML file usb_firmware_library chm found in docs folder 5 6 1 Adapting the USB Application Although the USB Firmware Library will work as is for most applications it may in some cases be desirable to reorganize the way interrupts events are handled In the default conf
20. ght mouse button pushing the joystick emulates the left mouse button Keyboard Mode In keyboard mode the joystick operations and button hits transmit characters to the PC according to Table 4 Character Joystick up Joystick down O D Joystick igt R Joystick press P Button St press B Table 4 Transmitted Characters in Keyboard Mode In order to observe the output from the HID example in keyboard mode it is recommended to open an editor like Notepad and make sure that the editor window has focus Please observe that when pressing the joystick or S1 button the letter will be transmitted as the button joystick is released 5 3 5 Packet Sniffer Capture Figure 8 shows the radio traffic when operating the joystick left in mouse mode The first byte of the MAC payload is the sequence number The second byte is the frame type where 7E identifies a data frame and 7F an ACK frame The third byte is the in this case single byte payload Frame 1 and 3 in the figure are data packets with the payload 45 and 42 respectively i e the letters E and B The source address of the EB is 25EB and the source address of the dongle is 25DE The mouse mode payload is decoded as shown in Table 5 Figure 8 gives an example of a mouse frame Byte 4 of the MAC payload is decoded as OxFF 1 which means mouse left movement Byte 2 identifies the frame as a mouse packet There is no button activity byte 3 and no activity on the Y byte 5 and Z
21. gs ide tates eee ome 17 ye USB FNWI e Ds O i A la ata sa ate 17 5 5 1 SIUI 8 gt geet er set a Rt te OO OS Ee a 17 5 6 USB SOUICe Code Organza isa ot aut atac eo ia ala aa eee ein eed 19 5 6 1 Adaping ine USB APplica ton 4 sein aia f0 in Mape Dei ncasat cita dala Debra dati E a ta d N 19 OF U E CSCH DONS raeo cae stea iat ela oa aaa se ul ta teste acea ales fra 20 RS TOI CCS A RR ENPI ERIN SR PRI AR e E NR RR E ACR od 21 General information ie cet ce oi e nd Oa ata ca Daia tat dig Daia Eau ia ant 21 Fel WIOCUIMCAETAISIONY istaaseceaae sei ama Doua AA au na AA la aa aia aia aj ia 21 1 22 1 A TEXAS Ai INSTRUMENTS swru222 1 Introduction This document describes the software examples for the CC1111 CC2511 and CC2531 RF USB dongles The Human Interface Device HID application emulates mouse and keyboard using a SmartRFOSEB or SmartRFO4EB The RF Modem example shows how the USB CDC class can be implemented to provide serial port emulation across USB Virtual COM port Both examples use the MRFI protocol for radio communication This document the software referred to in 5 2 About this Manual This manual covers the USB software examples and USB Firmware Library for the Texas Instruments Low Power RF USB Dongles for the chipsets CC1111 CC2511 and CC2531 3 Acronyms ACM Abstract Control Model API Application Programming Interface CCA Clear Channel Available CDC Communication Device Class DCE Distributed Comput
22. h the frame can be copied This routine should be called as a result of having MRFI_RxCompletelSR invoked At that time there is guaranteed to be a valid frame available The MRFI payload may be maximum 53 bytes for the CC1111 cCC2511 and maximum 117 bytes with the CC2531 void MRFI_RxCompletelSR void User code must implement this method When MRFI has obtained a frame from the radio and validated it MRFI will invoke this function This is done within the receive ISR context At the very least the function should invoke MRFI_Receive so that the new valid frame is copied into user space and queued for processing If the ISR thread is released before this copy is done it is possible that a second frame can be received and the first will be lost void MRFI_RxOn void This function sets the radio to receive mode Currently it is used only at startup by the mrfi_link layer When the radio wakes up it is in the state IDLE This call puts it in the RECEIVE state void MRFI_SetLogicalChannel uint8_t This function sets the logical channel to the value specified as the argument MRFI keeps a table of actual values to be written to the radio to accomplish the actual channel change The argument is not the channel value itself but a logical channel number that is mapped to a tabled value actually sent to the radio This table is instantiated at build time The maximum allowed logical channel can be determined by subtracting one from the number of
23. has the value 0x02 which means that the SHIFT LEFT button is pressed This is hard coded in the application for the purpose of this example Byte 6 is 0x18 which corresponds to the letter u The capitalization is achieved through the key modifier bit 1 Description Sequence number Frame type here DATA Keyboard data ID fixed 0 Key modifiers Reserved fixed 0 6 Key values Table 6 Keyboard Mode Payload gt o P nbr Time us Length Frame control field Sequence Dest Dest Source Source FCS EX 0 Type Sec Pnd Ack req PAN compr number PAN Address PAN Addres 4 1 O ag DATA O 0 0 a OxES Ox2007 Ox25DE Ox2007 Ox25EB 208 OF a P nbr Time us Length Frame control field Sequence Dest Dest Source Source Lor los Rx 1941 Type Sec Pnd Ack req PAN compr number PAN Address PAN Address 2 1941 15 DATA O a a OxD 1 Ox2007 Ox25EB Ox2007 Ox25DE 166 OF P nbr Time us Length Frame control field Sequence Dest Dest Source Source Lor pcs Rx 5466 Type Sec Phd Ack req PAN compr number PAN Address PAN Address 3 7407 ag DATA 0 0 0 0 OxEg Ox2007 Ox25DE Ox2007 Ox25EB 196 GE P nbr Time us erat Frame control field Sequence Dest Dest Source Source Lol l Fes Ex 1940 Type Sec Phd Ack req PAN compr number PAN Address PAN Address 4 9347 15 DATA O 0 0 0 OxDe Ox2007 Ox25EB Ox2007 Ox25DE 1864 OF Figure 9 Operating Joystick UP letter U
24. id usb_hid c All the processing in done in the main loop i e standard requests vendor requests class requests and data 19 22 19 A TEXAS Ai INSTRUMENTS swru222 transfer For the HID example this makes perfect sense as the data rates are very low The hooks found in usb class_hid usb_hid_hooks c These are just stubs for this application The stubs must be declared as the USB firmware library assumes that they are present In the CDC example the main loop processing is found in the file usb class_cdc usb_cdc c All the processing is done in the main loop i e standard requests vendor requests class requests and data transfer The hooks are found in usb class_cdc usb_cdc_hooks c Most of these are stubs only the hooks for setting and reading control lines and port settings are implemented Note that these are still processed by the main loop the reason for implementing this functionality as hooks is that it is application dependent 5 7 USB Descriptors One of the challenges when developing USB firmware is to understand and work with USB Descriptors Details can be found in the help file usb_firmware_library chm found in the docs directory of this software distribution 5 The USB class definitions 9 and 10 contain further guidelines on writing USB descriptor USB developers should also visit http www usb org developers for more resources 20 22 20 vi TEXAS INSTRUMENTS swru222 6 References 1 2 S 4 5
25. iguration handling USB standard requests USB class requests and USB data transfer is done in the main loop to keep interrupt processing time as brief as possible The interrupt handler simply schedules events and passes these on to the main loop for processing Simple round robin scheduling is thus implicitly determined by the order in which the event processing is done For more sophisticated pre emptive schemes the choice is either to do more of the processing in an interrupt context or devise a method for pre emptive scheduling in the main loop it is beyond the scope of this document to describe in detail how either can be achieved However this section will give a brief outline on how to achieve immediate processing of time critical code sections Note that there is no need to modify the USB Firmware Library the desired effect is achieved by moving code from the main loop to the USB interrupt hook The USB Firmware Library requires the application to provide a hook usbirgHookProcessEvents for events which needs immediate processing in an interrupt context The applications described in this document do all their USB processing in the main context this in effect gives the radio traffic priority over the USB traffic Hence usbirgHookProcessEvents is just a stub in both applications However it is straightforward to move code from the main loop to the interrupt hook In the HID example the main loop processing is found in the file usb class_h
26. ing Environment DTE Data Terminal Equipment FCS Frame Check Sequence HAL Hardware Abstraction Layer HID Human Interface Device ICE In Circuit Emulator lO Input Output PAN Personal Area Network MRFI Minimal RF Interface RF Radio Frequency RSSI Received Signal Strength Indicator SFD Start of Frame Delimiter SoC System on Chip USB Universal Serial Bus 2 22 2 A TEXAS Ai INSTRUMENTS swru222 4 Getting Started 4 1 Preparations The USB firmware described in this document may be debugged using any of the following In Circuit Emulators e CC Debugger e SmartRFO5EB e SmartRFO4EB with SOC_DEM debug connector 1 Please install SmartRF Studio before connecting the ICE to a PC SmartRF Studio is a PC application for Windows that helps you find and adjust the radio register settings Please refer to 3 for instructions on how to download and install SmartRF Studio Installing SmartRF Studio prior to connecting the debugger ensures that all the relevant Windows drivers are installed Please see the relevant USB Hardware User s Guide 7 or 8 for detailed instructions on how to interconnect the PC the ICE debugger and the target dongle When the drivers are installed and the debugger connected the USB dongle can be programmed and debugged using IAR Embedded Workbench Programming can also be done using the SmartRF Flash programmer 4 4 2 General Guidelines When writing and debugging USB f
27. ion demonstrates the use of the USB Dongle as a USB composite HID Human Interface Device with both keyboard and mouse This application example uses the USB framework found in the USB firmware library 5 to configure the USB part of the device and to handle all USB standard requests In addition the Class requests required by the HID device class are implemented in a separate file The radio communication between SmartRF board EM and the dongle is carried out using MRFI Please see 9 or more information about the HID class Note The application has been tested on Windows XP SP2 Windows XP SP3 Windows Vista SP1 and GNU Linux Ubuntu 9 04 Being a standard HID device it should work on other operating systems as well 5 3 1 Software Components The executables for the applications are located as follows simple _hid_dongle hex The file is located in ide rfusb_cc1111 iar ide rfusb_cc2511 iar or ide rfusb_cc2531 iar depending on the target device simple _hid_eb hex The file is located in ide srf04_cc1110 iar ide srf04_cc2511 iar or ide srf05_cc2531 iar depending on the target device 5 3 2 Installing the Application CC 1111 CC2511 e Attach the CC1110EM CC2510EM to the SmartRFO4EB and program it with the flash image simple_hid_eb hex using IAR Embedded Workbench or the SmartRF Flash Programmer See 1 for more information e Connect the CC1111 CC2511 USB dongle to the other SmartRFO4EB through the SOC_DEM and program
28. irmware one should remember that when Windows or another OS detects a USB device it will assume that it works in accordance with the USB specification During debugging this might not be the case Breakpoints may stop the execution of code on the USB Dongle and firmware under development may not be completed or error free This may lead to the PC disconnecting the USB device and turning off or toggling its power supply In some cases Windows or the OS in use may crash or misbehave Hence breakpoints should be used with caution Obviously inserting and using breakpoints in the firmware during debugging will be extremely useful to pinpoint bugs and follow code execution And they can and should be used But they will also stop the code execution on the target and may cause the device to act in conflict with the USB specification If the firmware contain bugs that make the PC disconnect the USB Dongle it may be necessary to disconnect the USB cable and power the USB Dongle from the SmartRFO4EB SmartRFO5EB in order to reprogram it Please refer to the relevant USB Hardware User s Guide 7 or 8 for instructions on how to reprogram the dongle without it being powered by the PC 4 3 Known Problems When using the debug interface through the level converter on the SmartRFO4EB it might become unstable This problem is more likely to occur at low voltages or with crosstalk in the cable at high interface speed Using the SOC_DEM instead of the P14
29. minal E lol x File Edit wiew Call Transfer Help This is the CC2530 sending data received from C Mi Connected 0 01 12 ANSI 38400 a M 1 SCROLL Caps NUM Capture Print echo Figure 16 CC2531 Receiving Data C0M1 38400 HyperTerminal ID xj File Edit wiew Call Transfer Help This is 602531 ad ene it received from the USB Virtual COM port Connected 0 08 25 ANSI 38400 5 M 1 SCROLL Caps ruta Capture Print echo Figure 17 CC2530 Receiving Data 5 4 6 Packet Sniffer Capture When typing single characters in the HyperTerm window the slow input speed means that each packet will only contain one byte of payload Figure 18 shows the radio traffic when typing the letters EB in the terminal window connected to COM1 The first byte of the MAC payload is the sequence number The second byte is the frame type where 7E identifies a data frame and 7F an ACK frame The third byte is the in this case single byte payload Frame 1 and 3 in the figure are data packets with the payload 45 and 42 respectively i e the letters E and B The source address of the EB is 25EB and the source address of the dongle is 25DE P nbr Time us Length Frame control field Sequence Dest Dest Source f Source Lol fres i i Type Sec mad Ack reg ai compr number FAH Address PAH Address DATA 0 Ox vo Ox 2007 Ox25DE 0x2007 Ox25EB 100 OF ES Time ES Len bye sac n okey PA compe control field Sequence Dest Des
30. ncel Figure 2 Reduce Interface Speed 4 22 13 TEXAS INSTRUMENTS swru222 5 USB Application Examples This section describes the application examples available for the USB dongles These application examples focus on how to use the USB part of the respective device The examples are available both as source code and ready to upload hex files from 5 There are two USB application examples Application re Wireless mouse keyboard HID Human Interface Device CDC ACM Communication Device Class with Abstract Control Model subclass rf modem Wireless USB to serial port converter Table 1 Overview of application examples Working together with the USB examples are peer applications running on CC1110EM CC2510EM and CC2530EM respectively The CC1110EM and CC2510EM must be plugged into a SmartRFO4EB The CC2530EM must be plugged into a SmartRFO5EB 5 1 Building and Running the Examples First of all make sure that the dongle is connected to the ICE as described the Programming section of the relevant USB Dongle User s Guide please see 7 for programming the CC1111 CC2511 or 8 for programming the CC2531 When building the examples from source with IAR EW8051 make sure you select the project corresponding to the target you are developing your software for Please see Figure 5 for an overview of the projects found the in the USB application example package The IAR workspace is located in the sub folder
31. nching the Debugger IAR Embedded Workbench IDE A Edt View Project Texas Instruments Emulator Tools Window Help sugere _ E A I E XII EI ATL E E Blusb_app_ex E rf_modern srf04_cc2510 1 Q O RETRATAR ARRE RAR ERA RARA RARA EERE EERE EEE REE EERE EERE EERE EEE Filename simple hid eb c Description Main program of HID EB keyboard mousej sample application application runs in one the following modes sub applicati E rf modem rfusb_cc2511 E rt_madem rfusb_cc1111 E rt_modem srt04_cc1110 E r_ modem srf05_cc2530 rf_modem rfusb_cc2531 simple_hid_dongle rfusb_cc1111 simple_hid_dongle fusb_cc2511 simple_hid_dongle rfusb_cc2531 simple_hid_eb srf04_cc2510 simple_hid_eb srf04_cc1110 simple_hid_eb srf05_cc2530 Ca application ka Ca common E simple_hid h ta EN ERIE ERIE II a El simple_hid_keyboard c E simple_hid_mouse c Lf hal include hal joystick h ae Overview if modem _rt_modem r _modem ime 4 gt Sabir A fad pam ae of 1 Mouse function by operating the joystick Mouse buttons are operated by joystick push and fl 2 Keyboard operation joystick and button operations write plain ASCII text to the PC eee eee ee ee ee eee ee ee ee cc a ee ee cc cc a cc cc cc a a cr cc a a a rc ar ce cr a cc cr cc e ce e ce cc bi Ss oC a AC LI 00 do Buba aaaaaaae ERERARRARERRAR RARA RAR AEA TEER REAR EERE EAL EER TEER EER E
32. place in the frame in which the payload information should be written This allows MRFI to protect the preamble portion of the frame into which MRFI itself populates radio specific information This implies that the mrfiPacket_t pointer must point to a valid object even if there is no payload at all The txType parameter specifies whether transmit should occur immediately and unconditionally or CCA should be applied 7 22 7 A TEXAS Ai INSTRUMENTS swru222 Valid values are e MRFI TX TYPE FORCED e MRFI TX TYPE CCA The address fields and the length field must also be set before the transmit call is invoked These fields are not strictly part of the network layer encapsulation but it is that layers responsibility to populate those fields MRFI supplies 3 macros to populate these fields and they should be used The p formal parameter is mrfiPacket_t The x parameter is the length to be set in when using that macro e MRFI_P_SRC_ADDR p e MRFI_P_DST_ADDR p e MRFI SET PAYLOAD LEN p x This routine returns a value indicating status of the transmit attempt e MRFI_TX RESULT SUCCESS e MRFI TX RESULT FAILED Transmit may fail if CCA is requested and the channel is not clear after a number of retries All symbols referenced here are defined in mrfi h void MRFI_Receive mrfiPacket_t This function copies a received frame into user space from the MRFI layer The parameter is a pointer to an area in user space into whic
33. t Source Source Lol lFes 2755 Hema nye sac n deea compe Sec me Ack req FAN compr number PAH Address PAN Address ES DATA 0 0xa7 Ox2007 Ox25EB 02007 Ox25DE 64 DE ES Time sae ia Dye sac Pad okey PA compe control field vane Dest Dest Source Source Lol lFes PX 4544429 Type Sec Pnd Ack req De sac Pad okey PA compe number PAN Address PAN Address ES sae ia DATA O oO D vane Dx 2007 O225DE 02007 Ox25EB 96 OE P nbr Time us engi Frame control field Sequence Dest Dest Source Source Lol llecs EX 2754 Type Sec Pnd Ack req PAN compr number PAH Address PAH Address 4 549938 15 DATA O 0 Oo D Dx 88 Dx 2007 OxZ25EB 02007 Ox25DE 64 OE Figure 18 Typing EB at COM1 5 5 USB Firmware Library 5 5 1 Structure Texas Instruments LPRF provides a USB Firmware Library which contains all the basic USB firmware needed for application development The firmware library handles the interface to the USB chip 17 22 17 A TEXAS INSTRUMENTS swru222 handles endpoints traffic flow descriptor parsing and configuration lt also performs USB standard request processing The USB Firmware Library consists of firmware common to all the three USB supported USB devices as well as some device specific low level code The USB Firmware Library does NOT contain any USB class specific components lt supports both vendor specified device classes and standardized device classes such as HID and USB audio with
Download Pdf Manuals
Related Search
Related Contents
1756-QS001 - Literature Library 仕様書 - ノボル電機製作所 Herren-Rasierer (Akku / Netz) SFR 1200 A1 UNIVERSIDADE DO VALE DO RIO DOS SINOS – UNISINOS Student User Manual Vol.30(2011年10月発行) User`s Manual User Guide Des référents à votre service ! Lindy 32339 User's Manual Copyright © All rights reserved.
Failed to retrieve file