@mchp-mcc/scf-pic8-osc-v1 4.3.2 → 4.3.4
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 +18 -0
- package/Readme.md +18 -0
- package/lib/generated_module/src/index.js +0 -5
- package/output/autoCreator.js +1657 -0
- package/output/autoCreator.js.map +1 -0
- package/output/autoProcessor.js +1659 -0
- package/output/autoProcessor.js.map +1 -0
- package/output/clock.c.ftl +38 -7
- package/output/clock.h.ftl +5 -5
- package/output/creator.js +6283 -1566
- package/output/creator.js.map +1 -1
- package/output/processor.js +5394 -5863
- package/output/processor.js.map +1 -1
- package/package.json +88 -22
- package/src/ClockCalculator.test.ts +0 -117
- package/src/ClockCalculator.ts +0 -81
- package/src/CreatorFunctions.ts +0 -12
- package/src/DerivedData.test.tsx +0 -927
- package/src/DerivedData.ts +0 -304
- package/src/PinsLogic.test.ts +0 -917
- 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/src/DerivedData.ts
DELETED
|
@@ -1,304 +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 | undefined): 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
|
-
export 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
|
-
export 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(),
|
|
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: this.getClockCalculator().getCurrentSystemClk().toString(),
|
|
116
|
-
|
|
117
|
-
initRegisters: initRegisters,
|
|
118
|
-
header: headers,
|
|
119
|
-
|
|
120
|
-
moduleNameUpperCase: this.getModuleName().toUpperCase(),
|
|
121
|
-
moduleNameLowerCase: this.getModuleName().toLowerCase(),
|
|
122
|
-
};
|
|
123
|
-
};
|
|
124
|
-
private initializer_system_results = (): initializer_system.Results => {
|
|
125
|
-
return {
|
|
126
|
-
initializer: {
|
|
127
|
-
name: "CLOCK_Initialize",
|
|
128
|
-
header: {
|
|
129
|
-
name: "clock.h",
|
|
130
|
-
path: "system/",
|
|
131
|
-
},
|
|
132
|
-
priority: initializer_system.INIT_PRIORITY.START,
|
|
133
|
-
},
|
|
134
|
-
};
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
private config_device_results = (): config_device.Results => {
|
|
138
|
-
return {
|
|
139
|
-
headers: [
|
|
140
|
-
{
|
|
141
|
-
name: "clock.h",
|
|
142
|
-
path: "system/",
|
|
143
|
-
},
|
|
144
|
-
],
|
|
145
|
-
};
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
private isEnabled = (componentName: string): boolean => {
|
|
149
|
-
switch (componentName) {
|
|
150
|
-
case "hffrqOscfrq":
|
|
151
|
-
return (
|
|
152
|
-
this.dataModel.getComponentValue("noscOsccon1")?.indexOf("HF") != -1
|
|
153
|
-
);
|
|
154
|
-
case "currentSystemClk":
|
|
155
|
-
return false;
|
|
156
|
-
case "lfIntOscFreq":
|
|
157
|
-
return false;
|
|
158
|
-
default:
|
|
159
|
-
return true;
|
|
160
|
-
}
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
private isVisible = (componentName: string): boolean => {
|
|
164
|
-
const componentValue = this.dataModel.getComponentValue("noscOsccon1");
|
|
165
|
-
switch (componentName) {
|
|
166
|
-
case "externalClk":
|
|
167
|
-
if (
|
|
168
|
-
componentValue === StringConstants.EXTOSC ||
|
|
169
|
-
componentValue === StringConstants.EXTOSC_4xPLL
|
|
170
|
-
) {
|
|
171
|
-
return true;
|
|
172
|
-
} else {
|
|
173
|
-
return false;
|
|
174
|
-
}
|
|
175
|
-
case "lfIntOscFreq":
|
|
176
|
-
if (componentValue != StringConstants.LFINTOSC) {
|
|
177
|
-
return false;
|
|
178
|
-
} else {
|
|
179
|
-
return true;
|
|
180
|
-
}
|
|
181
|
-
case "hffrqOscfrq":
|
|
182
|
-
if (
|
|
183
|
-
componentValue != StringConstants.HFINTOSC &&
|
|
184
|
-
componentValue != StringConstants.HFINTOSC_2xPLL
|
|
185
|
-
) {
|
|
186
|
-
return false;
|
|
187
|
-
} else {
|
|
188
|
-
return true;
|
|
189
|
-
}
|
|
190
|
-
default:
|
|
191
|
-
return true;
|
|
192
|
-
}
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
private getDynamicComponetDefaultValue = (
|
|
196
|
-
componentName: string,
|
|
197
|
-
): string | undefined => {
|
|
198
|
-
const externalClkSelectedOptions = this.dataModel.getImportValue(
|
|
199
|
-
"config_request",
|
|
200
|
-
)?.[componentName];
|
|
201
|
-
let selectedOptionVal: string | undefined;
|
|
202
|
-
if (externalClkSelectedOptions) {
|
|
203
|
-
selectedOptionVal = externalClkSelectedOptions["defaultValue"]["value"];
|
|
204
|
-
}
|
|
205
|
-
return selectedOptionVal ?? undefined;
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
private getMyAlerts = (): Processor.Alert[] => {
|
|
209
|
-
const alerts: Processor.Alert[] = [];
|
|
210
|
-
const selectedOptionVal: string =
|
|
211
|
-
this.getDynamicComponetDefaultValue("FEXTOSC") ?? "";
|
|
212
|
-
const noscOsccon1 = this.dataModel.getComponentValue("noscOsccon1");
|
|
213
|
-
|
|
214
|
-
if (
|
|
215
|
-
noscOsccon1 === StringConstants.EXTOSC_4xPLL ||
|
|
216
|
-
noscOsccon1 === StringConstants.EXTOSC
|
|
217
|
-
) {
|
|
218
|
-
alerts.push({
|
|
219
|
-
type: Processor.AlertTypes.Hint,
|
|
220
|
-
text:
|
|
221
|
-
'Please configure required "External Oscillator Selection" in System Module config bits',
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
if (
|
|
226
|
-
noscOsccon1 === StringConstants.EXTOSC_4xPLL &&
|
|
227
|
-
((this.getModel().getComponentValue("externalClk") ?? 0) <=
|
|
228
|
-
this.getClockCalculator().MIN_PLL ||
|
|
229
|
-
(this.getModel().getComponentValue("externalClk") ?? 0) >
|
|
230
|
-
this.getClockCalculator().MAX_PLL)
|
|
231
|
-
) {
|
|
232
|
-
alerts.push({
|
|
233
|
-
type: Processor.AlertTypes.Warning,
|
|
234
|
-
text:
|
|
235
|
-
"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.",
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
if (
|
|
240
|
-
noscOsccon1 === StringConstants.EXTOSC_4xPLL ||
|
|
241
|
-
noscOsccon1 === StringConstants.EXTOSC
|
|
242
|
-
) {
|
|
243
|
-
if (
|
|
244
|
-
selectedOptionVal?.indexOf("external clock") != -1 &&
|
|
245
|
-
this.getClockCalculator().getCurrentSystemClk() >
|
|
246
|
-
StringConstants.ExtClkFreq_64MHz
|
|
247
|
-
) {
|
|
248
|
-
alerts.push({
|
|
249
|
-
type: Processor.AlertTypes.Warning,
|
|
250
|
-
text:
|
|
251
|
-
"External clock frequency is greater than recommended value (" +
|
|
252
|
-
StringConstants.ExtClkFreq_64MHz +
|
|
253
|
-
" Hz)",
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
if (
|
|
258
|
-
selectedOptionVal?.indexOf("crystal oscillator") != -1 &&
|
|
259
|
-
(this.getModel().getComponentValue("externalClk") ?? 0) > 16000000 &&
|
|
260
|
-
this.getClockCalculator().getCurrentSystemClk() >
|
|
261
|
-
StringConstants.ExtClkFreq_20MHz
|
|
262
|
-
) {
|
|
263
|
-
alerts.push({
|
|
264
|
-
type: Processor.AlertTypes.Warning,
|
|
265
|
-
text:
|
|
266
|
-
"External clock frequency is greater than recommended value (" +
|
|
267
|
-
StringConstants.ExtClkFreq_20MHz +
|
|
268
|
-
" Hz)",
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
if (
|
|
273
|
-
selectedOptionVal.indexOf("Oscillator not enabled") != -1 &&
|
|
274
|
-
this.getClockCalculator().getCurrentSystemClk() >
|
|
275
|
-
StringConstants.ExtClkFreq_32MHz
|
|
276
|
-
) {
|
|
277
|
-
alerts.push({
|
|
278
|
-
type: Processor.AlertTypes.Warning,
|
|
279
|
-
text:
|
|
280
|
-
"External clock frequency is greater than recommended value (" +
|
|
281
|
-
StringConstants.ExtClkFreq_32MHz +
|
|
282
|
-
" Hz)",
|
|
283
|
-
});
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
const HFClk = parseInt(
|
|
288
|
-
this.dataModel.getComponentValue("hffrqOscfrq")?.replace("_MHz", "") ?? "0",
|
|
289
|
-
);
|
|
290
|
-
if (
|
|
291
|
-
this.dataModel.getComponentValue("noscOsccon1") ===
|
|
292
|
-
StringConstants.HFINTOSC_2xPLL &&
|
|
293
|
-
(HFClk == 1 || HFClk == 2 || HFClk == 4 || HFClk == 32)
|
|
294
|
-
) {
|
|
295
|
-
alerts.push({
|
|
296
|
-
type: Processor.AlertTypes.Warning,
|
|
297
|
-
text:
|
|
298
|
-
"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.",
|
|
299
|
-
});
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
return alerts;
|
|
303
|
-
};
|
|
304
|
-
}
|