@mchp-mcc/scf-pic8-opamp-v2 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,293 @@
1
+ import { AppModel } from "../generated_module/src/types/AutoModuleTypes";
2
+ import { pin_row, pin_attribs_enum } from "@microchip/pin-standard";
3
+ import { QueryAdapterKey } from "@microchip/pin-standard/lib/pin-standard";
4
+ import { Dictionary } from "@microchip/scf-common/lib/Processor";
5
+
6
+ // provide complete dynamic data for all pin rows. It overrides static pindata.json
7
+ export const getCompletePinData = (appModel: AppModel): any => {
8
+ // way to programatically override the json data
9
+ return {};
10
+ };
11
+
12
+ // overrides pin data for a particular row based on model.
13
+ export function getRowData(appModel: AppModel, rowData: pin_row): pin_row | undefined {
14
+ let retRowJSONdata: pin_row | undefined = rowData;
15
+ const mod = appModel.getHardware()?.getName() ?? "OPA";
16
+
17
+ const pinPayload = appModel.getImportValue("pin_standard");
18
+
19
+ const allPins = pinPayload?.[QueryAdapterKey.ALLPINS] ?? {};
20
+ const allPinsData = getInputPinsData(allPins, mod);
21
+
22
+ const posPinAttribs = getPinAttribs(allPinsData, "+");
23
+ const negPinAttribs = getPinAttribs(allPinsData, "-");
24
+
25
+ if (/^posPins$/.test(rowData.name)) {
26
+ if (appModel.getComponentValue("pchOpacon2") === mod + "IN+") {
27
+ if (appModel.getComponentValue("pssOpacon3") === mod + "IN0+") {
28
+ retRowJSONdata = {
29
+ ...retRowJSONdata,
30
+ module: mod,
31
+ function: mod + "INx+",
32
+ filter: { ...retRowJSONdata.filter, module: mod },
33
+ behaviourMeta: { lockPinRegEx: mod + "IN0+" },
34
+ attribs: posPinAttribs,
35
+ };
36
+ } else if (appModel.getComponentValue("pssOpacon3") === mod + "IN1+") {
37
+ retRowJSONdata = {
38
+ ...retRowJSONdata,
39
+ module: mod,
40
+ function: mod + "INx+",
41
+ filter: { ...retRowJSONdata.filter, module: mod },
42
+ behaviourMeta: { lockPinRegEx: mod + "IN1+" },
43
+ attribs: posPinAttribs,
44
+ };
45
+ } else if (appModel.getComponentValue("pssOpacon3") === mod + "IN2+") {
46
+ retRowJSONdata = {
47
+ ...retRowJSONdata,
48
+ module: mod,
49
+ function: mod + "INx+",
50
+ filter: { ...retRowJSONdata.filter, module: mod },
51
+ behaviourMeta: { lockPinRegEx: mod + "IN2+" },
52
+ attribs: posPinAttribs,
53
+ };
54
+ } else if (appModel.getComponentValue("pssOpacon3") === mod + "IN3+") {
55
+ retRowJSONdata = {
56
+ ...retRowJSONdata,
57
+ module: mod,
58
+ function: mod + "INx+",
59
+ filter: { ...retRowJSONdata.filter, module: mod },
60
+ behaviourMeta: { lockPinRegEx: mod + "IN3+" },
61
+ attribs: posPinAttribs,
62
+ };
63
+ }
64
+ let rowActions = [];
65
+ const posSrc = appModel
66
+ .getAutoModuleAppModel()
67
+ .getComponent("pssOpacon3")?.component;
68
+ if (posSrc) {
69
+ rowActions = rowActions.concat(
70
+ appModel
71
+ .getPCPHelper?.()
72
+ .stateActionBuilder(rowData)
73
+ .rowWithName("posPins")
74
+ .forComponent(posSrc)
75
+ .addIfLockedSetValue(mod + "IN0+", mod + "IN0+")
76
+ .addIfLockedSetValue(mod + "IN1+", mod + "IN1+")
77
+ .addIfLockedSetValue(mod + "IN2+", mod + "IN2+")
78
+ .addIfLockedSetValue(mod + "IN3+", mod + "IN3+")
79
+ .build(),
80
+ );
81
+ }
82
+ const neededAttribs: pin_attribs_enum[] = [pin_attribs_enum.cname];
83
+ const cnameAttribComponent = appModel.getComponent(
84
+ "cnameAttribforPosPins",
85
+ )?.component;
86
+ if (cnameAttribComponent) {
87
+ rowActions = rowActions.concat(
88
+ appModel
89
+ .getPCPHelper?.()
90
+ .stateActionBuilder(rowData)
91
+ .rowWithName("posPins")
92
+ .forComponent(cnameAttribComponent)
93
+ .addIfLockedProvideAttribs(".*", neededAttribs)
94
+ .addIfUnlockedProvideAttribs(".*", neededAttribs)
95
+ .build(),
96
+ );
97
+ }
98
+ retRowJSONdata = { ...retRowJSONdata, actions: rowActions };
99
+ } else {
100
+ retRowJSONdata = undefined;
101
+ }
102
+ } else if (/^negPins$/.test(rowData.name)) {
103
+ const config = appModel.getComponentValue("customConfig");
104
+ const negChannel = appModel.getComponentValue("nchOpacon2");
105
+ if (
106
+ negChannel === mod + "IN-" ||
107
+ (config?.indexOf("Programmable Gain Amplifier") !== -1 &&
108
+ negChannel === "GSEL" &&
109
+ config !== "Unity Gain Buffer")
110
+ ) {
111
+ if (appModel.getComponentValue("nssOpacon1") === mod + "IN0-") {
112
+ retRowJSONdata = {
113
+ ...retRowJSONdata,
114
+ module: mod,
115
+ function: mod + "INx-",
116
+ filter: { ...retRowJSONdata.filter, module: mod },
117
+ behaviourMeta: { lockPinRegEx: mod + "IN0-" },
118
+ attribs: negPinAttribs,
119
+ };
120
+ } else if (appModel.getComponentValue("nssOpacon1") === mod + "IN1-") {
121
+ retRowJSONdata = {
122
+ ...retRowJSONdata,
123
+ module: mod,
124
+ function: mod + "INx-",
125
+ filter: { ...retRowJSONdata.filter, module: mod },
126
+ behaviourMeta: { lockPinRegEx: mod + "IN1-" },
127
+ attribs: negPinAttribs,
128
+ };
129
+ } else if (appModel.getComponentValue("nssOpacon1") === mod + "IN2-") {
130
+ retRowJSONdata = {
131
+ ...retRowJSONdata,
132
+ module: mod,
133
+ function: mod + "INx-",
134
+ filter: { ...retRowJSONdata.filter, module: mod },
135
+ behaviourMeta: { lockPinRegEx: mod + "IN2-" },
136
+ attribs: negPinAttribs,
137
+ };
138
+ } else if (appModel.getComponentValue("nssOpacon1") === mod + "IN3-") {
139
+ retRowJSONdata = {
140
+ ...retRowJSONdata,
141
+ module: mod,
142
+ function: mod + "INx-",
143
+ filter: { ...retRowJSONdata.filter, module: mod },
144
+ behaviourMeta: { lockPinRegEx: mod + "IN3-" },
145
+ attribs: negPinAttribs,
146
+ };
147
+ } else if (appModel.getComponentValue("nssOpacon1") === "Vss") {
148
+ retRowJSONdata = {
149
+ ...retRowJSONdata,
150
+ module: mod,
151
+ function: mod + "INx-",
152
+ filter: { ...retRowJSONdata.filter, module: mod },
153
+ behaviourMeta: { lockPinRegEx: "^.{0}$" },
154
+ };
155
+ }
156
+ let rowActions = [];
157
+ const negSrc = appModel
158
+ .getAutoModuleAppModel()
159
+ .getComponent("nssOpacon1")?.component;
160
+ if (negSrc) {
161
+ rowActions = rowActions.concat(
162
+ appModel
163
+ .getPCPHelper?.()
164
+ .stateActionBuilder(rowData)
165
+ .rowWithName("negPins")
166
+ .forComponent(negSrc)
167
+ .addIfLockedSetValue(mod + "IN0-", mod + "IN0-")
168
+ .addIfLockedSetValue(mod + "IN1-", mod + "IN1-")
169
+ .addIfLockedSetValue(mod + "IN2-", mod + "IN2-")
170
+ .addIfLockedSetValue(mod + "IN3-", mod + "IN3-")
171
+ .addIfUnLockedSetValue(".*", "Vss")
172
+ .build(),
173
+ );
174
+ }
175
+ const neededAttribs: pin_attribs_enum[] = [pin_attribs_enum.cname];
176
+ const cnameAttribComponent = appModel.getComponent(
177
+ "cnameAttribforNegPins",
178
+ )?.component;
179
+ if (cnameAttribComponent) {
180
+ rowActions = rowActions.concat(
181
+ appModel
182
+ .getPCPHelper?.()
183
+ .stateActionBuilder(rowData)
184
+ .rowWithName("negPins")
185
+ .forComponent(cnameAttribComponent)
186
+ .addIfLockedProvideAttribs(".*", neededAttribs)
187
+ .addIfUnlockedProvideAttribs(".*", neededAttribs)
188
+ .build(),
189
+ );
190
+ }
191
+ retRowJSONdata = { ...retRowJSONdata, actions: rowActions };
192
+ } else {
193
+ retRowJSONdata = undefined;
194
+ }
195
+ } else if (/^outputPin$/.test(rowData.name)) {
196
+ if (!appModel.isComponentValue("intoeOpacon3")) {
197
+ retRowJSONdata = {
198
+ ...retRowJSONdata,
199
+ module: mod,
200
+ function: mod + "OUT",
201
+ filter: { ...retRowJSONdata.filter, module: mod },
202
+ behaviourMeta: { lockPinRegEx: mod + "OUT" },
203
+ };
204
+ retRowJSONdata = { ...retRowJSONdata };
205
+ } else {
206
+ retRowJSONdata = undefined;
207
+ }
208
+ } else if (/^ppsPin$/.test(rowData.name)) {
209
+ if (appModel.getComponentValue("orsOpaors") === "OPAxORPPS") {
210
+ retRowJSONdata = {
211
+ ...retRowJSONdata,
212
+ module: mod,
213
+ function: mod + "ORPPS",
214
+ filter: { ...retRowJSONdata.filter, module: mod },
215
+ };
216
+ retRowJSONdata = { ...retRowJSONdata };
217
+ } else {
218
+ retRowJSONdata = undefined;
219
+ }
220
+ }
221
+ return retRowJSONdata;
222
+ }
223
+
224
+ export interface AllPinsData {
225
+ [pinName: string]: {
226
+ [module: string]: {
227
+ [key: string]: {
228
+ alias: string;
229
+ };
230
+ };
231
+ };
232
+ }
233
+
234
+ export interface PinData {
235
+ funcName: string;
236
+ customName: string;
237
+ pinName: string;
238
+ }
239
+
240
+ export interface PinAttribs {
241
+ aliasReEx: string;
242
+ cname: string;
243
+ }
244
+
245
+ export const getInputPinsData = (
246
+ allPins: AllPinsData,
247
+ moduleName: string,
248
+ ): Dictionary<PinData> => {
249
+ return getPinsData(allPins, /OPA\d(IN\d)(\D)/, moduleName);
250
+ };
251
+
252
+ export const getPinsData = (
253
+ allPins: AllPinsData,
254
+ aliasRegex: RegExp,
255
+ modName: string,
256
+ ): Dictionary<PinData> => {
257
+ const pinData: Dictionary<PinData> = {};
258
+ Object.keys(allPins).forEach((pinName) => {
259
+ const pins = allPins[pinName];
260
+ const modPins = pins[modName];
261
+ if (modPins) {
262
+ Object.keys(modPins).forEach((key) => {
263
+ const opaPins = modPins[key].alias.match(aliasRegex);
264
+ if (opaPins) {
265
+ const customName = pinName + "_" + opaPins[1];
266
+ const funcName = opaPins[0];
267
+ pinData[funcName] = {
268
+ funcName,
269
+ customName,
270
+ pinName,
271
+ };
272
+ }
273
+ });
274
+ }
275
+ });
276
+ return pinData;
277
+ };
278
+
279
+ export const getPinAttribs = (
280
+ allPins: Dictionary<PinData>,
281
+ pinPolarity: string,
282
+ ): PinAttribs[] => {
283
+ const pinAttribArr: PinAttribs[] = [];
284
+ Object.keys(allPins)
285
+ .filter((key) => key.endsWith(pinPolarity))
286
+ .forEach((key) => {
287
+ pinAttribArr.push({
288
+ aliasReEx: allPins[key].funcName,
289
+ cname: allPins[key].customName,
290
+ });
291
+ });
292
+ return pinAttribArr;
293
+ };
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@mchp-mcc/local-catalog",
3
+ "version": "1.0.0",
4
+ "content": [
5
+ {
6
+ "name": "@mchp-mcc/scf-pic8-opamp-v2",
7
+ "version": "*",
8
+ "meta": {
9
+ "keywords": [
10
+ "pic8",
11
+ "opamp"
12
+ ],
13
+ "name": "OPA",
14
+ "category": "Drivers/OPAMP",
15
+ "description": "The Operational Amplifier (OPA) module features programmable gain options, adjustable input offset voltage and hardware override control capabilities.",
16
+ "deviceFilterRegEx": "^PIC18F.*Q71$",
17
+ "defaultSelection": true,
18
+ "releaseNotesLink": "https://onlinedocs.microchip.com/v2/keyword-lookup?keyword=MCC.MELODY.8BITPIC.RELEASENOTES&version=latest&redirect=true"
19
+ }
20
+ }
21
+
22
+ ],
23
+ "catalogs": []
24
+ }