This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
doc:crazyradio:usb:index [2012-04-02 09:07] arnaud [Dongle configuration] |
doc:crazyradio:usb:index [2013-01-06 00:14] arnaud |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Usb and Radio protocol of the Crazyradio dongle ====== | ====== Usb and Radio protocol of the Crazyradio dongle ====== | ||
- | The Crazyradio dongle is based on a Nordic semiconductor nRF24LU1 chip. The radio communication is done using the Nordic " | + | The Crazyradio dongle is based on a Nordic semiconductor nRF24LU1 chip. The radio communication is done using the Nordic " |
- | This page document the protocol used in the version 0.33 of the Crazyradio dongle. Future version (up to 1.0) will be kept compatible. | + | This page document the protocol used in the version 0.40 of the Crazyradio dongle. Future version (up to 1.0) will be kept compatible. |
===== USB protocol ===== | ===== USB protocol ===== | ||
- | The USB devices have the VID/PID couple 0x1915/ | + | The USB devices have the VID/PID couple 0x1915/ |
| EP0 | Control | Control endpoint. Used to configure the dongle | | | EP0 | Control | Control endpoint. Used to configure the dongle | | ||
- | | EP1 | Bulk | Data endpoint. Used to send and receive radio packets | | + | | EP1IN/ |
- | ==== Dongle configuration ==== | ||
- | |||
- | The following vendor control messages are implemented in the radio dongle: | ||
- | |||
- | ^ Control message | ||
- | | SET_RADIO_CHANNEL | 0x01 | SET | One 8bit integer representing the radio channel to set from 0 to 125 | | ||
- | | SET_RADIO_ADDRESS | 0x02 | | ||
- | | SET_DATA_RATE | ||
- | | LAUNCH_BOOTLOADER | 0xFF | - | Resets the dongle in nRF24LU1 bootloader mode. The dongle has to be disconnected and reconnected in order to restart in crazyradio mode | | ||
- | |||
- | Possible values for the datarate: | ||
- | ^ Value ^ Radio datarate ^ | ||
- | | 0 | 250Kbps | ||
- | | 1 | 1MBps | | ||
- | | 2 | 2Mbps (Default)| | ||
==== Data transfer ==== | ==== Data transfer ==== | ||
- | The radio dongle | + | The radio dongle |
- | The packet | + | To send a packet the following sequence must be followes: |
+ | * Send the packet to EP1_OUT. Its length should be between 1 to 32Bytes | ||
+ | * Read the ACK from EP1_IN. The first byte is the transfers | ||
< | < | ||
Line 39: | Line 26: | ||
To EP1_OUT: | To EP1_OUT: | ||
+-------------------------+ | +-------------------------+ | ||
- | 1..32 Bytes | + | |
- | 1Byte < | + | < |
- | +-----+----------------------+ | + | +--------+----------------------+ |
- | From EP1_IN: | + | From EP1_IN: |
- | +-----+----------------------+ | + | +--------+----------------------+ |
</ | </ | ||
- | This protocol permits to transfer about 500 packets per seconds. | + | The status byte contains flags indicating the quality of the link: |
- | ===== Radio protocol ===== | + | |
+ | ^ Status | ||
+ | | 4..7 | Number of retransmition | | ||
+ | | 2..3 | Reserved | ||
+ | | 1 | Power detector | ||
+ | | 0 | Ack received | ||
+ | ==== Dongle configuration and functions summary ==== | ||
+ | Crazyradio vendor requests summary: | ||
+ | ^ bmRequestType ^ bRequest | ||
+ | | 0x40 | SET_RADIO_CHANNEL (0x01) | ||
+ | | 0x40 | SET_RADIO_ADDRESS (0x02) | ||
+ | | 0x40 | SET_DATA_RATE (0x03) | ||
+ | | 0x40 | SET_RADIO_POWER (0x04) | ||
+ | | 0x40 | SET_RADIO_ARD (0x05) | ||
+ | | 0x40 | SET_RADIO_ARC (0x06) | ||
+ | | 0x40 | ACK_ENABLE (0x10) | ||
+ | | 0x40 | SET_CONT_CARRIER (0x20) | ||
+ | | 0x40 | START_SCAN_CHANNELS (0x21) | Start | Stop | Length | ||
+ | | 0xC0 | GET_SCAN_CHANNELS (0x21) | ||
+ | | 0x40 | LAUNCH_BOOTLOADER (0xFF) | ||
+ | |||
+ | ==== Set radio channel ==== | ||
+ | |||
+ | ^ bmRequestType ^ bRequest | ||
+ | | 0x40 | SET_RADIO_CHANNEL (0x01) | channel | ||
+ | |||
+ | The nrf24L chips provides 126 Channels of 1MHz from 2400MHz to 2525MHz. The channel parameter shall be between 0 and 125 (if not the command will be ignored). | ||
+ | |||
+ | The radio channel is set as soon as the USB setup transaction is completed which takes about 1ms. The new frequency is going to be used for the following transfered packets. Default value for the radio channel is 2. | ||
+ | |||
+ | ==== Set radio address ==== | ||
+ | |||
+ | ^ bmRequestType ^ bRequest | ||
+ | | 0x40 | SET_RADIO_ADDRESS (0x02) | Zero | Zero | 5 | Address | | ||
+ | |||
+ | The packet sent by the radio contains a 5 bytes address. The same address must be configured in the receiver for the communication to work. | ||
+ | |||
+ | The address must follow the requirement of the section 6.4.3.2 of the nRF24LU1 documentation: | ||
+ | |||
+ | < | ||
+ | Addresses where the level shifts only one time (that is, 000FFFFFFF) can often be detected in | ||
+ | noise and can give a false detection, which may give a raised Packet-Error-Rate. Addresses | ||
+ | as a continuation of the preamble (hi-low toggling) raises the Packet-Error-Rate. | ||
+ | </ | ||
+ | |||
+ | The default address is 0xE7E7E7E7E7. | ||
+ | |||
+ | ==== Set datarate ==== | ||
+ | |||
+ | ^ bmRequestType ^ bRequest | ||
+ | | 0x40 | SET_DATA_RATE (0x03) | ||
+ | |||
+ | Possible values for the datarate: | ||
+ | ^ Value ^ Radio datarate ^ | ||
+ | | 0 | 250Kbps | ||
+ | | 1 | 1MBps | | ||
+ | | 2 | 2Mbps (Default)| | ||
+ | |||
+ | |||
+ | ==== Set radio power ==== | ||
+ | |||
+ | ^ bmRequestType ^ bRequest | ||
+ | | 0x40 | SET_RADIO_POWER (0x04) | ||
+ | |||
+ | Sets the radio amplifier output power. Possible values: | ||
+ | |||
+ | ^ Value ^ Power ^ | ||
+ | | 0 | -18dBm | ||
+ | | 1 | -12dBm | ||
+ | | 2 | -6dBm | | ||
+ | | 3 | 0dBm | | ||
+ | |||
+ | ==== Configure auto retry (ARD/ARC) ==== | ||
+ | |||
+ | ^ bmRequestType ^ bRequest | ||
+ | | 0x40 | SET_RADIO_ARD (0x05) | ||
+ | | 0x40 | SET_RADIO_ARC (0x06) | ||
+ | |||
+ | After sending a packet the radio automatically waits for an acknowledge. ARD and ARC permits to configure the delay the radio waits for the acknowledge and the number of time the transfer will be retried in case the acknowledge is not received in that delay. | ||
+ | |||
+ | The delay ARD depends of the length, in second, of the ack packed. This depends of the datarate and the Payload length contained in the Ack packet. The ARD can be configured either by step of 250us or by ack payload length. If the ack payload length is configured the time will be recalculated automatically even if the datarate is changed. To set the Ack payload lenght the bit 7 of Ard must be set (length | 0x80) | ||
+ | |||
+ | Possible values for ARD: | ||
+ | |||
+ | ^ Value ^ ARD wait time ^ | ||
+ | | 0x00 | 250us | | ||
+ | | 0x01 | 500us | | ||
+ | | ... | ... | | ||
+ | | 0x0F | 4000us | ||
+ | ^ Value ^ Ack payload length ^ | ||
+ | | 0x80 | 0Byte | | ||
+ | | 0x81 | 1Byte | | ||
+ | | ... | ... | | ||
+ | | 0xA0 | 32Bytes | ||
+ | |||
+ | ARC configures the number of time the radio will retry a transfer if the Ack has not been received, it can be set from 0 to 15. | ||
+ | |||
+ | By default ARD=32Bytes (0xA0) and ARC=3. | ||
+ | |||
+ | ==== Auto ACK configuration ==== | ||
+ | |||
+ | ^ bmRequestType ^ bRequest | ||
+ | | 0x40 | ACK_ENABLE (0x10) | ||
+ | |||
+ | By default Crazyradio is configured with auto ack enable. It means that after transmiting a packet the radio waits for an acknoledge from the receiver. This setting permits to deactivate waiting for the Ack packet so that the packet will be sent only one time and there are no guarantee that it has been correctly received. | ||
+ | |||
+ | ^ Active values ^ Meaning | ||
+ | | 0 | Auto ack deactivated | ||
+ | | Not 0 | Auto ack enable (default) | | ||
+ | |||
+ | ==== Continuous carrier mode ==== | ||
+ | |||
+ | ^ bmRequestType ^ bRequest | ||
+ | | 0x40 | SET_CONT_CARRIER (0x20) | ||
+ | |||
+ | The nRF24L radio chip provides a test mode in which a continous non-modulated sine wave is emited. This permits, among other things, to test the quality of the RF elements of the board. When this mode is activated the radio dongle does not transmit any packets. | ||
+ | |||
+ | while the continuous carrier mode is active it is possible to set channel and power to change the frequency and power of the emitted wave. | ||
+ | |||
+ | ^ Active values ^ Meaning | ||
+ | | 0 | Dongle working normally (default) | | ||
+ | | Not 0 | Dongle in continuous carrier mode | | ||
+ | |||
+ | ==== Channels scanning ==== | ||
+ | |||
+ | This function is implemented in Crazyradio version 0.5 and over. | ||
+ | |||
+ | ^ bmRequestType ^ bRequest | ||
+ | | 0x40 | START_SCAN_CHANNELS (0x21) | Start | Stop | Length | ||
+ | | 0xC0 | GET_SCAN_CHANNELS (0x21) | ||
+ | |||
+ | Scan a range of channels and compile a list of channel from which an ack has been received. The command START_SCAN_CHANNELS should be executed first with start being the first scanned channel and stop the last one. Those should be within 0 to 125. The data is the packet payload sent on each channel, it should be at least one byte long. | ||
+ | |||
+ | All parameters, except the channel, are used unmodified during the scan. If the datarate is set to 2MBPs the scan is done every second channel. To get the list of channel that answered GET_SCANN_CHANNELS should be called just after a scan. Up to 63 bytes are returned corresponding to up to 63 channels on which the packet was acknowledged. | ||
+ | |||
+ | Note. After scanning the channel will be let to the last scanned channel. | ||
+ | |||
+ | ==== Launch bootloader ==== | ||
+ | |||
+ | ^ bmRequestType ^ bRequest | ||
+ | | 0x40 | LAUNCH_BOOTLOADER (0xFF) | Zero | Zero | Zero | None | | ||
+ | |||
+ | This command is used to launch the Nordic semiconductor USB bootloader. After sending this command a USB reset shall be emitted which will trigger the dongle to start the bootloader. After sending this command the Dongle is only waiting for a USB reset which means that any other commands or data will be ignored. | ||
+ | |||
+ | The bootloader is pre-loaded by Nordic Semi. in the nRF24LU1 chip at the address 0x7800. The Crazyradio firmware will jump to it when the sequence LAUCH_BOOTLOADER following by a USB reset is executed. The bootloader will appear at VID/PID of 0x1915/ | ||
+ | |||
+ | A PC client for the bootloader is part of the Crazyflie ground station program. | ||
+ | |||
+ | ===== Radio protocol ===== |