Search in sources :

Example 1 with DevicePackage

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 + ") ");
    }
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) DevicePackage(net.sourceforge.usbdm.deviceEditor.information.DevicePackage) UsbdmException(net.sourceforge.usbdm.jni.UsbdmException) IOException(java.io.IOException) MuxSelection(net.sourceforge.usbdm.deviceEditor.information.MuxSelection) Signal(net.sourceforge.usbdm.deviceEditor.information.Signal) Pin(net.sourceforge.usbdm.deviceEditor.information.Pin) MappingInfo(net.sourceforge.usbdm.deviceEditor.information.MappingInfo)

Example 2 with DevicePackage

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();
}
Also used : Pin(net.sourceforge.usbdm.deviceEditor.information.Pin) DevicePackage(net.sourceforge.usbdm.deviceEditor.information.DevicePackage) DeviceVariantInformation(net.sourceforge.usbdm.deviceEditor.information.DeviceVariantInformation)

Example 3 with DevicePackage

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>
 * &ltpackages&gt;
 *    &ltpackage name="BGA_121"&gt;
 *       &lt;placement pin="ADC0_DM0"      location="K2" /&gt;
 *       &lt;placement pin="ADC0_DP0"      location="K1" /&gt;
 *       ...
 *    &lt/package&gt;
 *    ...
 * &lt/packages&gt;
 * </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();
}
Also used : DevicePackage(net.sourceforge.usbdm.deviceEditor.information.DevicePackage)

Example 4 with DevicePackage

use of net.sourceforge.usbdm.deviceEditor.information.DevicePackage in project usbdm-eclipse-plugins by podonoghue.

the class ParseFamilyXML method parsePackage.

/**
 * Parse &lt;package&gt;
 *
 * @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() + "\'");
        }
    }
}
Also used : Pin(net.sourceforge.usbdm.deviceEditor.information.Pin) Node(org.w3c.dom.Node) Element(org.w3c.dom.Element) DevicePackage(net.sourceforge.usbdm.deviceEditor.information.DevicePackage)

Aggregations

DevicePackage (net.sourceforge.usbdm.deviceEditor.information.DevicePackage)4 Pin (net.sourceforge.usbdm.deviceEditor.information.Pin)3 IOException (java.io.IOException)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 DeviceVariantInformation (net.sourceforge.usbdm.deviceEditor.information.DeviceVariantInformation)1 MappingInfo (net.sourceforge.usbdm.deviceEditor.information.MappingInfo)1 MuxSelection (net.sourceforge.usbdm.deviceEditor.information.MuxSelection)1 Signal (net.sourceforge.usbdm.deviceEditor.information.Signal)1 UsbdmException (net.sourceforge.usbdm.jni.UsbdmException)1 Element (org.w3c.dom.Element)1 Node (org.w3c.dom.Node)1