12 #ifndef INCLUDE_BITBUFFER_H_ 13 #define INCLUDE_BITBUFFER_H_ 17 #define BITBUF_COLS 256 // Number of bytes in a column 18 #define BITBUF_ROWS 25 19 #define BITBUF_MAX_PRINT_BITS 50 // Maximum number of bits to print (in addition to hex values) 46 unsigned pos,
uint8_t *out,
unsigned len);
80 const uint8_t *pattern,
unsigned pattern_bits_len);
110 return bitrow[bit_idx >> 3] >> (7 - (bit_idx & 7)) & 1;
116 return ((bitrow[(bit_idx >> 3)] << (bit_idx & 7)) |
117 (bitrow[(bit_idx >> 3) + 1] >> (8 - (bit_idx & 7))));
void bitbuffer_nrzm_decode(bitbuffer_t *bits)
Non-Return-to-Zero Mark (NRZI) decode the bitbuffer.
Definition: bitbuffer.c:94
uint16_t syncs_before_row[BITBUF_ROWS]
Definition: bitbuffer.h:28
void bitbuffer_nrzs_decode(bitbuffer_t *bits)
Non-Return-to-Zero Space (NRZI) decode the bitbuffer.
Definition: bitbuffer.c:76
void bitbuffer_add_sync(bitbuffer_t *bits)
Increment sync counter, add new row if not empty.
Definition: bitbuffer.c:52
static int bit(const uint8_t *bytes, unsigned bit)
Definition: bitbuffer.c:142
unsigned short uint16_t
Definition: mongoose.h:271
void bitbuffer_invert(bitbuffer_t *bits)
Invert all bits in the bitbuffer (do not invert the empty bits).
Definition: bitbuffer.c:62
unsigned count_repeats(bitbuffer_t *bits, unsigned row)
Definition: bitbuffer.c:388
void bitbuffer_add_row(bitbuffer_t *bits)
Add a new row to the bitbuffer.
Definition: bitbuffer.c:39
void bitbuffer_parse(bitbuffer_t *bits, const char *code)
Parse a string into a bitbuffer.
Definition: bitbuffer.c:320
uint16_t bits_per_row[BITBUF_ROWS]
Definition: bitbuffer.h:27
struct bitbuffer bitbuffer_t
Bit buffer.
void bitbuffer_add_bit(bitbuffer_t *bits, int bit)
Add a single bit at the end of the bitbuffer (MSB first).
Definition: bitbuffer.c:24
uint16_t num_rows
Definition: bitbuffer.h:26
unsigned bitbuffer_search(bitbuffer_t *bitbuffer, unsigned row, unsigned start, const uint8_t *pattern, unsigned pattern_bits_len)
Search the specified row of the bitbuffer, starting from bit 'start', for the pattern provided...
Definition: bitbuffer.c:147
uint8_t bitrow_t[BITBUF_COLS]
Definition: bitbuffer.h:21
static uint8_t bitrow_get_byte(const bitrow_t bitrow, unsigned bit_idx)
Return a single byte from a bitrow at bit_idx position (which may be unaligned).
Definition: bitbuffer.h:114
unsigned bitbuffer_manchester_decode(bitbuffer_t *inbuf, unsigned row, unsigned start, bitbuffer_t *outbuf, unsigned max)
Manchester decoding from one bitbuffer into another, starting at the specified row and start bit...
Definition: bitbuffer.c:173
Bit buffer.
Definition: bitbuffer.h:25
int bitbuffer_find_repeated_row(bitbuffer_t *bits, unsigned min_repeats, unsigned min_bits)
Find a repeated row that has a minimum count of bits.
Definition: bitbuffer.c:399
void bitrow_print(bitrow_t const bitrow, unsigned bit_len)
Print the content of a bit row (byte buffer).
Definition: bitbuffer.c:310
void bitbuffer_clear(bitbuffer_t *bits)
Clear the content of the bitbuffer.
Definition: bitbuffer.c:17
unsigned char uint8_t
Definition: mongoose.h:267
int compare_rows(bitbuffer_t *bits, unsigned row_a, unsigned row_b)
Function to compare bitbuffer rows and count repetitions.
Definition: bitbuffer.c:381
void bitrow_debug(bitrow_t const bitrow, unsigned bit_len)
Debug the content of a bit row (byte buffer).
Definition: bitbuffer.c:315
static uint8_t bitrow_get_bit(const bitrow_t bitrow, unsigned bit_idx)
Return a single bit from a bitrow at bit_idx position.
Definition: bitbuffer.h:108
void bitbuffer_print(const bitbuffer_t *bits)
Print the content of the bitbuffer.
Definition: bitbuffer.c:300
unsigned bitbuffer_differential_manchester_decode(bitbuffer_t *inbuf, unsigned row, unsigned start, bitbuffer_t *outbuf, unsigned max)
Differential Manchester decoding from one bitbuffer into another, starting at the specified row and s...
Definition: bitbuffer.c:198
void bitbuffer_debug(const bitbuffer_t *bits)
Debug the content of the bitbuffer.
Definition: bitbuffer.c:305
bitrow_t bitarray_t[BITBUF_ROWS]
Definition: bitbuffer.h:22
void bitbuffer_extract_bytes(bitbuffer_t *bitbuffer, unsigned row, unsigned pos, uint8_t *out, unsigned len)
Extract (potentially unaligned) bytes from the bit buffer. Len is bits.
Definition: bitbuffer.c:112
bitarray_t bb
Definition: bitbuffer.h:29