-
Notifications
You must be signed in to change notification settings - Fork 19
/
iface_kcan.cpp
75 lines (65 loc) · 1.38 KB
/
iface_kcan.cpp
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
/*
* iface_kcan.cpp
*
* (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.
*/
#include "iface_kcan.h"
#include "iface_kl_tty.h"
#include "iface_can.h"
#include "os.h"
#include "autotty.h"
IfaceKCAN::IfaceKCAN(Cpu *c, UI* ui, const char *driver) : Interface(ui)
{
cpu = c;
can_enabled = false;
atty = new AutoTTY(ui, driver);
iface = new IfaceKLTTY(c, ui, atty);
iface->setSerial(serial);
}
void IfaceKCAN::setSerial(Serial *s)
{
serial = s;
iface->setSerial(serial);
}
IfaceKCAN::~IfaceKCAN()
{
delete iface;
delete atty;
}
void IfaceKCAN::setCAN(bool onoff)
{
DEBUG(IFACE, "KCAN setCAN %d\n", onoff);
if (onoff != can_enabled) {
delete iface;
if(onoff)
iface = new IfaceCAN(cpu, ui, atty);
else
iface = new IfaceKLTTY(cpu, ui, atty);
iface->setSerial(serial);
}
can_enabled = onoff;
}
void IfaceKCAN::setBaudDivisor(int divisor)
{
iface->setBaudDivisor(divisor);
}
void IfaceKCAN::checkInput()
{
iface->checkInput();
}
void IfaceKCAN::sendByte(uint8_t byte)
{
iface->sendByte(byte);
}
void IfaceKCAN::slowInitImminent()
{
iface->slowInitImminent();
}
bool IfaceKCAN::sendSlowInitBitwise(uint8_t bit)
{
return iface->sendSlowInitBitwise(bit);
}