-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_polynomials.c
75 lines (63 loc) · 1.15 KB
/
main_polynomials.c
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
* Main file.
*/
#define N 7
#include "../code_polynomials/config_polynomials.h"
#include "../code_polynomials/src/poly.h"
#include "config.h"
#include "src/onewire.h"
#include "../lib_data/data.h"
#include "../lib_uart/uart.h"
#include <avr/interrupt.h>
#include <stdio.h>
volatile uint32_t i;
uint8_t j;
struct Data* data;
Poly generator;
Poly* syndrome;
int main(void)
{
// Init the lib
poly_init_generator();
make_syndrome();
i = 0;
j = 0;
data = data_generate(N);
#ifdef DEBUG
// Setup led for debugging
//LED_DDR |= LED_PIN_MASK;
//LED_PORT &=~LED_PIN_MASK;
#endif
uart_init(BAUD_RATE);
// Pin change interrupt (INT1 pin)
EICRA |= (1 << ISC11); // Falling edge
EIMSK |= (1 << INT1); // Enable Interruption
EIFR |= (1 << INTF1);
char str[5];
// Enable interrupts.
sei();
// Main loop
for(;;)
{
if(i == 7)
{
i = 0;
Poly deco = poly_decode(data);
data_show(deco);
data_free(deco);
}
}
}
ISR (INT1_vect) // Falling edge detected
{
_delay_us(T/4);
if(bus_read())
{
data_set(i, 1, data);
}
else
{
data_set(i, 0, data);
}
i += 1;
}