openpcd/firmware/src/picc/decoder.h @ master
1 |
#ifndef _DECODER_H
|
---|---|
2 |
#define _DECODER_H
|
3 |
|
4 |
struct decoder_state; |
5 |
|
6 |
struct decoder_algo { |
7 |
uint8_t oversampling_rate; |
8 |
uint8_t bits_per_sampled_char; |
9 |
uint32_t bytesample_mask; |
10 |
int (*decode_sample)(const uint32_t sample, uint8_t data); |
11 |
uint32_t (*get_next_bytesample)(struct decoder_state *st, uint8_t *parity_sample); |
12 |
};
|
13 |
|
14 |
struct decoder_state { |
15 |
struct decoder_algo *algo; |
16 |
uint8_t bit_ofs; |
17 |
const char *buf; |
18 |
const uint32_t *buf32; |
19 |
};
|
20 |
|
21 |
extern int decoder_register(int algnum, struct decoder_algo *algo); |
22 |
extern int decoder_decode(uint8_t algo, const char *sample_buf, |
23 |
int sample_buf_size, char *data_buf); |
24 |
|
25 |
#define DECODER_MILLER 0
|
26 |
#define DECODER_NRZL 1
|
27 |
#define DECODER_NUM_ALGOS 2
|
28 |
|
29 |
static struct decoder_algo nrzl_decoder; |
30 |
static struct decoder_algo miller_decoder; |
31 |
|
32 |
#endif
|