@mchp-mcc/scf-pic8-osc-v1 4.3.1 → 4.3.3
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/Changelog.md +20 -0
- package/Readme.md +31 -2
- package/lib/generated_module/src/index.js +0 -5
- package/output/autoCreator.js +1624 -0
- package/output/autoCreator.js.map +1 -0
- package/output/autoProcessor.js +1626 -0
- package/output/autoProcessor.js.map +1 -0
- package/output/clock.c.ftl +46 -22
- package/output/clock.h.ftl +16 -18
- package/output/creator.js +6261 -1577
- package/output/creator.js.map +1 -1
- package/output/processor.js +5324 -5802
- package/output/processor.js.map +1 -1
- package/package.json +100 -27
- package/src/ClockCalculator.test.ts +0 -61
- package/src/ClockCalculator.ts +0 -81
- package/src/CreatorFunctions.ts +0 -12
- package/src/DerivedData.ts +0 -305
- package/src/PinsLogic.ts +0 -297
- package/src/StringConstants.ts +0 -13
- package/src/moduleConfig.json +0 -580
- package/src/pinsdata.json +0 -90
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mchp-mcc/scf-pic8-osc-v1",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.3",
|
|
4
4
|
"scf": {
|
|
5
5
|
"reducer": "auto",
|
|
6
6
|
"creator": "output/creator.js",
|
|
@@ -10,7 +10,74 @@
|
|
|
10
10
|
},
|
|
11
11
|
"displayName": "Clock Control",
|
|
12
12
|
"category": "System",
|
|
13
|
-
"nullPrototype": "output/nullPrototype.json"
|
|
13
|
+
"nullPrototype": "output/nullPrototype.json",
|
|
14
|
+
"autoProcessor": "output/autoProcessor.js",
|
|
15
|
+
"autoCreator": "output/autoCreator.js",
|
|
16
|
+
"prototype": {
|
|
17
|
+
"payload": null,
|
|
18
|
+
"imports": {
|
|
19
|
+
"scf_pic8_osc_v1": {
|
|
20
|
+
"interfaceId": {
|
|
21
|
+
"name": "scf-pic8-osc-v1",
|
|
22
|
+
"version": "1.0.0"
|
|
23
|
+
},
|
|
24
|
+
"isRequired": true
|
|
25
|
+
},
|
|
26
|
+
"initializer_system": {
|
|
27
|
+
"interfaceId": {
|
|
28
|
+
"name": "initializer-system",
|
|
29
|
+
"version": "^0.5.3"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"config_device": {
|
|
33
|
+
"interfaceId": {
|
|
34
|
+
"name": "config-device",
|
|
35
|
+
"version": "^1.1.1"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"config_request": {
|
|
39
|
+
"interfaceId": {
|
|
40
|
+
"name": "config-request",
|
|
41
|
+
"version": "^2.0.1"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"pin_standard": {
|
|
45
|
+
"interfaceId": {
|
|
46
|
+
"name": "pin-standard",
|
|
47
|
+
"version": "^0.1.0"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"device_meta": {
|
|
51
|
+
"interfaceId": {
|
|
52
|
+
"name": "device-meta",
|
|
53
|
+
"version": "1.0.0"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"exports": {
|
|
58
|
+
"osc_clocks": {
|
|
59
|
+
"interfaces": [
|
|
60
|
+
{
|
|
61
|
+
"interfaceId": {
|
|
62
|
+
"name": "osc-clocks",
|
|
63
|
+
"version": "0.2.0"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
},
|
|
68
|
+
"fosc": {
|
|
69
|
+
"interfaces": [
|
|
70
|
+
{
|
|
71
|
+
"interfaceId": {
|
|
72
|
+
"name": "fosc-hz",
|
|
73
|
+
"version": "0.3.0"
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
"isEntryPoint": true
|
|
80
|
+
}
|
|
14
81
|
},
|
|
15
82
|
"scf-automodule": {
|
|
16
83
|
"peripheral": {
|
|
@@ -23,11 +90,12 @@
|
|
|
23
90
|
},
|
|
24
91
|
"mode": "standard",
|
|
25
92
|
"hookPaths": {
|
|
26
|
-
"processor": "generated_module/src/processor.
|
|
27
|
-
"creator": "generated_module/src/creator.
|
|
93
|
+
"processor": "generated_module/src/processor.ts",
|
|
94
|
+
"creator": "generated_module/src/creator.ts"
|
|
28
95
|
},
|
|
29
96
|
"shouldNotifyOnDeploy": false
|
|
30
97
|
},
|
|
98
|
+
"jenkinsPipeline": "MCU8_DS_PIPELINE_2XY",
|
|
31
99
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
32
100
|
"scripts": {
|
|
33
101
|
"build": "gulp build --gulpfile config/gulpfile.js --cwd .",
|
|
@@ -47,8 +115,9 @@
|
|
|
47
115
|
"build-run-dir-future": "node config/extract-run-directory-future.js",
|
|
48
116
|
"profile": "jest profile",
|
|
49
117
|
"release": "yarn build && yarn test && node -e 'require(\"./config/scf-project-scripts\").releaseProject()'",
|
|
50
|
-
"test:itf:all": "node ./node_modules/@
|
|
51
|
-
"test:itf:dev": "node ./node_modules/@
|
|
118
|
+
"test:itf:all": "node ./node_modules/@microchip/ccl-itf/lib/index.js --sp=tests/itf --rd=run --df=\"PIC18F57Q43|PIC16F18877|PIC16LF18875|PIC18F16Q40|PIC18F16Q41|PIC18F47Q10\"",
|
|
119
|
+
"test:itf:dev": "node ./node_modules/@microchip/ccl-itf/lib/index.js --sp=tests/itf --rd=run --sf=osc.major.test.ts --df=\"PIC18F57Q43\"",
|
|
120
|
+
"postprocess": "node config/appendPrototype.js"
|
|
52
121
|
},
|
|
53
122
|
"husky": {
|
|
54
123
|
"hooks": {
|
|
@@ -62,16 +131,12 @@
|
|
|
62
131
|
},
|
|
63
132
|
"files": [
|
|
64
133
|
"output/**/*",
|
|
65
|
-
"config.json"
|
|
66
|
-
"src/**/*"
|
|
134
|
+
"config.json"
|
|
67
135
|
],
|
|
68
136
|
"repository": {
|
|
69
137
|
"type": "git",
|
|
70
138
|
"url": "git+ssh://git@https://bitbucket.microchip.com/scm/cc8scrip/scf-pic8-osc-v1.git"
|
|
71
139
|
},
|
|
72
|
-
"publishConfig": {
|
|
73
|
-
"registry": "https://artifacts.microchip.com/artifactory/api/npm/npm/"
|
|
74
|
-
},
|
|
75
140
|
"jest": {
|
|
76
141
|
"testPathIgnorePatterns": [
|
|
77
142
|
"/node_modules/",
|
|
@@ -84,19 +149,27 @@
|
|
|
84
149
|
"<rootDir>/run"
|
|
85
150
|
],
|
|
86
151
|
"preset": "ts-jest",
|
|
87
|
-
"collectCoverage": true
|
|
152
|
+
"collectCoverage": true,
|
|
153
|
+
"coverageThreshold": {
|
|
154
|
+
"./src": {
|
|
155
|
+
"branches": 80,
|
|
156
|
+
"functions": 80,
|
|
157
|
+
"lines": 80,
|
|
158
|
+
"statements": 80
|
|
159
|
+
}
|
|
160
|
+
}
|
|
88
161
|
},
|
|
89
162
|
"dependencies": {
|
|
90
163
|
"@microchip/api-prefix-registration": "^0.1.0",
|
|
91
164
|
"@microchip/basic_pin": "^1.0.2",
|
|
92
165
|
"@microchip/config-request": "^2.0.2",
|
|
93
166
|
"@microchip/fosc-hz": "^0.3.0",
|
|
94
|
-
"@microchip/scf-
|
|
95
|
-
"@microchip/scf-
|
|
96
|
-
"@microchip/scf-device": "^8.2.0",
|
|
167
|
+
"@microchip/scf-common": "^3.17.0",
|
|
168
|
+
"@microchip/scf-device": "^8.5.0",
|
|
97
169
|
"@microchip/scf-integration-test": "^1.0.0",
|
|
98
170
|
"@microchip/scf-interface": "^1.4.0",
|
|
99
|
-
"@microchip/scf-register-view-helper": "^2.
|
|
171
|
+
"@microchip/scf-register-view-helper": "^2.5.0",
|
|
172
|
+
"babel-jest": "^27.0.6"
|
|
100
173
|
},
|
|
101
174
|
"devDependencies": {
|
|
102
175
|
"@babel/core": "^7.9.6",
|
|
@@ -105,19 +178,19 @@
|
|
|
105
178
|
"@babel/preset-react": "^7.9.4",
|
|
106
179
|
"@babel/preset-typescript": "^7.9.0",
|
|
107
180
|
"@mchp-mcc/avr-8bit": "^4.2.6",
|
|
108
|
-
"@mchp-mcc/
|
|
109
|
-
"@mchp-mcc/pic-8bit": "^5.
|
|
110
|
-
"@
|
|
181
|
+
"@mchp-mcc/pic-8bit": "^5.13.0-dev.2",
|
|
182
|
+
"@mchp-mcc/pic-8bit-types": "^5.13.0-dev.2",
|
|
183
|
+
"@microchip/ccl-itf": "^1.5.0",
|
|
111
184
|
"@microchip/config-device": "^1.1.1",
|
|
112
185
|
"@microchip/initializer-system": "^0.5.4",
|
|
113
186
|
"@microchip/interrupt-vectored": "^1.2.0",
|
|
187
|
+
"@microchip/melody-automodule-interface": "^1.6.2",
|
|
114
188
|
"@microchip/osc-clocks": "^0.2.0",
|
|
115
|
-
"@microchip/
|
|
116
|
-
"@microchip/
|
|
117
|
-
"@microchip/
|
|
118
|
-
"@microchip/
|
|
119
|
-
"@microchip/scf-
|
|
120
|
-
"@microchip/scf-autoview": "^3.17.0",
|
|
189
|
+
"@microchip/pin-standard": "^0.4.1",
|
|
190
|
+
"@microchip/run-directory": "^4.2.3",
|
|
191
|
+
"@microchip/scf-automodule": "^5.6.2",
|
|
192
|
+
"@microchip/scf-automodule-impl": "^1.8.2",
|
|
193
|
+
"@microchip/scf-autoview": "^3.26.1",
|
|
121
194
|
"@microchip/scf-project-scripts": "^1.0.0",
|
|
122
195
|
"@microchip/scf-server": "^1.5.10",
|
|
123
196
|
"@types/core-js": "^2.5.1",
|
|
@@ -149,13 +222,13 @@
|
|
|
149
222
|
"hard-source-webpack-plugin": "^0.13.1",
|
|
150
223
|
"husky": "^4.2.4",
|
|
151
224
|
"is-wsl": "^2.1.0",
|
|
152
|
-
"jest": "^
|
|
225
|
+
"jest": "^27.0.6",
|
|
153
226
|
"jest-html-reporter": "^2.5.0",
|
|
154
227
|
"jest-pnp-resolver": "^1.2.1",
|
|
155
228
|
"lint-staged": "^10.1.3",
|
|
156
229
|
"pnp-webpack-plugin": "^1.5.0",
|
|
157
230
|
"prettier": "^2.0.5",
|
|
158
|
-
"ts-jest": "^
|
|
231
|
+
"ts-jest": "^27.0.3",
|
|
159
232
|
"ts-pnp": "^1.1.2",
|
|
160
233
|
"typescript": "^4.0.5",
|
|
161
234
|
"webpack": "^4.34.0",
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { ClockCalculator } from "./ClockCalculator";
|
|
2
|
-
|
|
3
|
-
describe("Osc Calculations", () => {
|
|
4
|
-
// jest cases for system oscillator calculations
|
|
5
|
-
it("Test case 1: oscSelect = SOSC, HFInternalClk = 4_MHz, externalClk = 1000000Hz, clkDevider = 1", () => {
|
|
6
|
-
expect(
|
|
7
|
-
new ClockCalculator("SOSC", "4_MHz", 1000000, 1).getCurrentSystemClk(),
|
|
8
|
-
).toBe(32768);
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
it("Test case 2: oscSelect = LFINTOSC, HFInternalClk = 4_MHz, externalClk = 1000000Hz, clkDevider = 1", () => {
|
|
12
|
-
expect(
|
|
13
|
-
new ClockCalculator("LFINTOSC", "4_MHz", 1000000, 1).getCurrentSystemClk(),
|
|
14
|
-
).toBe(31000);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it("Test case 3: oscSelect = HFINTOSC, HFInternalClk = 4_MHz, externalClk = 1000000Hz, clkDevider = 1", () => {
|
|
18
|
-
expect(
|
|
19
|
-
new ClockCalculator("HFINTOSC", "4_MHz", 1000000, 1).getCurrentSystemClk(),
|
|
20
|
-
).toBe(4000000);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it("Test case 4: oscSelect = EXTOSC, HFInternalClk = 4_MHz, externalClk = 1000000Hz, clkDevider = 1", () => {
|
|
24
|
-
expect(
|
|
25
|
-
new ClockCalculator("EXTOSC", "4_MHz", 1000000, 1).getCurrentSystemClk(),
|
|
26
|
-
).toBe(1000000);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it("Test case 5: oscSelect = EXTOSC with 4x PLL, HFInternalClk = 4_MHz, externalClk = 1000000Hz, clkDevider = 1", () => {
|
|
30
|
-
expect(
|
|
31
|
-
new ClockCalculator(
|
|
32
|
-
"EXTOSC with 4x PLL",
|
|
33
|
-
"4_MHz",
|
|
34
|
-
1000000,
|
|
35
|
-
1,
|
|
36
|
-
).getCurrentSystemClk(),
|
|
37
|
-
).toBe(1000000);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it("Test case 6: oscSelect = EXTOSC with 4x PLL, HFInternalClk = 4_MHz, externalClk = 5000000Hz, clkDevider = 1", () => {
|
|
41
|
-
expect(
|
|
42
|
-
new ClockCalculator(
|
|
43
|
-
"EXTOSC with 4x PLL",
|
|
44
|
-
"4_MHz",
|
|
45
|
-
5000000,
|
|
46
|
-
1,
|
|
47
|
-
).getCurrentSystemClk(),
|
|
48
|
-
).toBe(20000000);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it("Test case 7: oscSelect = EXTOSC with 4x PLL, HFInternalClk = 4_MHz, externalClk = 17000000Hz, clkDevider = 1", () => {
|
|
52
|
-
expect(
|
|
53
|
-
new ClockCalculator(
|
|
54
|
-
"EXTOSC with 4x PLL",
|
|
55
|
-
"4_MHz",
|
|
56
|
-
17000000,
|
|
57
|
-
1,
|
|
58
|
-
).getCurrentSystemClk(),
|
|
59
|
-
).toBe(17000000);
|
|
60
|
-
});
|
|
61
|
-
});
|
package/src/ClockCalculator.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { StringConstants } from "./StringConstants";
|
|
2
|
-
|
|
3
|
-
export class ClockCalculator {
|
|
4
|
-
private lfintosc = "31000";
|
|
5
|
-
private mfintosc = "500000";
|
|
6
|
-
private mfintosc_31KHz = "31250";
|
|
7
|
-
private sosc = "32768";
|
|
8
|
-
private oscSelect: string;
|
|
9
|
-
private HFInternalClk: string;
|
|
10
|
-
private externalClk: number;
|
|
11
|
-
private clkDivider: number;
|
|
12
|
-
|
|
13
|
-
MAX_PLL = 16000000; // in Hz
|
|
14
|
-
MIN_PLL = 3000000; // in Hz
|
|
15
|
-
|
|
16
|
-
public constructor(
|
|
17
|
-
oscSelect: string,
|
|
18
|
-
HFInternalClk: string,
|
|
19
|
-
externalClk: number,
|
|
20
|
-
clkDivider: number,
|
|
21
|
-
) {
|
|
22
|
-
this.oscSelect = oscSelect;
|
|
23
|
-
this.HFInternalClk = HFInternalClk;
|
|
24
|
-
this.externalClk = externalClk;
|
|
25
|
-
this.clkDivider = clkDivider;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
public getCurrentSystemClk = (): number => {
|
|
29
|
-
let currentSystemClk: number;
|
|
30
|
-
let HFClk: number;
|
|
31
|
-
|
|
32
|
-
if (this.oscSelect === StringConstants.SOSC) {
|
|
33
|
-
currentSystemClk = 32768 / this.clkDivider;
|
|
34
|
-
} else if (this.oscSelect === StringConstants.LFINTOSC) {
|
|
35
|
-
currentSystemClk = 31000 / this.clkDivider;
|
|
36
|
-
} else if (this.oscSelect === StringConstants.HFINTOSC) {
|
|
37
|
-
HFClk = parseInt(this.HFInternalClk?.replace("_MHz", "") ?? "1000000");
|
|
38
|
-
currentSystemClk = (HFClk * 1000000) / this.clkDivider;
|
|
39
|
-
} else if (this.oscSelect === StringConstants.HFINTOSC_2xPLL) {
|
|
40
|
-
HFClk = parseInt(this.HFInternalClk?.replace("_MHz", "") ?? "1000000");
|
|
41
|
-
if (HFClk == 8 || HFClk == 12 || HFClk == 16) {
|
|
42
|
-
currentSystemClk = (HFClk * 2 * 1000000) / this.clkDivider;
|
|
43
|
-
} else {
|
|
44
|
-
currentSystemClk = (HFClk * 1000000) / this.clkDivider;
|
|
45
|
-
}
|
|
46
|
-
} else if (this.oscSelect === StringConstants.EXTOSC) {
|
|
47
|
-
currentSystemClk = this.externalClk / this.clkDivider;
|
|
48
|
-
} else {
|
|
49
|
-
if (this.externalClk <= this.MIN_PLL || this.externalClk > this.MAX_PLL) {
|
|
50
|
-
currentSystemClk = this.externalClk / this.clkDivider;
|
|
51
|
-
} else {
|
|
52
|
-
currentSystemClk = (this.externalClk * 4) / this.clkDivider;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return Math.round(currentSystemClk);
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
public getHfIntOsc = (): string => {
|
|
59
|
-
return this.HFInternalClk?.replace("_MHz", "000000") ?? "1000000";
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
public getMfIntOsc = (): string => {
|
|
63
|
-
return this.mfintosc;
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
public getMfIntOsc_31KHz = (): string => {
|
|
67
|
-
return this.mfintosc_31KHz;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
public getLfIntOsc = (): string => {
|
|
71
|
-
return this.lfintosc;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
public getExtOsc = (): string => {
|
|
75
|
-
return this.externalClk.toString();
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
public getSosc = (): string => {
|
|
79
|
-
return this.sosc;
|
|
80
|
-
};
|
|
81
|
-
}
|
package/src/CreatorFunctions.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { CreatorFunctions } from "@microchip/scf-automodule-interface";
|
|
2
|
-
import { MyState } from "../generated_module/src/types/AutoModuleTypes";
|
|
3
|
-
|
|
4
|
-
export const getCreatorFunctions = (): CreatorFunctions => {
|
|
5
|
-
return {
|
|
6
|
-
shouldImport: shouldImport,
|
|
7
|
-
};
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
const shouldImport = (importKey: string, state: MyState): boolean => {
|
|
11
|
-
return true;
|
|
12
|
-
};
|
package/src/DerivedData.ts
DELETED
|
@@ -1,305 +0,0 @@
|
|
|
1
|
-
import * as Processor from "@microchip/scf-common/lib/Processor";
|
|
2
|
-
import { ClockCalculator } from "./ClockCalculator";
|
|
3
|
-
import * as initializer_system from "@microchip/initializer-system";
|
|
4
|
-
import * as config_device from "@microchip/config-device";
|
|
5
|
-
import { StringConstants } from "./StringConstants";
|
|
6
|
-
import osc_clocks from "@microchip/osc-clocks";
|
|
7
|
-
import * as config_request from "@microchip/config-request";
|
|
8
|
-
import {
|
|
9
|
-
AppModel,
|
|
10
|
-
DerivedData,
|
|
11
|
-
DerivedFunctions,
|
|
12
|
-
} from "../generated_module/src/types/AutoModuleTypes";
|
|
13
|
-
import * as InterfaceTypes from "@microchip/scf-interface";
|
|
14
|
-
|
|
15
|
-
export const getDerivedData = (dataModel: AppModel): DerivedData => {
|
|
16
|
-
if (dataModel) {
|
|
17
|
-
return new MyDerivedData(dataModel);
|
|
18
|
-
}
|
|
19
|
-
return new EmptyDerivedData();
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
//This data will be used at the creator stage and relies on only the state
|
|
23
|
-
class EmptyDerivedData implements DerivedData {
|
|
24
|
-
getMyFunctions = (): DerivedFunctions => {
|
|
25
|
-
return {};
|
|
26
|
-
};
|
|
27
|
-
getModel = (): AppModel | undefined => {
|
|
28
|
-
return undefined;
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
//This data will be used at the processor stage
|
|
33
|
-
class MyDerivedData implements DerivedData {
|
|
34
|
-
private dataModel: AppModel;
|
|
35
|
-
private clockCalculator: ClockCalculator;
|
|
36
|
-
|
|
37
|
-
constructor(dataModel: AppModel) {
|
|
38
|
-
this.dataModel = dataModel;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
getClockCalculator = (): ClockCalculator => {
|
|
42
|
-
if (!this.clockCalculator) {
|
|
43
|
-
this.clockCalculator = new ClockCalculator(
|
|
44
|
-
this.getModel().getComponentValue("noscOsccon1") ?? "",
|
|
45
|
-
this.getModel().getComponentValue("hffrqOscfrq") ?? "",
|
|
46
|
-
this.getModel().getComponentValue("externalClk") ?? 32768,
|
|
47
|
-
parseInt(this.getModel().getComponentValue("ndivOsccon1") ?? ""),
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
return this.clockCalculator;
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
getMyFunctions = (): DerivedFunctions => {
|
|
54
|
-
return {
|
|
55
|
-
moduleName: this.getModuleName,
|
|
56
|
-
alerts: this.getMyAlerts,
|
|
57
|
-
isEnabled: this.isEnabled,
|
|
58
|
-
isVisible: this.isVisible,
|
|
59
|
-
currentSystemClk: (): number =>
|
|
60
|
-
this.getClockCalculator()?.getCurrentSystemClk(),
|
|
61
|
-
"fosc-hz_payload": (): string =>
|
|
62
|
-
this.getClockCalculator()?.getCurrentSystemClk()?.toString() ?? "1000000",
|
|
63
|
-
initializer_system_results: this.initializer_system_results,
|
|
64
|
-
config_device_results: this.config_device_results,
|
|
65
|
-
templateData: this.getTemplateData,
|
|
66
|
-
config_request_args: (): config_request.Arguments => [
|
|
67
|
-
"FEXTOSC",
|
|
68
|
-
"CLKOUTEN",
|
|
69
|
-
"MCLRE",
|
|
70
|
-
"LVP",
|
|
71
|
-
],
|
|
72
|
-
"osc-clocks_payload": this.getOscClocksProcessedPayload,
|
|
73
|
-
};
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
private getOscClocksProcessedPayload = (): osc_clocks.ProcessedPayload => {
|
|
77
|
-
const oscObj: osc_clocks.ProcessedPayload = {
|
|
78
|
-
extosc: this.getClockCalculator().getExtOsc() ?? "32768",
|
|
79
|
-
fosc: this.getClockCalculator().getCurrentSystemClk().toString() ?? "1000000",
|
|
80
|
-
hfintosc: this.getClockCalculator().getHfIntOsc() ?? "1000000",
|
|
81
|
-
lfintosc: this.getClockCalculator().getLfIntOsc() ?? "31000",
|
|
82
|
-
mfintosc: this.getClockCalculator().getMfIntOsc() ?? "500000",
|
|
83
|
-
mfintosc_31Khz: this.getClockCalculator().getMfIntOsc_31KHz() ?? "31250",
|
|
84
|
-
sosc: this.getClockCalculator().getSosc() ?? "32768",
|
|
85
|
-
};
|
|
86
|
-
const hasSosc: boolean =
|
|
87
|
-
this.dataModel.isComponentValue("soscenOscen") !== undefined ? true : false;
|
|
88
|
-
if (hasSosc) {
|
|
89
|
-
oscObj.hasSosc = true;
|
|
90
|
-
oscObj.soscEnabled = this.dataModel.isComponentValue("soscenOscen");
|
|
91
|
-
oscObj.soscPowerMode = this.dataModel.getComponentValue("soscpwrOsccon3");
|
|
92
|
-
}
|
|
93
|
-
return oscObj;
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
public getModuleName = (): string => {
|
|
97
|
-
return "Clock Control";
|
|
98
|
-
};
|
|
99
|
-
public getModel = (): AppModel => {
|
|
100
|
-
return this.dataModel;
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
private getTemplateData = (): any => {
|
|
104
|
-
const headers: InterfaceTypes.HeaderFile = {
|
|
105
|
-
name: "clock.h",
|
|
106
|
-
path: "../",
|
|
107
|
-
};
|
|
108
|
-
const initRegisters = this.dataModel.getRegisterValues();
|
|
109
|
-
return {
|
|
110
|
-
productName: "CCL",
|
|
111
|
-
productVersion: "1.8.2",
|
|
112
|
-
compiler: "XC8 v2.20",
|
|
113
|
-
tool: "MPLAB X 5.40",
|
|
114
|
-
|
|
115
|
-
deviceFrequency:
|
|
116
|
-
this.getClockCalculator()?.getCurrentSystemClk()?.toString() ?? "1000000",
|
|
117
|
-
|
|
118
|
-
initRegisters: initRegisters,
|
|
119
|
-
header: headers,
|
|
120
|
-
|
|
121
|
-
moduleNameUpperCase: this.getModuleName()?.toUpperCase() ?? "",
|
|
122
|
-
moduleNameLowerCase: this.getModuleName()?.toLowerCase() ?? "",
|
|
123
|
-
};
|
|
124
|
-
};
|
|
125
|
-
private initializer_system_results = (): initializer_system.Results => {
|
|
126
|
-
return {
|
|
127
|
-
initializer: {
|
|
128
|
-
name: "CLOCK_Initialize",
|
|
129
|
-
header: {
|
|
130
|
-
name: "clock.h",
|
|
131
|
-
path: "system/",
|
|
132
|
-
},
|
|
133
|
-
priority: initializer_system.INIT_PRIORITY.START,
|
|
134
|
-
},
|
|
135
|
-
};
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
private config_device_results = (): config_device.Results => {
|
|
139
|
-
return {
|
|
140
|
-
headers: [
|
|
141
|
-
{
|
|
142
|
-
name: "clock.h",
|
|
143
|
-
path: "system/",
|
|
144
|
-
},
|
|
145
|
-
],
|
|
146
|
-
};
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
private isEnabled = (componentName: string): boolean => {
|
|
150
|
-
switch (componentName) {
|
|
151
|
-
case "hffrqOscfrq":
|
|
152
|
-
return (
|
|
153
|
-
this.dataModel.getComponentValue("noscOsccon1")?.indexOf("HF") != -1
|
|
154
|
-
);
|
|
155
|
-
case "currentSystemClk":
|
|
156
|
-
return false;
|
|
157
|
-
case "lfIntOscFreq":
|
|
158
|
-
return false;
|
|
159
|
-
default:
|
|
160
|
-
return true;
|
|
161
|
-
}
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
private isVisible = (componentName: string): boolean => {
|
|
165
|
-
const componentValue = this.dataModel.getComponentValue("noscOsccon1");
|
|
166
|
-
switch (componentName) {
|
|
167
|
-
case "externalClk":
|
|
168
|
-
if (
|
|
169
|
-
componentValue === StringConstants.EXTOSC ||
|
|
170
|
-
componentValue === StringConstants.EXTOSC_4xPLL
|
|
171
|
-
) {
|
|
172
|
-
return true;
|
|
173
|
-
} else {
|
|
174
|
-
return false;
|
|
175
|
-
}
|
|
176
|
-
case "lfIntOscFreq":
|
|
177
|
-
if (componentValue != StringConstants.LFINTOSC) {
|
|
178
|
-
return false;
|
|
179
|
-
} else {
|
|
180
|
-
return true;
|
|
181
|
-
}
|
|
182
|
-
case "hffrqOscfrq":
|
|
183
|
-
if (
|
|
184
|
-
componentValue != StringConstants.HFINTOSC &&
|
|
185
|
-
componentValue != StringConstants.HFINTOSC_2xPLL
|
|
186
|
-
) {
|
|
187
|
-
return false;
|
|
188
|
-
} else {
|
|
189
|
-
return true;
|
|
190
|
-
}
|
|
191
|
-
default:
|
|
192
|
-
return true;
|
|
193
|
-
}
|
|
194
|
-
};
|
|
195
|
-
|
|
196
|
-
private getDynamicComponetDefaultValue = (
|
|
197
|
-
componentName: string,
|
|
198
|
-
): string | undefined => {
|
|
199
|
-
const externalClkSelectedOptions = this.dataModel.getImportValue(
|
|
200
|
-
"config_request",
|
|
201
|
-
)?.[componentName];
|
|
202
|
-
let selectedOptionVal: string | undefined;
|
|
203
|
-
if (externalClkSelectedOptions) {
|
|
204
|
-
selectedOptionVal = externalClkSelectedOptions["defaultValue"]?.["value"];
|
|
205
|
-
}
|
|
206
|
-
return selectedOptionVal ?? undefined;
|
|
207
|
-
};
|
|
208
|
-
|
|
209
|
-
private getMyAlerts = (): Processor.Alert[] => {
|
|
210
|
-
const alerts: Processor.Alert[] = [];
|
|
211
|
-
const selectedOptionVal: string =
|
|
212
|
-
this.getDynamicComponetDefaultValue("FEXTOSC") ?? "";
|
|
213
|
-
const noscOsccon1 = this.dataModel.getComponentValue("noscOsccon1");
|
|
214
|
-
|
|
215
|
-
if (
|
|
216
|
-
noscOsccon1 === StringConstants.EXTOSC_4xPLL ||
|
|
217
|
-
noscOsccon1 === StringConstants.EXTOSC
|
|
218
|
-
) {
|
|
219
|
-
alerts.push({
|
|
220
|
-
type: Processor.AlertTypes.Hint,
|
|
221
|
-
text:
|
|
222
|
-
'Please configure required "External Oscillator Selection" in System Module config bits',
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
if (
|
|
227
|
-
noscOsccon1 === StringConstants.EXTOSC_4xPLL &&
|
|
228
|
-
((this.getModel().getComponentValue("externalClk") ?? 0) <=
|
|
229
|
-
this.getClockCalculator().MIN_PLL ||
|
|
230
|
-
(this.getModel().getComponentValue("externalClk") ?? 0) >
|
|
231
|
-
this.getClockCalculator().MAX_PLL)
|
|
232
|
-
) {
|
|
233
|
-
alerts.push({
|
|
234
|
-
type: Processor.AlertTypes.Warning,
|
|
235
|
-
text:
|
|
236
|
-
"The frequency selected does not fall within the PLL locking range. Therefore, the actual frequency produced by hardware maybe unpredictable when the PLL is enabled. Either change the clock frequency or select a different option in Oscillator select.",
|
|
237
|
-
});
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
if (
|
|
241
|
-
noscOsccon1 === StringConstants.EXTOSC_4xPLL ||
|
|
242
|
-
noscOsccon1 === StringConstants.EXTOSC
|
|
243
|
-
) {
|
|
244
|
-
if (
|
|
245
|
-
selectedOptionVal?.indexOf("external clock") != -1 &&
|
|
246
|
-
this.getClockCalculator().getCurrentSystemClk() >
|
|
247
|
-
StringConstants.ExtClkFreq_64MHz
|
|
248
|
-
) {
|
|
249
|
-
alerts.push({
|
|
250
|
-
type: Processor.AlertTypes.Warning,
|
|
251
|
-
text:
|
|
252
|
-
"External clock frequency is greater than recommended value (" +
|
|
253
|
-
StringConstants.ExtClkFreq_64MHz +
|
|
254
|
-
" Hz)",
|
|
255
|
-
});
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
if (
|
|
259
|
-
selectedOptionVal?.indexOf("crystal oscillator") != -1 &&
|
|
260
|
-
(this.getModel().getComponentValue("externalClk") ?? 0) > 16000000 &&
|
|
261
|
-
this.getClockCalculator().getCurrentSystemClk() >
|
|
262
|
-
StringConstants.ExtClkFreq_20MHz
|
|
263
|
-
) {
|
|
264
|
-
alerts.push({
|
|
265
|
-
type: Processor.AlertTypes.Warning,
|
|
266
|
-
text:
|
|
267
|
-
"External clock frequency is greater than recommended value (" +
|
|
268
|
-
StringConstants.ExtClkFreq_20MHz +
|
|
269
|
-
" Hz)",
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
if (
|
|
274
|
-
selectedOptionVal.indexOf("Oscillator not enabled") != -1 &&
|
|
275
|
-
this.getClockCalculator().getCurrentSystemClk() >
|
|
276
|
-
StringConstants.ExtClkFreq_32MHz
|
|
277
|
-
) {
|
|
278
|
-
alerts.push({
|
|
279
|
-
type: Processor.AlertTypes.Warning,
|
|
280
|
-
text:
|
|
281
|
-
"External clock frequency is greater than recommended value (" +
|
|
282
|
-
StringConstants.ExtClkFreq_32MHz +
|
|
283
|
-
" Hz)",
|
|
284
|
-
});
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
const HFClk = parseInt(
|
|
289
|
-
this.dataModel.getComponentValue("hffrqOscfrq")?.replace("_MHz", "") ?? "0",
|
|
290
|
-
);
|
|
291
|
-
if (
|
|
292
|
-
this.dataModel.getComponentValue("noscOsccon1") ===
|
|
293
|
-
StringConstants.HFINTOSC_2xPLL &&
|
|
294
|
-
(HFClk == 1 || HFClk == 2 || HFClk == 4 || HFClk == 32)
|
|
295
|
-
) {
|
|
296
|
-
alerts.push({
|
|
297
|
-
type: Processor.AlertTypes.Warning,
|
|
298
|
-
text:
|
|
299
|
-
"The frequency set in HF Internal Clock may not get generated by the clock hardware properly since it does not fall within the 2xPLL range of 8-16 MHz. Therefore, it is recommended that the option 'HFINTOSC' be selected in the Oscillator select combo box.",
|
|
300
|
-
});
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
return alerts;
|
|
304
|
-
};
|
|
305
|
-
}
|