9a9abd59e9
* WeatherStation: start * SubGhz: rename protocol magellen -> magellan * WeatherStation: err Unresolved symbols: {'subghz_protocol_decoder_base_get_string'} * WeatherStation: fix Unresolved symbols: {'subghz_protocol_decoder_base_get_string'} * Subghz: add set protocol_items * WeatherStation: adding your protocols * WS: add Infactory protocol * WS: add history * WS: add setting * WS: add lock * WS: add hopper frequency * WS: fix history * WS fix string_t -> FuriString* * WS: add images * WS: history record update when receiving data from the sensor again * WS: add receiver info, delete extra code * WS: add protocol ThermoPRO_TX4 * [FL-2900] SubGhz: Move icons in Sub-GHz * WS: add Notification * [FL-2890] SubGhz: Rename *_user files in resources to _user.example * WS: add about scene * WS: removing redundant code * WS: add protocol Nexus-TH * WS: add protocol GT_WT03 * WS: fix notification and rename "Weather Station" -> "Read Weather Station" * SubGhz: partial unit tests fix * SubGhz: fix unit_test * SubGhz: remove dead code * SubGhz: rename SubGhzPresetDefinition into SubGhzRadioPreset, cleanup subghz types. Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
80 lines
2.0 KiB
C
80 lines
2.0 KiB
C
#pragma once
|
|
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
#include <stddef.h>
|
|
|
|
#define bit_read(value, bit) (((value) >> (bit)) & 0x01)
|
|
#define bit_set(value, bit) ((value) |= (1UL << (bit)))
|
|
#define bit_clear(value, bit) ((value) &= ~(1UL << (bit)))
|
|
#define bit_write(value, bit, bitvalue) (bitvalue ? bit_set(value, bit) : bit_clear(value, bit))
|
|
#define DURATION_DIFF(x, y) ((x < y) ? (y - x) : (x - y))
|
|
#define abs(x) ((x) > 0 ? (x) : -(x))
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
/**
|
|
* Flip the data bitwise.
|
|
* @param key In data
|
|
* @param count_bit number of data bits
|
|
* @return Reverse data
|
|
*/
|
|
uint64_t subghz_protocol_blocks_reverse_key(uint64_t key, uint8_t count_bit);
|
|
|
|
/**
|
|
* Get parity the data bitwise.
|
|
* @param key In data
|
|
* @param count_bit number of data bits
|
|
* @return parity
|
|
*/
|
|
uint8_t subghz_protocol_blocks_get_parity(uint64_t key, uint8_t count_bit);
|
|
|
|
/**
|
|
* CRC-4.
|
|
* @param message array of bytes to check
|
|
* @param nBytes number of bytes in message
|
|
* @param polynomial CRC polynomial
|
|
* @param init starting crc value
|
|
* @return CRC value
|
|
*/
|
|
uint8_t subghz_protocol_blocks_crc4(
|
|
uint8_t const message[],
|
|
unsigned nBytes,
|
|
uint8_t polynomial,
|
|
uint8_t init);
|
|
|
|
/**
|
|
* CRC-7.
|
|
* @param message array of bytes to check
|
|
* @param nBytes number of bytes in message
|
|
* @param polynomial CRC polynomial
|
|
* @param init starting crc value
|
|
* @return CRC value
|
|
*/
|
|
uint8_t subghz_protocol_blocks_crc7(
|
|
uint8_t const message[],
|
|
unsigned nBytes,
|
|
uint8_t polynomial,
|
|
uint8_t init);
|
|
|
|
/**
|
|
* Generic Cyclic Redundancy Check CRC-8.
|
|
* Example polynomial: 0x31 = x8 + x5 + x4 + 1 (x8 is implicit)
|
|
* Example polynomial: 0x80 = x8 + x7 (a normal bit-by-bit parity XOR)
|
|
* @param message array of bytes to check
|
|
* @param nBytes number of bytes in message
|
|
* @param polynomial byte is from x^7 to x^0 (x^8 is implicitly one)
|
|
* @param init starting crc value
|
|
* @return CRC value
|
|
*/
|
|
uint8_t subghz_protocol_blocks_crc8(
|
|
uint8_t const message[],
|
|
unsigned nBytes,
|
|
uint8_t polynomial,
|
|
uint8_t init);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|