-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata_frame_utils.h
More file actions
86 lines (69 loc) · 2.44 KB
/
Copy pathdata_frame_utils.h
File metadata and controls
86 lines (69 loc) · 2.44 KB
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
76
77
78
79
80
81
82
83
84
85
86
//#include "mbed.h"
#include "math.h"
#include "stdlib.h"
#include "stdio.h"
#include "bitset"
typedef enum {SOF,arb_phase,control_field,data_field,CRC,ACK,EOFR,overload,erro,inter_frame_space,idle} states;
typedef enum {schrodinger_frame,can_A,can_B} can_types;
// transformed eof into a bool for praticity
typedef struct frame {
int id,id2,dlc,crc;
long data;
bool sof,rtr,srr,ide,r0,r1,crc_delimiter,ack_slot,ack_delimeter,eof;
}frame;
// Flags responsible for triggering erros
extern bool bit_stuff_erro;
extern bool start_seven_recessive_erro;
extern bool crc_erro;
extern bool form_erro;
//Bits responsible for logic control of reading and writing
extern bool send_ack;
extern bool write_bit;
extern bool this_bit;
extern bool last_bit;
extern bool bit_stuff;
//Auxiliar vars, mostly counters
extern int bit_stuff_count;
extern int count;
extern int tail_count;
//Var responsible for keeping track of the state of the system
extern states state;
extern states erro_state;
extern can_types can_type;
extern frame my_frame;
extern bool lock;
//----------------------------Functions Declarations---------------------------------------
// essa função deve setar todas as flags de modo que todos os outros módulos
// consigam interpretar se houve erro/bit_stuffed/qualquer flag de interesse
void bit_stuff_erro_detect();
//Sets all variables to it's inital/specified values
void setting_things_up ();
void my_frame_mount();
void my_frame_zeros();
void state_name(states curr_state);
// functions used to select the specific bit to send
bool set_bit_send();
void arb_phase_send_logic();
void control_field_send_logic();
void data_field_send_logic();
void crc_field_send_logic();
void ack_field_send_logic();
void eof_field_send_logic();
void erro_frame_logic();
void overload_frame_logic();
void inter_frame_space_logic();
// functions used to mount the package when reading
void mount_package(bool bit);
void arb_field_mount(bool bit);
void control_field_mount(bool read_bit);
void data_field_mount(bool read_bit);
void crc_field_mount(bool read_bit);
void ack_field_mount(bool read_bit);
void eof_field_mount(bool read_bit);
void inter_frame_space_check(bool read_bit);
// functions that run to assist the mounting/sending of messages
void bit_stuff_logic(bool read_bit);
void dlc_correction();
void change_mode(bool read_bit);
bool encoder();
void decoder(bool read_bit);