/
SerialWombatBase.PinDefinitions.cs
310 lines (285 loc) · 9.61 KB
/
SerialWombatBase.PinDefinitions.cs
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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
using Meadow.Hardware;
using System.Collections;
using System.Collections.Generic;
namespace Meadow.Foundation.ICs.IOExpanders
{
public abstract partial class SerialWombatBase
{
/// <summary>
/// Serial Wombat pin definition class
/// </summary>
public class PinDefinitions : IPinDefinitions
{
/// <summary>
/// Analog-digital converter precision
/// </summary>
public const int ADCPrecisionBits = 12;
/// <summary>
/// Collection of pins
/// </summary>
public IList<IPin> AllPins { get; } = new List<IPin>();
/// <summary>
/// The pin controller
/// </summary>
public IPinController? Controller { get; set; }
/// <summary>
/// Create a new PinDefinitions object
/// </summary>
public PinDefinitions(SerialWombatBase wombat)
{
Controller = wombat;
InitAllPins();
}
/// <summary>
/// Pin WP0
/// </summary>
public IPin WP0 => new Pin(
Controller,
"WP0",
(byte)0x00,
new List<IChannelInfo> {
new DigitalChannelInfo("WP0", interruptCapable: false),
new PwmChannelInfo("PWM0", 0, 0),
new AnalogChannelInfo("A0", ADCPrecisionBits, true, false),
}
);
/// <summary>
/// Pin WP1
/// </summary>
public IPin WP1 => new Pin(
Controller,
"WP1",
(byte)0x01,
new List<IChannelInfo> {
new DigitalChannelInfo("WP1", interruptCapable: false),
new PwmChannelInfo("PWM1", 0, 0),
new AnalogChannelInfo("A1", ADCPrecisionBits, true, false),
}
);
/// <summary>
/// Pin WP2
/// </summary>
public IPin WP2 => new Pin(
Controller,
"WP2",
(byte)0x02,
new List<IChannelInfo> {
new DigitalChannelInfo("WP2", interruptCapable: false),
new PwmChannelInfo("PWM2", 0, 0),
new AnalogChannelInfo("A2", ADCPrecisionBits, true, false),
}
);
/// <summary>
/// Pin WP5
/// </summary>
public IPin WP5 => new Pin(
Controller,
"WP5",
(byte)0x05,
new List<IChannelInfo> {
new DigitalChannelInfo("WP5", interruptCapable: false),
}
);
/// <summary>
/// Pin WP6
/// </summary>
public IPin WP6 => new Pin(
Controller,
"WP6",
(byte)0x06,
new List<IChannelInfo> {
new DigitalChannelInfo("WP5", interruptCapable: false),
}
);
/// <summary>
/// Pin WP7
/// </summary>
public IPin WP7 => new Pin(
Controller,
"WP7",
(byte)0x07,
new List<IChannelInfo> {
new DigitalChannelInfo("WP5", interruptCapable: false),
new PwmChannelInfo("PWM7", 0, 0)
}
);
/// <summary>
/// Pin WP8
/// </summary>
public IPin WP8 => new Pin(
Controller,
"WP8",
(byte)0x08,
new List<IChannelInfo> {
new DigitalChannelInfo("WP8", interruptCapable: false),
}
);
/// <summary>
/// Pin WP9
/// </summary>
public IPin WP9 => new Pin(
Controller,
"WP9",
(byte)0x09,
new List<IChannelInfo> {
new DigitalChannelInfo("WP9", interruptCapable: false),
new PwmChannelInfo("PWM9", 0, 0)
}
);
/// <summary>
/// Pin WP10
/// </summary>
public IPin WP10 => new Pin(
Controller,
"WP10",
(byte)0x0a,
new List<IChannelInfo> {
new DigitalChannelInfo("WP10", interruptCapable: false),
new PwmChannelInfo("PWM10", 0, 0)
}
);
/// <summary>
/// Pin WP11
/// </summary>
public IPin WP11 => new Pin(
Controller,
"WP11",
(byte)0x0b,
new List<IChannelInfo> {
new DigitalChannelInfo("WP11", interruptCapable: false),
new PwmChannelInfo("PWM11", 0, 0)
}
);
/// <summary>
/// Pin WP12
/// </summary>
public IPin WP12 => new Pin(
Controller,
"WP12",
(byte)0x0c,
new List<IChannelInfo> {
new DigitalChannelInfo("WP12", interruptCapable: false),
new PwmChannelInfo("PWM12", 0, 0)
}
);
/// <summary>
/// Pin WP13
/// </summary>
public IPin WP13 => new Pin(
Controller,
"WP13",
(byte)0x0d,
new List<IChannelInfo> {
new DigitalChannelInfo("WP13", interruptCapable: false),
new PwmChannelInfo("PWM13", 0, 0)
}
);
/// <summary>
/// Pin WP14
/// </summary>
public IPin WP14 => new Pin(
Controller,
"WP14",
(byte)0x0e,
new List<IChannelInfo> {
new DigitalChannelInfo("WP14", interruptCapable: false),
new PwmChannelInfo("PWM14", 0, 0)
}
);
/// <summary>
/// Pin WP15
/// </summary>
public IPin WP15 => new Pin(
Controller,
"WP15",
(byte)0x0f,
new List<IChannelInfo> {
new DigitalChannelInfo("WP15", interruptCapable: false),
new PwmChannelInfo("PWM15", 0, 0)
}
);
/// <summary>
/// Pin WP16
/// </summary>
public IPin WP16 => new Pin(
Controller,
"WP16",
(byte)0x10,
new List<IChannelInfo> {
new DigitalChannelInfo("WP16", interruptCapable: false),
new PwmChannelInfo("PWM16", 0, 0),
new AnalogChannelInfo("A16", ADCPrecisionBits, true, false),
}
);
/// <summary>
/// Pin WP17
/// </summary>
public IPin WP17 => new Pin(
Controller,
"WP17",
(byte)0x11,
new List<IChannelInfo> {
new DigitalChannelInfo("WP17", interruptCapable: false),
new PwmChannelInfo("PWM17", 0, 0),
new AnalogChannelInfo("A17", ADCPrecisionBits, true, false),
}
);
/// <summary>
/// Pin WP18
/// </summary>
public IPin WP18 => new Pin(
Controller,
"WP18",
(byte)0x12,
new List<IChannelInfo> {
new DigitalChannelInfo("WP18", interruptCapable: false),
new PwmChannelInfo("PWM18", 0, 0),
new AnalogChannelInfo("A18", ADCPrecisionBits, true, false),
}
);
/// <summary>
/// Pin WP19
/// </summary>
public IPin WP19 => new Pin(
Controller,
"WP19",
(byte)0x13,
new List<IChannelInfo> {
new DigitalChannelInfo("WP19", interruptCapable: false),
new PwmChannelInfo("PWM19", 0, 0),
new AnalogChannelInfo("A19", ADCPrecisionBits, true, false),
}
);
/// <summary>
/// Pin Initialize all serial wombat pins
/// </summary>
protected void InitAllPins()
{
// add all our pins to the collection
AllPins.Add(WP0);
AllPins.Add(WP1);
AllPins.Add(WP2);
AllPins.Add(WP5);
AllPins.Add(WP6);
AllPins.Add(WP7);
AllPins.Add(WP8);
AllPins.Add(WP9);
AllPins.Add(WP10);
AllPins.Add(WP11);
AllPins.Add(WP12);
AllPins.Add(WP13);
AllPins.Add(WP14);
AllPins.Add(WP15);
AllPins.Add(WP16);
AllPins.Add(WP17);
AllPins.Add(WP18);
AllPins.Add(WP19);
}
/// <summary>
/// Get Enumerator
/// </summary>
public IEnumerator<IPin> GetEnumerator() => AllPins.GetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
}
}