@mchp-mcc/scf-pic8-pwm-v2 4.2.8 → 4.2.10

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.
@@ -1,333 +0,0 @@
1
- import {
2
- AppModel,
3
- DerivedData,
4
- DerivedFunctions,
5
- } from "../generated_module/src/types/AutoModuleTypes";
6
- import * as Processor from "@microchip/scf-common/lib/Processor";
7
- import { PwmCalculator } from "./PwmCalculator";
8
- import * as pwm_general from "./interfaces/pwm_general_parameters";
9
- import * as initializer_system from "@microchip/initializer-system";
10
- import { Interface, Arguments } from "@microchip/scf-interface";
11
- import { getGeneratorModel, getHeaderFiles } from "./GeneratorModel";
12
- import { MyComponentNames, MyExportNames } from "../generated_module/src/types";
13
- import { getAutoSdlHelp } from "@microchip/scf-automodule-impl/lib/autoModule/ContextualHelp";
14
- import { getPinsLogic } from "../generated_module/src/pins/PCPHelper";
15
- import { MyImports } from "../generated_module/src/types";
16
- import { getCFunctionValidator, PatternValidator } from "@microchip/scf-validators/lib";
17
-
18
- export const getDerivedData = (dataModel: AppModel): DerivedData => {
19
- if (dataModel) {
20
- return new MyDerivedData(dataModel);
21
- }
22
- return new EmptyDerivedData();
23
- };
24
-
25
- //This data will be used at the creator stage and relies on only the state
26
- class EmptyDerivedData implements DerivedData {
27
- getMyFunctions = (): DerivedFunctions => {
28
- return {};
29
- };
30
- getModel = (): AppModel | undefined => {
31
- return undefined;
32
- };
33
- }
34
-
35
- //This data will be used at the processor stage
36
- class MyDerivedData implements DerivedData {
37
- private dataModel: AppModel;
38
- private pwmCalculator: PwmCalculator;
39
- private cValidator: PatternValidator = getCFunctionValidator();
40
-
41
- constructor(dataModel: AppModel) {
42
- this.dataModel = dataModel;
43
- }
44
-
45
- private getPwmCalculator = (): PwmCalculator => {
46
- if (!this.pwmCalculator) {
47
- this.pwmCalculator = new PwmCalculator(
48
- this.getTimerPrValue(),
49
- this.getTimerPrescaler(),
50
- this.dataModel.getImportValue("osc_clocks")?.fosc ?? 0,
51
- Number(this.dataModel.getComponentValue("dutyCycle")),
52
- );
53
- }
54
- return this.pwmCalculator;
55
- };
56
-
57
- getMyFunctions = (): DerivedFunctions => {
58
- return {
59
- overrideDefaultValues: this.overrideDefaultValues,
60
- overrideOptions: this.overrideDefaultOptions,
61
- moduleName: (): string | undefined => this.dataModel.getHardware()?.getName(),
62
- pinData: this.getMyPinData,
63
- alerts: this.getMyAlerts,
64
-
65
- pwm_general_parameters_payload: this.pwm_general_parameters_payload,
66
- initializer_system_results: this.initializer_system_results,
67
-
68
- dutyCycleValidator: this.dutyCycleValidator,
69
-
70
- componentName: this.componentName,
71
- pwmdcValue: (): number => this.getPwmCalculator().getCCPRValue(),
72
- pwmPeriod: (): number => this.getPwmCalculator().getPwmPeriod(),
73
- pwmFrequency: (): number => this.getPwmCalculator().getPwmFrequency(),
74
- pwmResolution: (): number => this.getPwmCalculator().getPwmResolution(),
75
-
76
- ctselCcptmrs1: this.ctselTimerSetting,
77
- ctselCcptmrs: this.ctselTimerSetting,
78
- ctselPwmtmrs: this.ctselTimerSetting,
79
- pwmdchPwmdch: (): number =>
80
- Number(this.dataModel.getComponentValue("pwmdcValue")) >> 2,
81
- pwmdclPwmdcl: (): number =>
82
- Number(this.dataModel.getComponentValue("pwmdcValue")) & 3,
83
-
84
- templateData: (): any => getGeneratorModel(this.dataModel),
85
- getHelpUrl: this.getSdlHelpOverride,
86
- filterImports: this.filterImports,
87
- getPinsLogic: getPinsLogic,
88
- importName: this.friendlyImportName,
89
- componentNameValidator: this.componentNameValidator,
90
- getCustomUiErrors: this.getCustomUiErrors,
91
- };
92
- };
93
-
94
- private friendlyImportName = (importKey: string): string => {
95
- if (importKey === "scf_pic8_pwm_v2") return "PWM Hardware";
96
- if (importKey === "osc_clocks") return "Oscillator Clock";
97
- if (importKey === "initializer_system") return "system.c Initialize()";
98
- if (importKey === "pin_standard") return "Pins";
99
- return importKey;
100
- };
101
-
102
- private overrideDefaultValues = (componentName: string): any => {
103
- switch (componentName) {
104
- case "componentName":
105
- return this.dataModel.getHardware()?.getName();
106
- default:
107
- return undefined;
108
- }
109
- };
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
-
131
- private overrideDefaultOptions = (componentName: string): any[] => {
132
- switch (componentName) {
133
- case "timerSelection": {
134
- const result: any[] = [];
135
- const CCPTMRSREG =
136
- this.dataModel.getPeripheralDescription()?.registers?.CCPTMRS1 ??
137
- this.dataModel.getPeripheralDescription()?.registers?.CCPTMRS;
138
- const PWMTMRSREG = this.dataModel.getPeripheralDescription()?.registers
139
- ?.PWMTMRS;
140
- if (CCPTMRSREG) {
141
- const CTSELSETT = CCPTMRSREG.settings?.CTSEL;
142
- for (const eachoptn of CTSELSETT?.options ?? []) {
143
- const timeroptnregex = /^pwm\d+timer(\d)$/i;
144
- const optnmatch = eachoptn.alias.match(timeroptnregex);
145
- const correctOptnName =
146
- (optnmatch?.length ?? 0) > 1 ? "TMR" + optnmatch?.[1] : "";
147
- result.push(correctOptnName);
148
- }
149
- }
150
- if (PWMTMRSREG) {
151
- const CTSELSETT = PWMTMRSREG.settings?.CTSEL;
152
- for (const eachoptn of CTSELSETT?.options ?? []) {
153
- const timeroptnregex = /^pwm\d+timer(\d)$/i;
154
- const optnmatch = eachoptn.alias.match(timeroptnregex);
155
- const correctOptnName =
156
- (optnmatch?.length ?? 0) > 1 ? "TMR" + optnmatch?.[1] : "";
157
- result.push(correctOptnName);
158
- }
159
- }
160
- if (!CCPTMRSREG && !PWMTMRSREG) {
161
- result.push("TMR2");
162
- }
163
- return result;
164
- }
165
- default:
166
- return [] /*for other fields - undefined as take options from moduleconfig.json*/;
167
- }
168
- };
169
-
170
- public getModel = (): AppModel => {
171
- return this.dataModel;
172
- };
173
-
174
- private getMyPinData = (): any => {
175
- return {};
176
- };
177
-
178
- private filterImports = (imports: MyImports): MyImports => {
179
- let filteredImports: MyImports = imports;
180
- const ImportKeys = ["Timer"];
181
-
182
- ImportKeys.forEach((importKey) => {
183
- filteredImports = this.getModel().filterImportBySetting(
184
- filteredImports,
185
- importKey,
186
- (option: Processor.Option<any>): any => {
187
- if (option.payload !== undefined) {
188
- const rstSource =
189
- this.dataModel.getComponentValue("timerSelection") ??
190
- "disabled";
191
- const regexpNumber = /\d/;
192
- const inst = rstSource.match(regexpNumber);
193
- if (rstSource.indexOf("TMR") !== -1) {
194
- return option.payload.moduleName === "TMR" + inst;
195
- }
196
- }
197
- },
198
- ) as MyImports;
199
- });
200
- return filteredImports;
201
- };
202
-
203
- private getMyAlerts = (): Processor.Alert[] => {
204
- const alerts: Processor.Alert[] = [];
205
-
206
- const timerSelection: string =
207
- this.dataModel.getComponentValue("timerSelection") ?? "";
208
- const groupmatch = timerSelection.match(/^TMR([0-9])$/) ?? "";
209
- const timersuffix = groupmatch?.length > 1 ? groupmatch[1] : "";
210
- if (
211
- this.dataModel.getAssignedImport("Timer") == undefined ||
212
- this.dataModel.getAssignedImport("Timer")?.handle?.label !==
213
- "TMR" + timersuffix
214
- ) {
215
- alerts.push({
216
- text: `Please select ${timerSelection} as the Timer Dependency.`,
217
- type: Processor.AlertTypes.Warning,
218
- });
219
- } else {
220
- alerts.push({
221
- text: `${this.dataModel.getName()} uses ${timerSelection}.`,
222
- type: Processor.AlertTypes.Hint,
223
- });
224
- alerts.push({
225
- text: `Postscaler setting in ${timerSelection} does not affect the calculated parameters in PWM module.`,
226
- type: Processor.AlertTypes.Hint,
227
- });
228
- if (
229
- Number(this.dataModel.getComponentValue("pwmdcValue")) / 4 >
230
- this.getTimerPrValue()
231
- ) {
232
- alerts.push({
233
- text: `The value for Duty Cycle percentage is crossing 100 because the period value set in tmr is greater than the dutycycle value set in PWM. Set the duty cycle to be less than 100 percent.`,
234
- type: Processor.AlertTypes.Warning,
235
- });
236
- }
237
- }
238
-
239
- return alerts;
240
- };
241
-
242
- private getSdlHelpOverride = (
243
- componentName: MyComponentNames,
244
- helpUrl: string,
245
- ): string => {
246
- if (componentName === "timerSelection") {
247
- if (this.getModel().getPeripheralDescription()?.registers?.CCPTMRS1) {
248
- componentName = "ctselCcptmrs1";
249
- } else if (this.getModel().getPeripheralDescription()?.registers?.CCPTMRS) {
250
- componentName = "ctselCcptmrs";
251
- } else if (this.getModel().getPeripheralDescription()?.registers?.PWMTMRS) {
252
- componentName = "ctselPwmtmrs";
253
- }
254
- } else if (componentName === "dutyCycle" || componentName === "pwmdcValue") {
255
- helpUrl = helpUrl?.replace(
256
- "${instance}",
257
- this.getModel().getHardware()?.getName() ?? "",
258
- );
259
- }
260
-
261
- return getAutoSdlHelp(this.getModel() as any, componentName, helpUrl);
262
- };
263
-
264
- private pwm_general_parameters_payload = (): pwm_general.ProcessedPayload => {
265
- return {
266
- interfaceApi: pwm_general.Interface.createFirmwareApi(
267
- this.dataModel.getComponentValue("componentName") ?? "",
268
- getHeaderFiles(this.dataModel),
269
- ),
270
- customName: this.dataModel.getComponentValue("componentName"),
271
- modulename: this.dataModel.getName(),
272
- isdriverisr: false,
273
- ispwmi_enabled: false,
274
- ispwmpi_enabled: false,
275
- moduleName: this.dataModel.getName(),
276
- };
277
- };
278
-
279
- private initializer_system_results = (): initializer_system.Results => {
280
- return {
281
- initializer: {
282
- name: this.dataModel.getComponentValue("componentName") + "_Initialize",
283
- header: getHeaderFiles(this.dataModel)[0],
284
- },
285
- };
286
- };
287
-
288
- private dutyCycleValidator = (): any => {
289
- return {
290
- minimum: 0,
291
- maximum: 100,
292
- };
293
- };
294
-
295
- private componentName = (): string | undefined => {
296
- const arg = this.getArg("pwm_general", pwm_general.Interface);
297
- if (arg) {
298
- const pwmArg: pwm_general.Arguments = arg;
299
- return pwmArg.customName;
300
- }
301
- return undefined;
302
- };
303
-
304
- private ctselTimerSetting = (): string | 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;
313
- }
314
- };
315
-
316
- private getTimerPrValue = (): number => {
317
- return this.dataModel.getImportValue("Timer")?.periodRegisterValue ?? 255;
318
- };
319
-
320
- private getTimerPrescaler = (): number => {
321
- return this.dataModel.getImportValue("Timer")?.prescaleValue ?? 1;
322
- };
323
-
324
- private getArg = (key: MyExportNames, id: Interface): Arguments => {
325
- const exportInterface = this.dataModel
326
- .getExportInterfaces()
327
- .getInterface(key, id.getInterfaceId());
328
- if (exportInterface?.args) {
329
- // choose the first requester for now
330
- return exportInterface.args[Object.keys(exportInterface.args)[0]];
331
- }
332
- };
333
- }
@@ -1,39 +0,0 @@
1
- //import { getModel } from "../generated_module/src/App/AppModel";
2
- import { AppModel } from "../generated_module/src/types/AutoModuleTypes";
3
- import { getModel, mockState } from "../generated_module/tests/AppModel.test";
4
- import { mockAssignedModule } from "../generated_module/tests/processor.test";
5
- import * as MyDerivedData from "./DerivedData";
6
- import * as GenertorModel from "./GeneratorModel";
7
-
8
- describe("GeneratorModel", () => {
9
- describe("getGeneratorModel", () => {
10
- test("componentName is undefined", () => {
11
- const mockModule = mockAssignedModule(mockState());
12
- const model = getModel(mockModule, MyDerivedData.getDerivedData as any);
13
- if (model) {
14
- model.getComponentValue = (comp_name: string): any => {
15
- const compData = {
16
- componentName: undefined,
17
- };
18
- return compData[comp_name];
19
- };
20
- expect(
21
- GenertorModel.getGeneratorModel(model as any).customName,
22
- ).toBeUndefined();
23
- }
24
- });
25
-
26
- test("PeripheralDescription is undefined", () => {
27
- const mockModule = mockAssignedModule(mockState());
28
- const model = getModel(mockModule, MyDerivedData.getDerivedData as any);
29
- if (model) {
30
- model.getPeripheralDescription = (): any => {
31
- return undefined;
32
- };
33
- expect(
34
- GenertorModel.getGeneratorModel(model as AppModel).hardwareSettings,
35
- ).toBeDefined;
36
- }
37
- });
38
- });
39
- });
@@ -1,65 +0,0 @@
1
- import { AppModel } from "../generated_module/src/types/AutoModuleTypes";
2
- import * as pwm_general from "./interfaces/pwm_general_parameters";
3
- import * as InterfaceTypes from "@microchip/scf-interface";
4
- import { getOptionValueByName } from "../generated_module/src/autoModule/AutoModuleHelpers";
5
- import { getTemplateSettings } from "../generated_module/src/autoModule/AutoModuleTemplates";
6
- import { values } from "../generated_module/src/Utils";
7
-
8
- export const getGeneratorModel = (model: AppModel): any => {
9
- if (!model.getHardware()) return {};
10
-
11
- const pwmInterface = pwm_general.Interface.createFirmwareApi(
12
- model.getComponentValue("componentName") ?? "",
13
- getHeaderFiles(model),
14
- );
15
-
16
- const templateSettings = getTemplateSettings(model);
17
-
18
- const registerValues = templateSettings?.registers;
19
- const initRegisters: any[] = values(registerValues ?? {});
20
-
21
- const ctsel = model.getPeripheralDescription()?.registers?.CCPTMRS1?.settings?.CTSEL;
22
- const CTSELvalue = ctsel
23
- ? getOptionValueByName(ctsel, model.getDerivedFunction("ctselCcptmrs1"))
24
- : 1;
25
-
26
- return {
27
- moduleNameLowerCase: model.getName()?.toLowerCase(),
28
- moduleNameUpperCase: model.getName()?.toUpperCase(),
29
- header: pwmInterface.headerFiles?.[0],
30
- api: pwmInterface.api,
31
- simpleApi: pwmInterface.simpleApi,
32
-
33
- productName: "",
34
- productVersion: "",
35
- selectedDevice: "PIC18F47Q10",
36
- compiler: "XC8 v2.20",
37
- tool: "MPLABX v5.40",
38
-
39
- //From System Manager
40
- useWatchdog: model.getImportValue("wdtEnable") ?? false, //TODO
41
-
42
- //Registers and Settings
43
- initRegisters: initRegisters,
44
- // PWMDCH: templateSettings?.registers?.PWMDCH.name ?? "",
45
- // PWMDCL: templateSettings?.registers?.PWMDCL?.name ?? "",
46
- CCPTMRSregname: templateSettings?.registers?.CCPTMRS1?.name ?? "",
47
- CTSELsettingname:
48
- templateSettings?.registers?.CCPTMRS1?.settings?.CTSEL.name ?? "",
49
- CTSELvalue: CTSELvalue,
50
- timerselpresence:
51
- (ctsel?.options?.length ?? 0) > 0 ? "timerselpresent" : "timerselabsent",
52
-
53
- pwmdcValue: model.getComponentValue("pwmdcValue"),
54
- ...registerValues,
55
- };
56
- };
57
-
58
- export const getHeaderFiles = (model: AppModel): InterfaceTypes.HeaderFile[] => {
59
- return [
60
- {
61
- name: model.getName().toLowerCase() + ".h",
62
- path: "pwm/",
63
- },
64
- ];
65
- };
@@ -1,103 +0,0 @@
1
- import { behaviour, direction, pin_row } from "@microchip/pin-standard";
2
- //import { getModel } from "../generated_module/src/App/AppModel";
3
- import { MyState } from "../generated_module/src/types/AutoModuleTypes";
4
- import { getModel, mockState } from "../generated_module/tests/AppModel.test";
5
- import { mockAssignedModule } from "../generated_module/tests/processor.test";
6
- import { getDerivedData } from "./DerivedData";
7
- import { getRowData } from "./PinsLogic";
8
-
9
- export const getMockState = (): MyState => {
10
- return {
11
- main: {
12
- software: {
13
- componentName: "PWM4",
14
- tmr2Dependency: "TMR2",
15
- },
16
- hardware: {
17
- timerSelection: "TMR2",
18
- dutyCycle: 50,
19
- pwmdcValue: 511,
20
- pwmPeriod: 0.001024,
21
- pwmFrequency: 976.56,
22
- pwmResolution: 10,
23
- pwmpolPwmcon: "active_hi",
24
- pwmenPwmcon: true,
25
- },
26
- },
27
- };
28
- };
29
-
30
- describe("PinsLogic --> Test Cases ", () => {
31
- describe("getRowData() test case ", () => {
32
- const mockModule = mockAssignedModule(getMockState());
33
- const model = getModel(mockModule, getDerivedData as any);
34
-
35
- const pwmPpsData: pin_row = {
36
- name: "pwmPps",
37
- module: "PWM6",
38
- function: "PWM6OUT",
39
- direction: direction.output,
40
- filter: {
41
- module: "PWM6",
42
- aliasReEx: "PWM[0-9]",
43
- },
44
- behaviour: behaviour.PPS,
45
- };
46
- it("Test for pwmPpsData pin data: PWM mode", () => {
47
- if (model) {
48
- expect(getRowData(model as any, pwmPpsData)).toMatchObject(pwmPpsData);
49
- expect(getRowData(model as any, pwmPpsData)?.actions).toBeUndefined();
50
- } else {
51
- throw "Model not configured for testcase";
52
- }
53
- });
54
- });
55
-
56
- describe("getRowData() test case : invalid", () => {
57
- const mockModule = mockAssignedModule(mockState());
58
- const model = getModel(mockModule, getDerivedData as any);
59
-
60
- const pwmPpsData: pin_row = {
61
- name: "dummy",
62
- module: "PWM6",
63
- function: "PWM6OUT",
64
- direction: direction.output,
65
- filter: {
66
- module: "PWM6",
67
- aliasReEx: "PWM[0-9]",
68
- },
69
- behaviour: behaviour.PPS,
70
- };
71
- it("Test for pwmPpsData pin data: invalid", () => {
72
- if (model) {
73
- expect(getRowData(model as any, pwmPpsData)).toMatchObject(pwmPpsData);
74
- expect(getRowData(model as any, pwmPpsData)?.actions).toBeUndefined();
75
- } else {
76
- throw "Model not configured for testcase";
77
- }
78
- });
79
- it("Test for ccpPpsData pin data, undefined registers", () => {
80
- let mockAssignedMod = mockAssignedModule(mockState());
81
- mockAssignedMod = {
82
- ...(mockAssignedMod ?? {}),
83
- imports: {
84
- ...(mockAssignedMod?.imports ?? {}),
85
- scf_pic8_pwm_v2: {
86
- ...(mockAssignedMod?.imports?.scf_pic8_pwm_v2 ?? {}),
87
- handle: undefined,
88
- payload: undefined,
89
- },
90
- },
91
- };
92
- const mockModel = getModel(mockAssignedMod, getDerivedData as any);
93
- if (mockModel) {
94
- expect(getRowData(mockModel as any, pwmPpsData)).toMatchObject(
95
- pwmPpsData,
96
- ); // check if the same data is returned
97
- expect(getRowData(mockModel as any, pwmPpsData)?.actions).toBeUndefined();
98
- } else {
99
- throw "Model not configured for testcase";
100
- }
101
- });
102
- });
103
- });
package/src/PinsLogic.ts DELETED
@@ -1,26 +0,0 @@
1
- import { AppModel } from "../generated_module/src/types/AutoModuleTypes";
2
- import { pin_row } from "@microchip/pin-standard";
3
-
4
- // provide complete dynamic data for all pin rows. It overrides static pindata.json
5
- export const getCompletePinData = (appModel: AppModel): any => {
6
- // way to programatically override the json data
7
- return {};
8
- };
9
-
10
- // overrides pin data for a particular row based on model.
11
- export function getRowData(appModel: AppModel, rowData: pin_row): pin_row {
12
- const pwminstancename = appModel.getHardware()?.getPeripheral()?.instance;
13
-
14
- if (rowData.name === "out") {
15
- rowData = {
16
- ...rowData,
17
- module: "PWM" + pwminstancename,
18
- function: "PWM" + pwminstancename + "OUT",
19
- filter: {
20
- module: "PWM" + pwminstancename,
21
- aliasReEx: "PWM" + pwminstancename,
22
- },
23
- };
24
- }
25
- return rowData;
26
- }
@@ -1,113 +0,0 @@
1
- import { PwmCalculator } from "./PwmCalculator";
2
-
3
- describe("Pwm Calculations: PR = 0x7c, Prescaler = 0x4, fosc = 4M, DC = 75", () => {
4
- const pwmCalculator = new PwmCalculator(0x7c, 16, 4000000, 75);
5
-
6
- test("getPwmPeriod", () => {
7
- expect(pwmCalculator.getPwmPeriod()).toBe(0.002);
8
- });
9
-
10
- test("getPwmFrequency", () => {
11
- expect(pwmCalculator.getPwmFrequency()).toBe(500);
12
- });
13
-
14
- test("getPwmResolution", () => {
15
- expect(pwmCalculator.getPwmResolution()).toBe(8);
16
- });
17
-
18
- test("getCCPRValue", () => {
19
- expect(pwmCalculator.getCCPRValue()).toBe(374);
20
- });
21
-
22
- test("getActualDutyCycle", () => {
23
- expect(pwmCalculator.getActualDutyCycle()).toBe(75);
24
- });
25
-
26
- test("getActualPulseWidth", () => {
27
- expect(pwmCalculator.getActualPulseWidth()).toBe(0.001496);
28
- });
29
- });
30
-
31
- describe("Pwm Calculations: PR = 0x4d, Prescaler = 0x5, fosc = 1M, DC = 60", () => {
32
- const pwmCalculator2 = new PwmCalculator(0x4d, 32, 1000000, 60);
33
-
34
- test("getPwmPeriod", () => {
35
- expect(pwmCalculator2.getPwmPeriod()).toBe(0.009984);
36
- });
37
-
38
- test("getPwmFrequency", () => {
39
- expect(pwmCalculator2.getPwmFrequency()).toBe(100.16);
40
- });
41
-
42
- test("getPwmResolution", () => {
43
- expect(pwmCalculator2.getPwmResolution()).toBe(8);
44
- });
45
-
46
- test("getCCPRValue", () => {
47
- expect(pwmCalculator2.getCCPRValue()).toBe(186);
48
- });
49
-
50
- test("getActualDutyCycle", () => {
51
- expect(pwmCalculator2.getActualDutyCycle()).toBe(60);
52
- });
53
-
54
- test("getActualPulseWidth", () => {
55
- expect(pwmCalculator2.getActualPulseWidth()).toBe(0.005952);
56
- });
57
- });
58
-
59
- describe("Pwm Calculations: PR = 0x0, Prescaler = 0x0, fosc = 1M, DC = 0", () => {
60
- const pwmCalculator2 = new PwmCalculator(0x0, 0, 1000000, 0);
61
-
62
- test("getPwmPeriod", () => {
63
- expect(pwmCalculator2.getPwmPeriod()).toBe(0);
64
- });
65
-
66
- test("getPwmFrequency", () => {
67
- expect(pwmCalculator2.getPwmFrequency()).toBe(0);
68
- });
69
-
70
- test("getPwmResolution", () => {
71
- expect(pwmCalculator2.getPwmResolution()).toBe(2);
72
- });
73
-
74
- test("getCCPRValue", () => {
75
- expect(pwmCalculator2.getCCPRValue()).toBe(0);
76
- });
77
-
78
- test("getActualDutyCycle", () => {
79
- expect(pwmCalculator2.getActualDutyCycle()).toBe(0);
80
- });
81
-
82
- test("getActualPulseWidth", () => {
83
- expect(pwmCalculator2.getActualPulseWidth()).toBe(0);
84
- });
85
- });
86
-
87
- describe("Pwm Calculations: PR = 0x0, Prescaler = 0x0, fosc = 0, DC = 0", () => {
88
- const pwmCalculator2 = new PwmCalculator(0x0, 0, 0, 0);
89
-
90
- test("getPwmPeriod", () => {
91
- expect(pwmCalculator2.getPwmPeriod()).toBe(0);
92
- });
93
-
94
- test("getPwmFrequency", () => {
95
- expect(pwmCalculator2.getPwmFrequency()).toBe(0);
96
- });
97
-
98
- test("getPwmResolution", () => {
99
- expect(pwmCalculator2.getPwmResolution()).toBe(2);
100
- });
101
-
102
- test("getCCPRValue", () => {
103
- expect(pwmCalculator2.getCCPRValue()).toBe(0);
104
- });
105
-
106
- test("getActualDutyCycle", () => {
107
- expect(pwmCalculator2.getActualDutyCycle()).toBe(0);
108
- });
109
-
110
- test("getActualPulseWidth", () => {
111
- expect(pwmCalculator2.getActualPulseWidth()).toBe(0);
112
- });
113
- });