use of net.sourceforge.usbdm.deviceEditor.information.Signal in project usbdm-eclipse-plugins by podonoghue.
the class LlwuValidate method doPinNames.
/**
* Extract pin names and create LLWU pin and peripheral C enum tables.<br>
* The description for pins is also annotated with the pin number found or (Reserved)<br>
*
* Tables are added to the following Peripheral Variables:
* <li>LlwuPins
* <li>LlwuPeripherals
*/
private void doPinNames() {
final String RESERVED = "Reserved";
if (donePinNames) {
return;
}
donePinNames = true;
StringBuilder sb = new StringBuilder();
sb.append("/**\n" + " * LLWU pin sources\n" + " */\n" + "enum LlwuPin : uint32_t {\n");
InfoTable pinTable = getPeripheral().getSignalTables().get(0);
for (int index = 0; index < 32; index++) {
String choiceName = "llwu_pe" + ((index / 4) + 1) + "_wupe" + index;
ChoiceVariable choiceVar = safeGetChoiceVariable(choiceName);
if (choiceVar == null) {
continue;
}
String llwuPinName;
if (index >= pinTable.table.size()) {
// Pin not in table (doesn't exist)
choiceVar.enable(false);
llwuPinName = RESERVED;
} else {
// Look up possible pin mapping in table
Signal signal = pinTable.table.elementAt(index);
Pin mappablePin = null;
if (signal != null) {
TreeSet<MappingInfo> pinMappings = signal.getPinMapping();
for (MappingInfo pinMapping : pinMappings) {
if (pinMapping.getMux() == MuxSelection.mux1) {
mappablePin = pinMapping.getPin();
}
}
}
if (mappablePin == null) {
// No mappable pin
choiceVar.enable(false);
llwuPinName = RESERVED;
} else {
// Mappable pin
choiceVar.enable(true);
llwuPinName = mappablePin.getName();
}
}
if (llwuPinName != RESERVED) {
String llwuPinLine = String.format(" LlwuPin_%-15s = %2d, //!< Wake-up pin LLWU_P%d\n", capitalCase(llwuPinName), index, index);
sb.append(llwuPinLine);
}
choiceVar.setDescription(choiceVar.getDescription() + " - " + llwuPinName);
}
sb.append("};\n\n");
StringVariable llwuPinsVar = new StringVariable("LlwuPins", getPeripheral().makeKey("LlwuPins"));
llwuPinsVar.setValue(sb.toString());
llwuPinsVar.setDerived(true);
getPeripheral().addVariable(llwuPinsVar);
sb = new StringBuilder();
sb.append("/**\n" + " * LLWU peripheral sources\n" + " */\n" + "enum LlwuPeripheral : uint32_t {\n");
for (int index = 0; index <= 7; index++) {
String choiceName = "llwu_me_wume" + index;
BooleanVariable choiceVar = safeGetBooleanVariable(choiceName);
String llwuPeripheralName;
if (choiceVar != null) {
llwuPeripheralName = choiceVar.getDescription();
String llwuPeripheralLine = String.format(" LlwuPeripheral_%-15s = (1<<%d), //!< Wake-up peripheral LLWU_M%dIF\n", capitalCase(llwuPeripheralName), index, index);
sb.append(llwuPeripheralLine);
}
}
sb.append("};\n\n");
StringVariable llwuPeripheralsVar = new StringVariable("LlwuPeripherals", getPeripheral().makeKey("LlwuPeripherals"));
llwuPeripheralsVar.setValue(sb.toString());
llwuPeripheralsVar.setDerived(true);
getPeripheral().addVariable(llwuPeripheralsVar);
}
use of net.sourceforge.usbdm.deviceEditor.information.Signal in project usbdm-eclipse-plugins by podonoghue.
the class PeripheralValidator method validateMappedPins.
/**
* Checks if signals are mapped to pins<br>
* If not then a warning is attached to pins category
*
* @param requiredSignals Array of required signals as index into the signal table
* @param table Peripheral signal table to use
*
* @throws Exception
*/
protected void validateMappedPins(int[] requiredSignals, Vector<Signal> table) throws Exception {
CategoryModel pinModel = getPeripheral().getPinModel();
Status unmappedSignals = null;
for (int pinNum : requiredSignals) {
Signal signal = table.get(pinNum);
if ((signal == null) || (signal.getMappedPin().getPin() == Pin.UNASSIGNED_PIN)) {
unmappedSignals = UNMAPPED_PIN_STATUS;
break;
}
}
pinModel.setStatus(unmappedSignals);
pinModel.update();
}
Aggregations