X-Git-Url: https://sigrok.org/gitweb/?p=libsigrokdecode.git;a=blobdiff_plain;f=decoders%2Fnrf24l01%2Fpd.py;h=02cdddbce06337be86a436e4c079c226ef3d50b9;hp=a40f454b40f04270c6c4bf364558e7ff3fb28677;hb=b197383cfb39b39ff04644855eef57f5d3c18bc1;hpb=3cc4c4a96dba8390ec4eabbd62cc1d50d653640e diff --git a/decoders/nrf24l01/pd.py b/decoders/nrf24l01/pd.py index a40f454..02cdddb 100644 --- a/decoders/nrf24l01/pd.py +++ b/decoders/nrf24l01/pd.py @@ -14,8 +14,7 @@ ## 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 +## along with this program; if not, see . ## import sigrokdecode as srd @@ -53,8 +52,14 @@ regs = { 0x1d: ('FEATURE', 1), } +xn297_regs = { + 0x19: ('DEMOD_CAL', 5), + 0x1e: ('RF_CAL', 7), + 0x1f: ('BB_CAL', 5), +} + class Decoder(srd.Decoder): - api_version = 2 + api_version = 3 id = 'nrf24l01' name = 'nRF24L01(+)' longname = 'Nordic Semiconductor nRF24L01/nRF24L01+' @@ -62,6 +67,10 @@ class Decoder(srd.Decoder): license = 'gplv2+' inputs = ['spi'] outputs = ['nrf24l01'] + options = ( + {'id': 'chip', 'desc': 'Chip type', + 'default': 'nrf24l01', 'values': ('nrf24l01', 'xn297')}, + ) annotations = ( # Sent from the host to the chip. ('cmd', 'Commands sent to the device'), @@ -84,12 +93,15 @@ class Decoder(srd.Decoder): ('warnings', 'Warnings', (ann_warn,)), ) - def __init__(self, **kwargs): + def __init__(self): self.next() self.requirements_met = True + self.cs_was_released = False def start(self): self.out_ann = self.register(srd.OUTPUT_ANN) + if self.options['chip'] == 'xn297': + regs.update(xn297_regs) def warn(self, pos, msg): '''Put a warning message 'msg' at 'pos'.''' @@ -271,10 +283,12 @@ class Decoder(srd.Decoder): ptype, data1, data2 = data if ptype == 'CS-CHANGE': - if data1 == -1: - if data2 == -1: + if data1 is None: + if data2 is None: self.requirements_met = False raise ChannelError('CS# pin required.') + elif data2 == 1: + self.cs_was_released = True if data1 == 0 and data2 == 1: # Rising edge, the complete command is transmitted, process @@ -288,7 +302,8 @@ class Decoder(srd.Decoder): self.finish_command((self.mb_s, self.mb_e)) self.next() - elif ptype == 'DATA': + self.cs_was_released = True + elif ptype == 'DATA' and self.cs_was_released: mosi, miso = data1, data2 pos = (ss, es)