use of net.sourceforge.usbdm.deviceEditor.information.DevicePackage in project usbdm-eclipse-plugins by podonoghue.
the class ParseFamilyCSV method parsePinLine.
/**
* Parse line containing Pin information
*
* @param line
* @throws Exception
*/
private void parsePinLine(String[] line) throws Exception {
StringBuffer sb = new StringBuffer();
if (!line[0].equals("Pin")) {
return;
}
String pinName = line[fPinIndex];
if ((pinName == null) || (pinName.isEmpty())) {
throw new Exception("No pin name");
}
pinName = fixSignalName(pinName);
// Use first name on pin as Pin name e.g. PTC4/LLWU_P8 => PTC4
Pattern p = Pattern.compile("(.+?)/.*");
Matcher m = p.matcher(pinName);
if (m.matches()) {
pinName = m.group(1);
}
final Pin pin = fDeviceInfo.createPin(pinName);
sb.append(String.format("%-10s => ", pin.getName()));
boolean pinIsMapped = false;
for (int col = fAltStartIndex; col <= fAltEndIndex; col++) {
if (col >= line.length) {
break;
}
ArrayList<Signal> signals = createSignalsFromString(line[col], true);
for (Signal signal : signals) {
sb.append(signal.getName() + ", ");
if ((signal != null)) {
MuxSelection muxValue = MuxSelection.valueOf(col - fAltStartIndex);
fDeviceInfo.createMapping(signal, pin, muxValue);
pinIsMapped = true;
}
}
}
if ((line.length > fResetIndex) && (line[fResetIndex] != null) && (!line[fResetIndex].isEmpty())) {
String resetName = line[fResetIndex];
ArrayList<Signal> resetSignals = createSignalsFromString(resetName, true);
if (!pinIsMapped) {
for (Signal resetSignal : resetSignals) {
sb.append("R:" + resetSignal.getName() + ", ");
// Pin is not mapped to this signal in the ALT columns - must be a non-mappable pin
MappingInfo mapping = fDeviceInfo.createMapping(resetSignal, pin, MuxSelection.fixed);
for (Signal signal : mapping.getSignals()) {
signal.setResetPin(mapping);
}
}
}
pin.setResetSignals(fDeviceInfo, resetName);
} else {
sb.append("R:" + Signal.DISABLED_SIGNAL.getName() + ", ");
fDeviceInfo.createMapping(Signal.DISABLED_SIGNAL, pin, MuxSelection.unassigned);
pin.setResetSignals(fDeviceInfo, Signal.DISABLED_SIGNAL.getName());
}
for (PackageColumnInfo pkgIndex : fPackageIndexes) {
String pinNum = line[pkgIndex.index];
if (pinNum.equals("*")) {
continue;
}
DevicePackage devicePackage = fDeviceInfo.findDevicePackage(pkgIndex.name);
if (devicePackage == null) {
throw new RuntimeException("Failed to find package " + pkgIndex.name + ", for " + pinName);
}
devicePackage.addPin(pin, pinNum);
sb.append("(" + pkgIndex.name + ":" + pinNum + ") ");
}
}
use of net.sourceforge.usbdm.deviceEditor.information.DevicePackage in project usbdm-eclipse-plugins by podonoghue.
the class TestParseXML method report.
static void report(DeviceInfo deviceInfo) {
for (String key : deviceInfo.getDeviceVariants().keySet()) {
DeviceVariantInformation deviceInformation = deviceInfo.findVariant(key);
System.err.println("deviceInformation = " + deviceInformation);
}
for (String packageName : deviceInfo.getDevicePackages().keySet()) {
DevicePackage devicePackage = deviceInfo.findDevicePackage(packageName);
System.err.println("Package = " + devicePackage);
for (String pinName : devicePackage.getPins().keySet()) {
String location = devicePackage.getLocation(pinName);
System.err.print(pinName + " => " + location + ", ");
}
System.err.println();
}
for (String pinName : deviceInfo.getPins().keySet()) {
Pin pin = deviceInfo.findPin(pinName);
System.err.print("Pin = " + pin.getName() + ", ");
}
;
System.err.println();
for (String peripheralName : deviceInfo.getPeripheralNames()) {
System.err.print("Peripheral = " + peripheralName + ", ");
}
;
System.err.println();
for (String signals : deviceInfo.getSignals().keySet()) {
System.err.print("Signal = " + signals + ", ");
}
;
System.err.println();
}
use of net.sourceforge.usbdm.deviceEditor.information.DevicePackage in project usbdm-eclipse-plugins by podonoghue.
the class FamilyXmlWriter method writePackages.
/**
* Writes XML describing how pins are mapped to package locations
*
* e.g.<pre>
* <packages>
* <package name="BGA_121">
* <placement pin="ADC0_DM0" location="K2" />
* <placement pin="ADC0_DP0" location="K1" />
* ...
* </package>
* ...
* </packages>
* </pre>
*
* @param documentUtilities Where to write
* @throws IOException
*/
private void writePackages(XmlDocumentUtilities documentUtilities) throws IOException {
documentUtilities.openTag("packages");
for (String packageName : fDeviceInfo.getDevicePackages().keySet()) {
documentUtilities.openTag("package");
documentUtilities.writeAttribute("name", packageName);
DevicePackage pkg = fDeviceInfo.findDevicePackage(packageName);
for (String pinName : pkg.getPins().keySet()) {
documentUtilities.openTag("placement");
String location = pkg.getLocation(pinName);
documentUtilities.writeAttribute("pin", pinName);
documentUtilities.writeAttribute("location", location);
documentUtilities.closeTag();
}
documentUtilities.closeTag();
}
documentUtilities.closeTag();
}
use of net.sourceforge.usbdm.deviceEditor.information.DevicePackage in project usbdm-eclipse-plugins by podonoghue.
the class ParseFamilyXML method parsePackage.
/**
* Parse <package>
*
* @param packageElement
* @throws Exception
*/
private void parsePackage(Element packageElement) throws Exception {
String packageName = packageElement.getAttribute("name");
for (Node node = packageElement.getFirstChild(); node != null; node = node.getNextSibling()) {
if (node.getNodeType() != Node.ELEMENT_NODE) {
continue;
}
Element element = (Element) node;
if (element.getTagName() == "placement") {
Pin pin = fDeviceInfo.findPin(element.getAttribute("pin"));
String location = element.getAttribute("location");
DevicePackage devicePackage = fDeviceInfo.findDevicePackage(packageName);
devicePackage.addPin(pin, location);
} else {
throw new Exception("Unexpected field in PACKAGE, value = \'" + element.getTagName() + "\'");
}
}
}
Aggregations