summaryrefslogtreecommitdiff
path: root/spi
diff options
context:
space:
mode:
authorJens Steinhauser <jens.steinhauser@gmail.com>2014-07-08 18:16:16 +0200
committerJens Steinhauser <jens.steinhauser@gmail.com>2014-07-08 18:16:16 +0200
commitaeada8ac42252c76cca250008a980bf4bab7b48f (patch)
treeb48ae9c5bf2ee9978b79b361de1a8139702eafbe /spi
parentb5ad4e978034aa34ecb579314ce08761b576f44f (diff)
downloadsigrok-dumps-aeada8ac42252c76cca250008a980bf4bab7b48f.tar.gz
sigrok-dumps-aeada8ac42252c76cca250008a980bf4bab7b48f.zip
Add some nRF24L01(+) captures.
Diffstat (limited to 'spi')
-rw-r--r--spi/nrf24l01/README109
-rwxr-xr-xspi/nrf24l01/gen-testfiles.py189
-rw-r--r--spi/nrf24l01/nrf24l01-communication-rx.srbin0 -> 3923 bytes
-rw-r--r--spi/nrf24l01/nrf24l01-communication-tx.srbin0 -> 4102 bytes
-rw-r--r--spi/nrf24l01/nrf24l01-communication.srbin0 -> 7900 bytes
-rw-r--r--spi/nrf24l01/nrf24l01-test-activate.srbin0 -> 454 bytes
-rw-r--r--spi/nrf24l01/nrf24l01-test-excess-bytes.srbin0 -> 547 bytes
-rw-r--r--spi/nrf24l01/nrf24l01-test-misc.srbin0 -> 508 bytes
-rw-r--r--spi/nrf24l01/nrf24l01-test-missing-bytes.srbin0 -> 449 bytes
-rw-r--r--spi/nrf24l01/nrf24l01-test-no-command.srbin0 -> 443 bytes
-rw-r--r--spi/nrf24l01/nrf24l01-test-unknown-command.srbin0 -> 452 bytes
-rw-r--r--spi/nrf24l01/nrf24l01-test-unknown-register.srbin0 -> 444 bytes
12 files changed, 298 insertions, 0 deletions
diff --git a/spi/nrf24l01/README b/spi/nrf24l01/README
new file mode 100644
index 0000000..0d7667c
--- /dev/null
+++ b/spi/nrf24l01/README
@@ -0,0 +1,109 @@
+-------------------------------------------------------------------------------
+nRF24L01/nRF24L01+
+-------------------------------------------------------------------------------
+
+This directory contains a capture of the communication between two nRF24L01+
+tranceivers, one connected to a Raspberry Pi and the other connected to an
+AVR microcontroller, and some generated files to test paths in the protocol
+decoder that aren't covered in the capture.
+
+
+nrf24l01-communication.sr
+-------------------------
+
+Logic analyzer setup
+--------------------
+
+The logic analyzer used was a Lcsoft Mini Board (at 12MHz):
+
+ Probe Description
+ ---------------------------
+ PB0 (TRG) used to trigger the logic analyzer
+ PB1 (rpi_CSN) chip select signal of the receiving chip, active low
+ PB2 (rpi_CLK) clock signal of the receiving chip
+ PB3 (rpi_MOSI) MOSI signal of the receiving chip
+ PB4 (rpi_MISO) MISO signal of the receiving chip
+ PB5 (rpi_IRQ) interrupt signal fo the receiving chip, active low
+ PD0 (uc_CSN) chip select signal of the sending chip, active low
+ PD1 (uc_CLK) clock signal of the sending chip
+ PD2 (uc_MOSI) MOSI signal of the sending chip
+ PD3 (uc_MISO) MISO signal of the sending chip
+
+ Note that the nRF24L01(+) chips have two chip select pins, "CE" used to
+ control the standby mode, and "CSN" used for SPI communication. This capture
+ only contains the "CSN" signals of the two chips.
+
+Data
+----
+
+The sigrok command line used was:
+
+ sigrok-cli --driver fx2lafw --config samplerate=12M \
+ -p '0=TRG,1=rpi_CSN,2=rpi_CLK,3=rpi_MOSI,4=rpi_MISO,5=rpi_IRQ,8=uc_CSN,9=uc_CLK,10=uc_MOSI,11=uc_MISO' \
+ -t TRG=0 --time 140 -o nrf24l01-communication.sr
+
+The capture starts with the Raspberry Pi initializing its chip as a receiver,
+followed by the microcontroller initializing the second chip as a transmitter
+at about 8.8ms - 9ms. 30ms after the start of the capture, the microcontroller
+starts sending the strings "message #0" to "message #9" in intervalls of about
+10ms. After sending a message, it uses polling to detect when the message is
+sent and the acknowledge from the receiver is received. The Raspberry Pi handles
+the first six messages after the receiving chip asserts the interrupt signal.
+Because it doesn't handle the other four messages and the receive fifo in the
+receiver runs full after three messages, the last message isn't acknowledged.
+The sender detects that and reads the lost packet counter from the sender chip,
+which consequently has a value of one.
+
+
+nrf24l01-communication-[rx|tx].sr
+----------------------------
+
+These files were generated from the file 'nrf24l01-communication.sr' using
+the commands
+
+ sigrok-cli -i nrf24l01-communication.sr -O csv | \
+ awk -F , '{if (NR > 3) {print $2","$3","$4","$5}}' | \
+ sigrok-cli -i /dev/fd/0 -I csv:samplerate=12M -o nrf24l01-communication-rx.sr
+
+and
+
+ sigrok-cli -i nrf24l01-communication.sr -O csv | \
+ awk -F , '{if (NR > 3) {print $7","$8","$9","$10}}' | \
+ sigrok-cli -i /dev/fd/0 -I csv:samplerate=12M -o nrf24l01-communication-tx.sr
+
+respectively, because apparently the pdtest/runtc tools don't support capture
+files with extra channels. The files are then used to check if the protocol
+decoder correctly decodes the message payload.
+
+
+nrf24l01-test-...
+--------------------
+
+These files were generated by the 'gen-testfiles.py' script and contain test
+cases for the decoder that aren't yet covered by the other captures.
+
+ ...-activate.sr: Tests decoding of the 'ACTIVATE' instruction. This
+ instruction is only valid for the nRF24L01 chips
+ (without the plus) and is therefore not in the
+ communication dump.
+
+ ...-excess-bytes.sr: Used to check if the protocol decoder correctly
+ recognizes and reports superfluous bytes after the
+ commands.
+
+ ...-misc.sr: Contains checks for the instructions 'REUSE_TX_PL',
+ 'R_RX_PL_WID', and 'W_ACK_PAYLOAD', that aren't
+ covered by the other dumps.
+
+ ...-missing-bytes.sr: Used to check if the protocol decoder correctly
+ recognizes and reports missing bytes after the
+ commands.
+
+ ...-no-command.sr: Used to check if the protocol decoder correctly
+ handles empty commands.
+
+ ...-unknown-command.sr: Used to check if the protocol decoder correctly
+ recognizes commands that do not exist.
+
+ ...-unknown-register.sr: Contains a 'R_REGISTER' (read register) instruction
+ of a non-existing register.
diff --git a/spi/nrf24l01/gen-testfiles.py b/spi/nrf24l01/gen-testfiles.py
new file mode 100755
index 0000000..5b14e43
--- /dev/null
+++ b/spi/nrf24l01/gen-testfiles.py
@@ -0,0 +1,189 @@
+#!/usr/bin/env python3
+##
+## This file is part of the sigrok-dumps project.
+##
+## Copyright (C) 2014 Jens Steinhauser <jens.steinhauser@gmail.com>
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+##
+
+## This script generates test cases for the nrf24l01 protocol decoder.
+
+import csv
+import subprocess
+import tempfile
+
+class SPI:
+ def __init__(self, filename):
+ self._filename = filename
+ self._data = []
+
+ def CSlow(self):
+ self._data.append([1, 0, 0, 0])
+ self._data.append([0, 0, 0, 0])
+
+ def CShigh(self):
+ self._data.append([0, 0, 0, 0])
+ self._data.append([1, 0, 0, 0])
+
+ def add(self, mosi, miso):
+ for _ in range(8):
+ mo = mosi & 0x80
+ mi = miso & 0x80
+ mosi <<= 1
+ miso <<= 1
+ self._data.append([0, 0, mo, mi])
+ self._data.append([0, 1, mo, mi])
+
+ self._data.append([0, 0, 0, 0])
+
+ def write(self):
+ with tempfile.NamedTemporaryFile() as tf:
+ with open(tf.name, 'w') as tff:
+ w = csv.writer(tff)
+ w.writerow(['CS', 'CLK', 'MOSI', 'MISO'])
+ w.writerows(self._data)
+
+ fn = '{}.sr'.format(self._filename)
+ I = 'csv:header=true:samplerate=1k'
+ subprocess.check_call(['sigrok-cli', '-I', I, '-i', tf.name, '-o', fn])
+
+spi = SPI('nrf24l01-test-activate')
+spi.CSlow()
+spi.add(0x50, 0x00) # ACTIVATE
+spi.add(0x73, 0x00) # correct payload
+spi.CShigh()
+spi.CSlow()
+spi.add(0x50, 0x00) # ACTIVATE
+spi.add(0x74, 0x00) # wrong payload
+spi.CShigh()
+spi.write()
+
+spi = SPI('nrf24l01-test-excess-bytes')
+spi.CSlow()
+spi.add(0x00, 0x00) # R_REGISTER, reg = CONFIG
+spi.add(0x00, 0x00)
+spi.CShigh()
+spi.CSlow()
+spi.add(0x00, 0x00) # R_REGISTER, reg = CONFIG
+spi.add(0x00, 0x00)
+spi.add(0x00, 0x00) # excess
+spi.CShigh()
+spi.CSlow()
+spi.add(0x20, 0x00) # W_REGISTER, reg = CONFIG
+spi.add(0x00, 0x00)
+spi.add(0x00, 0x00) # excess
+spi.CShigh()
+spi.CSlow()
+spi.add(0x20, 0x00) # W_REGISTER, reg = CONFIG
+spi.add(0x00, 0x00)
+spi.add(0x00, 0x00) # excess
+spi.add(0x00, 0x00) # excess
+spi.CShigh()
+spi.CSlow()
+spi.add(0x2a, 0x00) # W_REGISTER, reg = RX_ADDR_P0
+spi.add(0x00, 0x00)
+spi.add(0x00, 0x00)
+spi.add(0x00, 0x00)
+spi.add(0x00, 0x00)
+spi.add(0x00, 0x00)
+spi.add(0x00, 0x00) # excess
+spi.CShigh()
+spi.CSlow()
+spi.add(0x2c, 0x00) # W_REGISTER, reg = RX_ADDR_P2
+spi.add(0x00, 0x00)
+spi.add(0x00, 0x00) # excess
+spi.CShigh()
+spi.CSlow()
+spi.add(0xa0, 0x00) # W_ACK_PAYLOAD, pipe = 0
+for i in range(33):
+ spi.add(i, 0x00) # write 33 bytes, command only expects 32
+spi.CShigh()
+spi.write()
+
+spi = SPI('nrf24l01-test-missing-bytes')
+spi.CSlow()
+spi.add(0x00, 0x00) # R_REGISTER, reg = CONFIG
+spi.CShigh()
+spi.CSlow()
+spi.add(0xb0, 0x00) # W_TX_PAYLOAD_NOACK
+spi.CShigh()
+spi.write()
+
+spi = SPI('nrf24l01-test-no-command')
+spi.CSlow()
+spi.CShigh()
+spi.CSlow()
+spi.CShigh()
+spi.CSlow()
+spi.add(0x00, 0x00) # R_REGISTER, reg = CONFIG
+spi.add(0x00, 0x00)
+spi.CShigh()
+spi.CSlow()
+spi.CShigh()
+spi.CSlow()
+spi.add(0x00, 0x00) # R_REGISTER, reg = CONFIG
+spi.add(0x00, 0x00)
+spi.CShigh()
+spi.write()
+
+spi = SPI('nrf24l01-test-unknown-register')
+spi.CSlow()
+spi.add(0x1f, 0x00) # R_REGISTER, reg = 0x1f
+spi.add(0x00, 0x00)
+spi.CShigh()
+spi.write()
+
+spi = SPI('nrf24l01-test-unknown-command')
+spi.CSlow()
+spi.add(0x00, 0x00) # R_REGISTER, reg = CONFIG
+spi.add(0x00, 0x00)
+spi.CShigh()
+spi.CSlow()
+spi.add(0xf0, 0x00) # wrong command
+spi.add(0x00, 0x00)
+spi.CShigh()
+spi.CSlow()
+spi.add(0x20, 0x00) # W_REGISTER, reg = CONFIG
+spi.add(0x00, 0x00)
+spi.CShigh()
+spi.write()
+
+spi = SPI('nrf24l01-test-misc')
+spi.CSlow()
+spi.add(0xe3, 0x00) # REUSE_TX_PL
+spi.CShigh()
+spi.CSlow()
+spi.add(0x60, 0x00) # R_RX_PL_WID
+spi.add(0x00, 0x09)
+spi.CShigh()
+spi.CSlow()
+spi.add(0x60, 0x00) # R_RX_PL_WID
+spi.CShigh()
+spi.CSlow()
+spi.add(0x60, 0x00) # R_RX_PL_WID
+spi.add(0x00, 0x09)
+spi.add(0x00, 0x09) # excess
+spi.CShigh()
+spi.CSlow()
+spi.add(0xa9, 0x00) # W_ACK_PAYLOAD, pipe = 1
+for i in range(5):
+ spi.add(i, 0x00)
+for c in 'abcdef':
+ spi.add(ord(c), 0x00)
+for i in range(5):
+ spi.add(i, 0x00)
+spi.CShigh()
+spi.write()
diff --git a/spi/nrf24l01/nrf24l01-communication-rx.sr b/spi/nrf24l01/nrf24l01-communication-rx.sr
new file mode 100644
index 0000000..bc25f6b
--- /dev/null
+++ b/spi/nrf24l01/nrf24l01-communication-rx.sr
Binary files differ
diff --git a/spi/nrf24l01/nrf24l01-communication-tx.sr b/spi/nrf24l01/nrf24l01-communication-tx.sr
new file mode 100644
index 0000000..0dbf2e3
--- /dev/null
+++ b/spi/nrf24l01/nrf24l01-communication-tx.sr
Binary files differ
diff --git a/spi/nrf24l01/nrf24l01-communication.sr b/spi/nrf24l01/nrf24l01-communication.sr
new file mode 100644
index 0000000..faa3d6b
--- /dev/null
+++ b/spi/nrf24l01/nrf24l01-communication.sr
Binary files differ
diff --git a/spi/nrf24l01/nrf24l01-test-activate.sr b/spi/nrf24l01/nrf24l01-test-activate.sr
new file mode 100644
index 0000000..fddb811
--- /dev/null
+++ b/spi/nrf24l01/nrf24l01-test-activate.sr
Binary files differ
diff --git a/spi/nrf24l01/nrf24l01-test-excess-bytes.sr b/spi/nrf24l01/nrf24l01-test-excess-bytes.sr
new file mode 100644
index 0000000..7b64fd2
--- /dev/null
+++ b/spi/nrf24l01/nrf24l01-test-excess-bytes.sr
Binary files differ
diff --git a/spi/nrf24l01/nrf24l01-test-misc.sr b/spi/nrf24l01/nrf24l01-test-misc.sr
new file mode 100644
index 0000000..247691f
--- /dev/null
+++ b/spi/nrf24l01/nrf24l01-test-misc.sr
Binary files differ
diff --git a/spi/nrf24l01/nrf24l01-test-missing-bytes.sr b/spi/nrf24l01/nrf24l01-test-missing-bytes.sr
new file mode 100644
index 0000000..c1b15db
--- /dev/null
+++ b/spi/nrf24l01/nrf24l01-test-missing-bytes.sr
Binary files differ
diff --git a/spi/nrf24l01/nrf24l01-test-no-command.sr b/spi/nrf24l01/nrf24l01-test-no-command.sr
new file mode 100644
index 0000000..4b0e0dd
--- /dev/null
+++ b/spi/nrf24l01/nrf24l01-test-no-command.sr
Binary files differ
diff --git a/spi/nrf24l01/nrf24l01-test-unknown-command.sr b/spi/nrf24l01/nrf24l01-test-unknown-command.sr
new file mode 100644
index 0000000..6c72667
--- /dev/null
+++ b/spi/nrf24l01/nrf24l01-test-unknown-command.sr
Binary files differ
diff --git a/spi/nrf24l01/nrf24l01-test-unknown-register.sr b/spi/nrf24l01/nrf24l01-test-unknown-register.sr
new file mode 100644
index 0000000..633abc6
--- /dev/null
+++ b/spi/nrf24l01/nrf24l01-test-unknown-register.sr
Binary files differ