use of net.sourceforge.usbdm.deviceEditor.information.MappingInfo in project usbdm-eclipse-plugins by podonoghue.
the class ModelFactory method checkConflictsJob.
/**
* Check for mapping conflicts
*
* <li>Multiple signals mapped to a single pin
* <li>Signals mapped to multiple pins
*/
private void checkConflictsJob() {
// System.err.println("checkConflictsJob()");
testAndSetConflictCheckPending(false);
/**
* Used to check for multiple mappings to a single pin
*/
Map<String, List<MappingInfo>> mappedSignalsByPin = new HashMap<String, List<MappingInfo>>();
/**
* Used to check for a signal being mapped to multiple pins
*/
Map<String, List<MappingInfo>> mappedPinsBySignal = new HashMap<String, List<MappingInfo>>();
for (MappingInfo mapping : fPinModel.getMappingInfos()) {
mapping.setMessage("");
if (!mapping.isSelected()) {
continue;
}
/*
* Check for multiple Signals => Pin
*/
List<MappingInfo> signalsMappedToPin = addToMap(mappedSignalsByPin, mapping, mapping.getPin().getName());
if (signalsMappedToPin != null) {
// Signal previously mapped to this pin
// Check if any conflicts between new signal mapping and existing ones
// Note - Multiple signals may be mapped to the same pin without conflict
// since some signals share a mapping.
// Need to check the signalLists not the signals
boolean conflicting = false;
StringBuffer sb = null;
for (MappingInfo other : signalsMappedToPin) {
// Check for conflicts
if (!mapping.getSignalList().equals(other.getSignalList())) {
// Not shared port mapping
conflicting = true;
}
}
if (conflicting) {
// Construct conflict message
for (MappingInfo other : signalsMappedToPin) {
if (sb == null) {
sb = new StringBuffer();
sb.append("Error: (");
} else {
sb.append(", ");
}
sb.append(other.getSignalList());
sb.append("@" + other.getMux().name());
}
sb.append(") =>> ");
sb.append(mapping.getPin().getName());
sb.append("\nPin mapped to multiple signals");
// Mark all conflicting nodes
for (MappingInfo other : signalsMappedToPin) {
other.setMessage(sb.toString());
}
}
}
/*
* Check for Signal => multiple Pins
*/
List<MappingInfo> pinsMappedToSignal = addToMap(mappedPinsBySignal, mapping, mapping.getSignalList());
// System.err.println("checkConflictsJob(): " + mapping);
if (pinsMappedToSignal != null) {
// Pins previously mapped to this signal
// Construct conflict message
StringBuffer sb = null;
for (MappingInfo other : pinsMappedToSignal) {
if (sb == null) {
sb = new StringBuffer();
sb.append(mapping.getSignalList() + " =>> (");
} else {
sb.append(", ");
}
sb.append(other.getPin().getName());
}
// Multiple signals mapped to pin
sb.append(")");
sb.append("\nSignal mapped to multiple pins");
// Mark all conflicting nodes
for (MappingInfo other : pinsMappedToSignal) {
other.setMessage(sb.toString());
}
}
}
for (IPage model : fModels) {
model.updatePage();
}
}
use of net.sourceforge.usbdm.deviceEditor.information.MappingInfo in project usbdm-eclipse-plugins by podonoghue.
the class SignalModel method getStatus.
/**
* Get Message for model
*
* May return an error message from the pin mapping instead.
*/
@Override
Status getStatus() {
Status rv = null;
MappingInfo currentMapping = fSignal.getMappedPin();
if (currentMapping != null) {
rv = currentMapping.getMessage();
}
if (rv != null) {
return rv;
}
return super.getStatus();
}
use of net.sourceforge.usbdm.deviceEditor.information.MappingInfo 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);
}
Aggregations