Browse Source

add function to change syncword and preamble configuration

Nahuel D. Sánchez 7 years ago
parent
commit
9c6238d704
1 changed files with 10 additions and 1 deletions
  1. 10 1
      pycc1101/pycc1101.py

+ 10 - 1
pycc1101/pycc1101.py

@@ -330,7 +330,16 @@ class TICC1101(object):
         self._writeSingleByte(self.TEST0, 0x09)
         self._writeSingleByte(0x3E, 0xC0)           # Power 10dBm
 
-        return
+    def setSyncMode(self, syncmode):
+        regVal = list(self.getRegisterConfiguration("MDMCFG2"))
+
+        if syncmode > 7:
+            raise Exception("Invalid SYNC mode")
+
+        regVal[5:] = bin(syncmode)[2:].zfill(3)
+
+        regVal = int("".join(regVal), 2)
+        self._writeSingleByte(self.MDMCFG2, regVal)
 
     def setModulation(self, modulation):
         regVal = list(self.getRegisterConfiguration("MDMCFG2"))