forked from uli/cascade
-
Notifications
You must be signed in to change notification settings - Fork 0
/
iface_can.h
63 lines (51 loc) · 1.06 KB
/
iface_can.h
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
/*
* iface_can.h
*
* (C) Copyright 2014 Ulrich Hecht
*
* This file is part of CASCADE. CASCADE is almost free software; you can
* redistribute it and/or modify it under the terms of the Cascade Public
* License 1.0. Read the file "LICENSE" for details.
*/
#ifndef _IFACE_CAN_H
#define _IFACE_CAN_H
#include "interface.h"
class Cpu;
class UI;
class AutoTTY;
enum {
RDST_IDLE = 0,
RDST_EXPECT_LENGTH,
RDST_EXPECT_DATA,
};
enum {
TXST_IDLE = 0,
TXST_EXPECT_CMD,
TXST_EXPECT_LENGTH,
TXST_EXPECT_DATA,
};
class IfaceCAN : public Interface {
public:
IfaceCAN(Cpu *c, UI *ui, AutoTTY *atty);
~IfaceCAN();
virtual void setBaudDivisor(int divisor) {}
virtual void checkInput() {}
virtual void slowInitImminent() {}
virtual void sendByte(uint8_t byte);
private:
void msgIn();
void msgOut();
Cpu *cpu;
static int readThreadRunner(void *data);
void *read_thread;
AutoTTY *atty;
int rx_type;
int rx_len;
uint8_t rx_msg[0xff];
int tx_cmd;
int tx_len;
int tx_state;
int tx_msg_ptr;
uint8_t tx_msg[0xff];
};
#endif