소스 검색

add function to change syncword and preamble configuration

Nahuel D. Sánchez 7 년 전
부모
커밋
9c6238d704
1개의 변경된 파일10개의 추가작업 그리고 1개의 파일을 삭제
  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"))