use of net.sourceforge.usbdm.deviceEditor.model.Status in project usbdm-eclipse-plugins by podonoghue.
the class SimValidateMKL method validateIndexVariables.
/**
* Updates
* - sim_sopt2_pllfllsel[x]
* - system_peripheral_clock[x]
* - system_core_clock[x]
* - system_bus_clock[x]
* - system_flexbus_clock[x]
* - system_flash_clock[x]
* - sim_clkdiv1_outdiv1[x]
* - sim_clkdiv1_outdiv2[x]
* - sim_clkdiv1_outdiv3[x]
* - sim_clkdiv1_outdiv4[x]
*
* @param variable
* @throws Exception
*/
void validateIndexVariables(Variable variable) throws Exception {
final ChoiceVariable sim_sopt2_pllfllselVar = safeGetChoiceVariable("sim_sopt2_pllfllsel");
if (sim_sopt2_pllfllselVar != null) {
final LongVariable system_mcgfllclk_clockVar = safeGetLongVariable("/MCG/system_mcgfllclk_clock");
final LongVariable system_mcgpllclk_clockVar = safeGetLongVariable("/MCG/system_mcgpllclk_clock");
final LongVariable usb1pfdclk_ClockVar = safeGetLongVariable("/MCG/usb1pfdclk_Clock");
final LongVariable system_irc48m_clockVar = safeGetLongVariable("/MCG/system_irc48m_clock");
// Determine PLLFLLCLOCK
// =====================================
final LongVariable peripheralClockVar = getLongVariable("system_peripheral_clock");
switch((int) sim_sopt2_pllfllselVar.getValueAsLong()) {
default:
sim_sopt2_pllfllselVar.setValue(0);
case 0:
if (system_mcgfllclk_clockVar != null) {
peripheralClockVar.setValue(system_mcgfllclk_clockVar.getValueAsLong());
peripheralClockVar.setStatus(system_mcgfllclk_clockVar.getFilteredStatus());
peripheralClockVar.setOrigin(system_mcgfllclk_clockVar.getOrigin());
} else {
peripheralClockVar.setValue(0);
peripheralClockVar.setStatus(new Status("FLL not present", Severity.ERROR));
peripheralClockVar.setOrigin(null);
}
break;
case 1:
if (system_mcgpllclk_clockVar != null) {
peripheralClockVar.setValue(system_mcgpllclk_clockVar.getValueAsLong() / 2);
peripheralClockVar.setStatus(system_mcgpllclk_clockVar.getFilteredStatus());
peripheralClockVar.setOrigin(system_mcgpllclk_clockVar.getOrigin() + "/2");
} else {
sim_sopt2_pllfllselVar.setValue(0);
}
break;
case 2:
if (usb1pfdclk_ClockVar != null) {
peripheralClockVar.setValue(usb1pfdclk_ClockVar.getValueAsLong());
peripheralClockVar.setStatus(usb1pfdclk_ClockVar.getStatus());
peripheralClockVar.setOrigin(usb1pfdclk_ClockVar.getOrigin());
} else {
sim_sopt2_pllfllselVar.setValue(0);
}
break;
case 3:
if (system_irc48m_clockVar != null) {
peripheralClockVar.setValue(system_irc48m_clockVar.getValueAsLong());
peripheralClockVar.setStatus(system_irc48m_clockVar.getStatus());
peripheralClockVar.setOrigin(system_irc48m_clockVar.getOrigin());
} else {
sim_sopt2_pllfllselVar.setValue(0);
}
break;
}
}
// ======================================
final LongVariable system_core_clockVar = getLongVariable("system_core_clock");
final LongVariable system_bus_clockVar = getLongVariable("system_bus_clock");
final LongVariable sim_clkdiv1_outdiv1Var = getLongVariable("sim_clkdiv1_outdiv1");
final LongVariable sim_clkdiv1_outdiv4Var = getLongVariable("sim_clkdiv1_outdiv4");
// Core & System Clock
// ===========================================
// Attempt to find acceptable divisor
final LongVariable system_mcgoutclk_clockVar = getLongVariable("/MCG/system_mcgoutclk_clock");
long inputFrequency = system_mcgoutclk_clockVar.getValueAsLong();
final FindDivisor coreDivisor = new FindDivisor(inputFrequency, system_core_clockVar.getValueAsLong()) {
@Override
boolean okValue(int divisor, double frequency) {
return frequency <= MAX_CORE_CLOCK_FREQ;
}
};
Severity severity = Severity.OK;
StringBuilder sb = new StringBuilder();
if (variable == system_core_clockVar) {
// Clock variable changed - replace with nearest value if found
if (coreDivisor.divisor == 0) {
severity = Severity.ERROR;
sb.append("Illegal Frequency\n");
}
sb.append(coreDivisor.divisors);
system_core_clockVar.setValue(coreDivisor.nearestTargetFrequency);
system_core_clockVar.setStatus(new Status(sb.toString(), severity));
sim_clkdiv1_outdiv1Var.setValue(coreDivisor.divisor);
} else {
// Clock variable not changed - just validate
if ((coreDivisor.divisor == 0) || (system_core_clockVar.getValueAsLong() != (coreDivisor.nearestTargetFrequency))) {
severity = Severity.ERROR;
sb.append("Illegal Frequency\n");
}
sb.append(coreDivisor.divisors);
system_core_clockVar.setStatus(new Status(sb.toString(), severity));
sim_clkdiv1_outdiv1Var.setValue(coreDivisor.divisor);
}
// Bus & Flash Clock
// ===========================================
// Attempt to find acceptable divisor
final long coreFrequency = system_core_clockVar.getValueAsLong();
inputFrequency = coreFrequency;
final FindDivisor flashDivisor = new FindDivisor(inputFrequency, system_bus_clockVar.getValueAsLong()) {
@Override
boolean okValue(int divisor, double frequency) {
return (frequency <= MAX_BUS_CLOCK_FREQ) && (frequency <= coreFrequency);
}
};
severity = Severity.OK;
sb = new StringBuilder();
if (variable == system_bus_clockVar) {
// Clock variable changed - replace with nearest value if found
if (flashDivisor.divisor == 0) {
severity = Severity.ERROR;
sb.append("Illegal Frequency\n");
}
sb.append(flashDivisor.divisors);
system_bus_clockVar.setValue(flashDivisor.nearestTargetFrequency);
system_bus_clockVar.setStatus(new Status(sb.toString(), severity));
sim_clkdiv1_outdiv4Var.setValue(flashDivisor.divisor);
} else {
// Clock variable not changed - just validate
if ((flashDivisor.divisor == 0) || (system_bus_clockVar.getValueAsLong() != (flashDivisor.nearestTargetFrequency))) {
severity = Severity.ERROR;
sb.append("Illegal Frequency\n");
}
sb.append(flashDivisor.divisors);
system_bus_clockVar.setStatus(new Status(sb.toString(), severity));
sim_clkdiv1_outdiv4Var.setValue(flashDivisor.divisor);
}
}
use of net.sourceforge.usbdm.deviceEditor.model.Status in project usbdm-eclipse-plugins by podonoghue.
the class ClockValidator_MCG_Lite method validateClocks.
protected void validateClocks(Variable variable) throws Exception {
// System.err.println(getSimpleClassName()+" Var = "+variable);
super.validate(variable);
// C1
// =================================
Variable mcg_c1_clksVar;
Variable mcg_c1_irclkenVar;
Variable mcg_c1_irefstenVar;
// C2
// =================================
Variable mcg_c2_rangeVar;
Variable mcg_c2_ircsVar;
// SC
// =================================
Variable mcg_sc_fcrdivVar;
// MC
// =================================
Variable mcg_mc_hircenVar;
Variable mcg_mc_lirc_div2Var;
// LIRC
// =================================
Variable system_slow_irc_clockVar;
Variable system_fast_irc_clockVar;
Variable system_lirc_clockVar;
Variable system_lirc_div1_clockVar;
Variable system_mcgirclk_clockVar;
// Internal
// =================================
Variable system_irc48m_clockVar;
// Clocks and information from main oscillator
// =================================
Variable osc_clockVar;
Variable osc_oscillatorRangeVar;
// =================================
Variable clock_modeVar;
// =================================
Variable system_mcgoutclk_clock_sourceVar;
Variable system_mcgoutclk_clockVar;
Variable system_mcgpclk_clockVar;
mcg_c1_clksVar = getVariable("mcg_c1_clks");
mcg_c1_irclkenVar = getVariable("mcg_c1_irclken");
mcg_c1_irefstenVar = getVariable("mcg_c1_irefsten");
mcg_c2_rangeVar = getVariable("mcg_c2_range");
mcg_c2_ircsVar = getVariable("mcg_c2_ircs");
mcg_sc_fcrdivVar = safeGetVariable("mcg_sc_fcrdiv");
mcg_mc_hircenVar = safeGetVariable("mcg_mc_hircen");
mcg_mc_lirc_div2Var = safeGetVariable("mcg_mc_lirc_div2");
system_slow_irc_clockVar = getVariable("system_slow_irc_clock");
system_fast_irc_clockVar = getVariable("system_fast_irc_clock");
system_lirc_clockVar = getVariable("system_lirc_clock");
system_lirc_div1_clockVar = getVariable("system_lirc_div1_clock");
system_mcgirclk_clockVar = getVariable("system_mcgirclk_clock");
system_irc48m_clockVar = safeGetVariable("system_irc48m_clock");
osc_clockVar = getVariable("/OSC0/osc_clock");
osc_oscillatorRangeVar = getVariable("/OSC0/oscillatorRange");
clock_modeVar = getVariable("clock_mode");
system_mcgoutclk_clock_sourceVar = getVariable("system_mcgoutclk_clock_source");
system_mcgoutclk_clockVar = getVariable("system_mcgoutclk_clock");
system_mcgpclk_clockVar = getVariable("system_mcgpclk_clock");
long rangeIn = osc_oscillatorRangeVar.getValueAsLong();
if (rangeIn != OscValidate.UNCONSTRAINED_RANGE) {
mcg_c2_rangeVar.enable(true);
mcg_c2_rangeVar.setValue(osc_oscillatorRangeVar.getValueAsLong());
} else {
mcg_c2_rangeVar.enable(false);
}
// Main clock mode (MCGOUTCLK)
// =============================
ClockMode clock_mode = ClockMode.valueOf(clock_modeVar.getSubstitutionValue());
switch(clock_mode) {
default:
case ClockMode_None:
mcg_c1_clksVar.setValue(0);
mcg_c2_ircsVar.setLocked(false);
system_mcgoutclk_clockVar.setValue(system_slow_irc_clockVar.getValueAsLong());
system_mcgoutclk_clockVar.setOrigin(system_slow_irc_clockVar.getOrigin());
system_mcgoutclk_clockVar.setStatus(new Status("No clock settings are applied", Severity.WARNING));
system_mcgoutclk_clock_sourceVar.setValue("LIRC2");
break;
case ClockMode_HIRC_48M:
mcg_c1_clksVar.setValue(0);
mcg_c2_ircsVar.setLocked(false);
system_mcgoutclk_clockVar.setValue(system_irc48m_clockVar.getValueAsLong());
system_mcgoutclk_clockVar.setOrigin(system_irc48m_clockVar.getOrigin());
system_mcgoutclk_clockVar.setStatus((Status) null);
system_mcgoutclk_clock_sourceVar.setValue("HIRC 48M (IRCLK48MCLK)");
break;
case ClockMode_LIRC_2M:
mcg_c1_clksVar.setValue(1);
mcg_c2_ircsVar.setValue(0);
mcg_c2_ircsVar.setLocked(true);
system_mcgoutclk_clockVar.setValue(system_lirc_div1_clockVar.getValueAsLong());
system_mcgoutclk_clockVar.setOrigin(system_lirc_div1_clockVar.getOrigin());
system_mcgoutclk_clockVar.setStatus((Status) null);
system_mcgoutclk_clock_sourceVar.setValue("LIRC2");
break;
case ClockMode_LIRC_8M:
mcg_c1_clksVar.setValue(1);
mcg_c2_ircsVar.setValue(1);
mcg_c2_ircsVar.setLocked(true);
system_mcgoutclk_clockVar.setValue(system_lirc_div1_clockVar.getValueAsLong());
system_mcgoutclk_clockVar.setOrigin(system_lirc_div1_clockVar.getOrigin());
system_mcgoutclk_clockVar.setStatus((Status) null);
system_mcgoutclk_clock_sourceVar.setValue("LIRC8");
break;
case ClockMode_EXT:
mcg_c1_clksVar.setValue(2);
mcg_c2_ircsVar.setLocked(false);
system_mcgoutclk_clockVar.setValue(osc_clockVar.getValueAsLong());
system_mcgoutclk_clockVar.setOrigin(osc_clockVar.getOrigin());
system_mcgoutclk_clockVar.setStatus((Status) null);
system_mcgoutclk_clock_sourceVar.setValue("External Clock (OSCCLK)");
break;
}
system_mcgoutclk_clock_sourceVar.setStatus(system_mcgoutclk_clockVar.getStatus());
// ============================================
if (mcg_mc_hircenVar.getValueAsBoolean() || (clock_mode == ClockMode.ClockMode_HIRC_48M)) {
// HIRC Enabled
system_mcgpclk_clockVar.setValue(system_irc48m_clockVar.getValueAsLong());
system_mcgpclk_clockVar.enable(true);
system_mcgpclk_clockVar.setStatus((Status) null);
} else {
// HIRC Disabled
system_mcgpclk_clockVar.enable(false);
system_mcgpclk_clockVar.setStatus(new Status("Disabled by mcg_mc_hircen", Severity.INFO));
}
// ========================================
if (mcg_c1_irclkenVar.getValueAsBoolean() || (clock_mode == ClockMode.ClockMode_LIRC_2M) || (clock_mode == ClockMode.ClockMode_LIRC_8M)) {
// LIRC Enabled
mcg_c1_irefstenVar.enable(true);
system_lirc_clockVar.enable(true);
system_lirc_clockVar.setStatus((Status) null);
if (mcg_c2_ircsVar.getValueAsBoolean()) {
// Fast IRC selected
system_lirc_clockVar.setValue(system_fast_irc_clockVar.getValueAsLong());
system_lirc_clockVar.setOrigin(system_fast_irc_clockVar.getOrigin());
} else {
// Slow IRC selected
system_lirc_clockVar.setValue(system_slow_irc_clockVar.getValueAsLong());
system_lirc_clockVar.setOrigin(system_fast_irc_clockVar.getOrigin());
}
mcg_sc_fcrdivVar.enable(true);
system_lirc_div1_clockVar.enable(true);
mcg_mc_lirc_div2Var.enable(true);
system_mcgirclk_clockVar.enable(true);
system_mcgirclk_clockVar.setStatus((Status) null);
} else {
// LIRC Disabled
mcg_c1_irefstenVar.enable(false);
system_lirc_clockVar.enable(false);
system_lirc_clockVar.setStatus(new Status("Disabled by mcg_c1_irclken", Severity.WARNING));
mcg_sc_fcrdivVar.enable(false);
system_lirc_div1_clockVar.enable(false);
mcg_mc_lirc_div2Var.enable(false);
system_mcgirclk_clockVar.enable(false);
system_mcgirclk_clockVar.setStatus(new Status("Disabled by mcg_c1_irclken", Severity.WARNING));
}
long mcg_sc_fcrdiv = mcg_sc_fcrdivVar.getValueAsLong();
system_lirc_div1_clockVar.setValue(system_lirc_clockVar.getValueAsLong() / (1 << mcg_sc_fcrdiv));
system_lirc_div1_clockVar.setOrigin(system_lirc_clockVar.getOrigin() + "/LIRC_DIV1");
long mcg_mc_lirc_div2 = mcg_mc_lirc_div2Var.getValueAsLong();
system_mcgirclk_clockVar.setValue(system_lirc_div1_clockVar.getValueAsLong() / (1 << mcg_mc_lirc_div2));
system_mcgirclk_clockVar.setOrigin(system_lirc_div1_clockVar.getOrigin() + "/LIRC_DIV2");
}
use of net.sourceforge.usbdm.deviceEditor.model.Status in project usbdm-eclipse-plugins by podonoghue.
the class ClockValidator_MK_ICS48M method validateClocks.
protected void validateClocks(Variable variable) throws Exception {
// System.err.println(getSimpleClassName()+" Var = "+variable);
super.validate(variable);
StringVariable clockConfig = safeGetStringVariable("ClockConfig");
clockConfig.setStatus(isValidCIdentifier(clockConfig.getValueAsString()) ? (String) null : "Illegal C enum value");
// OSC0 Clock monitor
// =================================
Variable mcg_c6_cme0Var = getVariable("mcg_c6_cme0");
Variable mcg_c2_locre0Var = getVariable("mcg_c2_locre0");
mcg_c2_locre0Var.enable(mcg_c6_cme0Var.getValueAsBoolean());
// OSC1 (RTC) Clock monitor
// =================================
Variable mcg_c8_cme1Var = getVariable("mcg_c8_cme1");
Variable mcg_c8_locre1Var = getVariable("mcg_c8_locre1");
mcg_c8_locre1Var.enable(mcg_c8_cme1Var.getValueAsBoolean());
// PLL monitor
// =================================
Variable mcg_c9_pll_cmeVar = safeGetVariable("mcg_c9_pll_cme");
if (mcg_c9_pll_cmeVar != null) {
getVariable("mcg_c9_pll_locre").enable(mcg_c9_pll_cmeVar.getValueAsBoolean());
}
// =================================
Variable system_irc48m_clockVar = safeGetVariable("system_irc48m_clock");
Variable system_mcgfllclk_clockVar = getVariable("system_mcgfllclk_clock");
Variable mcg_c4_dmx32Var = getVariable("mcg_c4_dmx32");
Variable mcg_c1_frdivVar = getVariable("mcg_c1_frdiv");
Variable mcg_c4_drst_drsVar = getVariable("mcg_c4_drst_drs");
Variable pll0EnabledVar = getVariable("pll0Enabled");
Variable pll0InputFrequencyVar = getVariable("pll0InputFrequency");
Variable pll0OutputFrequency = getVariable("pll0OutputFrequency");
Variable mcg_c5_pllclkenVar = getVariable("mcg_c5_pllclken");
Variable mcg_c5_pllstenVar = getVariable("mcg_c5_pllsten");
Variable mcg_c5_prdiv0Var = getVariable("mcg_c5_prdiv0");
Variable mcg_c6_vdiv0Var = getVariable("mcg_c6_vdiv0");
Variable system_mcgpllclk_clockVar = getVariable("system_mcgpllclk_clock");
Variable system_mcgoutclk_clock_sourceVar = getVariable("system_mcgoutclk_clock_source");
Variable system_mcgoutclk_clockVar = getVariable("system_mcgoutclk_clock");
Variable mcg_c1_irefsVar = getVariable("mcg_c1_irefs");
Variable mcg_c1_clksVar = getVariable("mcg_c1_clks");
Variable mcg_c2_lpVar = getVariable("mcg_c2_lp");
Variable mcg_c6_pllsVar = getVariable("mcg_c6_plls");
// Determine MCGIRCLK (not gated/undivided and gated)
// ========================================
Variable mcg_sc_fcrdivVar = safeGetVariable("mcg_sc_fcrdiv");
Variable system_fast_irc_clockVar = getVariable("system_fast_irc_clock");
Variable system_slow_irc_clockVar = getVariable("system_slow_irc_clock");
Variable mcg_c2_ircsVar = getVariable("mcg_c2_ircs");
Variable system_mcgir_ungated_clock = new LongVariable("system_mcgir_ungated", null);
if (mcg_c2_ircsVar.getValueAsBoolean()) {
// Fast IRC selected
if (mcg_sc_fcrdivVar != null) {
// Variable divisor
long mcg_sc_fcrdiv = mcg_sc_fcrdivVar.getValueAsLong();
system_mcgir_ungated_clock.setOrigin("(Fast IRC)/FCRDIV");
system_mcgir_ungated_clock.setValue(system_fast_irc_clockVar.getValueAsLong() / (1 << mcg_sc_fcrdiv));
} else {
// Fixed divisor of 2
system_mcgir_ungated_clock.setOrigin("(Fast IRC)/2");
system_mcgir_ungated_clock.setValue(system_fast_irc_clockVar.getValueAsLong() / 2);
}
} else {
// Slow IRC selected
system_mcgir_ungated_clock.setOrigin("Slow IRC");
system_mcgir_ungated_clock.setValue(system_slow_irc_clockVar.getValueAsLong());
}
Variable system_mcgirclk_clockVar = getVariable("system_mcgirclk_clock");
system_mcgirclk_clockVar.setOrigin(system_mcgir_ungated_clock.getOrigin());
Variable mcg_c1_irclkenVar = getVariable("mcg_c1_irclken");
Variable mcg_c1_irefstenVar = getVariable("mcg_c1_irefsten");
if (mcg_c1_irclkenVar.getValueAsBoolean()) {
// Enabled
system_mcgirclk_clockVar.setValue(system_mcgir_ungated_clock.getValueAsLong());
system_mcgirclk_clockVar.setStatus((Status) null);
system_mcgirclk_clockVar.enable(true);
mcg_c1_irefstenVar.enable(true);
} else {
// Disabled
system_mcgirclk_clockVar.setValue(0);
system_mcgirclk_clockVar.setStatus(new Status("Disabled by mcg_c1_irclken", Severity.OK));
system_mcgirclk_clockVar.enable(false);
mcg_c1_irefstenVar.enable(false);
}
// Clock Mapping
// =================
String osc0_peripheral = getStringVariable("/SIM/osc0_peripheral").getValueAsString();
LongVariable osc0_osc_clockVar = getLongVariable(osc0_peripheral + "/osc_clock");
String osc32k_peripheral = getStringVariable("/SIM/osc32k_peripheral").getValueAsString();
LongVariable osc32k_osc_clockVar = getLongVariable(osc32k_peripheral + "/osc_clock");
// Determine MCG external reference clock [mcg_erc_clock]
// ========================================================
ChoiceVariable mcg_c7_oscselVar = safeGetChoiceVariable("mcg_c7_oscsel");
Variable mcg_erc_clockVar = getVariable("mcg_erc_clock");
switch((int) mcg_c7_oscselVar.getValueAsLong()) {
default:
case // ERC = OSCCLK (OSC0 main oscillator)
0:
mcg_erc_clockVar.setValue(osc0_osc_clockVar.getValueAsLong());
mcg_erc_clockVar.setStatus(osc0_osc_clockVar.getFilteredStatus());
mcg_erc_clockVar.setOrigin(osc0_osc_clockVar.getOrigin());
break;
case // ERC = RTCCLK (OSC1 oscillator)
1:
mcg_erc_clockVar.setValue(osc32k_osc_clockVar.getValueAsLong());
mcg_erc_clockVar.setStatus(osc32k_osc_clockVar.getFilteredStatus());
mcg_erc_clockVar.setOrigin(osc32k_osc_clockVar.getOrigin() + "[RTCCLK]");
break;
case // ERC = IRC48MCLK (OSC2)
2:
mcg_erc_clockVar.setValue(system_irc48m_clockVar.getValueAsLong());
mcg_erc_clockVar.setStatus((Status) null);
mcg_erc_clockVar.setOrigin("IRC48MCLK");
break;
}
Variable mcg_c11_pllcsVar = safeGetVariable("mcg_c11_pllcs");
boolean pllIsInternal = (mcg_c11_pllcsVar == null) || !mcg_c11_pllcsVar.getValueAsBoolean();
// Main clock mode
// ===============================
int mcg_c1_clks;
int mcg_c6_plls;
int mcg_c2_lp;
boolean mcg_c1_irefs;
// Main clock mode
// ====================
ClockMode clock_mode = ClockMode.valueOf(getVariable("clock_mode").getSubstitutionValue());
Variable fll_enabledVar = getVariable("fll_enabled");
Variable fllInputFrequencyVar = getVariable("fllInputFrequency");
switch(clock_mode) {
default:
case ClockMode_None:
mcg_c1_clks = 0;
mcg_c6_plls = 0;
mcg_c2_lp = 0;
mcg_c1_irefs = true;
system_mcgoutclk_clock_sourceVar.setValue("FLL output");
pll0EnabledVar.setValue(mcg_c5_pllclkenVar.getValueAsBoolean());
fll_enabledVar.setValue(true);
break;
case ClockMode_FEI:
mcg_c1_clks = 0;
mcg_c6_plls = 0;
mcg_c2_lp = 0;
mcg_c1_irefs = true;
system_mcgoutclk_clock_sourceVar.setValue("FLL output");
pll0EnabledVar.setValue(mcg_c5_pllclkenVar.getValueAsBoolean());
fll_enabledVar.setValue(true);
break;
case ClockMode_FEE:
mcg_c1_clks = 0;
mcg_c6_plls = 0;
mcg_c2_lp = 0;
mcg_c1_irefs = false;
system_mcgoutclk_clock_sourceVar.setValue("FLL output");
pll0EnabledVar.setValue(mcg_c5_pllclkenVar.getValueAsBoolean());
fll_enabledVar.setValue(true);
break;
case ClockMode_FBI:
mcg_c1_clks = 1;
mcg_c6_plls = 0;
mcg_c2_lp = 0;
mcg_c1_irefs = true;
system_mcgoutclk_clock_sourceVar.setValue("MCGIRCLK");
pll0EnabledVar.setValue(mcg_c5_pllclkenVar.getValueAsBoolean());
fll_enabledVar.setValue(true);
break;
case ClockMode_FBE:
mcg_c1_clks = 2;
mcg_c6_plls = 0;
mcg_c2_lp = 0;
mcg_c1_irefs = false;
system_mcgoutclk_clock_sourceVar.setValue("MCGERCLK");
pll0EnabledVar.setValue(mcg_c5_pllclkenVar.getValueAsBoolean());
fll_enabledVar.setValue(true);
break;
case ClockMode_BLPI:
mcg_c1_clks = 1;
mcg_c6_plls = 0;
mcg_c2_lp = 1;
mcg_c1_irefs = true;
system_mcgoutclk_clock_sourceVar.setValue("MCGIRCLK");
pll0EnabledVar.setValue(mcg_c5_pllclkenVar.getValueAsBoolean());
fll_enabledVar.setValue(false);
break;
case ClockMode_BLPE:
mcg_c1_clks = 2;
mcg_c6_plls = 0;
mcg_c2_lp = 1;
mcg_c1_irefs = false;
system_mcgoutclk_clock_sourceVar.setValue("MCGERCLK");
pll0EnabledVar.setValue(mcg_c5_pllclkenVar.getValueAsBoolean());
fll_enabledVar.setValue(false);
break;
case ClockMode_PBE:
mcg_c1_clks = 2;
mcg_c6_plls = 1;
mcg_c2_lp = 0;
mcg_c1_irefs = false;
system_mcgoutclk_clock_sourceVar.setValue("MCGERCLK");
pll0EnabledVar.setValue(pllIsInternal || mcg_c5_pllclkenVar.getValueAsBoolean());
fll_enabledVar.setValue(false);
break;
case ClockMode_PEE:
mcg_c1_clks = 0;
mcg_c6_plls = 1;
mcg_c2_lp = 0;
mcg_c1_irefs = false;
system_mcgoutclk_clock_sourceVar.setValue("PLL output");
pll0EnabledVar.setValue(pllIsInternal || mcg_c5_pllclkenVar.getValueAsBoolean());
fll_enabledVar.setValue(false);
break;
}
mcg_c1_clksVar.setValue(mcg_c1_clks);
mcg_c6_pllsVar.setValue(mcg_c6_plls);
mcg_c2_lpVar.setValue(mcg_c2_lp);
mcg_c1_irefsVar.setValue(mcg_c1_irefs);
Variable osc0_osc_cr_erclkenVar = safeGetBooleanVariable(osc0_peripheral + "/osc_cr_erclken");
// =======================================
// Find FLL dividers
FllConfigure fllCheck = new FllConfigure(osc0_osc_cr_erclkenVar, safeGetVariable(osc0_peripheral + "/oscillatorRange"), getVariable("mcg_c2_range"), mcg_c1_irefs, mcg_erc_clockVar, system_slow_irc_clockVar.getValueAsLong(), mcg_c7_oscselVar.getValueAsLong(), mcg_c4_dmx32Var.getValueAsBoolean(), fllInputFrequencyVar, system_mcgfllclk_clockVar, getVariable("system_mcgffclk_clock"), DRST_DRS_MAX);
mcg_c1_frdivVar.setValue(fllCheck.mcg_c1_frdiv);
mcg_c4_drst_drsVar.setValue(fllCheck.mcg_c4_drst_drs);
// External PLLs
// =================================================
Variable usb1pfdclk_ClockVar = safeGetVariable("usb1pfdclk_Clock");
if (usb1pfdclk_ClockVar != null) {
// Check USB HS PLL
long irClockFreq = osc0_osc_clockVar.getValueAsLong();
String failedPreCondition = null;
if (!osc0_osc_cr_erclkenVar.getValueAsBoolean()) {
failedPreCondition = "Disabled: to use PFDCLK, OSCCLK clock must be enabled by osc_cr_erclkenVar";
} else if (!mcg_c1_irclkenVar.getValueAsBoolean()) {
failedPreCondition = "Disabled: to use PFDCLK, IRC clock must be enabled by mcg_c1_irclken";
} else if ((irClockFreq != 12000000) && (irClockFreq != 16000000) && (irClockFreq != 24000000)) {
failedPreCondition = "Disabled: to use PFDCLK, OSCCLK must be in [12Mhz, 16MHz, 24MHz]";
}
if (failedPreCondition == null) {
usb1pfdclk_ClockVar.enable(true);
usb1pfdclk_ClockVar.setOrigin("Clock from USB HS PLL");
usb1pfdclk_ClockVar.setStatus((Status) null);
} else {
usb1pfdclk_ClockVar.enable(false);
usb1pfdclk_ClockVar.setOrigin("Clock from USB HS PLL (disabled)");
usb1pfdclk_ClockVar.setStatus(new Status(failedPreCondition, Severity.WARNING));
}
}
// Internal PLL
// ========================================
// Find PLL divider
PllConfigure pllConfigure = new PllConfigure(PLL_OUT_MIN, PLL_OUT_MAX, PLL_IN_MIN, PLL_IN_MAX, PRDIV_MIN, PRDIV_MAX, VDIV_MIN, VDIV_MAX, PLL_POST_DIV);
pllConfigure.validate(mcg_erc_clockVar, pll0InputFrequencyVar, pll0OutputFrequency, mcg_c5_prdiv0Var, mcg_c6_vdiv0Var);
boolean pll0Enabled = pll0EnabledVar.getValueAsBoolean();
pll0InputFrequencyVar.enable(pll0Enabled);
mcg_c5_prdiv0Var.enable(pll0Enabled);
mcg_c6_vdiv0Var.enable(pll0Enabled);
mcg_c5_pllstenVar.enable(pll0Enabled);
if (pll0Enabled) {
pll0OutputFrequency.enable(pll0InputFrequencyVar.getFilteredStatus() == null);
pll0OutputFrequency.setStatus(pllConfigure.getPllStatus());
} else {
pll0OutputFrequency.enable(false);
pll0OutputFrequency.setStatus(new Status("PLL is disabled", Severity.WARNING));
}
if (pllIsInternal) {
// Internal PLL
system_mcgpllclk_clockVar.setValue(pll0OutputFrequency.getValueAsLong());
system_mcgpllclk_clockVar.setOrigin(pll0OutputFrequency.getOrigin());
system_mcgpllclk_clockVar.setStatus(pll0OutputFrequency.getFilteredStatus());
} else {
// External PLL (USB1 (HS) PHY)
system_mcgpllclk_clockVar.setValue(usb1pfdclk_ClockVar.getValueAsLong());
system_mcgpllclk_clockVar.setOrigin(usb1pfdclk_ClockVar.getOrigin());
system_mcgpllclk_clockVar.setStatus(usb1pfdclk_ClockVar.getFilteredStatus());
}
// ======================================
// FLL status
boolean fllEnabled = fll_enabledVar.getValueAsBoolean();
fllInputFrequencyVar.enable(fllEnabled);
if (fllEnabled) {
boolean fllInputIsOK = (fllInputFrequencyVar.getStatus() == null) || (fllCheck.getFllStatus().getSeverity().lessThan(Severity.WARNING));
system_mcgfllclk_clockVar.enable(fllInputIsOK);
system_mcgfllclk_clockVar.setStatus(fllCheck.getFllStatus());
} else {
system_mcgfllclk_clockVar.enable(false);
system_mcgfllclk_clockVar.setStatus(new Status("FLL is disabled", Severity.WARNING));
}
mcg_c4_dmx32Var.enable(fllEnabled);
mcg_c4_drst_drsVar.enable(fllEnabled);
// Main clock mode
// ===============================
Status clock_mode_Status = null;
switch(clock_mode) {
default:
case ClockMode_None:
system_mcgoutclk_clockVar.setValue(system_mcgfllclk_clockVar.getValueAsLong());
system_mcgoutclk_clockVar.setOrigin(system_mcgfllclk_clockVar.getOrigin());
system_mcgoutclk_clockVar.setStatus((Status) null);
clock_mode_Status = new Status("No clock settings are applied", Severity.WARNING);
break;
case ClockMode_FEI:
system_mcgoutclk_clockVar.setValue(system_mcgfllclk_clockVar.getValueAsLong());
system_mcgoutclk_clockVar.setOrigin(system_mcgfllclk_clockVar.getOrigin());
system_mcgoutclk_clockVar.setStatus(system_mcgfllclk_clockVar.getFilteredStatus());
break;
case ClockMode_FEE:
system_mcgoutclk_clockVar.setValue(system_mcgfllclk_clockVar.getValueAsLong());
system_mcgoutclk_clockVar.setOrigin(system_mcgfllclk_clockVar.getOrigin());
system_mcgoutclk_clockVar.setStatus(system_mcgfllclk_clockVar.getFilteredStatus());
break;
case ClockMode_FBI:
system_mcgoutclk_clockVar.setValue(system_mcgir_ungated_clock.getValueAsLong());
system_mcgoutclk_clockVar.setOrigin(system_mcgir_ungated_clock.getOrigin());
system_mcgoutclk_clockVar.setStatus(system_mcgir_ungated_clock.getFilteredStatus());
break;
case ClockMode_FBE:
system_mcgoutclk_clockVar.setValue(mcg_erc_clockVar.getValueAsLong());
system_mcgoutclk_clockVar.setOrigin(mcg_erc_clockVar.getOrigin());
system_mcgoutclk_clockVar.setStatus(mcg_erc_clockVar.getFilteredStatus());
break;
case ClockMode_BLPI:
system_mcgoutclk_clockVar.setValue(system_mcgir_ungated_clock.getValueAsLong());
system_mcgoutclk_clockVar.setOrigin(system_mcgir_ungated_clock.getOrigin());
system_mcgoutclk_clockVar.setStatus(system_mcgir_ungated_clock.getFilteredStatus());
break;
case ClockMode_BLPE:
system_mcgoutclk_clockVar.setValue(mcg_erc_clockVar.getValueAsLong());
system_mcgoutclk_clockVar.setOrigin(mcg_erc_clockVar.getOrigin());
system_mcgoutclk_clockVar.setStatus(mcg_erc_clockVar.getFilteredStatus());
break;
case ClockMode_PBE:
system_mcgoutclk_clockVar.setValue(mcg_erc_clockVar.getValueAsLong());
system_mcgoutclk_clockVar.setOrigin(mcg_erc_clockVar.getOrigin());
system_mcgoutclk_clockVar.setStatus(mcg_erc_clockVar.getFilteredStatus());
break;
case ClockMode_PEE:
system_mcgoutclk_clockVar.setValue(system_mcgpllclk_clockVar.getValueAsLong());
system_mcgoutclk_clockVar.setOrigin(system_mcgpllclk_clockVar.getOrigin());
system_mcgoutclk_clockVar.setStatus(system_mcgpllclk_clockVar.getFilteredStatus());
break;
}
system_mcgoutclk_clock_sourceVar.setStatus(clock_mode_Status);
system_mcgoutclk_clock_sourceVar.setOrigin(system_mcgoutclk_clockVar.getOrigin());
}
use of net.sourceforge.usbdm.deviceEditor.model.Status in project usbdm-eclipse-plugins by podonoghue.
the class Variable method getDisplayToolTip.
/**
* Get tool tip.<br>
* This will be constructed from:
* <li>Status e.g. warning etc. {@link #setStatus(Status)}
* <li>Explicitly set Tooltip {@link #setToolTip(String)}
* <li>Origin {@link #setOrigin(String origin)})
*
* @return String
*/
public String getDisplayToolTip() {
StringBuilder sb = new StringBuilder();
Status status = getStatus();
if (status != null) {
if (status.greaterThan(Status.Severity.WARNING)) {
sb.append(status.getText());
} else if (status != null) {
sb.append(status.getSimpleText());
}
}
if (fToolTip != null) {
if (sb.length() != 0) {
sb.append('\n');
}
sb.append(fToolTip);
}
if (fOrigin != null) {
if (sb.length() != 0) {
sb.append('\n');
}
sb.append("Origin: ");
sb.append(fOrigin);
}
return (sb.length() == 0) ? null : sb.toString();
}
use of net.sourceforge.usbdm.deviceEditor.model.Status in project usbdm-eclipse-plugins by podonoghue.
the class MappingInfo method setMessage.
/**
* Set message to display
*
* @return Message to display
*/
public void setMessage(String msg) {
Status message = null;
if (msg.isEmpty()) {
msg = null;
}
if (msg == null) {
if (fMessage == null) {
return;
}
} else {
message = new Status(msg, Status.Severity.ERROR);
if (message.equals(fMessage)) {
return;
}
}
fMessage = message;
notifyStatusListeners();
}
Aggregations