-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathpysimulavr.i
210 lines (176 loc) · 4.6 KB
/
pysimulavr.i
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
%module(directors="1") pysimulavr
%{
#include "systemclocktypes.h"
#include "avrdevice.h"
#include "systemclock.h"
#include "hardware.h"
#include "externaltype.h"
#include "irqsystem.h"
#include "pin.h"
#include "pinatport.h"
#include "net.h"
#include "rwmem.h"
#include "hwsreg.h"
#include "avrfactory.h"
#include "avrreadelf.h"
#include "memory.h"
#include "flash.h"
#include "hweeprom.h"
#include "avrerror.h"
#include "pysimulationmember.h"
#include "hwport.h"
#include "hwstack.h"
#include "avrsignature.h"
#include "specialmem.h"
#include "cmd/dumpargs.h"
#include "cmd/gdb.h"
// to get devices registered (automatically on linux, but necessary on windows)
#include "atmega128.h"
#include "at4433.h"
#include "at8515.h"
#include "atmega2560base.h"
#include "atmega668base.h"
#include "atmega16_32.h"
#include "attiny2313.h"
#include "attiny25_45_85.h"
// support module version and build date
#include "config.h"
//const char *_BUILD_DATE_ = __DATE__ ", " __TIME__;
//const char *_VERSION_ = PACKAGE_VERSION;
const char _BUILD_DATE_[] = __DATE__ ", " __TIME__;
const char _VERSION_[] = PACKAGE_VERSION;
%}
%include "std_vector.i"
%include "std_map.i"
%include "std_iostream.i"
%include "std_sstream.i"
%include "types.h"
namespace std {
%template(DWordVector) vector<dword>;
// templates for AvrNameToSignatureMap and AvrSignatureToNameMap
%template(map_string_int) map<string, unsigned int>;
%template(map_int_string) map<unsigned int, string>;
// template for SetDumpTraceArgs
%template(string_vector) vector<string>;
};
%exception {
try {
$action
} catch(char const* s) {
PyErr_SetString(PyExc_SystemError, s);
return NULL;
} catch(int i) {
PyErr_Format(PyExc_RuntimeError, "%d", i);
return NULL;
}
}
%include "config.h"
%include "systemclocktypes.h"
%include "simulationmember.h"
%feature("director") PySimulationMember;
%include "pysimulationmember.h"
%include "externaltype.h"
%feature("director") HasPinNotifyFunction;
%include "pinnotify.h"
%include "traceval.h"
%include "irqsystem.h"
%include "avrdevice.h"
%extend DumpManager {
void addDumpVCD(const std::string &vcdname,
const std::string &istr,
const std::string &timebase,
const bool rstrobe,
const bool wstrobe) {
DumpVCD *d = new DumpVCD(vcdname, timebase, rstrobe, wstrobe);
$self->addDumper(d, $self->load(istr));
}
}
%extend AvrDevice {
// getRWMem and setRWMem are deprecated, don't use it in new code!
unsigned char getRWMem(unsigned a) { return $self->GetRWMem(a); }
bool setRWMem(unsigned a, unsigned char v) { return $self->SetRWMem(a, v); }
}
%include "systemclock.h"
%extend SystemClock {
int Step() {
bool untilCoreStepFinished = false;
return $self->Step(untilCoreStepFinished);
}
}
%feature("director") Hardware;
%include "hardware.h"
%include "hwport.h"
%include "hwstack.h"
%feature("director") Pin;
%include "pin.h"
%extend Pin {
char toChar() {
char c = *$self;
return c;
}
void SetPin(const char c) {
*$self = c;
}
}
%include "pinatport.h"
%extend PinAtPort {
bool GetPinInput(void) {
return (bool)*$self;
}
}
%include "net.h"
%feature("director") RWMemoryMember;
%include "rwmem.h"
%include "specialmem.h"
%include "hwsreg.h"
%extend RWSreg {
unsigned char GetValue(void) {
unsigned char v = *$self;
return v;
}
void SetValue(unsigned char v) {
RWMemoryMember* m = $self;
*m = v;
}
}
%include "avrfactory.h"
%include "avrreadelf.h"
%include "memory.h"
%extend Memory {
unsigned char GetMemory(unsigned int a) {
if(a < $self->GetSize())
return $self->myMemory[a];
return 0;
}
void PyWriteMem(char *src, unsigned int offset, unsigned int secSize) {
$self->WriteMem((const unsigned char *)src, offset, secSize);
}
}
%include "flash.h"
%include "hweeprom.h"
%extend Breakpoints {
void RemoveBreakpoint(unsigned bp) {
Breakpoints::iterator ii;
if ((ii = find($self->begin(), $self->end(), bp)) != $self->end()) $self->erase(ii);
}
void AddBreakpoint(unsigned bp) {
$self->push_back(bp);
}
}
%include "avrsignature.h"
%include "avrerror.h"
%include "cmd/dumpargs.h"
%include "cmd/gdb.h"
// to get devices registered (automatically on linux, but necessary on windows)
%include "atmega128.h"
%include "at4433.h"
%include "at8515.h"
%include "atmega668base.h"
%include "atmega2560base.h"
%include "atmega16_32.h"
%include "attiny2313.h"
%include "attiny25_45_85.h"
// support version and build time information
const char _BUILD_DATE_[];
const char _VERSION_[];
// EOF