@mchp-mcc/scf-pic8-pwm-v2 4.2.7 → 4.2.9

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.
package/src/PinsLogic.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { AppModel } from "../generated_module/src/types/AutoModuleTypes";
2
- import { pin_row } from "@microchip/pin-standard";
2
+ import { pin_row, behaviour } from "@microchip/pin-standard";
3
3
 
4
4
  // provide complete dynamic data for all pin rows. It overrides static pindata.json
5
5
  export const getCompletePinData = (appModel: AppModel): any => {
@@ -8,19 +8,206 @@ export const getCompletePinData = (appModel: AppModel): any => {
8
8
  };
9
9
 
10
10
  // overrides pin data for a particular row based on model.
11
- export function getRowData(appModel: AppModel, rowData: pin_row): pin_row {
11
+ export function getRowData(appModel: AppModel, rowData: pin_row): pin_row | undefined {
12
12
  const pwminstancename = appModel.getHardware()?.getPeripheral()?.instance;
13
+ const moduleName = appModel.getName() ?? "PWM";
14
+ const allPinsData: any = appModel.getImportValue("pin_standard")?.allpins;
15
+ const modulePins: string[] = getModulePins(allPinsData, moduleName);
16
+ const pinName: string = getPinName(modulePins, rowData.filter.aliasReEx);
17
+ const pinBehaviour: string = getpinBehaviour(allPinsData, moduleName, pinName);
18
+ const isPPS = pinBehaviour === "pps";
19
+ const isAPFCON = pinBehaviour === "apfcon";
13
20
 
21
+ if (pinName === "") {
22
+ return undefined;
23
+ }
14
24
  if (rowData.name === "out") {
15
25
  rowData = {
16
26
  ...rowData,
17
- module: "PWM" + pwminstancename,
18
- function: "PWM" + pwminstancename + "OUT",
27
+ module: moduleName,
28
+ function: moduleName + "OUT",
29
+ filter: {
30
+ module: moduleName,
31
+ aliasReEx: `^PWM${pwminstancename}$`,
32
+ },
33
+ behaviour: isPPS
34
+ ? behaviour.PPS
35
+ : isAPFCON
36
+ ? behaviour.APFCON
37
+ : behaviour.LOCK_UNLOCK,
38
+ };
39
+ } else if (rowData.name === "pwmx0") {
40
+ rowData = {
41
+ ...rowData,
42
+ module: moduleName,
43
+ function: moduleName + "0OUT",
44
+ filter: {
45
+ ...rowData.filter,
46
+ module: moduleName,
47
+ },
48
+ behaviour: isPPS
49
+ ? behaviour.PPS
50
+ : isAPFCON
51
+ ? behaviour.APFCON
52
+ : behaviour.LOCK_UNLOCK,
53
+ };
54
+ if (appModel.isComponentValue("pwmoe0Pwmaoe") === true) {
55
+ rowData = {
56
+ ...rowData,
57
+ behaviourMeta: { lockPinRegEx: moduleName + "0" },
58
+ };
59
+ }
60
+ } else if (rowData.name === "pwmx1") {
61
+ rowData = {
62
+ ...rowData,
63
+ module: moduleName,
64
+ function: moduleName + "1OUT",
65
+ filter: {
66
+ ...rowData.filter,
67
+ module: moduleName,
68
+ },
69
+ behaviour: isPPS
70
+ ? behaviour.PPS
71
+ : isAPFCON
72
+ ? behaviour.APFCON
73
+ : behaviour.LOCK_UNLOCK,
74
+ };
75
+ if (appModel.isComponentValue("pwmoe1Pwmaoe") === true) {
76
+ rowData = {
77
+ ...rowData,
78
+ behaviourMeta: { lockPinRegEx: moduleName + "1" },
79
+ };
80
+ }
81
+ } else if (rowData.name === "pwmx2") {
82
+ rowData = {
83
+ ...rowData,
84
+ module: moduleName,
85
+ function: moduleName + "2OUT",
19
86
  filter: {
20
- module: "PWM" + pwminstancename,
21
- aliasReEx: "PWM" + pwminstancename,
87
+ ...rowData.filter,
88
+ module: moduleName,
22
89
  },
90
+ behaviour: isPPS
91
+ ? behaviour.PPS
92
+ : isAPFCON
93
+ ? behaviour.APFCON
94
+ : behaviour.LOCK_UNLOCK,
23
95
  };
96
+ if (appModel.isComponentValue("pwmoe2Pwmaoe") === true) {
97
+ rowData = {
98
+ ...rowData,
99
+ behaviourMeta: { lockPinRegEx: moduleName + "2" },
100
+ };
101
+ }
102
+ } else if (rowData.name === "pwmx3") {
103
+ rowData = {
104
+ ...rowData,
105
+ module: moduleName,
106
+ function: moduleName + "3OUT",
107
+ filter: {
108
+ ...rowData.filter,
109
+ module: moduleName,
110
+ },
111
+ behaviour: isPPS
112
+ ? behaviour.PPS
113
+ : isAPFCON
114
+ ? behaviour.APFCON
115
+ : behaviour.LOCK_UNLOCK,
116
+ };
117
+ if (appModel.isComponentValue("pwmoe3Pwmaoe") === true) {
118
+ rowData = {
119
+ ...rowData,
120
+ behaviourMeta: { lockPinRegEx: moduleName + "3" },
121
+ };
122
+ }
123
+ }
124
+
125
+ let rowActions = [];
126
+ const pwmx0Regcomponent = appModel.getComponent("pwmoe0Pwmaoe")?.component;
127
+ const pwmx1Regcomponent = appModel.getComponent("pwmoe1Pwmaoe")?.component;
128
+ const pwmx2Regcomponent = appModel.getComponent("pwmoe2Pwmaoe")?.component;
129
+ const pwmx3Regcomponent = appModel.getComponent("pwmoe3Pwmaoe")?.component;
130
+
131
+ if (pwmx0Regcomponent) {
132
+ rowActions = rowActions.concat(
133
+ appModel
134
+ .getPCPHelper?.()
135
+ .stateActionBuilder(rowData)
136
+ .rowWithName("pwmx0")
137
+ .forComponent(pwmx0Regcomponent)
138
+ .addIfLockedSetValue(moduleName + "0", true)
139
+ .addIfUnLockedSetValue(".*", false)
140
+ .build(),
141
+ );
24
142
  }
143
+ if (pwmx1Regcomponent) {
144
+ rowActions = rowActions.concat(
145
+ appModel
146
+ .getPCPHelper?.()
147
+ .stateActionBuilder(rowData)
148
+ .rowWithName("pwmx1")
149
+ .forComponent(pwmx1Regcomponent)
150
+ .addIfLockedSetValue(moduleName + "1", true)
151
+ .addIfUnLockedSetValue(".*", false)
152
+ .build(),
153
+ );
154
+ }
155
+ if (pwmx2Regcomponent) {
156
+ rowActions = rowActions.concat(
157
+ appModel
158
+ .getPCPHelper?.()
159
+ .stateActionBuilder(rowData)
160
+ .rowWithName("pwmx2")
161
+ .forComponent(pwmx2Regcomponent)
162
+ .addIfLockedSetValue(moduleName + "2", true)
163
+ .addIfUnLockedSetValue(".*", false)
164
+ .build(),
165
+ );
166
+ }
167
+ if (pwmx3Regcomponent) {
168
+ rowActions = rowActions.concat(
169
+ appModel
170
+ .getPCPHelper?.()
171
+ .stateActionBuilder(rowData)
172
+ .rowWithName("pwmx3")
173
+ .forComponent(pwmx3Regcomponent)
174
+ .addIfLockedSetValue(moduleName + "3", true)
175
+ .addIfUnLockedSetValue(".*", false)
176
+ .build(),
177
+ );
178
+ }
179
+ rowData = { ...rowData, actions: rowActions };
25
180
  return rowData;
26
181
  }
182
+ const getModulePins = (allPins: any, moduleName: string): string[] => {
183
+ const pins: string[] = [];
184
+ for (const portPin in allPins) {
185
+ const modulePins: any = allPins[portPin]?.[moduleName];
186
+ for (const modulePin in modulePins) {
187
+ if (pins.indexOf(modulePin) === -1) {
188
+ pins.push(modulePin);
189
+ }
190
+ }
191
+ }
192
+ return pins;
193
+ };
194
+ const getPinName = (modulePins: string[], regEx: string): string => {
195
+ let pinName = "";
196
+ modulePins.forEach((pin) => {
197
+ if (pin.match(new RegExp(regEx, "g"))) {
198
+ pinName = pin;
199
+ }
200
+ });
201
+ return pinName;
202
+ };
203
+ const getpinBehaviour = (allPins: any, moduleName: string, pinName: string): string => {
204
+ for (const portPin in allPins) {
205
+ const pinData: any = allPins[portPin]?.[moduleName]?.[pinName];
206
+ if (pinData?.["pps"]) {
207
+ return "pps";
208
+ } else if (pinData?.["apfcon"]) {
209
+ return "apfcon";
210
+ }
211
+ }
212
+ return "lock_unlock";
213
+ };
package/src/catalog.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "name": "PWM",
15
15
  "category": "Drivers/PWM",
16
16
  "description": "This module is a 16-bit Pulse-Width Modulator (PWM) with a compare feature and multiple outputs.",
17
- "deviceFilterRegEx": "^PIC18F.*Q10$|^PIC16[L]{0,1}F188.*$|^PIC16F152.*$|^PIC16F180[57][45]$|^PIC18F.*K40$",
17
+ "deviceFilterRegEx": ".*",
18
18
  "releaseNotesLink": "https://onlinedocs.microchip.com/v2/keyword-lookup?keyword=MCC.MELODY.8BITPIC.RELEASENOTES&version=latest&redirect=true"
19
19
  }
20
20
  }
@@ -7,7 +7,8 @@
7
7
  },
8
8
  "UIGroups": {
9
9
  "software": "Software Settings",
10
- "hardware": "Hardware Settings"
10
+ "hardware": "Hardware Settings",
11
+ "additional": "Additional Pin Settings"
11
12
  },
12
13
  "UIOrder": {
13
14
  "software": [
@@ -15,6 +16,7 @@
15
16
  ],
16
17
  "hardware": [
17
18
  "pwmenPwmcon",
19
+ "pwmoePwmcon",
18
20
  "timerSelection",
19
21
  "dutyCycle",
20
22
  "pwmdcValue",
@@ -23,6 +25,9 @@
23
25
  "pwmFrequency",
24
26
  "pwmResolution",
25
27
  "*"
28
+ ],
29
+ "additional": [
30
+ "*"
26
31
  ]
27
32
  },
28
33
  "hasPins": true,
@@ -337,6 +342,63 @@
337
342
  "tooltip": "Click for more Information",
338
343
  "url": "v2/keyword-lookup?keyword=atmel;device:${deviceName};register:${registerName}&redirect=true"
339
344
  }
345
+ },
346
+ {
347
+ "setting": "PWMOE",
348
+ "name": "pwmoePwmcon",
349
+ "category": "hardware",
350
+ "description": "Enable Pin Output",
351
+ "type": "boolean",
352
+ "group": "hardware",
353
+ "tabs": [
354
+ "main"
355
+ ]
356
+ }
357
+ ],
358
+ "PWMAOE": [
359
+ {
360
+ "setting": "PWMOE0",
361
+ "name": "pwmoe0Pwmaoe",
362
+ "category": "hardware",
363
+ "description": "Enable Additional Output 1",
364
+ "type": "boolean",
365
+ "group": "additional",
366
+ "tabs": [
367
+ "main"
368
+ ]
369
+ },
370
+ {
371
+ "setting": "PWMOE1",
372
+ "name": "pwmoe1Pwmaoe",
373
+ "category": "hardware",
374
+ "description": "Enable Additional Output 2",
375
+ "type": "boolean",
376
+ "group": "additional",
377
+ "tabs": [
378
+ "main"
379
+ ]
380
+ },
381
+ {
382
+ "setting": "PWMOE2",
383
+ "name": "pwmoe2Pwmaoe",
384
+ "category": "hardware",
385
+ "description": "Enable Additional Output 3",
386
+ "type": "boolean",
387
+ "group": "additional",
388
+ "tabs": [
389
+ "main"
390
+ ]
391
+ },
392
+ {
393
+ "setting": "PWMOE3",
394
+ "name": "pwmoe3Pwmaoe",
395
+ "category": "hardware",
396
+ "description": "Enable Additional Output 4",
397
+ "type": "boolean",
398
+ "group": "additional",
399
+ "tabs": [
400
+ "main"
401
+ ]
340
402
  }
341
403
  ],
342
404
  "PWMDCH": [
package/src/pinsdata.json CHANGED
@@ -7,9 +7,48 @@
7
7
  "direction": "output",
8
8
  "filter": {
9
9
  "module": "PWM6",
10
- "aliasReEx": "^PWM6OUT$|PWM6$"
11
- },
12
- "behaviour": "PPS"
10
+ "aliasReEx": "^PWM[0-9]$"
11
+ }
12
+ },
13
+ {
14
+ "name": "pwmx0",
15
+ "module": "PWM1",
16
+ "function": "PWM10OUT",
17
+ "direction": "output",
18
+ "filter": {
19
+ "module": "PWM1",
20
+ "aliasReEx": "^PWM[0-9]0$"
21
+ }
22
+ },
23
+ {
24
+ "name": "pwmx1",
25
+ "module": "PWM1",
26
+ "function": "PWM10OUT",
27
+ "direction": "output",
28
+ "filter": {
29
+ "module": "PWM1",
30
+ "aliasReEx": "^PWM[0-9]1$"
31
+ }
32
+ },
33
+ {
34
+ "name": "pwmx2",
35
+ "module": "PWM1",
36
+ "function": "PWM10OUT",
37
+ "direction": "output",
38
+ "filter": {
39
+ "module": "PWM1",
40
+ "aliasReEx": "^PWM[0-9]2$"
41
+ }
42
+ },
43
+ {
44
+ "name": "pwmx3",
45
+ "module": "PWM1",
46
+ "function": "PWM10OUT",
47
+ "direction": "output",
48
+ "filter": {
49
+ "module": "PWM1",
50
+ "aliasReEx": "^PWM[0-9]3$"
51
+ }
13
52
  }
14
53
  ]
15
54
  }
package/src/pinlogic.json DELETED
@@ -1,20 +0,0 @@
1
- {
2
- "key":"pinmodekey",
3
- "pindata": [
4
- {
5
- "value": "normal",
6
- "rows": [
7
- {
8
- "name": "myPin",
9
- "pinRegEx": "",
10
- "direction": "output",
11
- "type": "digital",
12
- "interfaceId": {
13
- "name": "basic-pin",
14
- "version": "0.1.0"
15
- }
16
- }
17
- ]
18
- }
19
- ]
20
- }