Skip to content

Commit

Permalink
Add a second TPMS-specific mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
antirez committed Jan 7, 2023
1 parent 5fc223c commit f0a2607
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app_subghz.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ ProtoViewModulation ProtoViewModulations[] = {
{"2FSK 47.6Khz", FuriHalSubGhzPreset2FSKDev476Async, NULL},
{"MSK", FuriHalSubGhzPresetMSK99_97KbAsync, NULL},
{"GFSK", FuriHalSubGhzPresetGFSK9_99KbAsync, NULL},
{"FSK for TPMS", 0, (uint8_t*)protoview_subghz_tpms_async_regs},
{"TPMS FSK 28.56Khz", 0, (uint8_t*)protoview_subghz_tpms1_async_regs},
{"TPMS FSK 47.6Khz", 0, (uint8_t*)protoview_subghz_tpms2_async_regs},
{NULL, 0, NULL} /* End of list sentinel. */
};

Expand Down
48 changes: 47 additions & 1 deletion custom_presets.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <cc1101.h>

static uint8_t protoview_subghz_tpms_async_regs[][2] = {
/* 20 KBaud, 2FSK, 28.56 kHz deviation, 325 Khz bandwidth filter. */
static uint8_t protoview_subghz_tpms1_async_regs[][2] = {
/* GPIO GD0 */
{CC1101_IOCFG0, 0x0D}, // GD0 as async serial data output/input

Expand Down Expand Up @@ -44,3 +45,48 @@ static uint8_t protoview_subghz_tpms_async_regs[][2] = {
{0, 0},
};

/* 20 KBaud, 2FSK, 44.60 kHz deviation, 270 Khz bandwidth filter. */
static uint8_t protoview_subghz_tpms2_async_regs[][2] = {
/* GPIO GD0 */
{CC1101_IOCFG0, 0x0D}, // GD0 as async serial data output/input

/* Frequency Synthesizer Control */
{CC1101_FSCTRL1, 0x06}, // IF = (26*10^6) / (2^10) * 0x06 = 152343.75Hz

/* Packet engine */
{CC1101_PKTCTRL0, 0x32}, // Async, continious, no whitening
{CC1101_PKTCTRL1, 0x04},

// // Modem Configuration
{CC1101_MDMCFG0, 0x00},
{CC1101_MDMCFG1, 0x02},
{CC1101_MDMCFG2, 0x04}, // Format 2-FSK/FM, No preamble/sync, Disable (current optimized). Other code reading TPMS uses GFSK, but should be the same when in RX mode.
{CC1101_MDMCFG3, 0x93}, // Data rate is 20kBaud
{CC1101_MDMCFG4, 0x67}, // Rx BW filter is 270.833333 kHz
{CC1101_DEVIATN, 0x47}, // Deviation 47.60742 kHz

/* 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,
0x16}, // 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,
0x00}, // 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, 0x10}, // Adjusts current TX LO buffer
{CC1101_FREND1, 0x56},

/* End */
{0, 0},
};

0 comments on commit f0a2607

Please sign in to comment.