-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathz85c30.cpp
85 lines (64 loc) · 1.38 KB
/
z85c30.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
76
77
78
79
80
81
82
83
84
85
#include <stdint.h>
#include <string.h>
#include "debug.h"
#include "z85c30.h"
z85c30::z85c30()
{
memset(d, 0x00, sizeof d);
cr = 0;
tx_full = false;
}
z85c30::~z85c30()
{
}
void z85c30::ser_command_write(uint8_t data)
{
if (cr == 0)
{
uint8_t crc_reset_code = data >> 6;
uint8_t command_code = (data >> 3) & 7;
if (command_code == 1) // high point bit
cr = data & 15;
else
cr = data & 7;
// pdc -> dc_log("serial: select register %d, command code %d, crc reset code %d", cr, command_code, crc_reset_code);
}
else
{
// pdc -> dc_log("serial: write %02x to register %d", data, cr);
if (cr == 8)
{
// if (data == 0x0d)
// pdc -> dc_term("\n");
// else
// pdc -> dc_term("%c", data);
// LOG(INFO) << data;
// pdc -> dc_log("serial OUTPUT: %c (%02x)", data, data);
// tx_full = true; not neccessary
}
cr = 0;
}
}
uint8_t z85c30::ser_command_read()
{
uint8_t ret = -1;
if (cr == 0)
{
ret = 0x28 | (tx_full ? 0 : 4); // 00101t00 CTS/DCD, t: set when empty
tx_full = false;
}
cr = 0;
// pdc -> dc_log("serial: read from register %d: %02x", cr, ret);
return ret;
}
void z85c30::ser_data_write(uint8_t data)
{
ASSERT(cr < 16);
// pdc -> dc_term("%c", data);
// pdc -> dc_log("serial: write DATA %02x", data);
}
uint8_t z85c30::ser_data_read()
{
// pdc -> dc_log("serial: read DATA");
return 0;
}