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

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.
@@ -5,9 +5,9 @@
5
5
  *
6
6
  * @ingroup ${moduleNameLowerCase}
7
7
  *
8
- * @brief This file contains the driver code for ${moduleNameUpperCase} module.
8
+ * @brief This file contains the API implementations for the ${moduleNameUpperCase} module.
9
9
  *
10
- * @version ${moduleNameUpperCase} Driver Version 2.0.2
10
+ * @version ${moduleNameUpperCase} Driver Version 2.0.3
11
11
  */
12
12
 
13
13
  ${disclaimer}
@@ -28,7 +28,15 @@
28
28
  // Set the PWM to the options selected in the ${productName}.
29
29
  <#list initRegisters as reg>
30
30
  // ${reg.comment}
31
- ${reg.name} = ${reg.valueAsHex};
31
+ <#if reg.name == "CCPTMRS1">
32
+ ${CCPTMRS1.settings.CTSEL.bitName} = ${CCPTMRS1.settings.CTSEL.valueAsHex};
33
+ <#elseif reg.name == "CCPTMRS">
34
+ ${CCPTMRS.settings.CTSEL.bitName} = ${CCPTMRS.settings.CTSEL.valueAsHex};
35
+ <#elseif reg.name == "PWMTMRS0">
36
+ ${PWMTMRS.settings.CTSEL.bitName} = ${PWMTMRS.settings.CTSEL.valueAsHex};
37
+ <#else>
38
+ ${reg.name} = ${reg.valueAsHex};
39
+ </#if>
32
40
 
33
41
  </#list>
34
42
  <#if timerselpresence == "timerselpresent">
@@ -56,8 +64,8 @@
56
64
  void ${api.LoadDutyValue.name}(uint16_t dutyValue)
57
65
  {
58
66
  // Writing to 8 MSBs of PWM duty cycle in PWMDCH register
59
- ${PWMDCH} = (uint8_t) ((dutyValue & 0x03FCu) >> 2);
67
+ ${PWMDCH.name} = (uint8_t) ((dutyValue & 0x03FCu) >> 2);
60
68
 
61
69
  // Writing to 2 LSBs of PWM duty cycle in PWMDCL register
62
- ${PWMDCL} = (uint8_t) ((dutyValue & 0x0003u) << 6);
70
+ ${PWMDCL.name} = (uint8_t) ((dutyValue & 0x0003u) << 6);
63
71
  }
@@ -5,9 +5,9 @@
5
5
  *
6
6
  * @defgroup ${moduleNameLowerCase} ${moduleNameUpperCase}
7
7
  *
8
- * @brief This header file provides APIs for the ${moduleNameUpperCase} driver.
8
+ * @brief This file contains the API prototypes for the ${moduleNameUpperCase} driver.
9
9
  *
10
- * @version ${moduleNameUpperCase} Driver Version 2.0.2
10
+ * @version ${moduleNameUpperCase} Driver Version 2.0.3
11
11
  */
12
12
 
13
13
  ${disclaimer}
@@ -31,17 +31,17 @@ ${disclaimer}
31
31
 
32
32
  /**
33
33
  * @ingroup ${moduleNameLowerCase}
34
- * @brief This routine initializes the ${moduleNameUpperCase} interface.
35
- * @param none
36
- * @return none
34
+ * @brief Initializes the ${moduleNameUpperCase} interface.
35
+ * @param None.
36
+ * @return None.
37
37
  */
38
38
  ${simpleApi.Initialize};
39
39
 
40
40
  /**
41
41
  * @ingroup ${moduleNameLowerCase}
42
- * @brief This routine loads the 16 bit duty cycle value.
43
- * @param ${api.LoadDutyValue.arguments[0].type} ${api.LoadDutyValue.arguments[0].name} - load ${moduleNameUpperCase} duty cycle value.
44
- * @return none
42
+ * @brief Loads the 16-bit duty cycle value.
43
+ * @param ${api.LoadDutyValue.arguments[0].type} ${api.LoadDutyValue.arguments[0].name} - ${moduleNameUpperCase} duty cycle value to be loaded.
44
+ * @return None.
45
45
  */
46
46
  ${simpleApi.LoadDutyValue};
47
47
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mchp-mcc/scf-pic8-pwm-v2",
3
- "version": "4.2.5",
3
+ "version": "4.2.7",
4
4
  "scf": {
5
5
  "reducer": "auto",
6
6
  "creator": "output/creator.js",
@@ -105,8 +105,8 @@
105
105
  "profile": "jest profile",
106
106
  "build-run-dir-future": "node config/extract-run-directory-future.js",
107
107
  "release": "yarn build && yarn test && node -e 'require(\"./config/scf-project-scripts\").releaseProject()'",
108
- "test:itf:all": "node ./node_modules/@mchp-mcc/ccl-itf/lib/index.js --sp=./tests/itf --rd=./run",
109
- "test:itf:dev": "node ./node_modules/@mchp-mcc/ccl-itf/lib/index.js --sp=./tests/itf --rd=./run --sf=pwmV2.major.test.ts --df=\"PIC16F18076\"",
108
+ "test:itf:all": "node ./node_modules/@microchip/ccl-itf/lib/index.js --sp=./tests/itf --rd=./run --sf=pwmV2.major.test.ts --df=\"PIC16F18076|PIC16F18877|PIC18F47Q10\"",
109
+ "test:itf:dev": "node ./node_modules/@microchip/ccl-itf/lib/index.js --sp=./tests/itf --rd=./run --sf=pwmV2.major.test.ts --df=\"PIC16F18076\"",
110
110
  "postprocess": "node config/appendPrototype.js"
111
111
  },
112
112
  "husky": {
@@ -169,13 +169,13 @@
169
169
  "@babel/preset-env": "^7.9.6",
170
170
  "@babel/preset-react": "^7.9.4",
171
171
  "@babel/preset-typescript": "^7.9.0",
172
- "@mchp-mcc/ccl-itf": "^0.2.16",
173
172
  "@mchp-mcc/pic-8bit": "^5.9.0-dev.5",
174
173
  "@mchp-mcc/pic-8bit-types": "^5.9.0-dev.5",
174
+ "@microchip/ccl-itf": "^1.5.0",
175
175
  "@microchip/initializer-system": "^0.5.3",
176
176
  "@microchip/melody-automodule-interface": "^1.5.1",
177
177
  "@microchip/pic-8bit-types": "^5.0.1",
178
- "@microchip/run-directory": "^3.3.0",
178
+ "@microchip/run-directory": "^4.2.3",
179
179
  "@microchip/scf-automodule": "^5.5.1",
180
180
  "@microchip/scf-automodule-impl": "^1.7.1",
181
181
  "@microchip/scf-autoview": "^3.26.1",
@@ -230,4 +230,4 @@
230
230
  "description": "- Download & Install [nodejs](https://nodejs.org/en/download/)\r - Download & Install npm\r - Setup node & npm in enviroment path",
231
231
  "main": "lib/generated_module/src/index.js",
232
232
  "author": ""
233
- }
233
+ }
@@ -41,6 +41,17 @@ describe("Empty Derived Data Test ", () => {
41
41
  });
42
42
  });
43
43
 
44
+ describe("C custom name validator", () => {
45
+ it("invalid Custom name", () => {
46
+ const mockModule = mockAssignedModule(mockState());
47
+ const model = getModel(mockModule, getDerivedData);
48
+ const derivedData = model?.getDerivedData() as DerivedData;
49
+ const derivedFunctions = derivedData?.getMyFunctions();
50
+ const cName = new RegExp(derivedFunctions.componentNameValidator().pattern);
51
+ expect(cName.test("custom-Name")).toBe(false);
52
+ });
53
+ });
54
+
44
55
  describe("Import Interface test Cases ", () => {
45
56
  const mockMod = mockAssignedModule(mockState());
46
57
  const model = getModel(mockMod, MyDerivedData.getDerivedData);
@@ -288,8 +299,8 @@ describe("DerivedData for APIs: Timer selection -- >", () => {
288
299
  expect(derivedFunctions?.ctselPwmtmrs?.()).toEqual("PWM4timer2");
289
300
  });
290
301
  });
291
- describe("Invalid Timer 7 -->", () => {
292
- const mockModule = mockAssignedModule(getMockState(true, "TMR7", "TMR7"));
302
+ describe("Invalid Timer -->", () => {
303
+ const mockModule = mockAssignedModule(getMockState(true, "TMR", "TMR"));
293
304
  const model = getModel(mockModule, MyDerivedData.getDerivedData);
294
305
  const derivedData = model?.getDerivedData() as DerivedData;
295
306
  const derivedFunctions = derivedData?.getMyFunctions();
@@ -13,6 +13,7 @@ import { MyComponentNames, MyExportNames } from "../generated_module/src/types";
13
13
  import { getAutoSdlHelp } from "@microchip/scf-automodule-impl/lib/autoModule/ContextualHelp";
14
14
  import { getPinsLogic } from "../generated_module/src/pins/PCPHelper";
15
15
  import { MyImports } from "../generated_module/src/types";
16
+ import { getCFunctionValidator, PatternValidator } from "@microchip/scf-validators/lib";
16
17
 
17
18
  export const getDerivedData = (dataModel: AppModel): DerivedData => {
18
19
  if (dataModel) {
@@ -35,6 +36,7 @@ class EmptyDerivedData implements DerivedData {
35
36
  class MyDerivedData implements DerivedData {
36
37
  private dataModel: AppModel;
37
38
  private pwmCalculator: PwmCalculator;
39
+ private cValidator: PatternValidator = getCFunctionValidator();
38
40
 
39
41
  constructor(dataModel: AppModel) {
40
42
  this.dataModel = dataModel;
@@ -72,6 +74,7 @@ class MyDerivedData implements DerivedData {
72
74
  pwmResolution: (): number => this.getPwmCalculator().getPwmResolution(),
73
75
 
74
76
  ctselCcptmrs1: this.ctselTimerSetting,
77
+ ctselCcptmrs: this.ctselTimerSetting,
75
78
  ctselPwmtmrs: this.ctselTimerSetting,
76
79
  pwmdchPwmdch: (): number =>
77
80
  Number(this.dataModel.getComponentValue("pwmdcValue")) >> 2,
@@ -83,6 +86,8 @@ class MyDerivedData implements DerivedData {
83
86
  filterImports: this.filterImports,
84
87
  getPinsLogic: getPinsLogic,
85
88
  importName: this.friendlyImportName,
89
+ componentNameValidator: this.componentNameValidator,
90
+ getCustomUiErrors: this.getCustomUiErrors,
86
91
  };
87
92
  };
88
93
 
@@ -103,12 +108,33 @@ class MyDerivedData implements DerivedData {
103
108
  }
104
109
  };
105
110
 
111
+ private componentNameValidator = (): any => {
112
+ return {
113
+ pattern: this.cValidator.getRjsfValidation().pattern,
114
+ };
115
+ };
116
+
117
+ private getCustomUiErrors = (componentName: string): Error[] | undefined => {
118
+ switch (componentName) {
119
+ case "componentName":
120
+ return [
121
+ {
122
+ name: "pattern",
123
+ message: this.cValidator.getCustomErrorMessage(),
124
+ },
125
+ ];
126
+ default:
127
+ return undefined;
128
+ }
129
+ };
130
+
106
131
  private overrideDefaultOptions = (componentName: string): any[] => {
107
132
  switch (componentName) {
108
133
  case "timerSelection": {
109
134
  const result: any[] = [];
110
- const CCPTMRSREG = this.dataModel.getPeripheralDescription()?.registers
111
- ?.CCPTMRS1;
135
+ const CCPTMRSREG =
136
+ this.dataModel.getPeripheralDescription()?.registers?.CCPTMRS1 ??
137
+ this.dataModel.getPeripheralDescription()?.registers?.CCPTMRS;
112
138
  const PWMTMRSREG = this.dataModel.getPeripheralDescription()?.registers
113
139
  ?.PWMTMRS;
114
140
  if (CCPTMRSREG) {
@@ -276,15 +302,14 @@ class MyDerivedData implements DerivedData {
276
302
  };
277
303
 
278
304
  private ctselTimerSetting = (): string | undefined => {
279
- switch (this.dataModel.getComponentValue("timerSelection")) {
280
- case "TMR2":
281
- return this.dataModel.getHardware()?.getName() + "timer2";
282
- case "TMR4":
283
- return this.dataModel.getHardware()?.getName() + "timer4";
284
- case "TMR6":
285
- return this.dataModel.getHardware()?.getName() + "timer6";
286
- default:
287
- return undefined;
305
+ const timerSelection: string =
306
+ this.dataModel.getComponentValue("timerSelection") ?? "";
307
+ const groupmatch = timerSelection.match(/^TMR([0-9])$/) ?? "";
308
+ if (groupmatch.length > 1) {
309
+ const timersuffix = groupmatch?.length > 1 ? groupmatch[1] : "";
310
+ return this.dataModel.getHardware()?.getName() + "timer" + timersuffix;
311
+ } else {
312
+ return undefined;
288
313
  }
289
314
  };
290
315
 
@@ -41,8 +41,8 @@ export const getGeneratorModel = (model: AppModel): any => {
41
41
 
42
42
  //Registers and Settings
43
43
  initRegisters: initRegisters,
44
- PWMDCH: templateSettings?.registers?.PWMDCH.name ?? "",
45
- PWMDCL: templateSettings?.registers?.PWMDCL?.name ?? "",
44
+ // PWMDCH: templateSettings?.registers?.PWMDCH.name ?? "",
45
+ // PWMDCL: templateSettings?.registers?.PWMDCL?.name ?? "",
46
46
  CCPTMRSregname: templateSettings?.registers?.CCPTMRS1?.name ?? "",
47
47
  CTSELsettingname:
48
48
  templateSettings?.registers?.CCPTMRS1?.settings?.CTSEL.name ?? "",
@@ -51,6 +51,7 @@ export const getGeneratorModel = (model: AppModel): any => {
51
51
  (ctsel?.options?.length ?? 0) > 0 ? "timerselpresent" : "timerselabsent",
52
52
 
53
53
  pwmdcValue: model.getComponentValue("pwmdcValue"),
54
+ ...registerValues,
54
55
  };
55
56
  };
56
57
 
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]$",
17
+ "deviceFilterRegEx": "^PIC18F.*Q10$|^PIC16[L]{0,1}F188.*$|^PIC16F152.*$|^PIC16F180[57][45]$|^PIC18F.*K40$",
18
18
  "releaseNotesLink": "https://onlinedocs.microchip.com/v2/keyword-lookup?keyword=MCC.MELODY.8BITPIC.RELEASENOTES&version=latest&redirect=true"
19
19
  }
20
20
  }
@@ -136,7 +136,8 @@
136
136
  "tabs": [
137
137
  "main"
138
138
  ],
139
- "category": "software"
139
+ "category": "software",
140
+ "validation": true
140
141
  },
141
142
  "tmr2Dependency": {
142
143
  "name": "tmr2Dependency",