summaryrefslogtreecommitdiff
path: root/src/fecmodem.h
blob: 00487eecd20f3529b3144e6de1f3c5cd2514303a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <avr/io.h>
#include <stdlib.h>

#ifndef FECMODEM_H_
#define FECMODEM_H_

#include "hamming.h"
#include "modem.h"

class FECModem : public Modem {
	private:
		enum HammingState : uint8_t {
			FIRST_BYTE,
			SECOND_BYTE
		};
		HammingState hammingState;
		uint8_t buf_byte;

		uint8_t parity128(uint8_t byte);
		uint8_t parity2416(uint8_t byte1, uint8_t byte2);
		uint8_t correct128(uint8_t *byte, uint8_t parity);
		uint8_t hamming2416(uint8_t *byte1, uint8_t *byte2, uint8_t parity);
	public:
		FECModem() : Modem() { hammingState = FIRST_BYTE; };
		uint8_t buffer_available(void);
		uint8_t buffer_get(void);
};

extern FECModem modem;

#endif /* FECMODEM_H_ */