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);
}
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");
}
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<4>;
* using adc_p54 = const USBDM::Adc1<5>;
* </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();
}
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();
}
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;
}
Aggregations