Преглед изворни кода

CC1101 preset that works well with OOK TPMS.

antirez пре 3 година
родитељ
комит
54eea1ded7
3 измењених фајлова са 56 додато и 7 уклоњено
  1. 4 3
      app_subghz.c
  2. 51 3
      custom_presets.h
  3. 1 1
      protocols/toyota_tpms.c

+ 4 - 3
app_subghz.c

@@ -19,9 +19,10 @@ ProtoViewModulation ProtoViewModulations[] = {
     {"2FSK 47.6Khz", FuriHalSubGhzPreset2FSKDev476Async, NULL},
     {"MSK", FuriHalSubGhzPresetMSK99_97KbAsync, NULL},
     {"GFSK", FuriHalSubGhzPresetGFSK9_99KbAsync, NULL},
-    {"TPMS 1 (FSK)", 0, (uint8_t*)protoview_subghz_tpms1_async_regs},
-    {"TPMS 2 (FSK)", 0, (uint8_t*)protoview_subghz_tpms2_async_regs},
-    {"TPMS 3 (FSK)", 0, (uint8_t*)protoview_subghz_tpms3_async_regs},
+    {"TPMS 1 (FSK)", 0, (uint8_t*)protoview_subghz_tpms1_fsk_async_regs},
+    {"TPMS 2 (OOK)", 0, (uint8_t*)protoview_subghz_tpms2_ook_async_regs},
+    {"TPMS 3 (FSK)", 0, (uint8_t*)protoview_subghz_tpms3_fsk_async_regs},
+    {"TPMS 4 (FSK)", 0, (uint8_t*)protoview_subghz_tpms4_fsk_async_regs},
     {NULL, 0, NULL} /* End of list sentinel. */
 };
 

+ 51 - 3
custom_presets.h

@@ -58,7 +58,7 @@
  */
 
 /* 20 KBaud, 2FSK, 28.56 kHz deviation, 325 Khz bandwidth filter. */
-static uint8_t protoview_subghz_tpms1_async_regs[][2] = {
+static uint8_t protoview_subghz_tpms1_fsk_async_regs[][2] = {
     /* GPIO GD0 */
     {CC1101_IOCFG0, 0x0D}, // GD0 as async serial data output/input
 
@@ -102,8 +102,55 @@ static uint8_t protoview_subghz_tpms1_async_regs[][2] = {
     {0, 0},
 };
 
+/* This is like the default Flipper OOK 640Khz bandwidth preset, but
+ * the bandwidth is changed to 10kBaud to accomodate TPMS frequency. */
+static const uint8_t protoview_subghz_tpms2_ook_async_regs[][2] = {
+    /* GPIO GD0 */
+    {CC1101_IOCFG0, 0x0D}, // GD0 as async serial data output/input
+
+    /* FIFO and internals */
+    {CC1101_FIFOTHR, 0x07}, // The only important bit is ADC_RETENTION
+
+    /* Packet engine */
+    {CC1101_PKTCTRL0, 0x32}, // Async, continious, no whitening
+
+    /* Frequency Synthesizer Control */
+    {CC1101_FSCTRL1, 0x06}, // IF = (26*10^6) / (2^10) * 0x06 = 152343.75Hz
+
+    // Modem Configuration
+    {CC1101_MDMCFG0, 0x00}, // Channel spacing is 25kHz
+    {CC1101_MDMCFG1, 0x00}, // Channel spacing is 25kHz
+    {CC1101_MDMCFG2, 0x30}, // Format ASK/OOK, No preamble/sync
+    {CC1101_MDMCFG3, 0x93}, // Data rate is 10kBaud
+    {CC1101_MDMCFG4, 0x18}, // Rx BW filter is 650.000kHz
+
+    /* Main Radio Control State Machine */
+    {CC1101_MCSM0, 0x18}, // Autocalibrate on idle-to-rx/tx, PO_TIMEOUT is 64 cycles(149-155us)
+
+    /* Frequency Offset Compensation Configuration */
+    {CC1101_FOCCFG,
+     0x18}, // no frequency offset compensation, POST_K same as PRE_K, PRE_K is 4K, GATE is off
+
+    /* Automatic Gain Control */
+    {CC1101_AGCCTRL0,
+     0x91}, // 10 - Medium hysteresis, medium asymmetric dead zone, medium gain ; 01 - 16 samples agc; 00 - Normal AGC, 01 - 8dB boundary
+    {CC1101_AGCCTRL1,
+     0x0}, // 0; 0 - LNA 2 gain is decreased to minimum before decreasing LNA gain; 00 - Relative carrier sense threshold disabled; 0000 - RSSI to MAIN_TARGET
+    {CC1101_AGCCTRL2, 0x07}, // 00 - DVGA all; 000 - MAX LNA+LNA2; 111 - MAIN_TARGET 42 dB
+
+    /* Wake on radio and timeouts control */
+    {CC1101_WORCTRL, 0xFB}, // WOR_RES is 2^15 periods (0.91 - 0.94 s) 16.5 - 17.2 hours
+
+    /* Frontend configuration */
+    {CC1101_FREND0, 0x11}, // Adjusts current TX LO buffer + high is PATABLE[1]
+    {CC1101_FREND1, 0xB6}, //
+
+    /* End  */
+    {0, 0},
+};
+
 /* 40 KBaud, 2FSK, 19 kHz deviation, 102 Khz bandwidth filter. */
-static uint8_t protoview_subghz_tpms2_async_regs[][2] = {
+static uint8_t protoview_subghz_tpms3_fsk_async_regs[][2] = {
     /* GPIO GD0 */
     {CC1101_IOCFG0, 0x0D}, // GD0 as async serial data output/input
 
@@ -148,7 +195,7 @@ static uint8_t protoview_subghz_tpms2_async_regs[][2] = {
 };
 
 /* Parameters that should work well for the TPMS PVM C210 sensor. */
-static uint8_t protoview_subghz_tpms3_async_regs[][2] = {
+static uint8_t protoview_subghz_tpms4_fsk_async_regs[][2] = {
     /* GPIO GD0 */
     {CC1101_IOCFG0, 0x0D}, // GD0 as async serial data output/input
 
@@ -190,3 +237,4 @@ static uint8_t protoview_subghz_tpms3_async_regs[][2] = {
     {0, 0},
 };
 
+

+ 1 - 1
protocols/toyota_tpms.c

@@ -13,7 +13,7 @@
  * often can't decode correctly the initial alternating pattern 101010101,
  * so what we do is to seek just the sync, that is "001111" or "0011111",
  * however we now that it must be followed by one differenitally encoded
- * bit, so we can use also the first bit of data to force a more robust
+ * bit, so we can use also the first symbol of data to force a more robust
  * detection, and look for one of the following:
  *
  * [001111]00