Search in sources :

Example 1 with Peripheral

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

the class ParseMenuXML method parseSignalsOption.

/**
 * Parse the pin associated with the peripheral
 *
 * @param parentModel
 * @param element
 * @throws UsbdmException
 */
private void parseSignalsOption(BaseModel parentModel, Element element) throws UsbdmException {
    // Initially assume pins refer to current peripheral
    Peripheral peripheral = fPeripheral;
    boolean optional = Boolean.valueOf(element.getAttribute("optional"));
    String peripheralName = element.getAttribute("name");
    if (!peripheralName.isEmpty()) {
        // Change to referenced peripheral
        peripheral = fPeripheral.getDeviceInfo().getPeripherals().get(peripheralName);
    }
    if (peripheral == null) {
        if (!optional) {
            throw new UsbdmException("Unable to find peripheral '" + peripheralName + "' for pins");
        }
        return;
    }
    fPeripheral.addSignals(parentModel, peripheral);
}
Also used : Peripheral(net.sourceforge.usbdm.deviceEditor.information.Peripheral) UsbdmException(net.sourceforge.usbdm.jni.UsbdmException)

Example 2 with Peripheral

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

the class WriteFamilyCpp method writePortInfo.

/**
 * Write Port information
 *
 * <pre>
 * constexpr PortInfo  __attribute__((unused)) PortAInfo {PORTA_BasePtr, PORTA_CLOCK_MASK, PORTA_IRQn};
 * </pre>
 *
 * @param writer
 * @throws IOException
 */
private void writePortInfo(DocumentUtilities writer) throws IOException {
    writer.write("");
    writer.write("/** Dummy port information for pins without an associated PCR */\n");
    writer.write("constexpr PortInfo  __attribute__((unused)) NoPortInfo {0, 0, (IRQn_Type)-1};\n\n");
    String[] portClasses = { "GPIOA", "GPIOB", "GPIOC", "GPIOD", "GPIOE", "GPIOF", "GPIOG" };
    for (String key : portClasses) {
        Peripheral peripheral = fDeviceInfo.getPeripherals().get(key);
        if (peripheral != null) {
            String irqNum = "(IRQn_Type)-1";
            if (peripheral.getIrqCount() > 0) {
                irqNum = peripheral.getIrqNums().get(0);
            }
            String instanceName = peripheral.getInstance();
            writer.write(String.format("/** Port information for PORT%s*/\n", instanceName));
            writer.write(String.format("constexpr PortInfo  __attribute__((unused)) Port%sInfo {PORT%s_BasePtr, PORT%s_CLOCK_MASK, %s};\n\n", instanceName, instanceName, instanceName, irqNum));
        }
    }
    writer.write("\n");
}
Also used : Peripheral(net.sourceforge.usbdm.deviceEditor.information.Peripheral)

Example 3 with Peripheral

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

the class WriteFamilyCpp method writeMappedSignals.

/**
 * Write declarations for simple peripheral signals (e.g. GPIO,ADC,PWM) that
 * are mapped to pins e.g.
 *
 * <pre>
 *    using adc_p53              = const USBDM::Adc1&lt;4&gt;;
 *    using adc_p54              = const USBDM::Adc1&lt;5&gt;;
 * </pre>
 *
 * @param writer
 *           Where to write
 *
 * @throws Exception
 */
private void writeMappedSignals(DocumentUtilities writer) throws IOException {
    writeIncludes(writer);
    writer.writeOpenNamespace(DeviceInfo.NAME_SPACE, "Namespace enclosing USBDM classes");
    writer.openUsbdmDocumentationGroup();
    DocumentationGroups startGroup = new DocumentationGroups(writer);
    for (String key : fDeviceInfo.getPeripherals().keySet()) {
        Peripheral peripheral = fDeviceInfo.getPeripherals().get(key);
        for (Entry<String, Pin> pinEntry : fDeviceInfo.getPins().entrySet()) {
            Pin pin = pinEntry.getValue();
            Map<MuxSelection, MappingInfo> mappedSignals = pin.getMappableSignals();
            if (mappedSignals == null) {
                continue;
            }
            for (Entry<MuxSelection, MappingInfo> muxEntry : mappedSignals.entrySet()) {
                if (muxEntry.getKey() == MuxSelection.unassigned) {
                    continue;
                }
                MappingInfo mappedSignal = muxEntry.getValue();
                for (int fnIndex = 0; fnIndex < mappedSignal.getSignals().size(); fnIndex++) {
                    Signal function = mappedSignal.getSignals().get(fnIndex);
                    if (function.getPeripheral() == peripheral) {
                        String template = getMappedSignals(peripheral, mappedSignal, fnIndex);
                        if (template != null) {
                            startGroup.openGroup(peripheral);
                            writer.write(template);
                            writer.flush();
                        }
                    }
                }
            }
        }
    }
    startGroup.closeGroup();
    writer.writeDocBanner("Used to configure pin-mapping before 1st use of peripherals");
    writer.write("extern void " + DO_PIN_MAPPING_FUNCTION + "();\n");
    writer.closeDocumentationGroup();
    writer.writeCloseNamespace();
    writer.flush();
}
Also used : MuxSelection(net.sourceforge.usbdm.deviceEditor.information.MuxSelection) Signal(net.sourceforge.usbdm.deviceEditor.information.Signal) Peripheral(net.sourceforge.usbdm.deviceEditor.information.Peripheral) Pin(net.sourceforge.usbdm.deviceEditor.information.Pin) MappingInfo(net.sourceforge.usbdm.deviceEditor.information.MappingInfo)

Example 4 with Peripheral

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

the class FamilyXmlWriter method writePeripherals.

/**
 * Write XML for peripherals
 *
 * @param documentUtilities
 * @throws IOException
 * @throws UsbdmException
 */
void writePeripherals(XmlDocumentUtilities documentUtilities) throws IOException, UsbdmException {
    documentUtilities.openTag("peripherals");
    for (String key : fDeviceInfo.getPeripherals().keySet()) {
        Peripheral peripheral = fDeviceInfo.getPeripherals().get(key);
        peripheral.writeXmlInformation(documentUtilities);
    }
    documentUtilities.closeTag();
}
Also used : Peripheral(net.sourceforge.usbdm.deviceEditor.information.Peripheral)

Example 5 with Peripheral

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

the class ParseFamilyCSV method createSignalsFromString.

/**
 * Create a list of signals described by a string
 *
 * @param pinText Text of signal names e.g. <b><i>PTA4/LLWU_P3</b></i>
 *
 * @return List of signals created
 *
 * @throws Exception
 */
private ArrayList<Signal> createSignalsFromString(String pinText, Boolean convert) {
    ArrayList<Signal> signalList = new ArrayList<Signal>();
    pinText = pinText.trim();
    if (pinText.isEmpty()) {
        return signalList;
    }
    String[] signalNames = pinText.split("\\s*/\\s*");
    for (String signalName : signalNames) {
        signalName = signalName.trim();
        signalName = fixSignalName(signalName);
        if (signalName.isEmpty()) {
            continue;
        }
        if (convert) {
            signalName = convertName(signalName);
        }
        Signal signal = fDeviceInfo.findOrCreateSignal(signalName);
        if (signal != null) {
            // XXX Log creating signals
            // System.err.println("Added "+signalName+" to "+signal.getPeripheral());
            signalList.add(signal);
            if (signal != Signal.DISABLED_SIGNAL) {
                Peripheral x = signal.getPeripheral();
                if ((x == null) || x.getClass().equals(WriterForNull.class)) {
                    System.err.println("Signal \'" + signalName + "\' added to WriterForNull");
                }
            }
        } else {
            System.err.println("Signal not found for " + signalName);
        }
    }
    return signalList;
}
Also used : Signal(net.sourceforge.usbdm.deviceEditor.information.Signal) Peripheral(net.sourceforge.usbdm.deviceEditor.information.Peripheral) ArrayList(java.util.ArrayList)

Aggregations

Peripheral (net.sourceforge.usbdm.deviceEditor.information.Peripheral)9 ArrayList (java.util.ArrayList)2 Matcher (java.util.regex.Matcher)2 Pattern (java.util.regex.Pattern)2 Signal (net.sourceforge.usbdm.deviceEditor.information.Signal)2 UsbdmException (net.sourceforge.usbdm.jni.UsbdmException)2 BufferedReader (java.io.BufferedReader)1 MappingInfo (net.sourceforge.usbdm.deviceEditor.information.MappingInfo)1 MuxSelection (net.sourceforge.usbdm.deviceEditor.information.MuxSelection)1 Pin (net.sourceforge.usbdm.deviceEditor.information.Pin)1 StringVariable (net.sourceforge.usbdm.deviceEditor.information.StringVariable)1 PeripheralWithState (net.sourceforge.usbdm.deviceEditor.peripherals.PeripheralWithState)1 DevicePeripherals (net.sourceforge.usbdm.peripheralDatabase.DevicePeripherals)1 InterruptEntry (net.sourceforge.usbdm.peripheralDatabase.InterruptEntry)1 Element (org.w3c.dom.Element)1 Node (org.w3c.dom.Node)1