unleashed-firmware/applications/lf-rfid/helpers/encoder-indala-40134.cpp
SG ffd4948ae2
[FL-1058] Low frequency RFID app [Indala 40134 Encoder] (#447)
* App Lfrfid: Rename encoder to match extact protocol.
* Api-hal-gpio: fix alt fn config
* Api-hal-gpio: fixed fix
* App Lfrfid: indala 40134 timer stage
2021-05-06 11:45:52 +03:00

34 lines
873 B
C++

#include "encoder-indala-40134.h"
#include <furi.h>
void EncoderIndala_40134::init(const uint8_t* data, const uint8_t data_size) {
card_data = 0b1010000000000000000000000000000011010000010010001000011000110010;
last_bit = card_data & 1;
card_data_index = 0;
current_polarity = true;
}
void EncoderIndala_40134::get_next(bool* polarity, uint16_t* period, uint16_t* pulse) {
*period = 2;
*pulse = 1;
*polarity = current_polarity;
bit_clock_index++;
if(bit_clock_index >= clock_per_bit) {
bit_clock_index = 0;
bool current_bit = (card_data >> (63 - card_data_index)) & 1;
if(current_bit != last_bit) {
current_polarity = !current_polarity;
}
last_bit = current_bit;
card_data_index++;
if(card_data_index >= 64) {
card_data_index = 0;
}
}
}