mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-07-17 00:28:11 -07:00
Merge remote-tracking branch 'ofw/dev' into mntm-dev
This commit is contained in:
@@ -17,7 +17,7 @@ public:
|
||||
RecordController(const char* record_name) {
|
||||
name = record_name;
|
||||
value = static_cast<TRecordClass*>(furi_record_open(name));
|
||||
};
|
||||
}
|
||||
|
||||
~RecordController() {
|
||||
furi_record_close(name);
|
||||
|
||||
@@ -50,7 +50,8 @@ struct type_index {
|
||||
* Creates a type_index object for the specified type.
|
||||
*/
|
||||
template <typename T>
|
||||
type_index(tag_type<T>) noexcept : hash_code_{index<T>} {
|
||||
type_index(tag_type<T>) noexcept
|
||||
: hash_code_{index<T>} {
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -27,7 +27,7 @@ public:
|
||||
0)...);
|
||||
|
||||
gui = static_cast<Gui*>(furi_record_open("gui"));
|
||||
};
|
||||
}
|
||||
|
||||
~ViewController() {
|
||||
for(auto& it : holder) {
|
||||
|
||||
@@ -482,4 +482,4 @@ uint64_t bit_lib_bytes_to_num_bcd(const uint8_t* src, uint8_t len, bool* is_bcd)
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
Submodule lib/cxxheaderparser deleted from ba4222560f
@@ -4,10 +4,10 @@
|
||||
#define TAG "DateTime"
|
||||
|
||||
#define SECONDS_PER_MINUTE 60
|
||||
#define SECONDS_PER_HOUR (SECONDS_PER_MINUTE * 60)
|
||||
#define SECONDS_PER_DAY (SECONDS_PER_HOUR * 24)
|
||||
#define MONTHS_COUNT 12
|
||||
#define EPOCH_START_YEAR 1970
|
||||
#define SECONDS_PER_HOUR (SECONDS_PER_MINUTE * 60)
|
||||
#define SECONDS_PER_DAY (SECONDS_PER_HOUR * 24)
|
||||
#define MONTHS_COUNT 12
|
||||
#define EPOCH_START_YEAR 1970
|
||||
|
||||
static const uint8_t datetime_days_per_month[2][MONTHS_COUNT] = {
|
||||
{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#define DIGITAL_SEQUENCE_TIMER_MAX 0xFFFFFFFFUL
|
||||
|
||||
/* Time to wait in loops before returning */
|
||||
#define DIGITAL_SEQUENCE_LOCK_WAIT_MS 10UL
|
||||
#define DIGITAL_SEQUENCE_LOCK_WAIT_MS 10UL
|
||||
#define DIGITAL_SEQUENCE_LOCK_WAIT_TICKS (DIGITAL_SEQUENCE_LOCK_WAIT_MS * 1000 * 64)
|
||||
|
||||
#define DIGITAL_SEQUENCE_GPIO_BUFFER_SIZE 2
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define DIGITAL_SIGNAL_T_TIM 1562 /**< 15.625 ns *100 */
|
||||
#define DIGITAL_SIGNAL_T_TIM 1562 /**< 15.625 ns *100 */
|
||||
#define DIGITAL_SIGNAL_T_TIM_DIV2 (DIGITAL_SIGNAL_T_TIM / 2) /**< 15.625 ns / 2 *100 */
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,14 +5,14 @@
|
||||
#define BITS_IN_BYTE (8)
|
||||
|
||||
#define ISO14443_3A_SIGNAL_BIT_MAX_EDGES (10)
|
||||
#define ISO14443_3A_SIGNAL_MAX_EDGES (1350)
|
||||
#define ISO14443_3A_SIGNAL_MAX_EDGES (1350)
|
||||
|
||||
#define ISO14443_3A_SIGNAL_SEQUENCE_SIZE \
|
||||
(ISO14443_3A_SIGNAL_MAX_EDGES / (ISO14443_3A_SIGNAL_BIT_MAX_EDGES - 2))
|
||||
|
||||
#define ISO14443_3A_SIGNAL_F_SIG (13560000.0)
|
||||
#define ISO14443_3A_SIGNAL_T_SIG 7374 //73.746ns*100
|
||||
#define ISO14443_3A_SIGNAL_T_SIG_X8 58992 //T_SIG*8
|
||||
#define ISO14443_3A_SIGNAL_F_SIG (13560000.0)
|
||||
#define ISO14443_3A_SIGNAL_T_SIG 7374 //73.746ns*100
|
||||
#define ISO14443_3A_SIGNAL_T_SIG_X8 58992 //T_SIG*8
|
||||
#define ISO14443_3A_SIGNAL_T_SIG_X8_X8 471936 //T_SIG*8*8
|
||||
#define ISO14443_3A_SIGNAL_T_SIG_X8_X9 530928 //T_SIG*8*9
|
||||
|
||||
|
||||
@@ -8,13 +8,13 @@
|
||||
#define ISO15693_SIGNAL_COEFF_LO (4U)
|
||||
|
||||
#define ISO15693_SIGNAL_ZERO_EDGES (16U)
|
||||
#define ISO15693_SIGNAL_ONE_EDGES (ISO15693_SIGNAL_ZERO_EDGES + 1U)
|
||||
#define ISO15693_SIGNAL_EOF_EDGES (64U)
|
||||
#define ISO15693_SIGNAL_SOF_EDGES (ISO15693_SIGNAL_EOF_EDGES + 1U)
|
||||
#define ISO15693_SIGNAL_EDGES (1350U)
|
||||
#define ISO15693_SIGNAL_ONE_EDGES (ISO15693_SIGNAL_ZERO_EDGES + 1U)
|
||||
#define ISO15693_SIGNAL_EOF_EDGES (64U)
|
||||
#define ISO15693_SIGNAL_SOF_EDGES (ISO15693_SIGNAL_EOF_EDGES + 1U)
|
||||
#define ISO15693_SIGNAL_EDGES (1350U)
|
||||
|
||||
#define ISO15693_SIGNAL_FC (13.56e6)
|
||||
#define ISO15693_SIGNAL_FC_16 (16.0e11 / ISO15693_SIGNAL_FC)
|
||||
#define ISO15693_SIGNAL_FC (13.56e6)
|
||||
#define ISO15693_SIGNAL_FC_16 (16.0e11 / ISO15693_SIGNAL_FC)
|
||||
#define ISO15693_SIGNAL_FC_256 (256.0e11 / ISO15693_SIGNAL_FC)
|
||||
#define ISO15693_SIGNAL_FC_768 (768.0e11 / ISO15693_SIGNAL_FC)
|
||||
|
||||
|
||||
+78
-78
@@ -7,27 +7,27 @@
|
||||
#error Bit structures defined in this file is not portable to BE
|
||||
#endif
|
||||
|
||||
#define BQ25896_ADDRESS 0xD6
|
||||
#define BQ25896_ADDRESS 0xD6
|
||||
#define BQ25896_I2C_TIMEOUT 50
|
||||
|
||||
#define IILIM_1600 (1 << 5)
|
||||
#define IILIM_800 (1 << 4)
|
||||
#define IILIM_400 (1 << 3)
|
||||
#define IILIM_200 (1 << 2)
|
||||
#define IILIM_100 (1 << 1)
|
||||
#define IILIM_50 (1 << 0)
|
||||
#define IILIM_800 (1 << 4)
|
||||
#define IILIM_400 (1 << 3)
|
||||
#define IILIM_200 (1 << 2)
|
||||
#define IILIM_100 (1 << 1)
|
||||
#define IILIM_50 (1 << 0)
|
||||
|
||||
typedef struct {
|
||||
uint8_t IINLIM : 6; // Input Current Limit, mA, offset: +100mA
|
||||
bool EN_ILIM : 1; // Enable ILIM Pin
|
||||
bool EN_HIZ : 1; // Enable HIZ Mode
|
||||
bool EN_ILIM : 1; // Enable ILIM Pin
|
||||
bool EN_HIZ : 1; // Enable HIZ Mode
|
||||
} REG00;
|
||||
|
||||
#define VINDPM_OS_1600 (1 << 4)
|
||||
#define VINDPM_OS_800 (1 << 3)
|
||||
#define VINDPM_OS_400 (1 << 2)
|
||||
#define VINDPM_OS_200 (1 << 1)
|
||||
#define VINDPM_OS_100 (1 << 0)
|
||||
#define VINDPM_OS_800 (1 << 3)
|
||||
#define VINDPM_OS_400 (1 << 2)
|
||||
#define VINDPM_OS_200 (1 << 1)
|
||||
#define VINDPM_OS_100 (1 << 0)
|
||||
|
||||
typedef enum {
|
||||
Bhot34 = 0b00, // – VBHOT1 Threshold (34.75%) (default)
|
||||
@@ -38,18 +38,18 @@ typedef enum {
|
||||
|
||||
typedef struct {
|
||||
uint8_t VINDPM_OS : 5; // Input Voltage Limit Offset, mV
|
||||
bool BCOLD : 1; // Boost Mode Cold Temperature Monitor Threshold
|
||||
Bhot BHOT : 2; // Boost Mode Hot Temperature Monitor Threshold
|
||||
bool BCOLD : 1; // Boost Mode Cold Temperature Monitor Threshold
|
||||
Bhot BHOT : 2; // Boost Mode Hot Temperature Monitor Threshold
|
||||
} REG01;
|
||||
|
||||
typedef struct {
|
||||
bool AUTO_DPDM_EN : 1; // Automatic Input Detection Enable
|
||||
bool FORCE_DPDM : 1; // Force Input Detection
|
||||
uint8_t RES : 2; // Reserved
|
||||
bool ICO_EN : 1; // Input Current Optimizer (ICO) Enable
|
||||
bool BOOST_FREQ : 1; // Boost Mode Frequency Selection
|
||||
bool CONV_RATE : 1; // ADC Conversion Rate Selection
|
||||
bool CONV_START : 1; // ADC Conversion Start Control
|
||||
bool FORCE_DPDM : 1; // Force Input Detection
|
||||
uint8_t RES : 2; // Reserved
|
||||
bool ICO_EN : 1; // Input Current Optimizer (ICO) Enable
|
||||
bool BOOST_FREQ : 1; // Boost Mode Frequency Selection
|
||||
bool CONV_RATE : 1; // ADC Conversion Rate Selection
|
||||
bool CONV_START : 1; // ADC Conversion Start Control
|
||||
} REG02;
|
||||
|
||||
#define SYS_MIN_400 (1 << 2)
|
||||
@@ -58,45 +58,45 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
bool MIN_VBAT_SEL : 1; // Minimum Battery Voltage (falling) to exit boost mode
|
||||
uint8_t SYS_MIN : 3; // Minimum System Voltage Limit, mV, offset: +3000mV
|
||||
bool CHG_CONFIG : 1; // Charge Enable Configuration
|
||||
bool OTG_CONFIG : 1; // Boost (OTG) Mode Configuration
|
||||
bool WD_RST : 1; // I2C Watchdog Timer Reset
|
||||
bool BAT_LOADEN : 1; // Battery Load (IBATLOAD) Enable
|
||||
uint8_t SYS_MIN : 3; // Minimum System Voltage Limit, mV, offset: +3000mV
|
||||
bool CHG_CONFIG : 1; // Charge Enable Configuration
|
||||
bool OTG_CONFIG : 1; // Boost (OTG) Mode Configuration
|
||||
bool WD_RST : 1; // I2C Watchdog Timer Reset
|
||||
bool BAT_LOADEN : 1; // Battery Load (IBATLOAD) Enable
|
||||
} REG03;
|
||||
|
||||
#define ICHG_4096 (1 << 6)
|
||||
#define ICHG_2048 (1 << 5)
|
||||
#define ICHG_1024 (1 << 4)
|
||||
#define ICHG_512 (1 << 3)
|
||||
#define ICHG_256 (1 << 2)
|
||||
#define ICHG_128 (1 << 1)
|
||||
#define ICHG_64 (1 << 0)
|
||||
#define ICHG_512 (1 << 3)
|
||||
#define ICHG_256 (1 << 2)
|
||||
#define ICHG_128 (1 << 1)
|
||||
#define ICHG_64 (1 << 0)
|
||||
|
||||
typedef struct {
|
||||
uint8_t ICHG : 7; // Fast Charge Current Limit, mA
|
||||
uint8_t ICHG : 7; // Fast Charge Current Limit, mA
|
||||
bool EN_PUMPX : 1; // Current pulse control Enable
|
||||
} REG04;
|
||||
|
||||
#define IPRETERM_512 (1 << 3)
|
||||
#define IPRETERM_256 (1 << 2)
|
||||
#define IPRETERM_128 (1 << 1)
|
||||
#define IPRETERM_64 (1 << 0)
|
||||
#define IPRETERM_64 (1 << 0)
|
||||
|
||||
typedef struct {
|
||||
uint8_t ITERM : 4; // Termination Current Limit, offset: +64mA
|
||||
uint8_t ITERM : 4; // Termination Current Limit, offset: +64mA
|
||||
uint8_t IPRECHG : 4; // Precharge Current Limit, offset: +64mA
|
||||
} REG05;
|
||||
|
||||
#define VREG_512 (1 << 5)
|
||||
#define VREG_256 (1 << 4)
|
||||
#define VREG_128 (1 << 3)
|
||||
#define VREG_64 (1 << 2)
|
||||
#define VREG_32 (1 << 1)
|
||||
#define VREG_16 (1 << 0)
|
||||
#define VREG_64 (1 << 2)
|
||||
#define VREG_32 (1 << 1)
|
||||
#define VREG_16 (1 << 0)
|
||||
|
||||
typedef struct {
|
||||
bool VRECHG : 1; // Battery Recharge Threshold Offset
|
||||
bool VRECHG : 1; // Battery Recharge Threshold Offset
|
||||
bool BATLOWV : 1; // Battery Precharge to Fast Charge Threshold
|
||||
uint8_t VREG : 6; // Charge Voltage Limit, offset: +3840mV
|
||||
} REG06;
|
||||
@@ -116,12 +116,12 @@ typedef enum {
|
||||
} ChgTimer;
|
||||
|
||||
typedef struct {
|
||||
bool JEITA_ISET : 1; // JEITA Low Temperature Current Setting
|
||||
bool JEITA_ISET : 1; // JEITA Low Temperature Current Setting
|
||||
ChgTimer CHG_TIMER : 2; // Fast Charge Timer Setting
|
||||
bool EN_TIMER : 1; // Charging Safety Timer Enable
|
||||
Watchdog WATCHDOG : 2; // I2C Watchdog Timer Setting
|
||||
bool STAT_DIS : 1; // STAT Pin Disable
|
||||
bool EN_TERM : 1; // Charging Termination Enable
|
||||
bool EN_TIMER : 1; // Charging Safety Timer Enable
|
||||
Watchdog WATCHDOG : 2; // I2C Watchdog Timer Setting
|
||||
bool STAT_DIS : 1; // STAT Pin Disable
|
||||
bool EN_TERM : 1; // Charging Termination Enable
|
||||
} REG07;
|
||||
|
||||
#define BAT_COMP_80 (1 << 2)
|
||||
@@ -129,35 +129,35 @@ typedef struct {
|
||||
#define BAT_COMP_20 (1 << 0)
|
||||
|
||||
#define VCLAMP_128 (1 << 2)
|
||||
#define VCLAMP_64 (1 << 1)
|
||||
#define VCLAMP_32 (1 << 0)
|
||||
#define VCLAMP_64 (1 << 1)
|
||||
#define VCLAMP_32 (1 << 0)
|
||||
|
||||
#define TREG_60 (0b00)
|
||||
#define TREG_80 (0b01)
|
||||
#define TREG_60 (0b00)
|
||||
#define TREG_80 (0b01)
|
||||
#define TREG_100 (0b10)
|
||||
#define TREG_120 (0b11)
|
||||
|
||||
typedef struct {
|
||||
uint8_t TREG : 2; // Thermal Regulation Threshold
|
||||
uint8_t VCLAMP : 3; // IR Compensation Voltage Clamp
|
||||
uint8_t TREG : 2; // Thermal Regulation Threshold
|
||||
uint8_t VCLAMP : 3; // IR Compensation Voltage Clamp
|
||||
uint8_t BAT_COMP : 3; // IR Compensation Resistor Setting
|
||||
} REG08;
|
||||
|
||||
typedef struct {
|
||||
bool PUMPX_DN : 1; // Current pulse control voltage down enable
|
||||
bool PUMPX_UP : 1; // Current pulse control voltage up enable
|
||||
bool PUMPX_DN : 1; // Current pulse control voltage down enable
|
||||
bool PUMPX_UP : 1; // Current pulse control voltage up enable
|
||||
bool BATFET_RST_EN : 1; // BATFET full system reset enable
|
||||
bool BATFET_DLY : 1; // BATFET turn off delay control
|
||||
bool JEITA_VSET : 1; // JEITA High Temperature Voltage Setting
|
||||
bool BATFET_DIS : 1; // Force BATFET off to enable ship mode
|
||||
bool TMR2X_EN : 1; // Safety Timer Setting during DPM or Thermal Regulation
|
||||
bool FORCE_ICO : 1; // Force Start Input Current Optimizer
|
||||
bool BATFET_DLY : 1; // BATFET turn off delay control
|
||||
bool JEITA_VSET : 1; // JEITA High Temperature Voltage Setting
|
||||
bool BATFET_DIS : 1; // Force BATFET off to enable ship mode
|
||||
bool TMR2X_EN : 1; // Safety Timer Setting during DPM or Thermal Regulation
|
||||
bool FORCE_ICO : 1; // Force Start Input Current Optimizer
|
||||
} REG09;
|
||||
|
||||
#define BOOSTV_512 (1 << 3)
|
||||
#define BOOSTV_256 (1 << 2)
|
||||
#define BOOSTV_128 (1 << 1)
|
||||
#define BOOSTV_64 (1 << 0)
|
||||
#define BOOSTV_64 (1 << 0)
|
||||
|
||||
typedef enum {
|
||||
BoostLim_500 = 0b000,
|
||||
@@ -172,8 +172,8 @@ typedef enum {
|
||||
|
||||
typedef struct {
|
||||
uint8_t BOOST_LIM : 3; // Boost Mode Current Limit
|
||||
bool PFM_OTG_DIS : 1; // PFM mode allowed in boost mode
|
||||
uint8_t BOOSTV : 4; // Boost Mode Voltage Regulation, offset: +4550mV
|
||||
bool PFM_OTG_DIS : 1; // PFM mode allowed in boost mode
|
||||
uint8_t BOOSTV : 4; // Boost Mode Voltage Regulation, offset: +4550mV
|
||||
} REG0A;
|
||||
|
||||
typedef enum {
|
||||
@@ -191,9 +191,9 @@ typedef enum {
|
||||
} ChrgStat;
|
||||
|
||||
typedef struct {
|
||||
bool VSYS_STAT : 1; // VSYS Regulation Status
|
||||
bool RES : 1; // Reserved: Always reads 1
|
||||
bool PG_STAT : 1; // Power Good Status
|
||||
bool VSYS_STAT : 1; // VSYS Regulation Status
|
||||
bool RES : 1; // Reserved: Always reads 1
|
||||
bool PG_STAT : 1; // Power Good Status
|
||||
ChrgStat CHRG_STAT : 2; // Charging Status
|
||||
VBusStat VBUS_STAT : 3; // VBUS Status register
|
||||
} REG0B;
|
||||
@@ -214,49 +214,49 @@ typedef enum {
|
||||
} NtcFault;
|
||||
|
||||
typedef struct {
|
||||
NtcFault NTC_FAULT : 3; // NTC Fault Status
|
||||
bool BAT_FAULT : 1; // Battery Fault Status
|
||||
NtcFault NTC_FAULT : 3; // NTC Fault Status
|
||||
bool BAT_FAULT : 1; // Battery Fault Status
|
||||
ChrgFault CHRG_FAULT : 2; // Charge Fault Status
|
||||
bool BOOST_FAULT : 1; // Boost Mode Fault Status
|
||||
bool WATCHDOG_FAULT : 1; // Watchdog Fault Status
|
||||
bool BOOST_FAULT : 1; // Boost Mode Fault Status
|
||||
bool WATCHDOG_FAULT : 1; // Watchdog Fault Status
|
||||
} REG0C;
|
||||
|
||||
#define VINDPM_6400 (1 << 6)
|
||||
#define VINDPM_3200 (1 << 5)
|
||||
#define VINDPM_1600 (1 << 4)
|
||||
#define VINDPM_800 (1 << 3)
|
||||
#define VINDPM_400 (1 << 2)
|
||||
#define VINDPM_200 (1 << 1)
|
||||
#define VINDPM_100 (1 << 0)
|
||||
#define VINDPM_800 (1 << 3)
|
||||
#define VINDPM_400 (1 << 2)
|
||||
#define VINDPM_200 (1 << 1)
|
||||
#define VINDPM_100 (1 << 0)
|
||||
|
||||
typedef struct {
|
||||
uint8_t VINDPM : 7; // Absolute VINDPM Threshold, offset: +2600mV
|
||||
uint8_t VINDPM : 7; // Absolute VINDPM Threshold, offset: +2600mV
|
||||
bool FORCE_VINDPM : 1; // VINDPM Threshold Setting Method
|
||||
} REG0D;
|
||||
|
||||
typedef struct {
|
||||
uint8_t BATV : 7; // ADC conversion of Battery Voltage (VBAT), offset: +2304mV
|
||||
uint8_t BATV : 7; // ADC conversion of Battery Voltage (VBAT), offset: +2304mV
|
||||
bool THERM_STAT : 1; // Thermal Regulation Status
|
||||
} REG0E;
|
||||
|
||||
typedef struct {
|
||||
uint8_t SYSV : 7; // ADDC conversion of System Voltage (VSYS), offset: +2304mV
|
||||
uint8_t RES : 1; // Reserved: Always reads 0
|
||||
uint8_t RES : 1; // Reserved: Always reads 0
|
||||
} REG0F;
|
||||
|
||||
typedef struct {
|
||||
uint8_t TSPCT : 7; // ADC conversion of TS Voltage (TS) as percentage of REGN, offset: +21%
|
||||
uint8_t RES : 1; // Reserved: Always reads 0
|
||||
uint8_t RES : 1; // Reserved: Always reads 0
|
||||
} REG10;
|
||||
|
||||
typedef struct {
|
||||
uint8_t VBUSV : 7; // ADC conversion of VBUS voltage (VBUS), offset: +2600mV
|
||||
bool VBUS_GD : 1; // VBUS Good Status
|
||||
bool VBUS_GD : 1; // VBUS Good Status
|
||||
} REG11;
|
||||
|
||||
typedef struct {
|
||||
uint8_t ICHGR : 7; // ADC conversion of Charge Current (IBAT) when VBAT > VBATSHORT
|
||||
uint8_t RES : 1; // Reserved: Always reads 0
|
||||
uint8_t RES : 1; // Reserved: Always reads 0
|
||||
} REG12;
|
||||
|
||||
typedef struct {
|
||||
@@ -267,9 +267,9 @@ typedef struct {
|
||||
} REG13;
|
||||
|
||||
typedef struct {
|
||||
uint8_t DEV_REV : 2; // Device Revision
|
||||
bool TS_PROFILE : 1; // Temperature Profile
|
||||
uint8_t PN : 3; // Device Configuration
|
||||
uint8_t DEV_REV : 2; // Device Revision
|
||||
bool TS_PROFILE : 1; // Temperature Profile
|
||||
uint8_t PN : 3; // Device Configuration
|
||||
bool ICO_OPTIMIZED : 1; // Input Current Optimizer (ICO) Status
|
||||
bool REG_RST : 1; // Register Reset
|
||||
bool REG_RST : 1; // Register Reset
|
||||
} REG14;
|
||||
|
||||
+23
-23
@@ -4,45 +4,45 @@
|
||||
#include <stdbool.h>
|
||||
#include <furi_hal_i2c.h>
|
||||
|
||||
#define BQ27220_ERROR 0x0
|
||||
#define BQ27220_ERROR 0x0
|
||||
#define BQ27220_SUCCESS 0x1
|
||||
|
||||
typedef struct {
|
||||
// Low byte, Low bit first
|
||||
bool DSG : 1; // The device is in DISCHARGE
|
||||
bool SYSDWN : 1; // System down bit indicating the system should shut down
|
||||
bool TDA : 1; // Terminate Discharge Alarm
|
||||
bool DSG : 1; // The device is in DISCHARGE
|
||||
bool SYSDWN : 1; // System down bit indicating the system should shut down
|
||||
bool TDA : 1; // Terminate Discharge Alarm
|
||||
bool BATTPRES : 1; // Battery Present detected
|
||||
bool AUTH_GD : 1; // Detect inserted battery
|
||||
bool OCVGD : 1; // Good OCV measurement taken
|
||||
bool TCA : 1; // Terminate Charge Alarm
|
||||
bool RSVD : 1; // Reserved
|
||||
bool AUTH_GD : 1; // Detect inserted battery
|
||||
bool OCVGD : 1; // Good OCV measurement taken
|
||||
bool TCA : 1; // Terminate Charge Alarm
|
||||
bool RSVD : 1; // Reserved
|
||||
// High byte, Low bit first
|
||||
bool CHGINH : 1; // Charge inhibit
|
||||
bool FC : 1; // Full-charged is detected
|
||||
bool OTD : 1; // Overtemperature in discharge condition is detected
|
||||
bool OTC : 1; // Overtemperature in charge condition is detected
|
||||
bool SLEEP : 1; // Device is operating in SLEEP mode when set
|
||||
bool OCVFAIL : 1; // Status bit indicating that the OCV reading failed due to current
|
||||
bool OCVCOMP : 1; // An OCV measurement update is complete
|
||||
bool FD : 1; // Full-discharge is detected
|
||||
bool CHGINH : 1; // Charge inhibit
|
||||
bool FC : 1; // Full-charged is detected
|
||||
bool OTD : 1; // Overtemperature in discharge condition is detected
|
||||
bool OTC : 1; // Overtemperature in charge condition is detected
|
||||
bool SLEEP : 1; // Device is operating in SLEEP mode when set
|
||||
bool OCVFAIL : 1; // Status bit indicating that the OCV reading failed due to current
|
||||
bool OCVCOMP : 1; // An OCV measurement update is complete
|
||||
bool FD : 1; // Full-discharge is detected
|
||||
} BatteryStatus;
|
||||
|
||||
_Static_assert(sizeof(BatteryStatus) == 2, "Incorrect structure size");
|
||||
|
||||
typedef struct {
|
||||
// Low byte, Low bit first
|
||||
bool CALMD : 1; /**< Calibration mode enabled */
|
||||
bool CALMD : 1; /**< Calibration mode enabled */
|
||||
uint8_t SEC : 2; /**< Current security access */
|
||||
bool EDV2 : 1; /**< EDV2 threshold exceeded */
|
||||
bool EDV2 : 1; /**< EDV2 threshold exceeded */
|
||||
bool VDQ : 1; /**< Indicates if Current discharge cycle is NOT qualified or qualified for an FCC updated */
|
||||
bool INITCOMP : 1; /**< gauge initialization is complete */
|
||||
bool SMTH : 1; /**< RemainingCapacity is scaled by smooth engine */
|
||||
bool BTPINT : 1; /**< BTP threshold has been crossed */
|
||||
bool INITCOMP : 1; /**< gauge initialization is complete */
|
||||
bool SMTH : 1; /**< RemainingCapacity is scaled by smooth engine */
|
||||
bool BTPINT : 1; /**< BTP threshold has been crossed */
|
||||
// High byte, Low bit first
|
||||
uint8_t RSVD1 : 2;
|
||||
uint8_t RSVD1 : 2;
|
||||
bool CFGUPDATE : 1; /**< Gauge is in CONFIG UPDATE mode */
|
||||
uint8_t RSVD0 : 5;
|
||||
uint8_t RSVD0 : 5;
|
||||
} OperationStatus;
|
||||
|
||||
_Static_assert(sizeof(OperationStatus) == 2, "Incorrect structure size");
|
||||
|
||||
@@ -67,18 +67,18 @@ struct BQ27220DMData {
|
||||
|
||||
typedef struct {
|
||||
// Low byte, Low bit first
|
||||
const bool CCT : 1;
|
||||
const bool CSYNC : 1;
|
||||
const bool RSVD0 : 1;
|
||||
const bool EDV_CMP : 1;
|
||||
const bool SC : 1;
|
||||
const bool CCT : 1;
|
||||
const bool CSYNC : 1;
|
||||
const bool RSVD0 : 1;
|
||||
const bool EDV_CMP : 1;
|
||||
const bool SC : 1;
|
||||
const bool FIXED_EDV0 : 1;
|
||||
const uint8_t RSVD1 : 2;
|
||||
const uint8_t RSVD1 : 2;
|
||||
// High byte, Low bit first
|
||||
const bool FCC_LIM : 1;
|
||||
const bool RSVD2 : 1;
|
||||
const bool FCC_LIM : 1;
|
||||
const bool RSVD2 : 1;
|
||||
const bool FC_FOR_VDQ : 1;
|
||||
const bool IGNORE_SD : 1;
|
||||
const bool SME0 : 1;
|
||||
const uint8_t RSVD3 : 3;
|
||||
const bool IGNORE_SD : 1;
|
||||
const bool SME0 : 1;
|
||||
const uint8_t RSVD3 : 3;
|
||||
} BQ27220DMGaugingConfig;
|
||||
|
||||
+61
-61
@@ -1,68 +1,68 @@
|
||||
#pragma once
|
||||
|
||||
#define BQ27220_ADDRESS 0xAA
|
||||
#define BQ27220_ADDRESS 0xAA
|
||||
#define BQ27220_I2C_TIMEOUT 50
|
||||
|
||||
#define CommandControl 0x00
|
||||
#define CommandAtRate 0x02
|
||||
#define CommandAtRateTimeToEmpty 0x04
|
||||
#define CommandTemperature 0x06
|
||||
#define CommandVoltage 0x08
|
||||
#define CommandBatteryStatus 0x0A
|
||||
#define CommandCurrent 0x0C
|
||||
#define CommandRemainingCapacity 0x10
|
||||
#define CommandFullChargeCapacity 0x12
|
||||
#define CommandAverageCurrent 0x14
|
||||
#define CommandTimeToEmpty 0x16
|
||||
#define CommandTimeToFull 0x18
|
||||
#define CommandStandbyCurrent 0x1A
|
||||
#define CommandStandbyTimeToEmpty 0x1C
|
||||
#define CommandMaxLoadCurrent 0x1E
|
||||
#define CommandMaxLoadTimeToEmpty 0x20
|
||||
#define CommandRawCoulombCount 0x22
|
||||
#define CommandAveragePower 0x24
|
||||
#define CommandControl 0x00
|
||||
#define CommandAtRate 0x02
|
||||
#define CommandAtRateTimeToEmpty 0x04
|
||||
#define CommandTemperature 0x06
|
||||
#define CommandVoltage 0x08
|
||||
#define CommandBatteryStatus 0x0A
|
||||
#define CommandCurrent 0x0C
|
||||
#define CommandRemainingCapacity 0x10
|
||||
#define CommandFullChargeCapacity 0x12
|
||||
#define CommandAverageCurrent 0x14
|
||||
#define CommandTimeToEmpty 0x16
|
||||
#define CommandTimeToFull 0x18
|
||||
#define CommandStandbyCurrent 0x1A
|
||||
#define CommandStandbyTimeToEmpty 0x1C
|
||||
#define CommandMaxLoadCurrent 0x1E
|
||||
#define CommandMaxLoadTimeToEmpty 0x20
|
||||
#define CommandRawCoulombCount 0x22
|
||||
#define CommandAveragePower 0x24
|
||||
#define CommandInternalTemperature 0x28
|
||||
#define CommandCycleCount 0x2A
|
||||
#define CommandStateOfCharge 0x2C
|
||||
#define CommandStateOfHealth 0x2E
|
||||
#define CommandChargeVoltage 0x30
|
||||
#define CommandChargeCurrent 0x32
|
||||
#define CommandBTPDischargeSet 0x34
|
||||
#define CommandBTPChargeSet 0x36
|
||||
#define CommandOperationStatus 0x3A
|
||||
#define CommandDesignCapacity 0x3C
|
||||
#define CommandSelectSubclass 0x3E
|
||||
#define CommandMACData 0x40
|
||||
#define CommandMACDataSum 0x60
|
||||
#define CommandMACDataLen 0x61
|
||||
#define CommandAnalogCount 0x79
|
||||
#define CommandRawCurrent 0x7A
|
||||
#define CommandRawVoltage 0x7C
|
||||
#define CommandRawIntTemp 0x7E
|
||||
#define CommandCycleCount 0x2A
|
||||
#define CommandStateOfCharge 0x2C
|
||||
#define CommandStateOfHealth 0x2E
|
||||
#define CommandChargeVoltage 0x30
|
||||
#define CommandChargeCurrent 0x32
|
||||
#define CommandBTPDischargeSet 0x34
|
||||
#define CommandBTPChargeSet 0x36
|
||||
#define CommandOperationStatus 0x3A
|
||||
#define CommandDesignCapacity 0x3C
|
||||
#define CommandSelectSubclass 0x3E
|
||||
#define CommandMACData 0x40
|
||||
#define CommandMACDataSum 0x60
|
||||
#define CommandMACDataLen 0x61
|
||||
#define CommandAnalogCount 0x79
|
||||
#define CommandRawCurrent 0x7A
|
||||
#define CommandRawVoltage 0x7C
|
||||
#define CommandRawIntTemp 0x7E
|
||||
|
||||
#define Control_CONTROL_STATUS 0x0000
|
||||
#define Control_DEVICE_NUMBER 0x0001
|
||||
#define Control_FW_VERSION 0x0002
|
||||
#define Control_BOARD_OFFSET 0x0009
|
||||
#define Control_CC_OFFSET 0x000A
|
||||
#define Control_CC_OFFSET_SAVE 0x000B
|
||||
#define Control_OCV_CMD 0x000C
|
||||
#define Control_BAT_INSERT 0x000D
|
||||
#define Control_BAT_REMOVE 0x000E
|
||||
#define Control_SET_SNOOZE 0x0013
|
||||
#define Control_CLEAR_SNOOZE 0x0014
|
||||
#define Control_SET_PROFILE_1 0x0015
|
||||
#define Control_SET_PROFILE_2 0x0016
|
||||
#define Control_SET_PROFILE_3 0x0017
|
||||
#define Control_SET_PROFILE_4 0x0018
|
||||
#define Control_SET_PROFILE_5 0x0019
|
||||
#define Control_SET_PROFILE_6 0x001A
|
||||
#define Control_CAL_TOGGLE 0x002D
|
||||
#define Control_SEALED 0x0030
|
||||
#define Control_RESET 0x0041
|
||||
#define Control_EXIT_CAL 0x0080
|
||||
#define Control_ENTER_CAL 0x0081
|
||||
#define Control_ENTER_CFG_UPDATE 0x0090
|
||||
#define Control_CONTROL_STATUS 0x0000
|
||||
#define Control_DEVICE_NUMBER 0x0001
|
||||
#define Control_FW_VERSION 0x0002
|
||||
#define Control_BOARD_OFFSET 0x0009
|
||||
#define Control_CC_OFFSET 0x000A
|
||||
#define Control_CC_OFFSET_SAVE 0x000B
|
||||
#define Control_OCV_CMD 0x000C
|
||||
#define Control_BAT_INSERT 0x000D
|
||||
#define Control_BAT_REMOVE 0x000E
|
||||
#define Control_SET_SNOOZE 0x0013
|
||||
#define Control_CLEAR_SNOOZE 0x0014
|
||||
#define Control_SET_PROFILE_1 0x0015
|
||||
#define Control_SET_PROFILE_2 0x0016
|
||||
#define Control_SET_PROFILE_3 0x0017
|
||||
#define Control_SET_PROFILE_4 0x0018
|
||||
#define Control_SET_PROFILE_5 0x0019
|
||||
#define Control_SET_PROFILE_6 0x001A
|
||||
#define Control_CAL_TOGGLE 0x002D
|
||||
#define Control_SEALED 0x0030
|
||||
#define Control_RESET 0x0041
|
||||
#define Control_EXIT_CAL 0x0080
|
||||
#define Control_ENTER_CAL 0x0081
|
||||
#define Control_ENTER_CFG_UPDATE 0x0090
|
||||
#define Control_EXIT_CFG_UPDATE_REINIT 0x0091
|
||||
#define Control_EXIT_CFG_UPDATE 0x0092
|
||||
#define Control_RETURN_TO_ROM 0x0F00
|
||||
#define Control_EXIT_CFG_UPDATE 0x0092
|
||||
#define Control_RETURN_TO_ROM 0x0F00
|
||||
|
||||
@@ -185,4 +185,4 @@ uint8_t cc1101_read_fifo(FuriHalSpiBusHandle* handle, uint8_t* data, uint8_t* si
|
||||
furi_hal_spi_bus_trx(handle, NULL, data, *size, CC1101_TIMEOUT);
|
||||
|
||||
return *size;
|
||||
}
|
||||
}
|
||||
|
||||
+59
-59
@@ -9,65 +9,65 @@ extern "C" {
|
||||
|
||||
/* Frequency Synthesizer constants */
|
||||
#define CC1101_QUARTZ 26000000
|
||||
#define CC1101_FMASK 0xFFFFFF
|
||||
#define CC1101_FDIV 0x10000
|
||||
#define CC1101_IFDIV 0x400
|
||||
#define CC1101_FMASK 0xFFFFFF
|
||||
#define CC1101_FDIV 0x10000
|
||||
#define CC1101_IFDIV 0x400
|
||||
|
||||
/* IO Bus constants */
|
||||
#define CC1101_TIMEOUT 250
|
||||
|
||||
/* Bits and pieces */
|
||||
#define CC1101_READ (1 << 7) /** Read Bit */
|
||||
#define CC1101_READ (1 << 7) /** Read Bit */
|
||||
#define CC1101_BURST (1 << 6) /** Burst Bit */
|
||||
|
||||
/* Common registers, CC1101_BURST and CC1101_WRITE behaves as expected */
|
||||
#define CC1101_IOCFG2 0x00 /** GDO2 output pin configuration */
|
||||
#define CC1101_IOCFG1 0x01 /** GDO1 output pin configuration */
|
||||
#define CC1101_IOCFG0 0x02 /** GDO0 output pin configuration */
|
||||
#define CC1101_FIFOTHR 0x03 /** RX FIFO and TX FIFO thresholds */
|
||||
#define CC1101_SYNC1 0x04 /** Sync word, high byte */
|
||||
#define CC1101_SYNC0 0x05 /** Sync word, low byte */
|
||||
#define CC1101_PKTLEN 0x06 /** Packet length */
|
||||
#define CC1101_IOCFG2 0x00 /** GDO2 output pin configuration */
|
||||
#define CC1101_IOCFG1 0x01 /** GDO1 output pin configuration */
|
||||
#define CC1101_IOCFG0 0x02 /** GDO0 output pin configuration */
|
||||
#define CC1101_FIFOTHR 0x03 /** RX FIFO and TX FIFO thresholds */
|
||||
#define CC1101_SYNC1 0x04 /** Sync word, high byte */
|
||||
#define CC1101_SYNC0 0x05 /** Sync word, low byte */
|
||||
#define CC1101_PKTLEN 0x06 /** Packet length */
|
||||
#define CC1101_PKTCTRL1 0x07 /** Packet automation control */
|
||||
#define CC1101_PKTCTRL0 0x08 /** Packet automation control */
|
||||
#define CC1101_ADDR 0x09 /** Device address */
|
||||
#define CC1101_CHANNR 0x0A /** Channel number */
|
||||
#define CC1101_FSCTRL1 0x0B /** Frequency synthesizer control */
|
||||
#define CC1101_FSCTRL0 0x0C /** Frequency synthesizer control */
|
||||
#define CC1101_FREQ2 0x0D /** Frequency control word, high byte */
|
||||
#define CC1101_FREQ1 0x0E /** Frequency control word, middle byte */
|
||||
#define CC1101_FREQ0 0x0F /** Frequency control word, low byte */
|
||||
#define CC1101_MDMCFG4 0x10 /** Modem configuration */
|
||||
#define CC1101_MDMCFG3 0x11 /** Modem configuration */
|
||||
#define CC1101_MDMCFG2 0x12 /** Modem configuration */
|
||||
#define CC1101_MDMCFG1 0x13 /** Modem configuration */
|
||||
#define CC1101_MDMCFG0 0x14 /** Modem configuration */
|
||||
#define CC1101_DEVIATN 0x15 /** Modem deviation setting */
|
||||
#define CC1101_MCSM2 0x16 /** Main Radio Control State Machine configuration */
|
||||
#define CC1101_MCSM1 0x17 /** Main Radio Control State Machine configuration */
|
||||
#define CC1101_MCSM0 0x18 /** Main Radio Control State Machine configuration */
|
||||
#define CC1101_FOCCFG 0x19 /** Frequency Offset Compensation configuration */
|
||||
#define CC1101_BSCFG 0x1A /** Bit Synchronization configuration */
|
||||
#define CC1101_ADDR 0x09 /** Device address */
|
||||
#define CC1101_CHANNR 0x0A /** Channel number */
|
||||
#define CC1101_FSCTRL1 0x0B /** Frequency synthesizer control */
|
||||
#define CC1101_FSCTRL0 0x0C /** Frequency synthesizer control */
|
||||
#define CC1101_FREQ2 0x0D /** Frequency control word, high byte */
|
||||
#define CC1101_FREQ1 0x0E /** Frequency control word, middle byte */
|
||||
#define CC1101_FREQ0 0x0F /** Frequency control word, low byte */
|
||||
#define CC1101_MDMCFG4 0x10 /** Modem configuration */
|
||||
#define CC1101_MDMCFG3 0x11 /** Modem configuration */
|
||||
#define CC1101_MDMCFG2 0x12 /** Modem configuration */
|
||||
#define CC1101_MDMCFG1 0x13 /** Modem configuration */
|
||||
#define CC1101_MDMCFG0 0x14 /** Modem configuration */
|
||||
#define CC1101_DEVIATN 0x15 /** Modem deviation setting */
|
||||
#define CC1101_MCSM2 0x16 /** Main Radio Control State Machine configuration */
|
||||
#define CC1101_MCSM1 0x17 /** Main Radio Control State Machine configuration */
|
||||
#define CC1101_MCSM0 0x18 /** Main Radio Control State Machine configuration */
|
||||
#define CC1101_FOCCFG 0x19 /** Frequency Offset Compensation configuration */
|
||||
#define CC1101_BSCFG 0x1A /** Bit Synchronization configuration */
|
||||
#define CC1101_AGCCTRL2 0x1B /** AGC control */
|
||||
#define CC1101_AGCCTRL1 0x1C /** AGC control */
|
||||
#define CC1101_AGCCTRL0 0x1D /** AGC control */
|
||||
#define CC1101_WOREVT1 0x1E /** High byte Event 0 timeout */
|
||||
#define CC1101_WOREVT0 0x1F /** Low byte Event 0 timeout */
|
||||
#define CC1101_WORCTRL 0x20 /** Wake On Radio control */
|
||||
#define CC1101_FREND1 0x21 /** Front end RX configuration */
|
||||
#define CC1101_FREND0 0x22 /** Front end TX configuration */
|
||||
#define CC1101_FSCAL3 0x23 /** Frequency synthesizer calibration */
|
||||
#define CC1101_FSCAL2 0x24 /** Frequency synthesizer calibration */
|
||||
#define CC1101_FSCAL1 0x25 /** Frequency synthesizer calibration */
|
||||
#define CC1101_FSCAL0 0x26 /** Frequency synthesizer calibration */
|
||||
#define CC1101_RCCTRL1 0x27 /** RC oscillator configuration */
|
||||
#define CC1101_RCCTRL0 0x28 /** RC oscillator configuration */
|
||||
#define CC1101_FSTEST 0x29 /** Frequency synthesizer calibration control */
|
||||
#define CC1101_PTEST 0x2A /** Production test */
|
||||
#define CC1101_AGCTEST 0x2B /** AGC test */
|
||||
#define CC1101_TEST2 0x2C /** Various test settings */
|
||||
#define CC1101_TEST1 0x2D /** Various test settings */
|
||||
#define CC1101_TEST0 0x2E /** Various test settings */
|
||||
#define CC1101_WOREVT1 0x1E /** High byte Event 0 timeout */
|
||||
#define CC1101_WOREVT0 0x1F /** Low byte Event 0 timeout */
|
||||
#define CC1101_WORCTRL 0x20 /** Wake On Radio control */
|
||||
#define CC1101_FREND1 0x21 /** Front end RX configuration */
|
||||
#define CC1101_FREND0 0x22 /** Front end TX configuration */
|
||||
#define CC1101_FSCAL3 0x23 /** Frequency synthesizer calibration */
|
||||
#define CC1101_FSCAL2 0x24 /** Frequency synthesizer calibration */
|
||||
#define CC1101_FSCAL1 0x25 /** Frequency synthesizer calibration */
|
||||
#define CC1101_FSCAL0 0x26 /** Frequency synthesizer calibration */
|
||||
#define CC1101_RCCTRL1 0x27 /** RC oscillator configuration */
|
||||
#define CC1101_RCCTRL0 0x28 /** RC oscillator configuration */
|
||||
#define CC1101_FSTEST 0x29 /** Frequency synthesizer calibration control */
|
||||
#define CC1101_PTEST 0x2A /** Production test */
|
||||
#define CC1101_AGCTEST 0x2B /** AGC test */
|
||||
#define CC1101_TEST2 0x2C /** Various test settings */
|
||||
#define CC1101_TEST1 0x2D /** Various test settings */
|
||||
#define CC1101_TEST0 0x2E /** Various test settings */
|
||||
|
||||
/* Strobe registers, CC1101_BURST is not available, CC1101_WRITE ignored */
|
||||
#define CC1101_STROBE_SRES 0x30 /** Reset chip. */
|
||||
@@ -95,15 +95,15 @@ extern "C" {
|
||||
0x3D /** No operation. May be used to get access to the chip status byte.*/
|
||||
|
||||
/* Status registers, must be accessed with CC1101_BURST, but one by one */
|
||||
#define CC1101_STATUS_PARTNUM 0x30 /** Chip ID Part Number */
|
||||
#define CC1101_STATUS_VERSION 0x31 /** Chip ID Version */
|
||||
#define CC1101_STATUS_FREQEST 0x32 /** Frequency Offset Estimate from Demodulator */
|
||||
#define CC1101_STATUS_LQI 0x33 /** Demodulator Estimate for Link Quality, 7bit-CRC, 6..0-LQI*/
|
||||
#define CC1101_STATUS_RSSI 0x34 /** Received Signal Strength Indication */
|
||||
#define CC1101_STATUS_MARCSTATE 0x35 /** Main Radio Control State Machine State */
|
||||
#define CC1101_STATUS_WORTIME1 0x36 /** High Byte of WOR Time */
|
||||
#define CC1101_STATUS_WORTIME0 0x37 /** Low Byte of WOR Time */
|
||||
#define CC1101_STATUS_PKTSTATUS 0x38 /** Current GDOx Status and Packet Status */
|
||||
#define CC1101_STATUS_PARTNUM 0x30 /** Chip ID Part Number */
|
||||
#define CC1101_STATUS_VERSION 0x31 /** Chip ID Version */
|
||||
#define CC1101_STATUS_FREQEST 0x32 /** Frequency Offset Estimate from Demodulator */
|
||||
#define CC1101_STATUS_LQI 0x33 /** Demodulator Estimate for Link Quality, 7bit-CRC, 6..0-LQI*/
|
||||
#define CC1101_STATUS_RSSI 0x34 /** Received Signal Strength Indication */
|
||||
#define CC1101_STATUS_MARCSTATE 0x35 /** Main Radio Control State Machine State */
|
||||
#define CC1101_STATUS_WORTIME1 0x36 /** High Byte of WOR Time */
|
||||
#define CC1101_STATUS_WORTIME0 0x37 /** Low Byte of WOR Time */
|
||||
#define CC1101_STATUS_PKTSTATUS 0x38 /** Current GDOx Status and Packet Status */
|
||||
#define CC1101_STATUS_VCO_VC_DAC 0x39 /** Current Setting from PLL Calibration Module */
|
||||
#define CC1101_STATUS_TXBYTES \
|
||||
0x3A /** Underflow and Number of Bytes, 7bit-Underflow, 6..0-Number of Bytes*/
|
||||
@@ -188,8 +188,8 @@ typedef enum {
|
||||
|
||||
typedef struct {
|
||||
uint8_t FIFO_BYTES_AVAILABLE : 4;
|
||||
CC1101State STATE : 3;
|
||||
bool CHIP_RDYn : 1;
|
||||
CC1101State STATE : 3;
|
||||
bool CHIP_RDYn : 1;
|
||||
} CC1101Status;
|
||||
|
||||
typedef union {
|
||||
@@ -198,12 +198,12 @@ typedef union {
|
||||
} CC1101StatusRaw;
|
||||
|
||||
typedef struct {
|
||||
uint8_t NUM_TXBYTES : 7;
|
||||
uint8_t NUM_TXBYTES : 7;
|
||||
bool TXFIFO_UNDERFLOW : 1;
|
||||
} CC1101TxBytes;
|
||||
|
||||
typedef struct {
|
||||
uint8_t NUM_RXBYTES : 7;
|
||||
uint8_t NUM_RXBYTES : 7;
|
||||
bool RXFIFO_OVERFLOW : 1;
|
||||
} CC1101RxBytes;
|
||||
|
||||
|
||||
+21
-21
@@ -4,17 +4,17 @@
|
||||
#error Bit structures defined in this file is not portable to BE
|
||||
#endif
|
||||
|
||||
#define LP5562_ADDRESS 0x60
|
||||
#define LP5562_ADDRESS 0x60
|
||||
#define LP5562_I2C_TIMEOUT 50
|
||||
|
||||
#define LP5562_CHANNEL_RED_CURRENT_REGISTER 0x07
|
||||
#define LP5562_CHANNEL_RED_CURRENT_REGISTER 0x07
|
||||
#define LP5562_CHANNEL_GREEN_CURRENT_REGISTER 0x06
|
||||
#define LP5562_CHANNEL_BLUE_CURRENT_REGISTER 0x05
|
||||
#define LP5562_CHANNEL_BLUE_CURRENT_REGISTER 0x05
|
||||
#define LP5562_CHANNEL_WHITE_CURRENT_REGISTER 0x0F
|
||||
|
||||
#define LP5562_CHANNEL_RED_VALUE_REGISTER 0x04
|
||||
#define LP5562_CHANNEL_RED_VALUE_REGISTER 0x04
|
||||
#define LP5562_CHANNEL_GREEN_VALUE_REGISTER 0x03
|
||||
#define LP5562_CHANNEL_BLUE_VALUE_REGISTER 0x02
|
||||
#define LP5562_CHANNEL_BLUE_VALUE_REGISTER 0x02
|
||||
#define LP5562_CHANNEL_WHITE_VALUE_REGISTER 0x0E
|
||||
|
||||
typedef enum {
|
||||
@@ -28,8 +28,8 @@ typedef struct {
|
||||
EngExec ENG3_EXEC : 2;
|
||||
EngExec ENG2_EXEC : 2;
|
||||
EngExec ENG1_EXEC : 2;
|
||||
bool CHIP_EN : 1;
|
||||
bool LOG_EN : 1;
|
||||
bool CHIP_EN : 1;
|
||||
bool LOG_EN : 1;
|
||||
} Reg00_Enable;
|
||||
|
||||
typedef enum {
|
||||
@@ -43,39 +43,39 @@ typedef struct {
|
||||
EngMode ENG3_MODE : 2;
|
||||
EngMode ENG2_MODE : 2;
|
||||
EngMode ENG1_MODE : 2;
|
||||
uint8_t reserved : 2;
|
||||
uint8_t reserved : 2;
|
||||
} Reg01_OpMode;
|
||||
|
||||
typedef struct {
|
||||
bool INT_CLK_EN : 1;
|
||||
bool CLK_DET_EN : 1;
|
||||
bool INT_CLK_EN : 1;
|
||||
bool CLK_DET_EN : 1;
|
||||
uint8_t reserved0 : 3;
|
||||
bool PS_EN : 1;
|
||||
bool PWM_HF : 1;
|
||||
bool PS_EN : 1;
|
||||
bool PWM_HF : 1;
|
||||
uint8_t reserved1 : 1;
|
||||
} Reg08_Config;
|
||||
|
||||
typedef struct {
|
||||
uint8_t pc : 3;
|
||||
uint8_t pc : 3;
|
||||
uint8_t reserved : 5;
|
||||
} Reg09_Engine1PC;
|
||||
|
||||
typedef struct {
|
||||
uint8_t pc : 3;
|
||||
uint8_t pc : 3;
|
||||
uint8_t reserved : 5;
|
||||
} Reg0A_Engine2PC;
|
||||
|
||||
typedef struct {
|
||||
uint8_t pc : 3;
|
||||
uint8_t pc : 3;
|
||||
uint8_t reserved : 5;
|
||||
} Reg0B_Engine3PC;
|
||||
|
||||
typedef struct {
|
||||
bool ENG3_INT : 1;
|
||||
bool ENG2_INT : 1;
|
||||
bool ENG1_INT : 1;
|
||||
bool ENG3_INT : 1;
|
||||
bool ENG2_INT : 1;
|
||||
bool ENG1_INT : 1;
|
||||
bool EXT_CLK_USED : 1;
|
||||
uint8_t reserved : 5;
|
||||
uint8_t reserved : 5;
|
||||
} Reg0C_Status;
|
||||
|
||||
typedef struct {
|
||||
@@ -90,8 +90,8 @@ typedef enum {
|
||||
} EngSelect;
|
||||
|
||||
typedef struct {
|
||||
EngSelect blue : 2;
|
||||
EngSelect blue : 2;
|
||||
EngSelect green : 2;
|
||||
EngSelect red : 2;
|
||||
EngSelect red : 2;
|
||||
EngSelect white : 2;
|
||||
} Reg70_LedMap;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ST25R3916_IRQ_MASK_ALL (uint32_t)(0xFFFFFFFFUL) /** All ST25R3916 interrupt sources */
|
||||
#define ST25R3916_IRQ_MASK_ALL (uint32_t)(0xFFFFFFFFUL) /** All ST25R3916 interrupt sources */
|
||||
#define ST25R3916_IRQ_MASK_NONE (uint32_t)(0x00000000UL) /**No ST25R3916 interrupt source */
|
||||
|
||||
/** Main interrupt register */
|
||||
|
||||
@@ -253,5 +253,5 @@ bool st25r3916_check_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t mask,
|
||||
|
||||
uint8_t reg_val = 0;
|
||||
st25r3916_read_reg(handle, reg, ®_val);
|
||||
return ((reg_val & mask) == val);
|
||||
return (reg_val & mask) == val;
|
||||
}
|
||||
|
||||
+632
-632
File diff suppressed because it is too large
Load Diff
@@ -122,7 +122,11 @@ bool flipper_format_stream_seek_to_key(Stream* stream, const char* key, bool str
|
||||
}
|
||||
|
||||
static bool flipper_format_stream_read_value(Stream* stream, FuriString* value, bool* last) {
|
||||
enum { LeadingSpace, ReadValue, TrailingSpace } state = LeadingSpace;
|
||||
enum {
|
||||
LeadingSpace,
|
||||
ReadValue,
|
||||
TrailingSpace
|
||||
} state = LeadingSpace;
|
||||
const size_t buffer_size = 32;
|
||||
uint8_t buffer[buffer_size];
|
||||
bool result = false;
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
iButtonProtocolGroupInfo info; \
|
||||
ibutton_protocols_get_group_by_id(protocols, (id), &info);
|
||||
|
||||
#define GROUP_BASE (info.base)
|
||||
#define GROUP_DATA (info.group)
|
||||
#define GROUP_BASE (info.base)
|
||||
#define GROUP_DATA (info.group)
|
||||
#define PROTOCOL_ID (info.id)
|
||||
|
||||
struct iButtonProtocols {
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
#include <core/kernel.h>
|
||||
|
||||
#define RW1990_1_CMD_WRITE_RECORD_FLAG 0xD1
|
||||
#define RW1990_1_CMD_READ_RECORD_FLAG 0xB5
|
||||
#define RW1990_1_CMD_WRITE_ROM 0xD5
|
||||
#define RW1990_1_CMD_READ_RECORD_FLAG 0xB5
|
||||
#define RW1990_1_CMD_WRITE_ROM 0xD5
|
||||
|
||||
#define RW1990_2_CMD_WRITE_RECORD_FLAG 0x1D
|
||||
#define RW1990_2_CMD_READ_RECORD_FLAG 0x1E
|
||||
#define RW1990_2_CMD_WRITE_ROM 0xD5
|
||||
#define RW1990_2_CMD_READ_RECORD_FLAG 0x1E
|
||||
#define RW1990_2_CMD_WRITE_ROM 0xD5
|
||||
|
||||
#define DS1990_CMD_READ_ROM 0x33
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
#include <core/kernel.h>
|
||||
|
||||
#define TM2004_CMD_READ_STATUS 0xAA
|
||||
#define TM2004_CMD_READ_MEMORY 0xF0
|
||||
#define TM2004_CMD_WRITE_ROM 0x3C
|
||||
#define TM2004_CMD_FINALIZATION 0x35
|
||||
#define TM2004_CMD_READ_STATUS 0xAA
|
||||
#define TM2004_CMD_READ_MEMORY 0xF0
|
||||
#define TM2004_CMD_WRITE_ROM 0x3C
|
||||
#define TM2004_CMD_FINALIZATION 0x35
|
||||
#define TM2004_ANSWER_READ_MEMORY 0xF5
|
||||
|
||||
bool tm2004_write(OneWireHost* host, const uint8_t* data, size_t data_size) {
|
||||
|
||||
@@ -9,12 +9,12 @@
|
||||
#define DALLAS_COMMON_ROM_DATA_KEY_V2 "Rom Data"
|
||||
|
||||
#define DALLAS_COMMON_COPY_SCRATCH_MIN_TIMEOUT_US 5U
|
||||
#define DALLAS_COMMON_COPY_SCRATCH_POLL_COUNT 20U
|
||||
#define DALLAS_COMMON_COPY_SCRATCH_POLL_COUNT 20U
|
||||
|
||||
#define DALLAS_COMMON_END_ADDRESS_MASK 0x01F
|
||||
#define DALLAS_COMMON_STATUS_FLAG_PF (1U << 5)
|
||||
#define DALLAS_COMMON_STATUS_FLAG_OF (1U << 6)
|
||||
#define DALLAS_COMMON_STATUS_FLAG_AA (1U << 7)
|
||||
#define DALLAS_COMMON_STATUS_FLAG_PF (1U << 5)
|
||||
#define DALLAS_COMMON_STATUS_FLAG_OF (1U << 6)
|
||||
#define DALLAS_COMMON_STATUS_FLAG_AA (1U << 7)
|
||||
|
||||
#define DALLAS_COMMON_BRIEF_HEAD_COUNT 4U
|
||||
#define DALLAS_COMMON_BRIEF_TAIL_COUNT 3U
|
||||
|
||||
@@ -7,19 +7,19 @@
|
||||
|
||||
#define DALLAS_COMMON_MANUFACTURER_NAME "Dallas"
|
||||
|
||||
#define DALLAS_COMMON_CMD_READ_ROM 0x33U
|
||||
#define DALLAS_COMMON_CMD_MATCH_ROM 0x55U
|
||||
#define DALLAS_COMMON_CMD_SKIP_ROM 0xCCU
|
||||
#define DALLAS_COMMON_CMD_READ_ROM 0x33U
|
||||
#define DALLAS_COMMON_CMD_MATCH_ROM 0x55U
|
||||
#define DALLAS_COMMON_CMD_SKIP_ROM 0xCCU
|
||||
#define DALLAS_COMMON_CMD_COND_SEARCH 0xECU
|
||||
#define DALLAS_COMMON_CMD_SEARCH_ROM 0xF0U
|
||||
#define DALLAS_COMMON_CMD_SEARCH_ROM 0xF0U
|
||||
|
||||
#define DALLAS_COMMON_CMD_READ_SCRATCH 0xAAU
|
||||
#define DALLAS_COMMON_CMD_READ_SCRATCH 0xAAU
|
||||
#define DALLAS_COMMON_CMD_WRITE_SCRATCH 0x0FU
|
||||
#define DALLAS_COMMON_CMD_COPY_SCRATCH 0x55U
|
||||
#define DALLAS_COMMON_CMD_COPY_SCRATCH 0x55U
|
||||
|
||||
#define DALLAS_COMMON_CMD_READ_MEM 0xF0U
|
||||
|
||||
#define DALLAS_COMMON_CMD_OVERDRIVE_SKIP_ROM 0x3CU
|
||||
#define DALLAS_COMMON_CMD_OVERDRIVE_SKIP_ROM 0x3CU
|
||||
#define DALLAS_COMMON_CMD_OVERDRIVE_MATCH_ROM 0x69U
|
||||
|
||||
typedef enum {
|
||||
|
||||
@@ -8,14 +8,14 @@
|
||||
#define DS1971_FAMILY_CODE 0x14U
|
||||
#define DS1971_FAMILY_NAME "DS1971"
|
||||
|
||||
#define DS1971_EEPROM_DATA_SIZE 32U
|
||||
#define DS1971_SRAM_PAGE_SIZE 32U
|
||||
#define DS1971_EEPROM_DATA_SIZE 32U
|
||||
#define DS1971_SRAM_PAGE_SIZE 32U
|
||||
#define DS1971_COPY_SCRATCH_DELAY_US 250U
|
||||
|
||||
#define DS1971_DATA_BYTE_COUNT 4U
|
||||
|
||||
#define DS1971_EEPROM_DATA_KEY "Eeprom Data"
|
||||
#define DS1971_MEMORY_TYPE "EEPROM"
|
||||
#define DS1971_MEMORY_TYPE "EEPROM"
|
||||
|
||||
#define DS1971_CMD_FINALIZATION 0xA5
|
||||
|
||||
|
||||
@@ -10,14 +10,14 @@
|
||||
#define DS1992_FAMILY_CODE 0x08U
|
||||
#define DS1992_FAMILY_NAME "DS1992"
|
||||
|
||||
#define DS1992_SRAM_DATA_SIZE 128U
|
||||
#define DS1992_SRAM_PAGE_SIZE 4U
|
||||
#define DS1992_SRAM_DATA_SIZE 128U
|
||||
#define DS1992_SRAM_PAGE_SIZE 4U
|
||||
#define DS1992_COPY_SCRATCH_TIMEOUT_US 100U
|
||||
|
||||
#define DS1992_DATA_BYTE_COUNT 4U
|
||||
|
||||
#define DS1992_SRAM_DATA_KEY "Sram Data"
|
||||
#define DS1992_MEMORY_TYPE "SRAM"
|
||||
#define DS1992_MEMORY_TYPE "SRAM"
|
||||
|
||||
typedef struct {
|
||||
OneWireSlave* bus;
|
||||
|
||||
@@ -8,14 +8,14 @@
|
||||
#define DS1996_FAMILY_CODE 0x0CU
|
||||
#define DS1996_FAMILY_NAME "DS1996"
|
||||
|
||||
#define DS1996_SRAM_DATA_SIZE 8192U
|
||||
#define DS1996_SRAM_PAGE_SIZE 32U
|
||||
#define DS1996_SRAM_DATA_SIZE 8192U
|
||||
#define DS1996_SRAM_PAGE_SIZE 32U
|
||||
#define DS1996_COPY_SCRATCH_TIMEOUT_US 100U
|
||||
|
||||
#define DS1996_DATA_BYTE_COUNT 4U
|
||||
|
||||
#define DS1996_SRAM_DATA_KEY "Sram Data"
|
||||
#define DS1996_MEMORY_TYPE "SRAM"
|
||||
#define DS1996_MEMORY_TYPE "SRAM"
|
||||
|
||||
typedef struct {
|
||||
OneWireSlave* bus;
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
#include "protocol_cyfral.h"
|
||||
|
||||
#define CYFRAL_DATA_SIZE sizeof(uint16_t)
|
||||
#define CYFRAL_PERIOD (125 * furi_hal_cortex_instructions_per_microsecond())
|
||||
#define CYFRAL_0_LOW (CYFRAL_PERIOD * 0.66f)
|
||||
#define CYFRAL_0_HI (CYFRAL_PERIOD * 0.33f)
|
||||
#define CYFRAL_1_LOW (CYFRAL_PERIOD * 0.33f)
|
||||
#define CYFRAL_1_HI (CYFRAL_PERIOD * 0.66f)
|
||||
#define CYFRAL_PERIOD (125 * furi_hal_cortex_instructions_per_microsecond())
|
||||
#define CYFRAL_0_LOW (CYFRAL_PERIOD * 0.66f)
|
||||
#define CYFRAL_0_HI (CYFRAL_PERIOD * 0.33f)
|
||||
#define CYFRAL_1_LOW (CYFRAL_PERIOD * 0.33f)
|
||||
#define CYFRAL_1_HI (CYFRAL_PERIOD * 0.66f)
|
||||
|
||||
#define CYFRAL_MAX_PERIOD_US 230
|
||||
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
#include "protocol_metakom.h"
|
||||
|
||||
#define METAKOM_DATA_SIZE sizeof(uint32_t)
|
||||
#define METAKOM_PERIOD (125 * furi_hal_cortex_instructions_per_microsecond())
|
||||
#define METAKOM_0_LOW (METAKOM_PERIOD * 0.33f)
|
||||
#define METAKOM_0_HI (METAKOM_PERIOD * 0.66f)
|
||||
#define METAKOM_1_LOW (METAKOM_PERIOD * 0.66f)
|
||||
#define METAKOM_1_HI (METAKOM_PERIOD * 0.33f)
|
||||
#define METAKOM_PERIOD (125 * furi_hal_cortex_instructions_per_microsecond())
|
||||
#define METAKOM_0_LOW (METAKOM_PERIOD * 0.33f)
|
||||
#define METAKOM_0_HI (METAKOM_PERIOD * 0.66f)
|
||||
#define METAKOM_1_LOW (METAKOM_PERIOD * 0.66f)
|
||||
#define METAKOM_1_HI (METAKOM_PERIOD * 0.33f)
|
||||
|
||||
#define METAKOM_PERIOD_SAMPLE_COUNT 10
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#define INFRARED_COMMON_CARRIER_FREQUENCY ((uint32_t)38000)
|
||||
#define INFRARED_COMMON_DUTY_CYCLE ((float)0.33)
|
||||
#define INFRARED_COMMON_DUTY_CYCLE ((float)0.33)
|
||||
|
||||
/* if we want to see split raw signals during bruteforce,
|
||||
* we have to have RX raw timing delay less than TX */
|
||||
|
||||
@@ -2,23 +2,23 @@
|
||||
|
||||
#include "../common/infrared_common_i.h"
|
||||
|
||||
#define INFRARED_KASEIKYO_UNIT 432
|
||||
#define INFRARED_KASEIKYO_PREAMBLE_MARK (8 * INFRARED_KASEIKYO_UNIT)
|
||||
#define INFRARED_KASEIKYO_PREAMBLE_SPACE (4 * INFRARED_KASEIKYO_UNIT)
|
||||
#define INFRARED_KASEIKYO_BIT1_MARK INFRARED_KASEIKYO_UNIT
|
||||
#define INFRARED_KASEIKYO_BIT1_SPACE (3 * INFRARED_KASEIKYO_UNIT)
|
||||
#define INFRARED_KASEIKYO_BIT0_MARK INFRARED_KASEIKYO_UNIT
|
||||
#define INFRARED_KASEIKYO_BIT0_SPACE INFRARED_KASEIKYO_UNIT
|
||||
#define INFRARED_KASEIKYO_REPEAT_PERIOD 130000
|
||||
#define INFRARED_KASEIKYO_SILENCE INFRARED_KASEIKYO_REPEAT_PERIOD
|
||||
#define INFRARED_KASEIKYO_MIN_SPLIT_TIME INFRARED_KASEIKYO_REPEAT_PAUSE_MIN
|
||||
#define INFRARED_KASEIKYO_REPEAT_PAUSE_MIN 4000
|
||||
#define INFRARED_KASEIKYO_REPEAT_PAUSE_MAX 150000
|
||||
#define INFRARED_KASEIKYO_REPEAT_COUNT_MIN 1
|
||||
#define INFRARED_KASEIKYO_REPEAT_MARK INFRARED_KASEIKYO_PREAMBLE_MARK
|
||||
#define INFRARED_KASEIKYO_REPEAT_SPACE (INFRARED_KASEIKYO_REPEAT_PERIOD - 56000)
|
||||
#define INFRARED_KASEIKYO_UNIT 432
|
||||
#define INFRARED_KASEIKYO_PREAMBLE_MARK (8 * INFRARED_KASEIKYO_UNIT)
|
||||
#define INFRARED_KASEIKYO_PREAMBLE_SPACE (4 * INFRARED_KASEIKYO_UNIT)
|
||||
#define INFRARED_KASEIKYO_BIT1_MARK INFRARED_KASEIKYO_UNIT
|
||||
#define INFRARED_KASEIKYO_BIT1_SPACE (3 * INFRARED_KASEIKYO_UNIT)
|
||||
#define INFRARED_KASEIKYO_BIT0_MARK INFRARED_KASEIKYO_UNIT
|
||||
#define INFRARED_KASEIKYO_BIT0_SPACE INFRARED_KASEIKYO_UNIT
|
||||
#define INFRARED_KASEIKYO_REPEAT_PERIOD 130000
|
||||
#define INFRARED_KASEIKYO_SILENCE INFRARED_KASEIKYO_REPEAT_PERIOD
|
||||
#define INFRARED_KASEIKYO_MIN_SPLIT_TIME INFRARED_KASEIKYO_REPEAT_PAUSE_MIN
|
||||
#define INFRARED_KASEIKYO_REPEAT_PAUSE_MIN 4000
|
||||
#define INFRARED_KASEIKYO_REPEAT_PAUSE_MAX 150000
|
||||
#define INFRARED_KASEIKYO_REPEAT_COUNT_MIN 1
|
||||
#define INFRARED_KASEIKYO_REPEAT_MARK INFRARED_KASEIKYO_PREAMBLE_MARK
|
||||
#define INFRARED_KASEIKYO_REPEAT_SPACE (INFRARED_KASEIKYO_REPEAT_PERIOD - 56000)
|
||||
#define INFRARED_KASEIKYO_PREAMBLE_TOLERANCE 200 // us
|
||||
#define INFRARED_KASEIKYO_BIT_TOLERANCE 120 // us
|
||||
#define INFRARED_KASEIKYO_BIT_TOLERANCE 120 // us
|
||||
|
||||
extern const InfraredCommonProtocolSpec infrared_protocol_kaseikyo;
|
||||
|
||||
|
||||
@@ -2,22 +2,22 @@
|
||||
|
||||
#include "../common/infrared_common_i.h"
|
||||
|
||||
#define INFRARED_NEC_PREAMBLE_MARK 9000
|
||||
#define INFRARED_NEC_PREAMBLE_SPACE 4500
|
||||
#define INFRARED_NEC_BIT1_MARK 560
|
||||
#define INFRARED_NEC_BIT1_SPACE 1690
|
||||
#define INFRARED_NEC_BIT0_MARK 560
|
||||
#define INFRARED_NEC_BIT0_SPACE 560
|
||||
#define INFRARED_NEC_REPEAT_PERIOD 110000
|
||||
#define INFRARED_NEC_SILENCE INFRARED_NEC_REPEAT_PERIOD
|
||||
#define INFRARED_NEC_MIN_SPLIT_TIME INFRARED_NEC_REPEAT_PAUSE_MIN
|
||||
#define INFRARED_NEC_REPEAT_PAUSE_MIN 4000
|
||||
#define INFRARED_NEC_REPEAT_PAUSE_MAX 150000
|
||||
#define INFRARED_NEC_REPEAT_COUNT_MIN 1
|
||||
#define INFRARED_NEC_REPEAT_MARK 9000
|
||||
#define INFRARED_NEC_REPEAT_SPACE 2250
|
||||
#define INFRARED_NEC_PREAMBLE_MARK 9000
|
||||
#define INFRARED_NEC_PREAMBLE_SPACE 4500
|
||||
#define INFRARED_NEC_BIT1_MARK 560
|
||||
#define INFRARED_NEC_BIT1_SPACE 1690
|
||||
#define INFRARED_NEC_BIT0_MARK 560
|
||||
#define INFRARED_NEC_BIT0_SPACE 560
|
||||
#define INFRARED_NEC_REPEAT_PERIOD 110000
|
||||
#define INFRARED_NEC_SILENCE INFRARED_NEC_REPEAT_PERIOD
|
||||
#define INFRARED_NEC_MIN_SPLIT_TIME INFRARED_NEC_REPEAT_PAUSE_MIN
|
||||
#define INFRARED_NEC_REPEAT_PAUSE_MIN 4000
|
||||
#define INFRARED_NEC_REPEAT_PAUSE_MAX 150000
|
||||
#define INFRARED_NEC_REPEAT_COUNT_MIN 1
|
||||
#define INFRARED_NEC_REPEAT_MARK 9000
|
||||
#define INFRARED_NEC_REPEAT_SPACE 2250
|
||||
#define INFRARED_NEC_PREAMBLE_TOLERANCE 200 // us
|
||||
#define INFRARED_NEC_BIT_TOLERANCE 120 // us
|
||||
#define INFRARED_NEC_BIT_TOLERANCE 120 // us
|
||||
|
||||
extern const InfraredCommonProtocolSpec infrared_protocol_nec;
|
||||
|
||||
|
||||
@@ -2,19 +2,19 @@
|
||||
|
||||
#include "../common/infrared_common_i.h"
|
||||
|
||||
#define INFRARED_PIONEER_CARRIER_FREQUENCY 40000
|
||||
#define INFRARED_PIONEER_DUTY_CYCLE 0.33
|
||||
#define INFRARED_PIONEER_PREAMBLE_MARK 8500
|
||||
#define INFRARED_PIONEER_PREAMBLE_SPACE 4225
|
||||
#define INFRARED_PIONEER_BIT1_MARK 500
|
||||
#define INFRARED_PIONEER_BIT1_SPACE 1500
|
||||
#define INFRARED_PIONEER_BIT0_MARK 500
|
||||
#define INFRARED_PIONEER_BIT0_SPACE 500
|
||||
#define INFRARED_PIONEER_CARRIER_FREQUENCY 40000
|
||||
#define INFRARED_PIONEER_DUTY_CYCLE 0.33
|
||||
#define INFRARED_PIONEER_PREAMBLE_MARK 8500
|
||||
#define INFRARED_PIONEER_PREAMBLE_SPACE 4225
|
||||
#define INFRARED_PIONEER_BIT1_MARK 500
|
||||
#define INFRARED_PIONEER_BIT1_SPACE 1500
|
||||
#define INFRARED_PIONEER_BIT0_MARK 500
|
||||
#define INFRARED_PIONEER_BIT0_SPACE 500
|
||||
#define INFRARED_PIONEER_PREAMBLE_TOLERANCE 200 // us
|
||||
#define INFRARED_PIONEER_BIT_TOLERANCE 120 // us
|
||||
#define INFRARED_PIONEER_SILENCE 26000
|
||||
#define INFRARED_PIONEER_MIN_SPLIT_TIME (INFRARED_PIONEER_SILENCE)
|
||||
#define INFRARED_PIONEER_REPEAT_COUNT_MIN 2
|
||||
#define INFRARED_PIONEER_BIT_TOLERANCE 120 // us
|
||||
#define INFRARED_PIONEER_SILENCE 26000
|
||||
#define INFRARED_PIONEER_MIN_SPLIT_TIME (INFRARED_PIONEER_SILENCE)
|
||||
#define INFRARED_PIONEER_REPEAT_COUNT_MIN 2
|
||||
|
||||
extern const InfraredCommonProtocolSpec infrared_protocol_pioneer;
|
||||
|
||||
@@ -22,4 +22,4 @@ bool infrared_decoder_pioneer_interpret(InfraredCommonDecoder* decoder);
|
||||
InfraredStatus infrared_encoder_pioneer_encode_repeat(
|
||||
InfraredCommonEncoder* encoder,
|
||||
uint32_t* duration,
|
||||
bool* level);
|
||||
bool* level);
|
||||
|
||||
@@ -3,17 +3,17 @@
|
||||
#include "../common/infrared_common_i.h"
|
||||
|
||||
#define INFRARED_RC5_CARRIER_FREQUENCY 36000
|
||||
#define INFRARED_RC5_DUTY_CYCLE 0.33
|
||||
#define INFRARED_RC5_DUTY_CYCLE 0.33
|
||||
|
||||
#define INFRARED_RC5_PREAMBLE_MARK 0
|
||||
#define INFRARED_RC5_PREAMBLE_SPACE 0
|
||||
#define INFRARED_RC5_BIT 888 // half of time-quant for 1 bit
|
||||
#define INFRARED_RC5_PREAMBLE_MARK 0
|
||||
#define INFRARED_RC5_PREAMBLE_SPACE 0
|
||||
#define INFRARED_RC5_BIT 888 // half of time-quant for 1 bit
|
||||
#define INFRARED_RC5_PREAMBLE_TOLERANCE 200 // us
|
||||
#define INFRARED_RC5_BIT_TOLERANCE 120 // us
|
||||
#define INFRARED_RC5_BIT_TOLERANCE 120 // us
|
||||
/* protocol allows 2700 silence, but it is hard to send 1 message without repeat */
|
||||
#define INFRARED_RC5_SILENCE (2700 * 10)
|
||||
#define INFRARED_RC5_MIN_SPLIT_TIME 2700
|
||||
#define INFRARED_RC5_REPEAT_COUNT_MIN 1
|
||||
#define INFRARED_RC5_SILENCE (2700 * 10)
|
||||
#define INFRARED_RC5_MIN_SPLIT_TIME 2700
|
||||
#define INFRARED_RC5_REPEAT_COUNT_MIN 1
|
||||
|
||||
extern const InfraredCommonProtocolSpec infrared_protocol_rc5;
|
||||
|
||||
|
||||
@@ -3,17 +3,17 @@
|
||||
#include "../common/infrared_common_i.h"
|
||||
|
||||
#define INFRARED_RC6_CARRIER_FREQUENCY 36000
|
||||
#define INFRARED_RC6_DUTY_CYCLE 0.33
|
||||
#define INFRARED_RC6_DUTY_CYCLE 0.33
|
||||
|
||||
#define INFRARED_RC6_PREAMBLE_MARK 2666
|
||||
#define INFRARED_RC6_PREAMBLE_SPACE 889
|
||||
#define INFRARED_RC6_BIT 444 // half of time-quant for 1 bit
|
||||
#define INFRARED_RC6_PREAMBLE_MARK 2666
|
||||
#define INFRARED_RC6_PREAMBLE_SPACE 889
|
||||
#define INFRARED_RC6_BIT 444 // half of time-quant for 1 bit
|
||||
#define INFRARED_RC6_PREAMBLE_TOLERANCE 200 // us
|
||||
#define INFRARED_RC6_BIT_TOLERANCE 120 // us
|
||||
#define INFRARED_RC6_BIT_TOLERANCE 120 // us
|
||||
/* protocol allows 2700 silence, but it is hard to send 1 message without repeat */
|
||||
#define INFRARED_RC6_SILENCE (2700 * 10)
|
||||
#define INFRARED_RC6_MIN_SPLIT_TIME 2700
|
||||
#define INFRARED_RC6_REPEAT_COUNT_MIN 1
|
||||
#define INFRARED_RC6_SILENCE (2700 * 10)
|
||||
#define INFRARED_RC6_MIN_SPLIT_TIME 2700
|
||||
#define INFRARED_RC6_REPEAT_COUNT_MIN 1
|
||||
|
||||
extern const InfraredCommonProtocolSpec infrared_protocol_rc6;
|
||||
|
||||
|
||||
@@ -2,23 +2,23 @@
|
||||
|
||||
#include "../common/infrared_common_i.h"
|
||||
|
||||
#define INFRARED_RCA_PREAMBLE_MARK 4000
|
||||
#define INFRARED_RCA_PREAMBLE_MARK 4000
|
||||
#define INFRARED_RCA_PREAMBLE_SPACE 4000
|
||||
#define INFRARED_RCA_BIT1_MARK 500
|
||||
#define INFRARED_RCA_BIT1_SPACE 2000
|
||||
#define INFRARED_RCA_BIT0_MARK 500
|
||||
#define INFRARED_RCA_BIT0_SPACE 1000
|
||||
#define INFRARED_RCA_REPEAT_PERIOD 8000
|
||||
#define INFRARED_RCA_SILENCE INFRARED_RCA_REPEAT_PERIOD
|
||||
#define INFRARED_RCA_BIT1_MARK 500
|
||||
#define INFRARED_RCA_BIT1_SPACE 2000
|
||||
#define INFRARED_RCA_BIT0_MARK 500
|
||||
#define INFRARED_RCA_BIT0_SPACE 1000
|
||||
#define INFRARED_RCA_REPEAT_PERIOD 8000
|
||||
#define INFRARED_RCA_SILENCE INFRARED_RCA_REPEAT_PERIOD
|
||||
|
||||
#define INFRARED_RCA_MIN_SPLIT_TIME INFRARED_RCA_REPEAT_PAUSE_MIN
|
||||
#define INFRARED_RCA_REPEAT_PAUSE_MIN 4000
|
||||
#define INFRARED_RCA_REPEAT_PAUSE_MAX 150000
|
||||
#define INFRARED_RCA_REPEAT_COUNT_MIN 1
|
||||
#define INFRARED_RCA_REPEAT_MARK INFRARED_RCA_PREAMBLE_MARK
|
||||
#define INFRARED_RCA_REPEAT_SPACE INFRARED_RCA_PREAMBLE_SPACE
|
||||
#define INFRARED_RCA_MIN_SPLIT_TIME INFRARED_RCA_REPEAT_PAUSE_MIN
|
||||
#define INFRARED_RCA_REPEAT_PAUSE_MIN 4000
|
||||
#define INFRARED_RCA_REPEAT_PAUSE_MAX 150000
|
||||
#define INFRARED_RCA_REPEAT_COUNT_MIN 1
|
||||
#define INFRARED_RCA_REPEAT_MARK INFRARED_RCA_PREAMBLE_MARK
|
||||
#define INFRARED_RCA_REPEAT_SPACE INFRARED_RCA_PREAMBLE_SPACE
|
||||
#define INFRARED_RCA_PREAMBLE_TOLERANCE 200 // us
|
||||
#define INFRARED_RCA_BIT_TOLERANCE 120 // us
|
||||
#define INFRARED_RCA_BIT_TOLERANCE 120 // us
|
||||
|
||||
extern const InfraredCommonProtocolSpec infrared_protocol_rca;
|
||||
|
||||
|
||||
@@ -2,28 +2,28 @@
|
||||
|
||||
#include "../common/infrared_common_i.h"
|
||||
|
||||
#define INFRARED_SAMSUNG_PREAMBLE_MARK 4500
|
||||
#define INFRARED_SAMSUNG_PREAMBLE_SPACE 4500
|
||||
#define INFRARED_SAMSUNG_BIT1_MARK 550
|
||||
#define INFRARED_SAMSUNG_BIT1_SPACE 1650
|
||||
#define INFRARED_SAMSUNG_BIT0_MARK 550
|
||||
#define INFRARED_SAMSUNG_BIT0_SPACE 550
|
||||
#define INFRARED_SAMSUNG_REPEAT_PAUSE_MIN 30000
|
||||
#define INFRARED_SAMSUNG_REPEAT_PAUSE_MAX 140000
|
||||
#define INFRARED_SAMSUNG_REPEAT_PAUSE1 46000
|
||||
#define INFRARED_SAMSUNG_REPEAT_PAUSE2 97000
|
||||
#define INFRARED_SAMSUNG_REPEAT_COUNT_MIN 1
|
||||
#define INFRARED_SAMSUNG_PREAMBLE_MARK 4500
|
||||
#define INFRARED_SAMSUNG_PREAMBLE_SPACE 4500
|
||||
#define INFRARED_SAMSUNG_BIT1_MARK 550
|
||||
#define INFRARED_SAMSUNG_BIT1_SPACE 1650
|
||||
#define INFRARED_SAMSUNG_BIT0_MARK 550
|
||||
#define INFRARED_SAMSUNG_BIT0_SPACE 550
|
||||
#define INFRARED_SAMSUNG_REPEAT_PAUSE_MIN 30000
|
||||
#define INFRARED_SAMSUNG_REPEAT_PAUSE_MAX 140000
|
||||
#define INFRARED_SAMSUNG_REPEAT_PAUSE1 46000
|
||||
#define INFRARED_SAMSUNG_REPEAT_PAUSE2 97000
|
||||
#define INFRARED_SAMSUNG_REPEAT_COUNT_MIN 1
|
||||
/* Samsung silence have to be greater than REPEAT MAX
|
||||
* otherwise there can be problems during unit tests parsing
|
||||
* of some data. Real tolerances we don't know, but in real life
|
||||
* silence time should be greater than max repeat time. This is
|
||||
* because of similar preambule timings for repeat and first messages. */
|
||||
#define INFRARED_SAMSUNG_MIN_SPLIT_TIME 5000
|
||||
#define INFRARED_SAMSUNG_SILENCE 145000
|
||||
#define INFRARED_SAMSUNG_REPEAT_MARK 4500
|
||||
#define INFRARED_SAMSUNG_REPEAT_SPACE 4500
|
||||
#define INFRARED_SAMSUNG_MIN_SPLIT_TIME 5000
|
||||
#define INFRARED_SAMSUNG_SILENCE 145000
|
||||
#define INFRARED_SAMSUNG_REPEAT_MARK 4500
|
||||
#define INFRARED_SAMSUNG_REPEAT_SPACE 4500
|
||||
#define INFRARED_SAMSUNG_PREAMBLE_TOLERANCE 200 // us
|
||||
#define INFRARED_SAMSUNG_BIT_TOLERANCE 120 // us
|
||||
#define INFRARED_SAMSUNG_BIT_TOLERANCE 120 // us
|
||||
|
||||
bool infrared_decoder_samsung32_interpret(InfraredCommonDecoder* decoder);
|
||||
InfraredStatus infrared_decoder_samsung32_decode_repeat(InfraredCommonDecoder* decoder);
|
||||
|
||||
@@ -2,20 +2,20 @@
|
||||
|
||||
#include "../common/infrared_common_i.h"
|
||||
|
||||
#define INFRARED_SIRC_CARRIER_FREQUENCY 40000
|
||||
#define INFRARED_SIRC_DUTY_CYCLE 0.33
|
||||
#define INFRARED_SIRC_PREAMBLE_MARK 2400
|
||||
#define INFRARED_SIRC_PREAMBLE_SPACE 600
|
||||
#define INFRARED_SIRC_BIT1_MARK 1200
|
||||
#define INFRARED_SIRC_BIT1_SPACE 600
|
||||
#define INFRARED_SIRC_BIT0_MARK 600
|
||||
#define INFRARED_SIRC_BIT0_SPACE 600
|
||||
#define INFRARED_SIRC_CARRIER_FREQUENCY 40000
|
||||
#define INFRARED_SIRC_DUTY_CYCLE 0.33
|
||||
#define INFRARED_SIRC_PREAMBLE_MARK 2400
|
||||
#define INFRARED_SIRC_PREAMBLE_SPACE 600
|
||||
#define INFRARED_SIRC_BIT1_MARK 1200
|
||||
#define INFRARED_SIRC_BIT1_SPACE 600
|
||||
#define INFRARED_SIRC_BIT0_MARK 600
|
||||
#define INFRARED_SIRC_BIT0_SPACE 600
|
||||
#define INFRARED_SIRC_PREAMBLE_TOLERANCE 200 // us
|
||||
#define INFRARED_SIRC_BIT_TOLERANCE 120 // us
|
||||
#define INFRARED_SIRC_SILENCE 10000
|
||||
#define INFRARED_SIRC_MIN_SPLIT_TIME (INFRARED_SIRC_SILENCE - 1000)
|
||||
#define INFRARED_SIRC_REPEAT_PERIOD 45000
|
||||
#define INFRARED_SIRC_REPEAT_COUNT_MIN 3
|
||||
#define INFRARED_SIRC_BIT_TOLERANCE 120 // us
|
||||
#define INFRARED_SIRC_SILENCE 10000
|
||||
#define INFRARED_SIRC_MIN_SPLIT_TIME (INFRARED_SIRC_SILENCE - 1000)
|
||||
#define INFRARED_SIRC_REPEAT_PERIOD 45000
|
||||
#define INFRARED_SIRC_REPEAT_COUNT_MIN 3
|
||||
|
||||
extern const InfraredCommonProtocolSpec infrared_protocol_sirc;
|
||||
|
||||
|
||||
@@ -10,12 +10,12 @@
|
||||
|
||||
#define INFRARED_WORKER_RX_TIMEOUT INFRARED_RAW_RX_TIMING_DELAY_US
|
||||
|
||||
#define INFRARED_WORKER_RX_RECEIVED 0x01
|
||||
#define INFRARED_WORKER_RX_RECEIVED 0x01
|
||||
#define INFRARED_WORKER_RX_TIMEOUT_RECEIVED 0x02
|
||||
#define INFRARED_WORKER_OVERRUN 0x04
|
||||
#define INFRARED_WORKER_EXIT 0x08
|
||||
#define INFRARED_WORKER_TX_FILL_BUFFER 0x10
|
||||
#define INFRARED_WORKER_TX_MESSAGE_SENT 0x20
|
||||
#define INFRARED_WORKER_OVERRUN 0x04
|
||||
#define INFRARED_WORKER_EXIT 0x08
|
||||
#define INFRARED_WORKER_TX_FILL_BUFFER 0x10
|
||||
#define INFRARED_WORKER_TX_MESSAGE_SENT 0x20
|
||||
|
||||
#define INFRARED_WORKER_ALL_RX_EVENTS \
|
||||
(INFRARED_WORKER_RX_RECEIVED | INFRARED_WORKER_RX_TIMEOUT_RECEIVED | \
|
||||
|
||||
@@ -185,4 +185,4 @@ ProtocolId lfrfid_dict_file_load(ProtocolDict* dict, const char* filename) {
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,4 +28,4 @@ ProtocolId lfrfid_dict_file_load(ProtocolDict* dict, const char* filename);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <toolbox/stream/file_stream.h>
|
||||
#include <toolbox/varint.h>
|
||||
|
||||
#define LFRFID_RAW_FILE_MAGIC 0x4C464952
|
||||
#define LFRFID_RAW_FILE_MAGIC 0x4C464952
|
||||
#define LFRFID_RAW_FILE_VERSION 1
|
||||
|
||||
#define TAG "LfRfidRawFile"
|
||||
@@ -71,7 +71,7 @@ bool lfrfid_raw_file_write_header(
|
||||
.max_buffer_size = max_buffer_size};
|
||||
|
||||
size_t size = stream_write(file->stream, (uint8_t*)&header, sizeof(LFRFIDRawFileHeader));
|
||||
return (size == sizeof(LFRFIDRawFileHeader));
|
||||
return size == sizeof(LFRFIDRawFileHeader);
|
||||
}
|
||||
|
||||
bool lfrfid_raw_file_write_buffer(LFRFIDRawFile* file, uint8_t* buffer_data, size_t buffer_size) {
|
||||
@@ -166,4 +166,4 @@ bool lfrfid_raw_file_read_pair(
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
#include "lfrfid_raw_file.h"
|
||||
#include "tools/varint_pair.h"
|
||||
|
||||
#define EMULATE_BUFFER_SIZE 1024
|
||||
#define RFID_DATA_BUFFER_SIZE 2048
|
||||
#define EMULATE_BUFFER_SIZE 1024
|
||||
#define RFID_DATA_BUFFER_SIZE 2048
|
||||
#define READ_DATA_BUFFER_COUNT 4
|
||||
|
||||
#define TAG_EMULATE "RawEmulate"
|
||||
|
||||
@@ -65,4 +65,4 @@ void lfrfid_raw_worker_stop(LFRFIDRawWorker* worker);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -155,7 +155,7 @@ void lfrfid_worker_stop_thread(LFRFIDWorker* worker) {
|
||||
bool lfrfid_worker_check_for_stop(LFRFIDWorker* worker) {
|
||||
UNUSED(worker);
|
||||
uint32_t flags = furi_thread_flags_get();
|
||||
return (flags & LFRFIDEventStopMode);
|
||||
return flags & LFRFIDEventStopMode;
|
||||
}
|
||||
|
||||
size_t lfrfid_worker_dict_get_data_size(LFRFIDWorker* worker, LFRFIDProtocol protocol) {
|
||||
|
||||
@@ -19,23 +19,23 @@
|
||||
|
||||
#ifdef LFRFID_WORKER_READ_DEBUG_GPIO
|
||||
#define LFRFID_WORKER_READ_DEBUG_GPIO_VALUE &gpio_ext_pa7
|
||||
#define LFRFID_WORKER_READ_DEBUG_GPIO_LOAD &gpio_ext_pa6
|
||||
#define LFRFID_WORKER_READ_DEBUG_GPIO_LOAD &gpio_ext_pa6
|
||||
#endif
|
||||
|
||||
#define LFRFID_WORKER_READ_AVERAGE_COUNT 64
|
||||
#define LFRFID_WORKER_READ_MIN_TIME_US 16
|
||||
#define LFRFID_WORKER_READ_MIN_TIME_US 16
|
||||
|
||||
#define LFRFID_WORKER_READ_DROP_TIME_MS 50
|
||||
#define LFRFID_WORKER_READ_DROP_TIME_MS 50
|
||||
#define LFRFID_WORKER_READ_STABILIZE_TIME_MS 450
|
||||
#define LFRFID_WORKER_READ_SWITCH_TIME_MS 2000
|
||||
#define LFRFID_WORKER_READ_SWITCH_TIME_MS 2000
|
||||
|
||||
#define LFRFID_WORKER_WRITE_VERIFY_TIME_MS 2000
|
||||
#define LFRFID_WORKER_WRITE_DROP_TIME_MS 50
|
||||
#define LFRFID_WORKER_WRITE_VERIFY_TIME_MS 2000
|
||||
#define LFRFID_WORKER_WRITE_DROP_TIME_MS 50
|
||||
#define LFRFID_WORKER_WRITE_TOO_LONG_TIME_MS 10000
|
||||
|
||||
#define LFRFID_WORKER_WRITE_MAX_UNSUCCESSFUL_READS 5
|
||||
|
||||
#define LFRFID_WORKER_READ_BUFFER_SIZE 512
|
||||
#define LFRFID_WORKER_READ_BUFFER_SIZE 512
|
||||
#define LFRFID_WORKER_READ_BUFFER_COUNT 16
|
||||
|
||||
#define LFRFID_WORKER_EMULATE_BUFFER_SIZE 1024
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
#include "lfrfid_protocols.h"
|
||||
|
||||
#define JITTER_TIME (20)
|
||||
#define MIN_TIME (64 - JITTER_TIME)
|
||||
#define MAX_TIME (80 + JITTER_TIME)
|
||||
#define MIN_TIME (64 - JITTER_TIME)
|
||||
#define MAX_TIME (80 + JITTER_TIME)
|
||||
|
||||
#define AWID_DECODED_DATA_SIZE (9)
|
||||
|
||||
#define AWID_ENCODED_BIT_SIZE (96)
|
||||
#define AWID_ENCODED_BIT_SIZE (96)
|
||||
#define AWID_ENCODED_DATA_SIZE (((AWID_ENCODED_BIT_SIZE) / 8) + 1)
|
||||
#define AWID_ENCODED_DATA_LAST (AWID_ENCODED_DATA_SIZE - 1)
|
||||
|
||||
@@ -37,21 +37,21 @@ ProtocolAwid* protocol_awid_alloc(void) {
|
||||
protocol->encoder.fsk_osc = fsk_osc_alloc(8, 10, 50);
|
||||
|
||||
return protocol;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_awid_free(ProtocolAwid* protocol) {
|
||||
fsk_demod_free(protocol->decoder.fsk_demod);
|
||||
fsk_osc_free(protocol->encoder.fsk_osc);
|
||||
free(protocol);
|
||||
};
|
||||
}
|
||||
|
||||
uint8_t* protocol_awid_get_data(ProtocolAwid* protocol) {
|
||||
return protocol->data;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_awid_decoder_start(ProtocolAwid* protocol) {
|
||||
memset(protocol->encoded_data, 0, AWID_ENCODED_DATA_SIZE);
|
||||
};
|
||||
}
|
||||
|
||||
static bool protocol_awid_can_be_decoded(uint8_t* data) {
|
||||
bool result = false;
|
||||
@@ -112,7 +112,7 @@ bool protocol_awid_decoder_feed(ProtocolAwid* protocol, bool level, uint32_t dur
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
static void protocol_awid_encode(const uint8_t* decoded_data, uint8_t* encoded_data) {
|
||||
memset(encoded_data, 0, AWID_ENCODED_DATA_SIZE);
|
||||
@@ -125,14 +125,14 @@ static void protocol_awid_encode(const uint8_t* decoded_data, uint8_t* encoded_d
|
||||
value |= bit_lib_test_parity_32(value, BitLibParityOdd);
|
||||
bit_lib_set_bits(encoded_data, 8 + i * 4, value, 4);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_awid_encoder_start(ProtocolAwid* protocol) {
|
||||
protocol_awid_encode(protocol->data, (uint8_t*)protocol->encoded_data);
|
||||
protocol->encoder.encoded_index = 0;
|
||||
fsk_osc_reset(protocol->encoder.fsk_osc);
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
LevelDuration protocol_awid_encoder_yield(ProtocolAwid* protocol) {
|
||||
bool level;
|
||||
@@ -145,7 +145,7 @@ LevelDuration protocol_awid_encoder_yield(ProtocolAwid* protocol) {
|
||||
bit_lib_increment_index(protocol->encoder.encoded_index, AWID_ENCODED_BIT_SIZE);
|
||||
}
|
||||
return level_duration_make(level, duration);
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_awid_render_data(ProtocolAwid* protocol, FuriString* result) {
|
||||
// Index map
|
||||
@@ -186,7 +186,7 @@ void protocol_awid_render_data(ProtocolAwid* protocol, FuriString* result) {
|
||||
furi_string_cat_printf(result, "%02hhX", decoded_data[i]);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_awid_render_brief_data(ProtocolAwid* protocol, FuriString* result) {
|
||||
uint8_t* decoded_data = protocol->data;
|
||||
@@ -210,7 +210,7 @@ void protocol_awid_render_brief_data(ProtocolAwid* protocol, FuriString* result)
|
||||
} else {
|
||||
furi_string_cat(result, "\nData: Unknown");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_awid_write_data(ProtocolAwid* protocol, void* data) {
|
||||
LFRFIDWriteRequest* request = (LFRFIDWriteRequest*)data;
|
||||
@@ -239,7 +239,7 @@ bool protocol_awid_write_data(ProtocolAwid* protocol, void* data) {
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
const ProtocolBase protocol_awid = {
|
||||
.name = "AWID",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
#include <toolbox/protocols/protocol.h>
|
||||
|
||||
extern const ProtocolBase protocol_awid;
|
||||
extern const ProtocolBase protocol_awid;
|
||||
|
||||
@@ -61,17 +61,17 @@
|
||||
|
||||
typedef uint64_t ElectraDecodedData;
|
||||
|
||||
#define EM_HEADER_POS (55)
|
||||
#define EM_HEADER_POS (55)
|
||||
#define EM_HEADER_MASK (0x1FFLLU << EM_HEADER_POS)
|
||||
|
||||
#define EM_FIRST_ROW_POS (50)
|
||||
|
||||
#define EM_ROW_COUNT (10)
|
||||
#define EM_COLUMN_COUNT (4)
|
||||
#define EM_ROW_COUNT (10)
|
||||
#define EM_COLUMN_COUNT (4)
|
||||
#define EM_BITS_PER_ROW_COUNT (EM_COLUMN_COUNT + 1)
|
||||
|
||||
#define EM_COLUMN_POS (4)
|
||||
#define ELECTRA_STOP_POS (0)
|
||||
#define EM_COLUMN_POS (4)
|
||||
#define ELECTRA_STOP_POS (0)
|
||||
#define ELECTRA_STOP_MASK (0x1LLU << ELECTRA_STOP_POS)
|
||||
|
||||
#define EM_HEADER_AND_STOP_MASK (EM_HEADER_MASK | ELECTRA_STOP_MASK)
|
||||
@@ -90,14 +90,14 @@ typedef uint64_t ElectraDecodedData;
|
||||
|
||||
#define ELECTRA_CLOCK_PER_BIT (64)
|
||||
|
||||
#define ELECTRA_READ_SHORT_TIME (256)
|
||||
#define ELECTRA_READ_LONG_TIME (512)
|
||||
#define ELECTRA_READ_SHORT_TIME (256)
|
||||
#define ELECTRA_READ_LONG_TIME (512)
|
||||
#define ELECTRA_READ_JITTER_TIME (100)
|
||||
|
||||
#define ELECTRA_READ_SHORT_TIME_LOW (ELECTRA_READ_SHORT_TIME - ELECTRA_READ_JITTER_TIME)
|
||||
#define ELECTRA_READ_SHORT_TIME_LOW (ELECTRA_READ_SHORT_TIME - ELECTRA_READ_JITTER_TIME)
|
||||
#define ELECTRA_READ_SHORT_TIME_HIGH (ELECTRA_READ_SHORT_TIME + ELECTRA_READ_JITTER_TIME)
|
||||
#define ELECTRA_READ_LONG_TIME_LOW (ELECTRA_READ_LONG_TIME - ELECTRA_READ_JITTER_TIME)
|
||||
#define ELECTRA_READ_LONG_TIME_HIGH (ELECTRA_READ_LONG_TIME + ELECTRA_READ_JITTER_TIME)
|
||||
#define ELECTRA_READ_LONG_TIME_LOW (ELECTRA_READ_LONG_TIME - ELECTRA_READ_JITTER_TIME)
|
||||
#define ELECTRA_READ_LONG_TIME_HIGH (ELECTRA_READ_LONG_TIME + ELECTRA_READ_JITTER_TIME)
|
||||
|
||||
#define EM_ENCODED_DATA_HEADER (0xFF80000000000000ULL)
|
||||
|
||||
@@ -116,15 +116,15 @@ typedef struct {
|
||||
ProtocolElectra* protocol_electra_alloc(void) {
|
||||
ProtocolElectra* proto = malloc(sizeof(ProtocolElectra));
|
||||
return (void*)proto;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_electra_free(ProtocolElectra* proto) {
|
||||
free(proto);
|
||||
};
|
||||
}
|
||||
|
||||
uint8_t* protocol_electra_get_data(ProtocolElectra* proto) {
|
||||
return proto->data;
|
||||
};
|
||||
}
|
||||
|
||||
static void electra_decode(
|
||||
const uint8_t* encoded_base_data,
|
||||
@@ -198,7 +198,7 @@ static bool electra_can_be_decoded(
|
||||
parity_sum += (*base_data >> (EM_FIRST_ROW_POS - i * EM_BITS_PER_ROW_COUNT + j)) & 1;
|
||||
}
|
||||
|
||||
if((parity_sum % 2)) {
|
||||
if(parity_sum % 2) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -211,7 +211,7 @@ static bool electra_can_be_decoded(
|
||||
parity_sum += (*base_data >> (EM_COLUMN_POS - i + j * EM_BITS_PER_ROW_COUNT)) & 1;
|
||||
}
|
||||
|
||||
if((parity_sum % 2)) {
|
||||
if(parity_sum % 2) {
|
||||
FURI_LOG_D(
|
||||
TAG,
|
||||
"Unexpected column parity found. EM4100 data: %016llX",
|
||||
@@ -242,7 +242,7 @@ void protocol_electra_decoder_start(ProtocolElectra* proto) {
|
||||
ManchesterEventReset,
|
||||
&proto->decoder_manchester_state,
|
||||
NULL);
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_electra_decoder_feed(ProtocolElectra* proto, bool level, uint32_t duration) {
|
||||
bool result = false;
|
||||
@@ -299,7 +299,7 @@ bool protocol_electra_decoder_feed(ProtocolElectra* proto, bool level, uint32_t
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
static void em_write_nibble(bool low_nibble, uint8_t data, ElectraDecodedData* encoded_base_data) {
|
||||
uint8_t parity_sum = 0;
|
||||
@@ -354,7 +354,7 @@ bool protocol_electra_encoder_start(ProtocolElectra* proto) {
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
LevelDuration protocol_electra_encoder_yield(ProtocolElectra* proto) {
|
||||
bool level;
|
||||
@@ -378,7 +378,7 @@ LevelDuration protocol_electra_encoder_yield(ProtocolElectra* proto) {
|
||||
}
|
||||
|
||||
return level_duration_make(level, duration);
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_electra_write_data(ProtocolElectra* protocol, void* data) {
|
||||
LFRFIDWriteRequest* request = (LFRFIDWriteRequest*)data;
|
||||
@@ -408,12 +408,12 @@ bool protocol_electra_write_data(ProtocolElectra* protocol, void* data) {
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_electra_render_data(ProtocolElectra* protocol, FuriString* result) {
|
||||
protocol_electra_encoder_start(protocol);
|
||||
furi_string_printf(result, "Epilogue: %016llX", protocol->encoded_epilogue);
|
||||
};
|
||||
}
|
||||
|
||||
const ProtocolBase protocol_electra = {
|
||||
.name = "Electra",
|
||||
@@ -437,4 +437,4 @@ const ProtocolBase protocol_electra = {
|
||||
.render_data = (ProtocolRenderData)protocol_electra_render_data,
|
||||
.render_brief_data = (ProtocolRenderData)protocol_electra_render_data,
|
||||
.write_data = (ProtocolWriteData)protocol_electra_write_data,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
#include <toolbox/protocols/protocol.h>
|
||||
|
||||
extern const ProtocolBase protocol_electra;
|
||||
extern const ProtocolBase protocol_electra;
|
||||
|
||||
@@ -6,18 +6,18 @@
|
||||
typedef uint64_t EM4100DecodedData;
|
||||
typedef uint64_t EM4100Epilogue;
|
||||
|
||||
#define EM_HEADER_POS (55)
|
||||
#define EM_HEADER_POS (55)
|
||||
#define EM_HEADER_MASK (0x1FFLLU << EM_HEADER_POS)
|
||||
|
||||
#define EM_FIRST_ROW_POS (50)
|
||||
|
||||
#define EM_ROW_COUNT (10)
|
||||
#define EM_COLUMN_COUNT (4)
|
||||
#define EM_ROW_COUNT (10)
|
||||
#define EM_COLUMN_COUNT (4)
|
||||
#define EM_BITS_PER_ROW_COUNT (EM_COLUMN_COUNT + 1)
|
||||
|
||||
#define EM_COLUMN_POS (4)
|
||||
#define EM_STOP_POS (0)
|
||||
#define EM_STOP_MASK (0x1LLU << EM_STOP_POS)
|
||||
#define EM_STOP_POS (0)
|
||||
#define EM_STOP_MASK (0x1LLU << EM_STOP_POS)
|
||||
|
||||
#define EM_HEADER_AND_STOP_MASK (EM_HEADER_MASK | EM_STOP_MASK)
|
||||
#define EM_HEADER_AND_STOP_DATA (EM_HEADER_MASK)
|
||||
@@ -25,8 +25,8 @@ typedef uint64_t EM4100Epilogue;
|
||||
#define EM4100_DECODED_DATA_SIZE (5)
|
||||
#define EM4100_ENCODED_DATA_SIZE (sizeof(EM4100DecodedData))
|
||||
|
||||
#define EM_READ_SHORT_TIME_BASE (256)
|
||||
#define EM_READ_LONG_TIME_BASE (512)
|
||||
#define EM_READ_SHORT_TIME_BASE (256)
|
||||
#define EM_READ_LONG_TIME_BASE (512)
|
||||
#define EM_READ_JITTER_TIME_BASE (100)
|
||||
|
||||
#define EM_ENCODED_DATA_HEADER (0xFF80000000000000ULL)
|
||||
@@ -93,27 +93,27 @@ ProtocolEM4100* protocol_em4100_alloc(void) {
|
||||
ProtocolEM4100* proto = malloc(sizeof(ProtocolEM4100));
|
||||
proto->clock_per_bit = 64;
|
||||
return (void*)proto;
|
||||
};
|
||||
}
|
||||
|
||||
ProtocolEM4100* protocol_em4100_16_alloc(void) {
|
||||
ProtocolEM4100* proto = malloc(sizeof(ProtocolEM4100));
|
||||
proto->clock_per_bit = 16;
|
||||
return (void*)proto;
|
||||
};
|
||||
}
|
||||
|
||||
ProtocolEM4100* protocol_em4100_32_alloc(void) {
|
||||
ProtocolEM4100* proto = malloc(sizeof(ProtocolEM4100));
|
||||
proto->clock_per_bit = 32;
|
||||
return (void*)proto;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_em4100_free(ProtocolEM4100* proto) {
|
||||
free(proto);
|
||||
};
|
||||
}
|
||||
|
||||
uint8_t* protocol_em4100_get_data(ProtocolEM4100* proto) {
|
||||
return proto->data;
|
||||
};
|
||||
}
|
||||
|
||||
static void em4100_decode(
|
||||
const uint8_t* encoded_data,
|
||||
@@ -173,7 +173,7 @@ static bool em4100_can_be_decoded(
|
||||
parity_sum += (*card_data >> (EM_FIRST_ROW_POS - i * EM_BITS_PER_ROW_COUNT + j)) & 1;
|
||||
}
|
||||
|
||||
if((parity_sum % 2)) {
|
||||
if(parity_sum % 2) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -186,7 +186,7 @@ static bool em4100_can_be_decoded(
|
||||
parity_sum += (*card_data >> (EM_COLUMN_POS - i + j * EM_BITS_PER_ROW_COUNT)) & 1;
|
||||
}
|
||||
|
||||
if((parity_sum % 2)) {
|
||||
if(parity_sum % 2) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -202,7 +202,7 @@ void protocol_em4100_decoder_start(ProtocolEM4100* proto) {
|
||||
ManchesterEventReset,
|
||||
&proto->decoder_manchester_state,
|
||||
NULL);
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_em4100_decoder_feed(ProtocolEM4100* proto, bool level, uint32_t duration) {
|
||||
bool result = false;
|
||||
@@ -252,7 +252,7 @@ bool protocol_em4100_decoder_feed(ProtocolEM4100* proto, bool level, uint32_t du
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
static void em4100_write_nibble(bool low_nibble, uint8_t data, EM4100DecodedData* encoded_data) {
|
||||
uint8_t parity_sum = 0;
|
||||
@@ -296,7 +296,7 @@ bool protocol_em4100_encoder_start(ProtocolEM4100* proto) {
|
||||
proto->encoded_polarity = true;
|
||||
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
LevelDuration protocol_em4100_encoder_yield(ProtocolEM4100* proto) {
|
||||
bool level = (proto->encoded_data >> (63 - proto->encoded_data_index)) & 1;
|
||||
@@ -315,7 +315,7 @@ LevelDuration protocol_em4100_encoder_yield(ProtocolEM4100* proto) {
|
||||
}
|
||||
|
||||
return level_duration_make(level, duration);
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_em4100_write_data(ProtocolEM4100* protocol, void* data) {
|
||||
LFRFIDWriteRequest* request = (LFRFIDWriteRequest*)data;
|
||||
@@ -341,7 +341,7 @@ bool protocol_em4100_write_data(ProtocolEM4100* protocol, void* data) {
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_em4100_render_data(ProtocolEM4100* protocol, FuriString* result) {
|
||||
uint8_t* data = protocol->data;
|
||||
@@ -353,7 +353,7 @@ void protocol_em4100_render_data(ProtocolEM4100* protocol, FuriString* result) {
|
||||
(uint16_t)((data[3] << 8) | (data[4])),
|
||||
protocol->clock_per_bit,
|
||||
(uint32_t)((data[2] << 16) | (data[3] << 8) | (data[4])));
|
||||
};
|
||||
}
|
||||
|
||||
const ProtocolBase protocol_em4100 = {
|
||||
.name = "EM4100",
|
||||
|
||||
@@ -6,16 +6,16 @@
|
||||
#include <bit_lib/bit_lib.h>
|
||||
|
||||
#define JITTER_TIME (20)
|
||||
#define MIN_TIME (64 - JITTER_TIME)
|
||||
#define MAX_TIME (80 + JITTER_TIME)
|
||||
#define MIN_TIME (64 - JITTER_TIME)
|
||||
#define MAX_TIME (80 + JITTER_TIME)
|
||||
|
||||
#define FDXA_DATA_SIZE 10
|
||||
#define FDXA_DATA_SIZE 10
|
||||
#define FDXA_PREAMBLE_SIZE 2
|
||||
|
||||
#define FDXA_ENCODED_DATA_SIZE (FDXA_PREAMBLE_SIZE + FDXA_DATA_SIZE + FDXA_PREAMBLE_SIZE)
|
||||
#define FDXA_ENCODED_BIT_SIZE ((FDXA_PREAMBLE_SIZE + FDXA_DATA_SIZE) * 8)
|
||||
#define FDXA_ENCODED_BIT_SIZE ((FDXA_PREAMBLE_SIZE + FDXA_DATA_SIZE) * 8)
|
||||
#define FDXA_DECODED_DATA_SIZE (5)
|
||||
#define FDXA_DECODED_BIT_SIZE ((FDXA_ENCODED_BIT_SIZE - FDXA_PREAMBLE_SIZE * 8) / 2)
|
||||
#define FDXA_DECODED_BIT_SIZE ((FDXA_ENCODED_BIT_SIZE - FDXA_PREAMBLE_SIZE * 8) / 2)
|
||||
|
||||
#define FDXA_PREAMBLE_0 0x55
|
||||
#define FDXA_PREAMBLE_1 0x1D
|
||||
@@ -44,21 +44,21 @@ ProtocolFDXA* protocol_fdx_a_alloc(void) {
|
||||
protocol->encoder.fsk_osc = fsk_osc_alloc(8, 10, 50);
|
||||
|
||||
return protocol;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_fdx_a_free(ProtocolFDXA* protocol) {
|
||||
fsk_demod_free(protocol->decoder.fsk_demod);
|
||||
fsk_osc_free(protocol->encoder.fsk_osc);
|
||||
free(protocol);
|
||||
};
|
||||
}
|
||||
|
||||
uint8_t* protocol_fdx_a_get_data(ProtocolFDXA* protocol) {
|
||||
return protocol->data;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_fdx_a_decoder_start(ProtocolFDXA* protocol) {
|
||||
memset(protocol->encoded_data, 0, FDXA_ENCODED_DATA_SIZE);
|
||||
};
|
||||
}
|
||||
|
||||
static bool protocol_fdx_a_decode(const uint8_t* from, uint8_t* to) {
|
||||
size_t bit_index = 0;
|
||||
@@ -104,7 +104,7 @@ static bool protocol_fdx_a_can_be_decoded(const uint8_t* data) {
|
||||
decoded_data[i] &= 0x7F;
|
||||
}
|
||||
|
||||
return (parity_sum == 0);
|
||||
return parity_sum == 0;
|
||||
}
|
||||
|
||||
bool protocol_fdx_a_decoder_feed(ProtocolFDXA* protocol, bool level, uint32_t duration) {
|
||||
@@ -124,7 +124,7 @@ bool protocol_fdx_a_decoder_feed(ProtocolFDXA* protocol, bool level, uint32_t du
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
static void protocol_fdx_a_encode(ProtocolFDXA* protocol) {
|
||||
protocol->encoded_data[0] = FDXA_PREAMBLE_0;
|
||||
@@ -150,7 +150,7 @@ bool protocol_fdx_a_encoder_start(ProtocolFDXA* protocol) {
|
||||
protocol_fdx_a_encode(protocol);
|
||||
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
LevelDuration protocol_fdx_a_encoder_yield(ProtocolFDXA* protocol) {
|
||||
bool level = 0;
|
||||
@@ -180,7 +180,7 @@ LevelDuration protocol_fdx_a_encoder_yield(ProtocolFDXA* protocol) {
|
||||
}
|
||||
|
||||
return level_duration_make(level, duration);
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_fdx_a_write_data(ProtocolFDXA* protocol, void* data) {
|
||||
LFRFIDWriteRequest* request = (LFRFIDWriteRequest*)data;
|
||||
@@ -203,7 +203,7 @@ bool protocol_fdx_a_write_data(ProtocolFDXA* protocol, void* data) {
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_fdx_a_render_data(ProtocolFDXA* protocol, FuriString* result) {
|
||||
uint8_t data[FDXA_DECODED_DATA_SIZE];
|
||||
@@ -221,7 +221,7 @@ void protocol_fdx_a_render_data(ProtocolFDXA* protocol, FuriString* result) {
|
||||
"Parity: %c",
|
||||
bit_lib_get_bits_64(data, 0, 40),
|
||||
parity_sum == 0 ? '+' : '-');
|
||||
};
|
||||
}
|
||||
|
||||
const ProtocolBase protocol_fdx_a = {
|
||||
.name = "FDX-A",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
#include <toolbox/protocols/protocol.h>
|
||||
|
||||
extern const ProtocolBase protocol_fdx_a;
|
||||
extern const ProtocolBase protocol_fdx_a;
|
||||
|
||||
@@ -6,22 +6,22 @@
|
||||
#include "lfrfid_protocols.h"
|
||||
#include <furi_hal_rtc.h>
|
||||
|
||||
#define FDX_B_ENCODED_BIT_SIZE (128)
|
||||
#define FDX_B_ENCODED_BYTE_SIZE (((FDX_B_ENCODED_BIT_SIZE) / 8))
|
||||
#define FDX_B_PREAMBLE_BIT_SIZE (11)
|
||||
#define FDX_B_PREAMBLE_BYTE_SIZE (2)
|
||||
#define FDX_B_ENCODED_BIT_SIZE (128)
|
||||
#define FDX_B_ENCODED_BYTE_SIZE (((FDX_B_ENCODED_BIT_SIZE) / 8))
|
||||
#define FDX_B_PREAMBLE_BIT_SIZE (11)
|
||||
#define FDX_B_PREAMBLE_BYTE_SIZE (2)
|
||||
#define FDX_B_ENCODED_BYTE_FULL_SIZE (FDX_B_ENCODED_BYTE_SIZE + FDX_B_PREAMBLE_BYTE_SIZE)
|
||||
|
||||
#define FDXB_DECODED_DATA_SIZE (11)
|
||||
|
||||
#define FDX_B_SHORT_TIME (128)
|
||||
#define FDX_B_LONG_TIME (256)
|
||||
#define FDX_B_SHORT_TIME (128)
|
||||
#define FDX_B_LONG_TIME (256)
|
||||
#define FDX_B_JITTER_TIME (60)
|
||||
|
||||
#define FDX_B_SHORT_TIME_LOW (FDX_B_SHORT_TIME - FDX_B_JITTER_TIME)
|
||||
#define FDX_B_SHORT_TIME_LOW (FDX_B_SHORT_TIME - FDX_B_JITTER_TIME)
|
||||
#define FDX_B_SHORT_TIME_HIGH (FDX_B_SHORT_TIME + FDX_B_JITTER_TIME)
|
||||
#define FDX_B_LONG_TIME_LOW (FDX_B_LONG_TIME - FDX_B_JITTER_TIME)
|
||||
#define FDX_B_LONG_TIME_HIGH (FDX_B_LONG_TIME + FDX_B_JITTER_TIME)
|
||||
#define FDX_B_LONG_TIME_LOW (FDX_B_LONG_TIME - FDX_B_JITTER_TIME)
|
||||
#define FDX_B_LONG_TIME_HIGH (FDX_B_LONG_TIME + FDX_B_JITTER_TIME)
|
||||
|
||||
typedef struct {
|
||||
bool last_short;
|
||||
@@ -34,20 +34,20 @@ typedef struct {
|
||||
ProtocolFDXB* protocol_fdx_b_alloc(void) {
|
||||
ProtocolFDXB* protocol = malloc(sizeof(ProtocolFDXB));
|
||||
return protocol;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_fdx_b_free(ProtocolFDXB* protocol) {
|
||||
free(protocol);
|
||||
};
|
||||
}
|
||||
|
||||
uint8_t* protocol_fdx_b_get_data(ProtocolFDXB* proto) {
|
||||
return proto->data;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_fdx_b_decoder_start(ProtocolFDXB* protocol) {
|
||||
memset(protocol->encoded_data, 0, FDX_B_ENCODED_BYTE_FULL_SIZE);
|
||||
protocol->last_short = false;
|
||||
};
|
||||
}
|
||||
|
||||
static bool protocol_fdx_b_can_be_decoded(ProtocolFDXB* protocol) {
|
||||
bool result = false;
|
||||
@@ -179,7 +179,7 @@ bool protocol_fdx_b_decoder_feed(ProtocolFDXB* protocol, bool level, uint32_t du
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_fdx_b_encoder_start(ProtocolFDXB* protocol) {
|
||||
memset(protocol->encoded_data, 0, FDX_B_ENCODED_BYTE_FULL_SIZE);
|
||||
@@ -203,7 +203,7 @@ bool protocol_fdx_b_encoder_start(ProtocolFDXB* protocol) {
|
||||
protocol->last_short = false;
|
||||
protocol->last_level = false;
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
LevelDuration protocol_fdx_b_encoder_yield(ProtocolFDXB* protocol) {
|
||||
uint32_t duration;
|
||||
@@ -228,7 +228,7 @@ LevelDuration protocol_fdx_b_encoder_yield(ProtocolFDXB* protocol) {
|
||||
}
|
||||
|
||||
return level_duration_make(protocol->last_level, duration);
|
||||
};
|
||||
}
|
||||
|
||||
// 0 nnnnnnnn
|
||||
// 8 nnnnnnnn 38 bit (12 digit) National code.
|
||||
@@ -320,7 +320,7 @@ void protocol_fdx_b_render_data(ProtocolFDXB* protocol, FuriString* result) {
|
||||
reserved,
|
||||
user_info,
|
||||
replacement_number);
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_fdx_b_render_brief_data(ProtocolFDXB* protocol, FuriString* result) {
|
||||
// 38 bits of national code
|
||||
@@ -348,7 +348,7 @@ void protocol_fdx_b_render_brief_data(ProtocolFDXB* protocol, FuriString* result
|
||||
} else {
|
||||
furi_string_cat(result, "---");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_fdx_b_write_data(ProtocolFDXB* protocol, void* data) {
|
||||
LFRFIDWriteRequest* request = (LFRFIDWriteRequest*)data;
|
||||
@@ -371,7 +371,7 @@ bool protocol_fdx_b_write_data(ProtocolFDXB* protocol, void* data) {
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
const ProtocolBase protocol_fdx_b = {
|
||||
.name = "FDX-B",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
#include <toolbox/protocols/protocol.h>
|
||||
|
||||
extern const ProtocolBase protocol_fdx_b;
|
||||
extern const ProtocolBase protocol_fdx_b;
|
||||
|
||||
@@ -6,22 +6,22 @@
|
||||
|
||||
#define GALLAGHER_CLOCK_PER_BIT (32)
|
||||
|
||||
#define GALLAGHER_ENCODED_BIT_SIZE (96)
|
||||
#define GALLAGHER_ENCODED_BYTE_SIZE ((GALLAGHER_ENCODED_BIT_SIZE) / 8)
|
||||
#define GALLAGHER_PREAMBLE_BIT_SIZE (16)
|
||||
#define GALLAGHER_ENCODED_BIT_SIZE (96)
|
||||
#define GALLAGHER_ENCODED_BYTE_SIZE ((GALLAGHER_ENCODED_BIT_SIZE) / 8)
|
||||
#define GALLAGHER_PREAMBLE_BIT_SIZE (16)
|
||||
#define GALLAGHER_PREAMBLE_BYTE_SIZE ((GALLAGHER_PREAMBLE_BIT_SIZE) / 8)
|
||||
#define GALLAGHER_ENCODED_BYTE_FULL_SIZE \
|
||||
(GALLAGHER_ENCODED_BYTE_SIZE + GALLAGHER_PREAMBLE_BYTE_SIZE)
|
||||
#define GALLAGHER_DECODED_DATA_SIZE 8
|
||||
|
||||
#define GALLAGHER_READ_SHORT_TIME (128)
|
||||
#define GALLAGHER_READ_LONG_TIME (256)
|
||||
#define GALLAGHER_READ_SHORT_TIME (128)
|
||||
#define GALLAGHER_READ_LONG_TIME (256)
|
||||
#define GALLAGHER_READ_JITTER_TIME (60)
|
||||
|
||||
#define GALLAGHER_READ_SHORT_TIME_LOW (GALLAGHER_READ_SHORT_TIME - GALLAGHER_READ_JITTER_TIME)
|
||||
#define GALLAGHER_READ_SHORT_TIME_LOW (GALLAGHER_READ_SHORT_TIME - GALLAGHER_READ_JITTER_TIME)
|
||||
#define GALLAGHER_READ_SHORT_TIME_HIGH (GALLAGHER_READ_SHORT_TIME + GALLAGHER_READ_JITTER_TIME)
|
||||
#define GALLAGHER_READ_LONG_TIME_LOW (GALLAGHER_READ_LONG_TIME - GALLAGHER_READ_JITTER_TIME)
|
||||
#define GALLAGHER_READ_LONG_TIME_HIGH (GALLAGHER_READ_LONG_TIME + GALLAGHER_READ_JITTER_TIME)
|
||||
#define GALLAGHER_READ_LONG_TIME_LOW (GALLAGHER_READ_LONG_TIME - GALLAGHER_READ_JITTER_TIME)
|
||||
#define GALLAGHER_READ_LONG_TIME_HIGH (GALLAGHER_READ_LONG_TIME + GALLAGHER_READ_JITTER_TIME)
|
||||
|
||||
typedef struct {
|
||||
uint8_t data[GALLAGHER_DECODED_DATA_SIZE];
|
||||
@@ -36,15 +36,15 @@ typedef struct {
|
||||
ProtocolGallagher* protocol_gallagher_alloc(void) {
|
||||
ProtocolGallagher* proto = malloc(sizeof(ProtocolGallagher));
|
||||
return (void*)proto;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_gallagher_free(ProtocolGallagher* protocol) {
|
||||
free(protocol);
|
||||
};
|
||||
}
|
||||
|
||||
uint8_t* protocol_gallagher_get_data(ProtocolGallagher* protocol) {
|
||||
return protocol->data;
|
||||
};
|
||||
}
|
||||
|
||||
static void protocol_gallagher_scramble(uint8_t* data, size_t length) {
|
||||
const uint8_t lut[] = {
|
||||
@@ -152,7 +152,7 @@ void protocol_gallagher_decoder_start(ProtocolGallagher* protocol) {
|
||||
ManchesterEventReset,
|
||||
&protocol->decoder_manchester_state,
|
||||
NULL);
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_gallagher_decoder_feed(ProtocolGallagher* protocol, bool level, uint32_t duration) {
|
||||
bool result = false;
|
||||
@@ -189,7 +189,7 @@ bool protocol_gallagher_decoder_feed(ProtocolGallagher* protocol, bool level, ui
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_gallagher_encoder_start(ProtocolGallagher* protocol) {
|
||||
// Preamble
|
||||
@@ -227,7 +227,7 @@ bool protocol_gallagher_encoder_start(ProtocolGallagher* protocol) {
|
||||
bit_lib_set_bits(protocol->encoded_data, 16 + (9 * 8), crc, 8);
|
||||
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
LevelDuration protocol_gallagher_encoder_yield(ProtocolGallagher* protocol) {
|
||||
bool level = bit_lib_get_bit(protocol->encoded_data, protocol->encoded_data_index);
|
||||
@@ -243,7 +243,7 @@ LevelDuration protocol_gallagher_encoder_yield(ProtocolGallagher* protocol) {
|
||||
}
|
||||
|
||||
return level_duration_make(level, duration);
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_gallagher_write_data(ProtocolGallagher* protocol, void* data) {
|
||||
LFRFIDWriteRequest* request = (LFRFIDWriteRequest*)data;
|
||||
@@ -266,7 +266,7 @@ bool protocol_gallagher_write_data(ProtocolGallagher* protocol, void* data) {
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
static void protocol_gallagher_render_data_internal(
|
||||
ProtocolGallagher* protocol,
|
||||
@@ -296,7 +296,7 @@ static void protocol_gallagher_render_data_internal(
|
||||
region,
|
||||
issue_level);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_gallagher_render_data(ProtocolGallagher* protocol, FuriString* result) {
|
||||
protocol_gallagher_render_data_internal(protocol, result, false);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
#include <toolbox/protocols/protocol.h>
|
||||
|
||||
extern const ProtocolBase protocol_gallagher;
|
||||
extern const ProtocolBase protocol_gallagher;
|
||||
|
||||
@@ -5,14 +5,14 @@
|
||||
#include "lfrfid_protocols.h"
|
||||
|
||||
#define JITTER_TIME (20)
|
||||
#define MIN_TIME (64 - JITTER_TIME)
|
||||
#define MAX_TIME (80 + JITTER_TIME)
|
||||
#define MIN_TIME (64 - JITTER_TIME)
|
||||
#define MAX_TIME (80 + JITTER_TIME)
|
||||
|
||||
#define H10301_DECODED_DATA_SIZE (3)
|
||||
#define H10301_DECODED_DATA_SIZE (3)
|
||||
#define H10301_ENCODED_DATA_SIZE_U32 (3)
|
||||
#define H10301_ENCODED_DATA_SIZE (sizeof(uint32_t) * H10301_ENCODED_DATA_SIZE_U32)
|
||||
#define H10301_ENCODED_DATA_SIZE (sizeof(uint32_t) * H10301_ENCODED_DATA_SIZE_U32)
|
||||
|
||||
#define H10301_BIT_SIZE (sizeof(uint32_t) * 8)
|
||||
#define H10301_BIT_SIZE (sizeof(uint32_t) * 8)
|
||||
#define H10301_BIT_MAX_SIZE (H10301_BIT_SIZE * H10301_DECODED_DATA_SIZE)
|
||||
|
||||
typedef struct {
|
||||
@@ -38,21 +38,21 @@ ProtocolH10301* protocol_h10301_alloc(void) {
|
||||
protocol->encoder.fsk_osc = fsk_osc_alloc(8, 10, 50);
|
||||
|
||||
return protocol;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_h10301_free(ProtocolH10301* protocol) {
|
||||
fsk_demod_free(protocol->decoder.fsk_demod);
|
||||
fsk_osc_free(protocol->encoder.fsk_osc);
|
||||
free(protocol);
|
||||
};
|
||||
}
|
||||
|
||||
uint8_t* protocol_h10301_get_data(ProtocolH10301* protocol) {
|
||||
return protocol->data;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_h10301_decoder_start(ProtocolH10301* protocol) {
|
||||
memset(protocol->encoded_data, 0, sizeof(uint32_t) * 3);
|
||||
};
|
||||
}
|
||||
|
||||
static void protocol_h10301_decoder_store_data(ProtocolH10301* protocol, bool data) {
|
||||
protocol->encoded_data[0] = (protocol->encoded_data[0] << 1) |
|
||||
@@ -205,7 +205,7 @@ bool protocol_h10301_decoder_feed(ProtocolH10301* protocol, bool level, uint32_t
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
static void protocol_h10301_write_raw_bit(bool bit, uint8_t position, uint32_t* card_data) {
|
||||
if(bit) {
|
||||
@@ -295,7 +295,7 @@ bool protocol_h10301_encoder_start(ProtocolH10301* protocol) {
|
||||
protocol->encoder.pulse = 0;
|
||||
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
LevelDuration protocol_h10301_encoder_yield(ProtocolH10301* protocol) {
|
||||
bool level = 0;
|
||||
@@ -331,7 +331,7 @@ LevelDuration protocol_h10301_encoder_yield(ProtocolH10301* protocol) {
|
||||
}
|
||||
|
||||
return level_duration_make(level, duration);
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_h10301_write_data(ProtocolH10301* protocol, void* data) {
|
||||
LFRFIDWriteRequest* request = (LFRFIDWriteRequest*)data;
|
||||
@@ -353,7 +353,7 @@ bool protocol_h10301_write_data(ProtocolH10301* protocol, void* data) {
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_h10301_render_data(ProtocolH10301* protocol, FuriString* result) {
|
||||
uint8_t* data = protocol->data;
|
||||
@@ -363,7 +363,7 @@ void protocol_h10301_render_data(ProtocolH10301* protocol, FuriString* result) {
|
||||
"Card: %hu",
|
||||
data[0],
|
||||
(uint16_t)((data[1] << 8) | (data[2])));
|
||||
};
|
||||
}
|
||||
|
||||
const ProtocolBase protocol_h10301 = {
|
||||
.name = "H10301",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
#include <toolbox/protocols/protocol.h>
|
||||
|
||||
extern const ProtocolBase protocol_h10301;
|
||||
extern const ProtocolBase protocol_h10301;
|
||||
|
||||
@@ -6,16 +6,16 @@
|
||||
#include <bit_lib/bit_lib.h>
|
||||
|
||||
#define JITTER_TIME (20)
|
||||
#define MIN_TIME (64 - JITTER_TIME)
|
||||
#define MAX_TIME (80 + JITTER_TIME)
|
||||
#define MIN_TIME (64 - JITTER_TIME)
|
||||
#define MAX_TIME (80 + JITTER_TIME)
|
||||
|
||||
#define HID_DATA_SIZE 23
|
||||
#define HID_DATA_SIZE 23
|
||||
#define HID_PREAMBLE_SIZE 1
|
||||
|
||||
#define HID_ENCODED_DATA_SIZE (HID_PREAMBLE_SIZE + HID_DATA_SIZE + HID_PREAMBLE_SIZE)
|
||||
#define HID_ENCODED_BIT_SIZE ((HID_PREAMBLE_SIZE + HID_DATA_SIZE) * 8)
|
||||
#define HID_ENCODED_BIT_SIZE ((HID_PREAMBLE_SIZE + HID_DATA_SIZE) * 8)
|
||||
#define HID_DECODED_DATA_SIZE (12)
|
||||
#define HID_DECODED_BIT_SIZE ((HID_ENCODED_BIT_SIZE - HID_PREAMBLE_SIZE * 8) / 2)
|
||||
#define HID_DECODED_BIT_SIZE ((HID_ENCODED_BIT_SIZE - HID_PREAMBLE_SIZE * 8) / 2)
|
||||
|
||||
#define HID_PREAMBLE 0x1D
|
||||
|
||||
@@ -43,21 +43,21 @@ ProtocolHIDEx* protocol_hid_ex_generic_alloc(void) {
|
||||
protocol->encoder.fsk_osc = fsk_osc_alloc(8, 10, 50);
|
||||
|
||||
return protocol;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_hid_ex_generic_free(ProtocolHIDEx* protocol) {
|
||||
fsk_demod_free(protocol->decoder.fsk_demod);
|
||||
fsk_osc_free(protocol->encoder.fsk_osc);
|
||||
free(protocol);
|
||||
};
|
||||
}
|
||||
|
||||
uint8_t* protocol_hid_ex_generic_get_data(ProtocolHIDEx* protocol) {
|
||||
return protocol->data;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_hid_ex_generic_decoder_start(ProtocolHIDEx* protocol) {
|
||||
memset(protocol->encoded_data, 0, HID_ENCODED_DATA_SIZE);
|
||||
};
|
||||
}
|
||||
|
||||
static bool protocol_hid_ex_generic_can_be_decoded(const uint8_t* data) {
|
||||
// check preamble
|
||||
@@ -110,7 +110,7 @@ bool protocol_hid_ex_generic_decoder_feed(ProtocolHIDEx* protocol, bool level, u
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
static void protocol_hid_ex_generic_encode(ProtocolHIDEx* protocol) {
|
||||
protocol->encoded_data[0] = HID_PREAMBLE;
|
||||
@@ -135,7 +135,7 @@ bool protocol_hid_ex_generic_encoder_start(ProtocolHIDEx* protocol) {
|
||||
protocol_hid_ex_generic_encode(protocol);
|
||||
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
LevelDuration protocol_hid_ex_generic_encoder_yield(ProtocolHIDEx* protocol) {
|
||||
bool level = 0;
|
||||
@@ -165,7 +165,7 @@ LevelDuration protocol_hid_ex_generic_encoder_yield(ProtocolHIDEx* protocol) {
|
||||
}
|
||||
|
||||
return level_duration_make(level, duration);
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_hid_ex_generic_write_data(ProtocolHIDEx* protocol, void* data) {
|
||||
LFRFIDWriteRequest* request = (LFRFIDWriteRequest*)data;
|
||||
@@ -190,7 +190,7 @@ bool protocol_hid_ex_generic_write_data(ProtocolHIDEx* protocol, void* data) {
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_hid_ex_generic_render_data(ProtocolHIDEx* protocol, FuriString* result) {
|
||||
UNUSED(protocol);
|
||||
@@ -200,7 +200,7 @@ void protocol_hid_ex_generic_render_data(ProtocolHIDEx* protocol, FuriString* re
|
||||
result,
|
||||
"Type: Generic HID Extended\n"
|
||||
"Data: Unknown");
|
||||
};
|
||||
}
|
||||
|
||||
const ProtocolBase protocol_hid_ex_generic = {
|
||||
.name = "HIDExt",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
#include <toolbox/protocols/protocol.h>
|
||||
|
||||
extern const ProtocolBase protocol_hid_ex_generic;
|
||||
extern const ProtocolBase protocol_hid_ex_generic;
|
||||
|
||||
@@ -6,17 +6,17 @@
|
||||
#include <bit_lib/bit_lib.h>
|
||||
|
||||
#define JITTER_TIME (20)
|
||||
#define MIN_TIME (64 - JITTER_TIME)
|
||||
#define MAX_TIME (80 + JITTER_TIME)
|
||||
#define MIN_TIME (64 - JITTER_TIME)
|
||||
#define MAX_TIME (80 + JITTER_TIME)
|
||||
|
||||
#define HID_DATA_SIZE 11
|
||||
#define HID_PREAMBLE_SIZE 1
|
||||
#define HID_DATA_SIZE 11
|
||||
#define HID_PREAMBLE_SIZE 1
|
||||
#define HID_PROTOCOL_SIZE_UNKNOWN 0
|
||||
|
||||
#define HID_ENCODED_DATA_SIZE (HID_PREAMBLE_SIZE + HID_DATA_SIZE + HID_PREAMBLE_SIZE)
|
||||
#define HID_ENCODED_BIT_SIZE ((HID_PREAMBLE_SIZE + HID_DATA_SIZE) * 8)
|
||||
#define HID_ENCODED_BIT_SIZE ((HID_PREAMBLE_SIZE + HID_DATA_SIZE) * 8)
|
||||
#define HID_DECODED_DATA_SIZE (6)
|
||||
#define HID_DECODED_BIT_SIZE ((HID_ENCODED_BIT_SIZE - HID_PREAMBLE_SIZE * 8) / 2)
|
||||
#define HID_DECODED_BIT_SIZE ((HID_ENCODED_BIT_SIZE - HID_PREAMBLE_SIZE * 8) / 2)
|
||||
|
||||
#define HID_PREAMBLE 0x1D
|
||||
|
||||
@@ -43,21 +43,21 @@ ProtocolHID* protocol_hid_generic_alloc(void) {
|
||||
protocol->encoder.fsk_osc = fsk_osc_alloc(8, 10, 50);
|
||||
|
||||
return protocol;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_hid_generic_free(ProtocolHID* protocol) {
|
||||
fsk_demod_free(protocol->decoder.fsk_demod);
|
||||
fsk_osc_free(protocol->encoder.fsk_osc);
|
||||
free(protocol);
|
||||
};
|
||||
}
|
||||
|
||||
uint8_t* protocol_hid_generic_get_data(ProtocolHID* protocol) {
|
||||
return protocol->data;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_hid_generic_decoder_start(ProtocolHID* protocol) {
|
||||
memset(protocol->encoded_data, 0, HID_ENCODED_DATA_SIZE);
|
||||
};
|
||||
}
|
||||
|
||||
static bool protocol_hid_generic_can_be_decoded(const uint8_t* data) {
|
||||
// check preamble
|
||||
@@ -142,7 +142,7 @@ bool protocol_hid_generic_decoder_feed(ProtocolHID* protocol, bool level, uint32
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
static void protocol_hid_generic_encode(ProtocolHID* protocol) {
|
||||
protocol->encoded_data[0] = HID_PREAMBLE;
|
||||
@@ -167,7 +167,7 @@ bool protocol_hid_generic_encoder_start(ProtocolHID* protocol) {
|
||||
protocol_hid_generic_encode(protocol);
|
||||
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
LevelDuration protocol_hid_generic_encoder_yield(ProtocolHID* protocol) {
|
||||
bool level = 0;
|
||||
@@ -197,7 +197,7 @@ LevelDuration protocol_hid_generic_encoder_yield(ProtocolHID* protocol) {
|
||||
}
|
||||
|
||||
return level_duration_make(level, duration);
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_hid_generic_write_data(ProtocolHID* protocol, void* data) {
|
||||
LFRFIDWriteRequest* request = (LFRFIDWriteRequest*)data;
|
||||
@@ -219,7 +219,7 @@ bool protocol_hid_generic_write_data(ProtocolHID* protocol, void* data) {
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
static void protocol_hid_generic_string_cat_protocol_bits(
|
||||
ProtocolHID* protocol,
|
||||
@@ -261,7 +261,7 @@ void protocol_hid_generic_render_data(ProtocolHID* protocol, FuriString* result)
|
||||
protocol_size);
|
||||
protocol_hid_generic_string_cat_protocol_bits(protocol, protocol_size, result);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const ProtocolBase protocol_hid_generic = {
|
||||
.name = "HIDProx",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
#include <toolbox/protocols/protocol.h>
|
||||
|
||||
extern const ProtocolBase protocol_hid_generic;
|
||||
extern const ProtocolBase protocol_hid_generic;
|
||||
|
||||
@@ -8,17 +8,17 @@
|
||||
// 4 9 4 4 5 4 4 B 3 5 1 F B E 4 B
|
||||
// 0100 1001 0100 0100 0101 0100 0100 1011 0011 0101 0001 1111 1011 1110 0100 1011
|
||||
|
||||
#define IDTECK_PREAMBLE_BIT_SIZE (32)
|
||||
#define IDTECK_PREAMBLE_BIT_SIZE (32)
|
||||
#define IDTECK_PREAMBLE_DATA_SIZE (8)
|
||||
|
||||
#define IDTECK_ENCODED_BIT_SIZE (64)
|
||||
#define IDTECK_ENCODED_BIT_SIZE (64)
|
||||
#define IDTECK_ENCODED_DATA_SIZE (((IDTECK_ENCODED_BIT_SIZE) / 8) + IDTECK_PREAMBLE_DATA_SIZE)
|
||||
#define IDTECK_ENCODED_DATA_LAST ((IDTECK_ENCODED_BIT_SIZE) / 8)
|
||||
|
||||
#define IDTECK_DECODED_BIT_SIZE (64)
|
||||
#define IDTECK_DECODED_BIT_SIZE (64)
|
||||
#define IDTECK_DECODED_DATA_SIZE (8)
|
||||
|
||||
#define IDTECK_US_PER_BIT (255)
|
||||
#define IDTECK_US_PER_BIT (255)
|
||||
#define IDTECK_ENCODER_PULSES_PER_BIT (16)
|
||||
|
||||
typedef struct {
|
||||
@@ -42,22 +42,22 @@ typedef struct {
|
||||
ProtocolIdteck* protocol_idteck_alloc(void) {
|
||||
ProtocolIdteck* protocol = malloc(sizeof(ProtocolIdteck));
|
||||
return protocol;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_idteck_free(ProtocolIdteck* protocol) {
|
||||
free(protocol);
|
||||
};
|
||||
}
|
||||
|
||||
uint8_t* protocol_idteck_get_data(ProtocolIdteck* protocol) {
|
||||
return protocol->data;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_idteck_decoder_start(ProtocolIdteck* protocol) {
|
||||
memset(protocol->encoded_data, 0, IDTECK_ENCODED_DATA_SIZE);
|
||||
memset(protocol->negative_encoded_data, 0, IDTECK_ENCODED_DATA_SIZE);
|
||||
memset(protocol->corrupted_encoded_data, 0, IDTECK_ENCODED_DATA_SIZE);
|
||||
memset(protocol->corrupted_negative_encoded_data, 0, IDTECK_ENCODED_DATA_SIZE);
|
||||
};
|
||||
}
|
||||
|
||||
static bool protocol_idteck_check_preamble(uint8_t* data, size_t bit_index) {
|
||||
// Preamble 01001001 01000100 01010100 01001011
|
||||
@@ -144,7 +144,7 @@ bool protocol_idteck_decoder_feed(ProtocolIdteck* protocol, bool level, uint32_t
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_idteck_encoder_start(ProtocolIdteck* protocol) {
|
||||
memset(protocol->encoded_data, 0, IDTECK_ENCODED_DATA_SIZE);
|
||||
@@ -159,7 +159,7 @@ bool protocol_idteck_encoder_start(ProtocolIdteck* protocol) {
|
||||
protocol->encoder.bit_clock_index = 0;
|
||||
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
LevelDuration protocol_idteck_encoder_yield(ProtocolIdteck* protocol) {
|
||||
LevelDuration level_duration;
|
||||
@@ -189,7 +189,7 @@ LevelDuration protocol_idteck_encoder_yield(ProtocolIdteck* protocol) {
|
||||
}
|
||||
|
||||
return level_duration;
|
||||
};
|
||||
}
|
||||
|
||||
// factory code
|
||||
static uint32_t get_fc(const uint8_t* data) {
|
||||
@@ -232,7 +232,7 @@ bool protocol_idteck_write_data(ProtocolIdteck* protocol, void* data) {
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
const ProtocolBase protocol_idteck = {
|
||||
.name = "Idteck",
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <bit_lib/bit_lib.h>
|
||||
#include "lfrfid_protocols.h"
|
||||
|
||||
#define INDALA26_PREAMBLE_BIT_SIZE (33)
|
||||
#define INDALA26_PREAMBLE_BIT_SIZE (33)
|
||||
#define INDALA26_PREAMBLE_DATA_SIZE (5)
|
||||
|
||||
#define INDALA26_ENCODED_BIT_SIZE (64)
|
||||
@@ -11,10 +11,10 @@
|
||||
(((INDALA26_ENCODED_BIT_SIZE) / 8) + INDALA26_PREAMBLE_DATA_SIZE)
|
||||
#define INDALA26_ENCODED_DATA_LAST ((INDALA26_ENCODED_BIT_SIZE) / 8)
|
||||
|
||||
#define INDALA26_DECODED_BIT_SIZE (28)
|
||||
#define INDALA26_DECODED_BIT_SIZE (28)
|
||||
#define INDALA26_DECODED_DATA_SIZE (4)
|
||||
|
||||
#define INDALA26_US_PER_BIT (255)
|
||||
#define INDALA26_US_PER_BIT (255)
|
||||
#define INDALA26_ENCODER_PULSES_PER_BIT (16)
|
||||
|
||||
typedef struct {
|
||||
@@ -38,22 +38,22 @@ typedef struct {
|
||||
ProtocolIndala* protocol_indala26_alloc(void) {
|
||||
ProtocolIndala* protocol = malloc(sizeof(ProtocolIndala));
|
||||
return protocol;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_indala26_free(ProtocolIndala* protocol) {
|
||||
free(protocol);
|
||||
};
|
||||
}
|
||||
|
||||
uint8_t* protocol_indala26_get_data(ProtocolIndala* protocol) {
|
||||
return protocol->data;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_indala26_decoder_start(ProtocolIndala* protocol) {
|
||||
memset(protocol->encoded_data, 0, INDALA26_ENCODED_DATA_SIZE);
|
||||
memset(protocol->negative_encoded_data, 0, INDALA26_ENCODED_DATA_SIZE);
|
||||
memset(protocol->corrupted_encoded_data, 0, INDALA26_ENCODED_DATA_SIZE);
|
||||
memset(protocol->corrupted_negative_encoded_data, 0, INDALA26_ENCODED_DATA_SIZE);
|
||||
};
|
||||
}
|
||||
|
||||
static bool protocol_indala26_check_preamble(uint8_t* data, size_t bit_index) {
|
||||
// Preamble 10100000 00000000 00000000 00000000 1
|
||||
@@ -146,7 +146,7 @@ bool protocol_indala26_decoder_feed(ProtocolIndala* protocol, bool level, uint32
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_indala26_encoder_start(ProtocolIndala* protocol) {
|
||||
memset(protocol->encoded_data, 0, INDALA26_ENCODED_DATA_SIZE);
|
||||
@@ -164,7 +164,7 @@ bool protocol_indala26_encoder_start(ProtocolIndala* protocol) {
|
||||
protocol->encoder.bit_clock_index = 0;
|
||||
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
LevelDuration protocol_indala26_encoder_yield(ProtocolIndala* protocol) {
|
||||
LevelDuration level_duration;
|
||||
@@ -194,7 +194,7 @@ LevelDuration protocol_indala26_encoder_yield(ProtocolIndala* protocol) {
|
||||
}
|
||||
|
||||
return level_duration;
|
||||
};
|
||||
}
|
||||
|
||||
// factory code
|
||||
static uint8_t get_fc(const uint8_t* data) {
|
||||
@@ -328,7 +328,7 @@ bool protocol_indala26_write_data(ProtocolIndala* protocol, void* data) {
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
const ProtocolBase protocol_indala26 = {
|
||||
.name = "Indala26",
|
||||
|
||||
@@ -6,13 +6,13 @@
|
||||
#include "lfrfid_protocols.h"
|
||||
|
||||
#define JITTER_TIME (20)
|
||||
#define MIN_TIME (64 - JITTER_TIME)
|
||||
#define MAX_TIME (80 + JITTER_TIME)
|
||||
#define MIN_TIME (64 - JITTER_TIME)
|
||||
#define MAX_TIME (80 + JITTER_TIME)
|
||||
|
||||
#define IOPROXXSF_DECODED_DATA_SIZE (4)
|
||||
#define IOPROXXSF_ENCODED_DATA_SIZE (8)
|
||||
|
||||
#define IOPROXXSF_BIT_SIZE (8)
|
||||
#define IOPROXXSF_BIT_SIZE (8)
|
||||
#define IOPROXXSF_BIT_MAX_SIZE (IOPROXXSF_BIT_SIZE * IOPROXXSF_ENCODED_DATA_SIZE)
|
||||
|
||||
typedef struct {
|
||||
@@ -36,21 +36,21 @@ ProtocolIOProxXSF* protocol_io_prox_xsf_alloc(void) {
|
||||
protocol->decoder.fsk_demod = fsk_demod_alloc(MIN_TIME, 8, MAX_TIME, 6);
|
||||
protocol->encoder.fsk_osc = fsk_osc_alloc(8, 10, 64);
|
||||
return protocol;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_io_prox_xsf_free(ProtocolIOProxXSF* protocol) {
|
||||
fsk_demod_free(protocol->decoder.fsk_demod);
|
||||
fsk_osc_free(protocol->encoder.fsk_osc);
|
||||
free(protocol);
|
||||
};
|
||||
}
|
||||
|
||||
uint8_t* protocol_io_prox_xsf_get_data(ProtocolIOProxXSF* protocol) {
|
||||
return protocol->data;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_io_prox_xsf_decoder_start(ProtocolIOProxXSF* protocol) {
|
||||
memset(protocol->encoded_data, 0, IOPROXXSF_ENCODED_DATA_SIZE);
|
||||
};
|
||||
}
|
||||
|
||||
static uint8_t protocol_io_prox_xsf_compute_checksum(const uint8_t* data) {
|
||||
// Packet structure:
|
||||
@@ -172,7 +172,7 @@ bool protocol_io_prox_xsf_decoder_feed(ProtocolIOProxXSF* protocol, bool level,
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
static void protocol_io_prox_xsf_encode(const uint8_t* decoded_data, uint8_t* encoded_data) {
|
||||
// Packet to transmit:
|
||||
@@ -217,7 +217,7 @@ bool protocol_io_prox_xsf_encoder_start(ProtocolIOProxXSF* protocol) {
|
||||
protocol->encoder.encoded_index = 0;
|
||||
fsk_osc_reset(protocol->encoder.fsk_osc);
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
LevelDuration protocol_io_prox_xsf_encoder_yield(ProtocolIOProxXSF* protocol) {
|
||||
bool level;
|
||||
@@ -230,7 +230,7 @@ LevelDuration protocol_io_prox_xsf_encoder_yield(ProtocolIOProxXSF* protocol) {
|
||||
bit_lib_increment_index(protocol->encoder.encoded_index, IOPROXXSF_BIT_MAX_SIZE);
|
||||
}
|
||||
return level_duration_make(level, duration);
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_io_prox_xsf_render_data(ProtocolIOProxXSF* protocol, FuriString* result) {
|
||||
uint8_t* data = protocol->data;
|
||||
@@ -274,7 +274,7 @@ bool protocol_io_prox_xsf_write_data(ProtocolIOProxXSF* protocol, void* data) {
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
const ProtocolBase protocol_io_prox_xsf = {
|
||||
.name = "IoProxXSF",
|
||||
|
||||
@@ -5,23 +5,23 @@
|
||||
#include <bit_lib/bit_lib.h>
|
||||
#include "lfrfid_protocols.h"
|
||||
|
||||
#define JABLOTRON_ENCODED_BIT_SIZE (64)
|
||||
#define JABLOTRON_ENCODED_BYTE_SIZE (((JABLOTRON_ENCODED_BIT_SIZE) / 8))
|
||||
#define JABLOTRON_PREAMBLE_BIT_SIZE (16)
|
||||
#define JABLOTRON_ENCODED_BIT_SIZE (64)
|
||||
#define JABLOTRON_ENCODED_BYTE_SIZE (((JABLOTRON_ENCODED_BIT_SIZE) / 8))
|
||||
#define JABLOTRON_PREAMBLE_BIT_SIZE (16)
|
||||
#define JABLOTRON_PREAMBLE_BYTE_SIZE (2)
|
||||
#define JABLOTRON_ENCODED_BYTE_FULL_SIZE \
|
||||
(JABLOTRON_ENCODED_BYTE_SIZE + JABLOTRON_PREAMBLE_BYTE_SIZE)
|
||||
|
||||
#define JABLOTRON_DECODED_DATA_SIZE (5)
|
||||
|
||||
#define JABLOTRON_SHORT_TIME (256)
|
||||
#define JABLOTRON_LONG_TIME (512)
|
||||
#define JABLOTRON_SHORT_TIME (256)
|
||||
#define JABLOTRON_LONG_TIME (512)
|
||||
#define JABLOTRON_JITTER_TIME (120)
|
||||
|
||||
#define JABLOTRON_SHORT_TIME_LOW (JABLOTRON_SHORT_TIME - JABLOTRON_JITTER_TIME)
|
||||
#define JABLOTRON_SHORT_TIME_LOW (JABLOTRON_SHORT_TIME - JABLOTRON_JITTER_TIME)
|
||||
#define JABLOTRON_SHORT_TIME_HIGH (JABLOTRON_SHORT_TIME + JABLOTRON_JITTER_TIME)
|
||||
#define JABLOTRON_LONG_TIME_LOW (JABLOTRON_LONG_TIME - JABLOTRON_JITTER_TIME)
|
||||
#define JABLOTRON_LONG_TIME_HIGH (JABLOTRON_LONG_TIME + JABLOTRON_JITTER_TIME)
|
||||
#define JABLOTRON_LONG_TIME_LOW (JABLOTRON_LONG_TIME - JABLOTRON_JITTER_TIME)
|
||||
#define JABLOTRON_LONG_TIME_HIGH (JABLOTRON_LONG_TIME + JABLOTRON_JITTER_TIME)
|
||||
|
||||
typedef struct {
|
||||
bool last_short;
|
||||
@@ -34,20 +34,20 @@ typedef struct {
|
||||
ProtocolJablotron* protocol_jablotron_alloc(void) {
|
||||
ProtocolJablotron* protocol = malloc(sizeof(ProtocolJablotron));
|
||||
return protocol;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_jablotron_free(ProtocolJablotron* protocol) {
|
||||
free(protocol);
|
||||
};
|
||||
}
|
||||
|
||||
uint8_t* protocol_jablotron_get_data(ProtocolJablotron* proto) {
|
||||
return proto->data;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_jablotron_decoder_start(ProtocolJablotron* protocol) {
|
||||
memset(protocol->encoded_data, 0, JABLOTRON_ENCODED_BYTE_FULL_SIZE);
|
||||
protocol->last_short = false;
|
||||
};
|
||||
}
|
||||
|
||||
uint8_t protocol_jablotron_checksum(uint8_t* bits) {
|
||||
uint8_t chksum = 0;
|
||||
@@ -115,7 +115,7 @@ bool protocol_jablotron_decoder_feed(ProtocolJablotron* protocol, bool level, ui
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_jablotron_encoder_start(ProtocolJablotron* protocol) {
|
||||
// preamble
|
||||
@@ -133,7 +133,7 @@ bool protocol_jablotron_encoder_start(ProtocolJablotron* protocol) {
|
||||
protocol->last_short = false;
|
||||
protocol->last_level = false;
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
LevelDuration protocol_jablotron_encoder_yield(ProtocolJablotron* protocol) {
|
||||
uint32_t duration;
|
||||
@@ -158,12 +158,12 @@ LevelDuration protocol_jablotron_encoder_yield(ProtocolJablotron* protocol) {
|
||||
}
|
||||
|
||||
return level_duration_make(protocol->last_level, duration);
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_jablotron_render_data(ProtocolJablotron* protocol, FuriString* result) {
|
||||
uint64_t id = protocol_jablotron_card_id(protocol->data);
|
||||
furi_string_printf(result, "Card: %llX", id);
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_jablotron_write_data(ProtocolJablotron* protocol, void* data) {
|
||||
LFRFIDWriteRequest* request = (LFRFIDWriteRequest*)data;
|
||||
@@ -184,7 +184,7 @@ bool protocol_jablotron_write_data(ProtocolJablotron* protocol, void* data) {
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
const ProtocolBase protocol_jablotron = {
|
||||
.name = "Jablotron",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
#include <toolbox/protocols/protocol.h>
|
||||
|
||||
extern const ProtocolBase protocol_jablotron;
|
||||
extern const ProtocolBase protocol_jablotron;
|
||||
|
||||
@@ -3,17 +3,17 @@
|
||||
#include <bit_lib/bit_lib.h>
|
||||
#include "lfrfid_protocols.h"
|
||||
|
||||
#define KERI_PREAMBLE_BIT_SIZE (33)
|
||||
#define KERI_PREAMBLE_BIT_SIZE (33)
|
||||
#define KERI_PREAMBLE_DATA_SIZE (5)
|
||||
|
||||
#define KERI_ENCODED_BIT_SIZE (64)
|
||||
#define KERI_ENCODED_BIT_SIZE (64)
|
||||
#define KERI_ENCODED_DATA_SIZE (((KERI_ENCODED_BIT_SIZE) / 8) + KERI_PREAMBLE_DATA_SIZE)
|
||||
#define KERI_ENCODED_DATA_LAST ((KERI_ENCODED_BIT_SIZE) / 8)
|
||||
|
||||
#define KERI_DECODED_BIT_SIZE (28)
|
||||
#define KERI_DECODED_BIT_SIZE (28)
|
||||
#define KERI_DECODED_DATA_SIZE (4)
|
||||
|
||||
#define KERI_US_PER_BIT (255)
|
||||
#define KERI_US_PER_BIT (255)
|
||||
#define KERI_ENCODER_PULSES_PER_BIT (16)
|
||||
|
||||
typedef struct {
|
||||
@@ -37,22 +37,22 @@ typedef struct {
|
||||
ProtocolKeri* protocol_keri_alloc(void) {
|
||||
ProtocolKeri* protocol = malloc(sizeof(ProtocolKeri));
|
||||
return protocol;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_keri_free(ProtocolKeri* protocol) {
|
||||
free(protocol);
|
||||
};
|
||||
}
|
||||
|
||||
uint8_t* protocol_keri_get_data(ProtocolKeri* protocol) {
|
||||
return protocol->data;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_keri_decoder_start(ProtocolKeri* protocol) {
|
||||
memset(protocol->encoded_data, 0, KERI_ENCODED_DATA_SIZE);
|
||||
memset(protocol->negative_encoded_data, 0, KERI_ENCODED_DATA_SIZE);
|
||||
memset(protocol->corrupted_encoded_data, 0, KERI_ENCODED_DATA_SIZE);
|
||||
memset(protocol->corrupted_negative_encoded_data, 0, KERI_ENCODED_DATA_SIZE);
|
||||
};
|
||||
}
|
||||
|
||||
static bool protocol_keri_check_preamble(uint8_t* data, size_t bit_index) {
|
||||
// Preamble 11100000 00000000 00000000 00000000 1
|
||||
@@ -164,7 +164,7 @@ bool protocol_keri_decoder_feed(ProtocolKeri* protocol, bool level, uint32_t dur
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_keri_encoder_start(ProtocolKeri* protocol) {
|
||||
memset(protocol->encoded_data, 0, KERI_ENCODED_DATA_SIZE);
|
||||
@@ -180,7 +180,7 @@ bool protocol_keri_encoder_start(ProtocolKeri* protocol) {
|
||||
protocol->encoder.bit_clock_index = 0;
|
||||
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
LevelDuration protocol_keri_encoder_yield(ProtocolKeri* protocol) {
|
||||
LevelDuration level_duration;
|
||||
@@ -210,7 +210,7 @@ LevelDuration protocol_keri_encoder_yield(ProtocolKeri* protocol) {
|
||||
}
|
||||
|
||||
return level_duration;
|
||||
};
|
||||
}
|
||||
|
||||
static void
|
||||
protocol_keri_render_data_internal(ProtocolKeri* protocol, FuriString* result, bool brief) {
|
||||
@@ -267,7 +267,7 @@ bool protocol_keri_write_data(ProtocolKeri* protocol, void* data) {
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
const ProtocolBase protocol_keri = {
|
||||
.name = "Keri",
|
||||
|
||||
@@ -3,16 +3,16 @@
|
||||
#include <bit_lib/bit_lib.h>
|
||||
#include "lfrfid_protocols.h"
|
||||
|
||||
#define NEXWATCH_PREAMBLE_BIT_SIZE (8)
|
||||
#define NEXWATCH_PREAMBLE_BIT_SIZE (8)
|
||||
#define NEXWATCH_PREAMBLE_DATA_SIZE (1)
|
||||
|
||||
#define NEXWATCH_ENCODED_BIT_SIZE (96)
|
||||
#define NEXWATCH_ENCODED_BIT_SIZE (96)
|
||||
#define NEXWATCH_ENCODED_DATA_SIZE ((NEXWATCH_ENCODED_BIT_SIZE) / 8)
|
||||
|
||||
#define NEXWATCH_DECODED_BIT_SIZE (NEXWATCH_DECODED_DATA_SIZE * 8)
|
||||
#define NEXWATCH_DECODED_BIT_SIZE (NEXWATCH_DECODED_DATA_SIZE * 8)
|
||||
#define NEXWATCH_DECODED_DATA_SIZE (8)
|
||||
|
||||
#define NEXWATCH_US_PER_BIT (255)
|
||||
#define NEXWATCH_US_PER_BIT (255)
|
||||
#define NEXWATCH_ENCODER_PULSES_PER_BIT (16)
|
||||
|
||||
typedef struct {
|
||||
@@ -47,22 +47,22 @@ typedef struct {
|
||||
ProtocolNexwatch* protocol_nexwatch_alloc(void) {
|
||||
ProtocolNexwatch* protocol = malloc(sizeof(ProtocolNexwatch));
|
||||
return protocol;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_nexwatch_free(ProtocolNexwatch* protocol) {
|
||||
free(protocol);
|
||||
};
|
||||
}
|
||||
|
||||
uint8_t* protocol_nexwatch_get_data(ProtocolNexwatch* protocol) {
|
||||
return protocol->data;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_nexwatch_decoder_start(ProtocolNexwatch* protocol) {
|
||||
memset(protocol->encoded_data, 0, NEXWATCH_ENCODED_DATA_SIZE);
|
||||
memset(protocol->negative_encoded_data, 0, NEXWATCH_ENCODED_DATA_SIZE);
|
||||
memset(protocol->corrupted_encoded_data, 0, NEXWATCH_ENCODED_DATA_SIZE);
|
||||
memset(protocol->corrupted_negative_encoded_data, 0, NEXWATCH_ENCODED_DATA_SIZE);
|
||||
};
|
||||
}
|
||||
|
||||
static bool protocol_nexwatch_check_preamble(uint8_t* data, size_t bit_index) {
|
||||
// 01010110
|
||||
@@ -71,7 +71,7 @@ static bool protocol_nexwatch_check_preamble(uint8_t* data, size_t bit_index) {
|
||||
}
|
||||
|
||||
static uint8_t protocol_nexwatch_parity_swap(uint8_t parity) {
|
||||
uint8_t a = (((parity >> 3) & 1));
|
||||
uint8_t a = ((parity >> 3) & 1);
|
||||
a |= (((parity >> 1) & 1) << 1);
|
||||
a |= (((parity >> 2) & 1) << 2);
|
||||
a |= ((parity & 1) << 3);
|
||||
@@ -215,7 +215,7 @@ bool protocol_nexwatch_decoder_feed(ProtocolNexwatch* protocol, bool level, uint
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_nexwatch_encoder_start(ProtocolNexwatch* protocol) {
|
||||
memset(protocol->encoded_data, 0, NEXWATCH_ENCODED_DATA_SIZE);
|
||||
@@ -231,7 +231,7 @@ bool protocol_nexwatch_encoder_start(ProtocolNexwatch* protocol) {
|
||||
protocol->encoder.bit_clock_index = 0;
|
||||
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
LevelDuration protocol_nexwatch_encoder_yield(ProtocolNexwatch* protocol) {
|
||||
LevelDuration level_duration;
|
||||
@@ -261,7 +261,7 @@ LevelDuration protocol_nexwatch_encoder_yield(ProtocolNexwatch* protocol) {
|
||||
}
|
||||
|
||||
return level_duration;
|
||||
};
|
||||
}
|
||||
|
||||
static void protocol_nexwatch_render_data_internal(
|
||||
ProtocolNexwatch* protocol,
|
||||
@@ -328,7 +328,7 @@ bool protocol_nexwatch_write_data(ProtocolNexwatch* protocol, void* data) {
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
const ProtocolBase protocol_nexwatch = {
|
||||
.name = "Nexwatch",
|
||||
|
||||
@@ -5,13 +5,13 @@
|
||||
#include <bit_lib/bit_lib.h>
|
||||
#include "lfrfid_protocols.h"
|
||||
|
||||
#define PAC_STANLEY_ENCODED_BIT_SIZE (128)
|
||||
#define PAC_STANLEY_ENCODED_BYTE_SIZE (((PAC_STANLEY_ENCODED_BIT_SIZE) / 8))
|
||||
#define PAC_STANLEY_PREAMBLE_BIT_SIZE (8)
|
||||
#define PAC_STANLEY_ENCODED_BIT_SIZE (128)
|
||||
#define PAC_STANLEY_ENCODED_BYTE_SIZE (((PAC_STANLEY_ENCODED_BIT_SIZE) / 8))
|
||||
#define PAC_STANLEY_PREAMBLE_BIT_SIZE (8)
|
||||
#define PAC_STANLEY_PREAMBLE_BYTE_SIZE (1)
|
||||
#define PAC_STANLEY_ENCODED_BYTE_FULL_SIZE \
|
||||
(PAC_STANLEY_ENCODED_BYTE_SIZE + PAC_STANLEY_PREAMBLE_BYTE_SIZE)
|
||||
#define PAC_STANLEY_BYTE_LENGTH (10) // start bit, 7 data bits, parity bit, stop bit
|
||||
#define PAC_STANLEY_BYTE_LENGTH (10) // start bit, 7 data bits, parity bit, stop bit
|
||||
#define PAC_STANLEY_DATA_START_INDEX (8 + (3 * PAC_STANLEY_BYTE_LENGTH) + 1)
|
||||
|
||||
#define PAC_STANLEY_DECODED_DATA_SIZE (4)
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
#define PAC_STANLEY_CLOCKS_IN_US (32)
|
||||
#define PAC_STANLEY_CYCLE_LENGTH (256)
|
||||
#define PAC_STANLEY_MIN_TIME (60)
|
||||
#define PAC_STANLEY_MAX_TIME (4000)
|
||||
#define PAC_STANLEY_MIN_TIME (60)
|
||||
#define PAC_STANLEY_MAX_TIME (4000)
|
||||
|
||||
typedef struct {
|
||||
bool inverted;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
#include <toolbox/protocols/protocol.h>
|
||||
|
||||
extern const ProtocolBase protocol_pac_stanley;
|
||||
extern const ProtocolBase protocol_pac_stanley;
|
||||
|
||||
@@ -6,13 +6,13 @@
|
||||
#include "lfrfid_protocols.h"
|
||||
|
||||
#define JITTER_TIME (20)
|
||||
#define MIN_TIME (64 - JITTER_TIME)
|
||||
#define MAX_TIME (80 + JITTER_TIME)
|
||||
#define MIN_TIME (64 - JITTER_TIME)
|
||||
#define MAX_TIME (80 + JITTER_TIME)
|
||||
|
||||
#define PARADOX_DECODED_DATA_SIZE (6)
|
||||
|
||||
#define PARADOX_PREAMBLE_LENGTH (8)
|
||||
#define PARADOX_ENCODED_BIT_SIZE (96)
|
||||
#define PARADOX_PREAMBLE_LENGTH (8)
|
||||
#define PARADOX_ENCODED_BIT_SIZE (96)
|
||||
#define PARADOX_ENCODED_DATA_SIZE (((PARADOX_ENCODED_BIT_SIZE) / 8) + 1)
|
||||
#define PARADOX_ENCODED_DATA_LAST (PARADOX_ENCODED_DATA_SIZE - 1)
|
||||
|
||||
@@ -38,21 +38,21 @@ ProtocolParadox* protocol_paradox_alloc(void) {
|
||||
protocol->encoder.fsk_osc = fsk_osc_alloc(8, 10, 50);
|
||||
|
||||
return protocol;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_paradox_free(ProtocolParadox* protocol) {
|
||||
fsk_demod_free(protocol->decoder.fsk_demod);
|
||||
fsk_osc_free(protocol->encoder.fsk_osc);
|
||||
free(protocol);
|
||||
};
|
||||
}
|
||||
|
||||
uint8_t* protocol_paradox_get_data(ProtocolParadox* protocol) {
|
||||
return protocol->data;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_paradox_decoder_start(ProtocolParadox* protocol) {
|
||||
memset(protocol->encoded_data, 0, PARADOX_ENCODED_DATA_SIZE);
|
||||
};
|
||||
}
|
||||
|
||||
static bool protocol_paradox_can_be_decoded(ProtocolParadox* protocol) {
|
||||
// check preamble
|
||||
@@ -101,7 +101,7 @@ bool protocol_paradox_decoder_feed(ProtocolParadox* protocol, bool level, uint32
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
static void protocol_paradox_encode(const uint8_t* decoded_data, uint8_t* encoded_data) {
|
||||
// preamble
|
||||
@@ -114,14 +114,14 @@ static void protocol_paradox_encode(const uint8_t* decoded_data, uint8_t* encode
|
||||
bit_lib_set_bits(encoded_data, PARADOX_PREAMBLE_LENGTH + i * 2, 0b01, 2);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_paradox_encoder_start(ProtocolParadox* protocol) {
|
||||
protocol_paradox_encode(protocol->data, (uint8_t*)protocol->encoded_data);
|
||||
protocol->encoder.encoded_index = 0;
|
||||
fsk_osc_reset(protocol->encoder.fsk_osc);
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
LevelDuration protocol_paradox_encoder_yield(ProtocolParadox* protocol) {
|
||||
bool level;
|
||||
@@ -134,7 +134,7 @@ LevelDuration protocol_paradox_encoder_yield(ProtocolParadox* protocol) {
|
||||
bit_lib_increment_index(protocol->encoder.encoded_index, PARADOX_ENCODED_BIT_SIZE);
|
||||
}
|
||||
return level_duration_make(level, duration);
|
||||
};
|
||||
}
|
||||
|
||||
static uint8_t protocol_paradox_calculate_checksum(uint8_t fc, uint16_t card_id) {
|
||||
uint8_t card_hi = (card_id >> 8) & 0xff;
|
||||
@@ -185,7 +185,7 @@ void protocol_paradox_render_data(ProtocolParadox* protocol, FuriString* result)
|
||||
if(card_crc != calc_crc) {
|
||||
furi_string_cat(result, "\nCRC Mismatch, Invalid Card!");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_paradox_render_brief_data(ProtocolParadox* protocol, FuriString* result) {
|
||||
uint8_t* decoded_data = protocol->data;
|
||||
@@ -200,7 +200,7 @@ void protocol_paradox_render_brief_data(ProtocolParadox* protocol, FuriString* r
|
||||
if(calc_crc != card_crc) {
|
||||
furi_string_cat(result, "\nCRC Mismatch, Invalid Card!");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_paradox_write_data(ProtocolParadox* protocol, void* data) {
|
||||
LFRFIDWriteRequest* request = (LFRFIDWriteRequest*)data;
|
||||
@@ -222,7 +222,7 @@ bool protocol_paradox_write_data(ProtocolParadox* protocol, void* data) {
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
const ProtocolBase protocol_paradox = {
|
||||
.name = "Paradox",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
#include <toolbox/protocols/protocol.h>
|
||||
|
||||
extern const ProtocolBase protocol_paradox;
|
||||
extern const ProtocolBase protocol_paradox;
|
||||
|
||||
@@ -6,17 +6,17 @@
|
||||
#include <bit_lib/bit_lib.h>
|
||||
|
||||
#define JITTER_TIME (20)
|
||||
#define MIN_TIME (64 - JITTER_TIME)
|
||||
#define MAX_TIME (80 + JITTER_TIME)
|
||||
#define MIN_TIME (64 - JITTER_TIME)
|
||||
#define MAX_TIME (80 + JITTER_TIME)
|
||||
|
||||
#define PYRAMID_DATA_SIZE 13
|
||||
#define PYRAMID_DATA_SIZE 13
|
||||
#define PYRAMID_PREAMBLE_SIZE 3
|
||||
|
||||
#define PYRAMID_ENCODED_DATA_SIZE \
|
||||
(PYRAMID_PREAMBLE_SIZE + PYRAMID_DATA_SIZE + PYRAMID_PREAMBLE_SIZE)
|
||||
#define PYRAMID_ENCODED_BIT_SIZE ((PYRAMID_PREAMBLE_SIZE + PYRAMID_DATA_SIZE) * 8)
|
||||
#define PYRAMID_ENCODED_BIT_SIZE ((PYRAMID_PREAMBLE_SIZE + PYRAMID_DATA_SIZE) * 8)
|
||||
#define PYRAMID_DECODED_DATA_SIZE (4)
|
||||
#define PYRAMID_DECODED_BIT_SIZE ((PYRAMID_ENCODED_BIT_SIZE - PYRAMID_PREAMBLE_SIZE * 8) / 2)
|
||||
#define PYRAMID_DECODED_BIT_SIZE ((PYRAMID_ENCODED_BIT_SIZE - PYRAMID_PREAMBLE_SIZE * 8) / 2)
|
||||
|
||||
typedef struct {
|
||||
FSKDemod* fsk_demod;
|
||||
@@ -41,21 +41,21 @@ ProtocolPyramid* protocol_pyramid_alloc(void) {
|
||||
protocol->encoder.fsk_osc = fsk_osc_alloc(8, 10, 50);
|
||||
|
||||
return protocol;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_pyramid_free(ProtocolPyramid* protocol) {
|
||||
fsk_demod_free(protocol->decoder.fsk_demod);
|
||||
fsk_osc_free(protocol->encoder.fsk_osc);
|
||||
free(protocol);
|
||||
};
|
||||
}
|
||||
|
||||
uint8_t* protocol_pyramid_get_data(ProtocolPyramid* protocol) {
|
||||
return protocol->data;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_pyramid_decoder_start(ProtocolPyramid* protocol) {
|
||||
memset(protocol->encoded_data, 0, PYRAMID_ENCODED_DATA_SIZE);
|
||||
};
|
||||
}
|
||||
|
||||
static bool protocol_pyramid_can_be_decoded(uint8_t* data) {
|
||||
// check preamble
|
||||
@@ -122,7 +122,7 @@ bool protocol_pyramid_decoder_feed(ProtocolPyramid* protocol, bool level, uint32
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_pyramid_get_parity(const uint8_t* bits, uint8_t type, int length) {
|
||||
int x;
|
||||
@@ -184,7 +184,7 @@ bool protocol_pyramid_encoder_start(ProtocolPyramid* protocol) {
|
||||
protocol_pyramid_encode(protocol);
|
||||
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
LevelDuration protocol_pyramid_encoder_yield(ProtocolPyramid* protocol) {
|
||||
bool level = 0;
|
||||
@@ -214,7 +214,7 @@ LevelDuration protocol_pyramid_encoder_yield(ProtocolPyramid* protocol) {
|
||||
}
|
||||
|
||||
return level_duration_make(level, duration);
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_pyramid_write_data(ProtocolPyramid* protocol, void* data) {
|
||||
LFRFIDWriteRequest* request = (LFRFIDWriteRequest*)data;
|
||||
@@ -238,7 +238,7 @@ bool protocol_pyramid_write_data(ProtocolPyramid* protocol, void* data) {
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_pyramid_render_data(ProtocolPyramid* protocol, FuriString* result) {
|
||||
uint8_t* decoded_data = protocol->data;
|
||||
@@ -256,7 +256,7 @@ void protocol_pyramid_render_data(ProtocolPyramid* protocol, FuriString* result)
|
||||
} else {
|
||||
furi_string_cat_printf(result, "Data: Unknown");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const ProtocolBase protocol_pyramid = {
|
||||
.name = "Pyramid",
|
||||
|
||||
@@ -11,28 +11,29 @@
|
||||
#include <toolbox/manchester_decoder.h>
|
||||
|
||||
#define TAG "SECURAKEY"
|
||||
|
||||
#define SECURAKEY_RKKT_ENCODED_FULL_SIZE_BITS (96)
|
||||
#define SECURAKEY_RKKT_ENCODED_FULL_SIZE_BYTE (12)
|
||||
|
||||
#define SECURAKEY_RKKTH_ENCODED_FULL_SIZE_BITS (64)
|
||||
#define SECURAKEY_RKKTH_ENCODED_FULL_SIZE_BYTE (8)
|
||||
|
||||
#define SECURAKEY_DECODED_DATA_SIZE_BITS (48)
|
||||
#define SECURAKEY_DECODED_DATA_SIZE_BITS (48)
|
||||
// RKKT: 16-bit for facility code/number, 16-bit for card number, 16-bit for two checksum
|
||||
// RKKTH: 16-bit zero padding, 32-bit card number
|
||||
#define SECURAKEY_DECODED_DATA_SIZE_BYTES (SECURAKEY_DECODED_DATA_SIZE_BITS / 8)
|
||||
#define LFRFID_FREQUENCY (125000)
|
||||
#define SECURAKEY_CLOCK_PER_BIT (40) // RF/40
|
||||
#define LFRFID_FREQUENCY (125000)
|
||||
#define SECURAKEY_CLOCK_PER_BIT (40) // RF/40
|
||||
#define SECURAKEY_READ_LONG_TIME \
|
||||
(1000000 / (LFRFID_FREQUENCY / SECURAKEY_CLOCK_PER_BIT)) // 1000000 micro sec / sec
|
||||
#define SECURAKEY_READ_SHORT_TIME (SECURAKEY_READ_LONG_TIME / 2)
|
||||
#define SECURAKEY_READ_SHORT_TIME (SECURAKEY_READ_LONG_TIME / 2)
|
||||
#define SECURAKEY_READ_JITTER_TIME (SECURAKEY_READ_SHORT_TIME * 40 / 100) // 40% jitter tolerance
|
||||
#define SECURAKEY_READ_SHORT_TIME_LOW \
|
||||
(SECURAKEY_READ_SHORT_TIME - \
|
||||
SECURAKEY_READ_JITTER_TIME) // these are used for manchester decoding
|
||||
#define SECURAKEY_READ_SHORT_TIME_HIGH (SECURAKEY_READ_SHORT_TIME + SECURAKEY_READ_JITTER_TIME)
|
||||
#define SECURAKEY_READ_LONG_TIME_LOW (SECURAKEY_READ_LONG_TIME - SECURAKEY_READ_JITTER_TIME)
|
||||
#define SECURAKEY_READ_LONG_TIME_HIGH (SECURAKEY_READ_LONG_TIME + SECURAKEY_READ_JITTER_TIME)
|
||||
#define SECURAKEY_READ_LONG_TIME_LOW (SECURAKEY_READ_LONG_TIME - SECURAKEY_READ_JITTER_TIME)
|
||||
#define SECURAKEY_READ_LONG_TIME_HIGH (SECURAKEY_READ_LONG_TIME + SECURAKEY_READ_JITTER_TIME)
|
||||
|
||||
typedef struct {
|
||||
uint8_t data[SECURAKEY_DECODED_DATA_SIZE_BYTES];
|
||||
@@ -47,15 +48,15 @@ typedef struct {
|
||||
ProtocolSecurakey* protocol_securakey_alloc(void) {
|
||||
ProtocolSecurakey* protocol = malloc(sizeof(ProtocolSecurakey));
|
||||
return (void*)protocol;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_securakey_free(ProtocolSecurakey* protocol) {
|
||||
free(protocol);
|
||||
};
|
||||
}
|
||||
|
||||
uint8_t* protocol_securakey_get_data(ProtocolSecurakey* protocol) {
|
||||
return protocol->data;
|
||||
};
|
||||
}
|
||||
|
||||
static bool protocol_securakey_can_be_decoded(ProtocolSecurakey* protocol) {
|
||||
// check 19 bits preamble + format flag
|
||||
@@ -71,7 +72,7 @@ static bool protocol_securakey_can_be_decoded(ProtocolSecurakey* protocol) {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
static void protocol_securakey_decode(ProtocolSecurakey* protocol) {
|
||||
memset(protocol->data, 0, SECURAKEY_DECODED_DATA_SIZE_BYTES);
|
||||
@@ -142,7 +143,7 @@ static void protocol_securakey_decode(ProtocolSecurakey* protocol) {
|
||||
// plaintext format (preamble and 32-bit? card number)
|
||||
// pppppppp pppppppp cccccccc cccccccc cccccccc cccccccc
|
||||
// 00000000 00000000 00101011 00011101 00000100 01001010
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_securakey_decoder_start(ProtocolSecurakey* protocol) {
|
||||
// always takes in encoded data as RKKT for simplicity
|
||||
@@ -153,7 +154,7 @@ void protocol_securakey_decoder_start(ProtocolSecurakey* protocol) {
|
||||
ManchesterEventReset,
|
||||
&protocol->decoder_manchester_state,
|
||||
NULL);
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_securakey_decoder_feed(ProtocolSecurakey* protocol, bool level, uint32_t duration) {
|
||||
bool result = false;
|
||||
@@ -187,7 +188,7 @@ bool protocol_securakey_decoder_feed(ProtocolSecurakey* protocol, bool level, ui
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_securakey_render_data(ProtocolSecurakey* protocol, FuriString* result) {
|
||||
if(bit_lib_get_bits_16(protocol->data, 0, 16) == 0) {
|
||||
@@ -209,7 +210,7 @@ void protocol_securakey_render_data(ProtocolSecurakey* protocol, FuriString* res
|
||||
bit_lib_get_bits_16(protocol->data, 0, 16),
|
||||
bit_lib_get_bits_16(protocol->data, 16, 16));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_securakey_encoder_start(ProtocolSecurakey* protocol) {
|
||||
// set all of our encoded_data bits to zeros.
|
||||
@@ -277,7 +278,7 @@ bool protocol_securakey_encoder_start(ProtocolSecurakey* protocol) {
|
||||
protocol->encoded_data_index = 0;
|
||||
protocol->encoded_polarity = true;
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
LevelDuration protocol_securakey_encoder_yield(ProtocolSecurakey* protocol) {
|
||||
if(bit_lib_get_bits_16(protocol->data, 0, 16) == 0) {
|
||||
@@ -305,7 +306,7 @@ LevelDuration protocol_securakey_encoder_yield(ProtocolSecurakey* protocol) {
|
||||
}
|
||||
return level_duration_make(level, duration);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_securakey_write_data(ProtocolSecurakey* protocol, void* data) {
|
||||
protocol_securakey_encoder_start(protocol);
|
||||
@@ -337,7 +338,7 @@ bool protocol_securakey_write_data(ProtocolSecurakey* protocol, void* data) {
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
const ProtocolBase protocol_securakey = {
|
||||
.name = "Radio Key",
|
||||
@@ -361,4 +362,4 @@ const ProtocolBase protocol_securakey = {
|
||||
.render_data = (ProtocolRenderData)protocol_securakey_render_data,
|
||||
.render_brief_data = (ProtocolRenderData)protocol_securakey_render_data,
|
||||
.write_data = (ProtocolWriteData)protocol_securakey_write_data,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
#include <toolbox/protocols/protocol.h>
|
||||
|
||||
extern const ProtocolBase protocol_securakey;
|
||||
extern const ProtocolBase protocol_securakey;
|
||||
|
||||
@@ -6,21 +6,21 @@
|
||||
|
||||
#define VIKING_CLOCK_PER_BIT (32)
|
||||
|
||||
#define VIKING_ENCODED_BIT_SIZE (64)
|
||||
#define VIKING_ENCODED_BYTE_SIZE (((VIKING_ENCODED_BIT_SIZE) / 8))
|
||||
#define VIKING_PREAMBLE_BIT_SIZE (24)
|
||||
#define VIKING_PREAMBLE_BYTE_SIZE (3)
|
||||
#define VIKING_ENCODED_BIT_SIZE (64)
|
||||
#define VIKING_ENCODED_BYTE_SIZE (((VIKING_ENCODED_BIT_SIZE) / 8))
|
||||
#define VIKING_PREAMBLE_BIT_SIZE (24)
|
||||
#define VIKING_PREAMBLE_BYTE_SIZE (3)
|
||||
#define VIKING_ENCODED_BYTE_FULL_SIZE (VIKING_ENCODED_BYTE_SIZE + VIKING_PREAMBLE_BYTE_SIZE)
|
||||
#define VIKING_DECODED_DATA_SIZE 4
|
||||
#define VIKING_DECODED_DATA_SIZE 4
|
||||
|
||||
#define VIKING_READ_SHORT_TIME (128)
|
||||
#define VIKING_READ_LONG_TIME (256)
|
||||
#define VIKING_READ_SHORT_TIME (128)
|
||||
#define VIKING_READ_LONG_TIME (256)
|
||||
#define VIKING_READ_JITTER_TIME (60)
|
||||
|
||||
#define VIKING_READ_SHORT_TIME_LOW (VIKING_READ_SHORT_TIME - VIKING_READ_JITTER_TIME)
|
||||
#define VIKING_READ_SHORT_TIME_LOW (VIKING_READ_SHORT_TIME - VIKING_READ_JITTER_TIME)
|
||||
#define VIKING_READ_SHORT_TIME_HIGH (VIKING_READ_SHORT_TIME + VIKING_READ_JITTER_TIME)
|
||||
#define VIKING_READ_LONG_TIME_LOW (VIKING_READ_LONG_TIME - VIKING_READ_JITTER_TIME)
|
||||
#define VIKING_READ_LONG_TIME_HIGH (VIKING_READ_LONG_TIME + VIKING_READ_JITTER_TIME)
|
||||
#define VIKING_READ_LONG_TIME_LOW (VIKING_READ_LONG_TIME - VIKING_READ_JITTER_TIME)
|
||||
#define VIKING_READ_LONG_TIME_HIGH (VIKING_READ_LONG_TIME + VIKING_READ_JITTER_TIME)
|
||||
|
||||
typedef struct {
|
||||
uint8_t data[VIKING_DECODED_DATA_SIZE];
|
||||
@@ -35,15 +35,15 @@ typedef struct {
|
||||
ProtocolViking* protocol_viking_alloc(void) {
|
||||
ProtocolViking* proto = malloc(sizeof(ProtocolViking));
|
||||
return (void*)proto;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_viking_free(ProtocolViking* protocol) {
|
||||
free(protocol);
|
||||
};
|
||||
}
|
||||
|
||||
uint8_t* protocol_viking_get_data(ProtocolViking* protocol) {
|
||||
return protocol->data;
|
||||
};
|
||||
}
|
||||
|
||||
static void protocol_viking_decode(ProtocolViking* protocol) {
|
||||
// Copy Card ID
|
||||
@@ -80,7 +80,7 @@ void protocol_viking_decoder_start(ProtocolViking* protocol) {
|
||||
ManchesterEventReset,
|
||||
&protocol->decoder_manchester_state,
|
||||
NULL);
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_viking_decoder_feed(ProtocolViking* protocol, bool level, uint32_t duration) {
|
||||
bool result = false;
|
||||
@@ -117,7 +117,7 @@ bool protocol_viking_decoder_feed(ProtocolViking* protocol, bool level, uint32_t
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_viking_encoder_start(ProtocolViking* protocol) {
|
||||
// Preamble
|
||||
@@ -135,7 +135,7 @@ bool protocol_viking_encoder_start(ProtocolViking* protocol) {
|
||||
bit_lib_set_bits(protocol->encoded_data, 56, checksum, 8);
|
||||
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
LevelDuration protocol_viking_encoder_yield(ProtocolViking* protocol) {
|
||||
bool level = bit_lib_get_bit(protocol->encoded_data, protocol->encoded_data_index);
|
||||
@@ -151,7 +151,7 @@ LevelDuration protocol_viking_encoder_yield(ProtocolViking* protocol) {
|
||||
}
|
||||
|
||||
return level_duration_make(level, duration);
|
||||
};
|
||||
}
|
||||
|
||||
bool protocol_viking_write_data(ProtocolViking* protocol, void* data) {
|
||||
LFRFIDWriteRequest* request = (LFRFIDWriteRequest*)data;
|
||||
@@ -173,11 +173,11 @@ bool protocol_viking_write_data(ProtocolViking* protocol, void* data) {
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
void protocol_viking_render_data(ProtocolViking* protocol, FuriString* result) {
|
||||
furi_string_printf(result, "ID: %08lX", bit_lib_get_bits_32(protocol->data, 0, 32));
|
||||
};
|
||||
}
|
||||
|
||||
const ProtocolBase protocol_viking = {
|
||||
.name = "Viking",
|
||||
|
||||
@@ -59,4 +59,4 @@ bool fsk_osc_next_half(FSKOsc* osc, bool bit, bool* level, uint32_t* duration) {
|
||||
}
|
||||
|
||||
return advance;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,4 +57,4 @@ bool fsk_osc_next_half(FSKOsc* osc, bool bit, bool* level, uint32_t* duration);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -5,13 +5,13 @@
|
||||
#define T5577_TIMING_WAIT_TIME 400
|
||||
#define T5577_TIMING_START_GAP 30
|
||||
#define T5577_TIMING_WRITE_GAP 18
|
||||
#define T5577_TIMING_DATA_0 24
|
||||
#define T5577_TIMING_DATA_1 56
|
||||
#define T5577_TIMING_PROGRAM 700
|
||||
#define T5577_TIMING_DATA_0 24
|
||||
#define T5577_TIMING_DATA_1 56
|
||||
#define T5577_TIMING_PROGRAM 700
|
||||
|
||||
#define T5577_OPCODE_PAGE_0 0b10
|
||||
#define T5577_OPCODE_PAGE_1 0b11
|
||||
#define T5577_OPCODE_RESET 0b00
|
||||
#define T5577_OPCODE_RESET 0b00
|
||||
|
||||
#define T5577_BLOCKS_IN_PAGE_0 8
|
||||
#define T5577_BLOCKS_IN_PAGE_1 4
|
||||
|
||||
+29
-29
@@ -9,35 +9,35 @@ extern "C" {
|
||||
#define LFRFID_T5577_BLOCK_COUNT 8
|
||||
|
||||
// T5577 block 0 definitions, thanks proxmark3!
|
||||
#define LFRFID_T5577_POR_DELAY 0x00000001
|
||||
#define LFRFID_T5577_ST_TERMINATOR 0x00000008
|
||||
#define LFRFID_T5577_PWD 0x00000010
|
||||
#define LFRFID_T5577_MAXBLOCK_SHIFT 5
|
||||
#define LFRFID_T5577_AOR 0x00000200
|
||||
#define LFRFID_T5577_PSKCF_RF_2 0
|
||||
#define LFRFID_T5577_PSKCF_RF_4 0x00000400
|
||||
#define LFRFID_T5577_PSKCF_RF_8 0x00000800
|
||||
#define LFRFID_T5577_MODULATION_DIRECT 0
|
||||
#define LFRFID_T5577_MODULATION_PSK1 0x00001000
|
||||
#define LFRFID_T5577_MODULATION_PSK2 0x00002000
|
||||
#define LFRFID_T5577_MODULATION_PSK3 0x00003000
|
||||
#define LFRFID_T5577_MODULATION_FSK1 0x00004000
|
||||
#define LFRFID_T5577_MODULATION_FSK2 0x00005000
|
||||
#define LFRFID_T5577_MODULATION_FSK1a 0x00006000
|
||||
#define LFRFID_T5577_MODULATION_FSK2a 0x00007000
|
||||
#define LFRFID_T5577_POR_DELAY 0x00000001
|
||||
#define LFRFID_T5577_ST_TERMINATOR 0x00000008
|
||||
#define LFRFID_T5577_PWD 0x00000010
|
||||
#define LFRFID_T5577_MAXBLOCK_SHIFT 5
|
||||
#define LFRFID_T5577_AOR 0x00000200
|
||||
#define LFRFID_T5577_PSKCF_RF_2 0
|
||||
#define LFRFID_T5577_PSKCF_RF_4 0x00000400
|
||||
#define LFRFID_T5577_PSKCF_RF_8 0x00000800
|
||||
#define LFRFID_T5577_MODULATION_DIRECT 0
|
||||
#define LFRFID_T5577_MODULATION_PSK1 0x00001000
|
||||
#define LFRFID_T5577_MODULATION_PSK2 0x00002000
|
||||
#define LFRFID_T5577_MODULATION_PSK3 0x00003000
|
||||
#define LFRFID_T5577_MODULATION_FSK1 0x00004000
|
||||
#define LFRFID_T5577_MODULATION_FSK2 0x00005000
|
||||
#define LFRFID_T5577_MODULATION_FSK1a 0x00006000
|
||||
#define LFRFID_T5577_MODULATION_FSK2a 0x00007000
|
||||
#define LFRFID_T5577_MODULATION_MANCHESTER 0x00008000
|
||||
#define LFRFID_T5577_MODULATION_BIPHASE 0x00010000
|
||||
#define LFRFID_T5577_MODULATION_DIPHASE 0x00018000
|
||||
#define LFRFID_T5577_X_MODE 0x00020000
|
||||
#define LFRFID_T5577_BITRATE_RF_8 0
|
||||
#define LFRFID_T5577_BITRATE_RF_16 0x00040000
|
||||
#define LFRFID_T5577_BITRATE_RF_32 0x00080000
|
||||
#define LFRFID_T5577_BITRATE_RF_40 0x000C0000
|
||||
#define LFRFID_T5577_BITRATE_RF_50 0x00100000
|
||||
#define LFRFID_T5577_BITRATE_RF_64 0x00140000
|
||||
#define LFRFID_T5577_BITRATE_RF_100 0x00180000
|
||||
#define LFRFID_T5577_BITRATE_RF_128 0x001C0000
|
||||
#define LFRFID_T5577_TESTMODE_DISABLED 0x60000000
|
||||
#define LFRFID_T5577_MODULATION_BIPHASE 0x00010000
|
||||
#define LFRFID_T5577_MODULATION_DIPHASE 0x00018000
|
||||
#define LFRFID_T5577_X_MODE 0x00020000
|
||||
#define LFRFID_T5577_BITRATE_RF_8 0
|
||||
#define LFRFID_T5577_BITRATE_RF_16 0x00040000
|
||||
#define LFRFID_T5577_BITRATE_RF_32 0x00080000
|
||||
#define LFRFID_T5577_BITRATE_RF_40 0x000C0000
|
||||
#define LFRFID_T5577_BITRATE_RF_50 0x00100000
|
||||
#define LFRFID_T5577_BITRATE_RF_64 0x00140000
|
||||
#define LFRFID_T5577_BITRATE_RF_100 0x00180000
|
||||
#define LFRFID_T5577_BITRATE_RF_128 0x001C0000
|
||||
#define LFRFID_T5577_TESTMODE_DISABLED 0x60000000
|
||||
|
||||
typedef struct {
|
||||
uint32_t block[LFRFID_T5577_BLOCK_COUNT];
|
||||
@@ -58,4 +58,4 @@ void t5577_write_with_mask(LFRFIDT5577* data, uint8_t page, bool with_pass, uint
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -76,4 +76,4 @@ bool varint_pair_unpack(
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -12,12 +12,12 @@
|
||||
#define TAG "MusicWorker"
|
||||
|
||||
#define MUSIC_PLAYER_FILETYPE "Flipper Music Format"
|
||||
#define MUSIC_PLAYER_VERSION 0
|
||||
#define MUSIC_PLAYER_VERSION 0
|
||||
|
||||
#define SEMITONE_PAUSE 0xFF
|
||||
|
||||
#define NOTE_C4 261.63f
|
||||
#define NOTE_C4_SEMITONE (4.0f * 12.0f)
|
||||
#define NOTE_C4 261.63f
|
||||
#define NOTE_C4_SEMITONE (4.0f * 12.0f)
|
||||
#define TWO_POW_TWELTH_ROOT 1.059463094359f
|
||||
|
||||
typedef struct {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#define SWAPENDIAN(x) \
|
||||
((x) = ((x) >> 8 & 0xff00ff) | ((x) & 0xff00ff) << 8, (x) = (x) >> 16 | (x) << 16)
|
||||
#define LF_POLY_ODD (0x29CE5C)
|
||||
#define LF_POLY_ODD (0x29CE5C)
|
||||
#define LF_POLY_EVEN (0x870804)
|
||||
|
||||
#define BEBIT(x, n) FURI_BIT(x, (n) ^ 24)
|
||||
|
||||
@@ -45,7 +45,7 @@ bool felica_crc_check(const BitBuffer* buf) {
|
||||
const uint8_t* data = bit_buffer_get_data(buf);
|
||||
const uint16_t crc_calc = felica_crc_calculate(data, data_size - FELICA_CRC_SIZE);
|
||||
|
||||
return (crc_calc == crc_received);
|
||||
return crc_calc == crc_received;
|
||||
}
|
||||
|
||||
void felica_crc_trim(BitBuffer* buf) {
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
#include <core/check.h>
|
||||
|
||||
#define ISO13239_CRC_INIT_DEFAULT (0xFFFFU)
|
||||
#define ISO13239_CRC_INIT_DEFAULT (0xFFFFU)
|
||||
#define ISO13239_CRC_INIT_PICOPASS (0xE012U)
|
||||
#define ISO13239_CRC_POLY (0x8408U)
|
||||
#define ISO13239_CRC_POLY (0x8408U)
|
||||
|
||||
static uint16_t
|
||||
iso13239_crc_calculate(Iso13239CrcType type, const uint8_t* data, size_t data_size) {
|
||||
@@ -55,7 +55,7 @@ bool iso13239_crc_check(Iso13239CrcType type, const BitBuffer* buf) {
|
||||
const uint8_t* data = bit_buffer_get_data(buf);
|
||||
const uint16_t crc_calc = iso13239_crc_calculate(type, data, data_size - ISO13239_CRC_SIZE);
|
||||
|
||||
return (crc_calc == crc_received);
|
||||
return crc_calc == crc_received;
|
||||
}
|
||||
|
||||
void iso13239_crc_trim(BitBuffer* buf) {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <furi.h>
|
||||
|
||||
#define ISO14443_4_BLOCK_PCB (1U << 1)
|
||||
#define ISO14443_4_BLOCK_PCB (1U << 1)
|
||||
#define ISO14443_4_BLOCK_PCB_I (0U)
|
||||
#define ISO14443_4_BLOCK_PCB_R (5U << 5)
|
||||
#define ISO14443_4_BLOCK_PCB_S (3U << 6)
|
||||
|
||||
@@ -50,7 +50,7 @@ bool iso14443_crc_check(Iso14443CrcType type, const BitBuffer* buf) {
|
||||
const uint8_t* data = bit_buffer_get_data(buf);
|
||||
const uint16_t crc_calc = iso14443_crc_calculate(type, data, data_size - ISO14443_CRC_SIZE);
|
||||
|
||||
return (crc_calc == crc_received);
|
||||
return crc_calc == crc_received;
|
||||
}
|
||||
|
||||
void iso14443_crc_trim(BitBuffer* buf) {
|
||||
|
||||
@@ -17,7 +17,7 @@ uint8_t nfc_util_even_parity32(uint32_t data) {
|
||||
// data ^= data >> 16;
|
||||
// data ^= data >> 8;
|
||||
// return !nfc_util_odd_byte_parity[data];
|
||||
return (__builtin_parity(data) & 0xFF);
|
||||
return __builtin_parity(data) & 0xFF;
|
||||
}
|
||||
|
||||
uint8_t nfc_util_odd_parity8(uint8_t data) {
|
||||
@@ -45,4 +45,4 @@ void nfc_util_odd_parity(const uint8_t* src, uint8_t* dst, uint8_t len) {
|
||||
if(bit) {
|
||||
*dst = parity;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,13 +9,13 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/* NFC file format version which changed ATQA format. Deprecated. */
|
||||
#define NFC_LSB_ATQA_FORMAT_VERSION (2)
|
||||
#define NFC_LSB_ATQA_FORMAT_VERSION (2)
|
||||
/* NFC file format version which is still supported as backwards compatible. */
|
||||
#define NFC_MINIMUM_SUPPORTED_FORMAT_VERSION NFC_LSB_ATQA_FORMAT_VERSION
|
||||
/* NFC file format version which implemented the unified loading process. */
|
||||
#define NFC_UNIFIED_FORMAT_VERSION (4)
|
||||
#define NFC_UNIFIED_FORMAT_VERSION (4)
|
||||
/* Current NFC file format version. */
|
||||
#define NFC_CURRENT_FORMAT_VERSION NFC_UNIFIED_FORMAT_VERSION
|
||||
#define NFC_CURRENT_FORMAT_VERSION NFC_UNIFIED_FORMAT_VERSION
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
#include "nfc_common.h"
|
||||
#include "protocols/nfc_device_defs.h"
|
||||
|
||||
#define NFC_FILE_HEADER "Flipper NFC device"
|
||||
#define NFC_FILE_HEADER "Flipper NFC device"
|
||||
#define NFC_DEV_TYPE_ERROR "Protocol type mismatch"
|
||||
|
||||
#define NFC_DEVICE_UID_KEY "UID"
|
||||
#define NFC_DEVICE_UID_KEY "UID"
|
||||
#define NFC_DEVICE_TYPE_KEY "Device type"
|
||||
|
||||
#define NFC_DEVICE_UID_MAX_LEN (10U)
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
#include <nfc/nfc_common.h>
|
||||
|
||||
#define FELICA_PROTOCOL_NAME "FeliCa"
|
||||
#define FELICA_DEVICE_NAME "FeliCa"
|
||||
#define FELICA_DEVICE_NAME "FeliCa"
|
||||
|
||||
#define FELICA_DATA_FORMAT_VERSION "Data format version"
|
||||
#define FELICA_MANUFACTURE_ID "Manufacture id"
|
||||
#define FELICA_DATA_FORMAT_VERSION "Data format version"
|
||||
#define FELICA_MANUFACTURE_ID "Manufacture id"
|
||||
#define FELICA_MANUFACTURE_PARAMETER "Manufacture parameter"
|
||||
|
||||
static const uint32_t felica_data_format_version = 1;
|
||||
@@ -353,4 +353,4 @@ void felica_calculate_mac_write(
|
||||
memcpy(session_swapped, session_key + 8, 8);
|
||||
memcpy(session_swapped + 8, session_key, 8);
|
||||
felica_calculate_mac(ctx, session_swapped, rc, first_block, data, FELICA_DATA_BLOCK_SIZE, mac);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,44 +8,44 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define FELICA_IDM_SIZE (8U)
|
||||
#define FELICA_PMM_SIZE (8U)
|
||||
#define FELICA_IDM_SIZE (8U)
|
||||
#define FELICA_PMM_SIZE (8U)
|
||||
#define FELICA_DATA_BLOCK_SIZE (16U)
|
||||
|
||||
#define FELICA_CMD_READ_WITHOUT_ENCRYPTION (0x06U)
|
||||
#define FELICA_CMD_READ_WITHOUT_ENCRYPTION (0x06U)
|
||||
#define FELICA_CMD_WRITE_WITHOUT_ENCRYPTION (0x08U)
|
||||
|
||||
#define FELICA_SERVICE_RW_ACCESS (0x0009U)
|
||||
#define FELICA_SERVICE_RO_ACCESS (0x000BU)
|
||||
|
||||
#define FELICA_BLOCKS_TOTAL_COUNT (28U)
|
||||
#define FELICA_BLOCK_INDEX_REG (0x0EU)
|
||||
#define FELICA_BLOCK_INDEX_RC (0x80U)
|
||||
#define FELICA_BLOCK_INDEX_MAC (0x81U)
|
||||
#define FELICA_BLOCK_INDEX_ID (0x82U)
|
||||
#define FELICA_BLOCK_INDEX_D_ID (0x83U)
|
||||
#define FELICA_BLOCK_INDEX_SER_C (0x84U)
|
||||
#define FELICA_BLOCK_INDEX_SYS_C (0x85U)
|
||||
#define FELICA_BLOCK_INDEX_CKV (0x86U)
|
||||
#define FELICA_BLOCK_INDEX_CK (0x87U)
|
||||
#define FELICA_BLOCK_INDEX_MC (0x88U)
|
||||
#define FELICA_BLOCK_INDEX_WCNT (0x90U)
|
||||
#define FELICA_BLOCK_INDEX_MAC_A (0x91U)
|
||||
#define FELICA_BLOCK_INDEX_STATE (0x92U)
|
||||
#define FELICA_BLOCKS_TOTAL_COUNT (28U)
|
||||
#define FELICA_BLOCK_INDEX_REG (0x0EU)
|
||||
#define FELICA_BLOCK_INDEX_RC (0x80U)
|
||||
#define FELICA_BLOCK_INDEX_MAC (0x81U)
|
||||
#define FELICA_BLOCK_INDEX_ID (0x82U)
|
||||
#define FELICA_BLOCK_INDEX_D_ID (0x83U)
|
||||
#define FELICA_BLOCK_INDEX_SER_C (0x84U)
|
||||
#define FELICA_BLOCK_INDEX_SYS_C (0x85U)
|
||||
#define FELICA_BLOCK_INDEX_CKV (0x86U)
|
||||
#define FELICA_BLOCK_INDEX_CK (0x87U)
|
||||
#define FELICA_BLOCK_INDEX_MC (0x88U)
|
||||
#define FELICA_BLOCK_INDEX_WCNT (0x90U)
|
||||
#define FELICA_BLOCK_INDEX_MAC_A (0x91U)
|
||||
#define FELICA_BLOCK_INDEX_STATE (0x92U)
|
||||
#define FELICA_BLOCK_INDEX_CRC_CHECK (0xA0U)
|
||||
|
||||
#define FELICA_GUARD_TIME_US (20000U)
|
||||
#define FELICA_FDT_POLL_FC (10000U)
|
||||
#define FELICA_GUARD_TIME_US (20000U)
|
||||
#define FELICA_FDT_POLL_FC (10000U)
|
||||
#define FELICA_POLL_POLL_MIN_US (1280U)
|
||||
|
||||
#define FELICA_FDT_LISTEN_FC (1172)
|
||||
|
||||
#define FELICA_SYSTEM_CODE_CODE (0xFFFFU)
|
||||
#define FELICA_TIME_SLOT_1 (0x00U)
|
||||
#define FELICA_TIME_SLOT_2 (0x01U)
|
||||
#define FELICA_TIME_SLOT_4 (0x03U)
|
||||
#define FELICA_TIME_SLOT_8 (0x07U)
|
||||
#define FELICA_TIME_SLOT_16 (0x0FU)
|
||||
#define FELICA_TIME_SLOT_1 (0x00U)
|
||||
#define FELICA_TIME_SLOT_2 (0x01U)
|
||||
#define FELICA_TIME_SLOT_4 (0x03U)
|
||||
#define FELICA_TIME_SLOT_8 (0x07U)
|
||||
#define FELICA_TIME_SLOT_16 (0x0FU)
|
||||
|
||||
/** @brief Type of possible Felica errors */
|
||||
typedef enum {
|
||||
@@ -174,8 +174,8 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
uint8_t service_code : 4;
|
||||
uint8_t access_mode : 3;
|
||||
uint8_t length : 1;
|
||||
uint8_t access_mode : 3;
|
||||
uint8_t length : 1;
|
||||
uint8_t block_number;
|
||||
} FelicaBlockListElement;
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
#include <nfc/helpers/felica_crc.h>
|
||||
#include <furi_hal_nfc.h>
|
||||
|
||||
#define FELICA_LISTENER_MAX_BUFFER_SIZE (128)
|
||||
#define FELICA_LISTENER_RESPONSE_CODE_READ (0x07)
|
||||
#define FELICA_LISTENER_MAX_BUFFER_SIZE (128)
|
||||
#define FELICA_LISTENER_RESPONSE_CODE_READ (0x07)
|
||||
#define FELICA_LISTENER_RESPONSE_CODE_WRITE (0x09)
|
||||
|
||||
#define TAG "FelicaListener"
|
||||
@@ -207,4 +207,4 @@ const NfcListenerBase nfc_listener_felica = {
|
||||
.set_callback = (NfcListenerSetCallback)felica_listener_set_callback,
|
||||
.get_data = (NfcListenerGetData)felica_listener_get_data,
|
||||
.run = (NfcListenerRun)felica_listener_run,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -11,4 +11,4 @@ typedef struct FelicaListener FelicaListener;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -2,25 +2,25 @@
|
||||
|
||||
#include <nfc/helpers/felica_crc.h>
|
||||
|
||||
#define FELICA_WCNT_MC2_FF_MAX_VALUE (0x00FFFFFFU)
|
||||
#define FELICA_WCNT_MC2_00_MAX_VALUE (0x00FFFE00U)
|
||||
#define FELICA_WCNT_MC2_FF_MAX_VALUE (0x00FFFFFFU)
|
||||
#define FELICA_WCNT_MC2_00_MAX_VALUE (0x00FFFE00U)
|
||||
#define FELICA_WCNT_MC2_00_WARNING_BEGIN_VALUE (0x00001027U)
|
||||
#define FELICA_WCNT_MC2_00_WARNING_END_VALUE (0x00FFFDFFU)
|
||||
#define FELICA_WCNT_MC2_00_WARNING_END_VALUE (0x00FFFDFFU)
|
||||
|
||||
#define FELICA_MC_SP_REG_ALL_RW_BYTES_0_1 (0U)
|
||||
#define FELICA_MC_ALL_BYTE (2U)
|
||||
#define FELICA_MC_SYS_OP (3U)
|
||||
#define FELICA_MC_RF_PRM (4U)
|
||||
#define FELICA_MC_CKCKV_W_MAC_A (5U)
|
||||
#define FELICA_MC_SP_REG_R_RESTR_BYTES_6_7 (6U)
|
||||
#define FELICA_MC_SP_REG_W_RESTR_BYTES_8_9 (8U)
|
||||
#define FELICA_MC_SP_REG_ALL_RW_BYTES_0_1 (0U)
|
||||
#define FELICA_MC_ALL_BYTE (2U)
|
||||
#define FELICA_MC_SYS_OP (3U)
|
||||
#define FELICA_MC_RF_PRM (4U)
|
||||
#define FELICA_MC_CKCKV_W_MAC_A (5U)
|
||||
#define FELICA_MC_SP_REG_R_RESTR_BYTES_6_7 (6U)
|
||||
#define FELICA_MC_SP_REG_W_RESTR_BYTES_8_9 (8U)
|
||||
#define FELICA_MC_SP_REG_W_MAC_A_BYTES_10_11 (10U)
|
||||
#define FELICA_MC_STATE_W_MAC_A (12U)
|
||||
#define FELICA_MC_RESERVED_13 (13U)
|
||||
#define FELICA_MC_RESERVED_14 (14U)
|
||||
#define FELICA_MC_RESERVED_15 (15U)
|
||||
#define FELICA_MC_STATE_W_MAC_A (12U)
|
||||
#define FELICA_MC_RESERVED_13 (13U)
|
||||
#define FELICA_MC_RESERVED_14 (14U)
|
||||
#define FELICA_MC_RESERVED_15 (15U)
|
||||
|
||||
#define FELICA_MC_BYTE_GET(data, byte) (data->data.fs.mc.data[byte])
|
||||
#define FELICA_MC_BYTE_GET(data, byte) (data->data.fs.mc.data[byte])
|
||||
#define FELICA_SYSTEM_BLOCK_RO_ACCESS(data) (FELICA_MC_BYTE_GET(data, FELICA_MC_ALL_BYTE) == 0x00)
|
||||
#define FELICA_SYSTEM_BLOCK_RW_ACCESS(data) (FELICA_MC_BYTE_GET(data, FELICA_MC_ALL_BYTE) == 0xFF)
|
||||
|
||||
@@ -39,10 +39,9 @@ static uint32_t felica_wcnt_get_max_value(const FelicaData* data) {
|
||||
|
||||
static bool felica_wcnt_check_warning_boundary(const FelicaData* data) {
|
||||
const uint32_t* wcnt_ptr = (uint32_t*)data->data.fs.wcnt.data;
|
||||
return (
|
||||
FELICA_SYSTEM_BLOCK_RO_ACCESS(data) &&
|
||||
((*wcnt_ptr > FELICA_WCNT_MC2_00_WARNING_BEGIN_VALUE) &&
|
||||
(*wcnt_ptr < FELICA_WCNT_MC2_00_WARNING_END_VALUE)));
|
||||
return FELICA_SYSTEM_BLOCK_RO_ACCESS(data) &&
|
||||
((*wcnt_ptr > FELICA_WCNT_MC2_00_WARNING_BEGIN_VALUE) &&
|
||||
(*wcnt_ptr < FELICA_WCNT_MC2_00_WARNING_END_VALUE));
|
||||
}
|
||||
|
||||
static bool felica_wcnt_check_error_boundary(const FelicaData* data) {
|
||||
@@ -138,7 +137,7 @@ static bool felica_listener_check_write_request_data_size(
|
||||
uint8_t possible_data_size = fact_item_cnt * FELICA_DATA_BLOCK_SIZE;
|
||||
uint8_t fact_data_size =
|
||||
request->base.length - sizeof(FelicaListenerGenericRequest) - instance->block_list_size;
|
||||
return (possible_data_size <= fact_data_size);
|
||||
return possible_data_size <= fact_data_size;
|
||||
}
|
||||
|
||||
static bool felica_listener_test_block_list_size_bounds(const FelicaListenerGenericRequest* req) {
|
||||
@@ -735,4 +734,4 @@ FelicaError
|
||||
} while(false);
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
#include <nfc/protocols/nfc_generic_event.h>
|
||||
|
||||
#define FELICA_LISTENER_READ_BLOCK_COUNT_MAX (4U)
|
||||
#define FELICA_LISTENER_READ_BLOCK_COUNT_MIN (1U)
|
||||
#define FELICA_LISTENER_READ_BLOCK_COUNT_MAX (4U)
|
||||
#define FELICA_LISTENER_READ_BLOCK_COUNT_MIN (1U)
|
||||
#define FELICA_LISTENER_WRITE_BLOCK_COUNT_MAX (2U)
|
||||
#define FELICA_LISTENER_WRITE_BLOCK_COUNT_MIN (1U)
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user