Search in sources :

Example 6 with DevicePeripherals

use of net.sourceforge.usbdm.peripheralDatabase.DevicePeripherals in project usbdm-eclipse-plugins by podonoghue.

the class UsbdmPeripheralDescriptionProvider method main.

public static void main(String[] args) throws Exception {
    UsbdmPeripheralDescriptionProvider provider = new UsbdmPeripheralDescriptionProvider();
    Vector<String> fileNames = provider.getDeviceNames();
    for (String s : fileNames) {
        System.err.println("Name = " + s);
    }
    DevicePeripherals devicePeripherals = provider.getDevicePeripherals("LPC11Uxx");
    System.err.println(devicePeripherals);
}
Also used : DevicePeripherals(net.sourceforge.usbdm.peripheralDatabase.DevicePeripherals)

Example 7 with DevicePeripherals

use of net.sourceforge.usbdm.peripheralDatabase.DevicePeripherals in project usbdm-eclipse-plugins by podonoghue.

the class CreatePeripheralDatabase method mergeFiles.

static void mergeFiles(Path svdSourceFolderPath, final DirectoryStream.Filter<Path> directoryFilter, PeripheralDatabaseMerger merger) throws Exception {
    FileFilter fileFilter = new FileFilter(firstFileToProcess, firstFileToReject);
    Pattern rejectPattern = null;
    if (filesToReject != null) {
        rejectPattern = Pattern.compile(filesToReject);
    }
    int deviceCount = 500;
    DirectoryStream<Path> svdSourceFolderStream = Files.newDirectoryStream(svdSourceFolderPath.toAbsolutePath(), directoryFilter);
    for (Path filePath : svdSourceFolderStream) {
        if (deviceCount-- == 0) {
            break;
        }
        if (Files.isRegularFile(filePath)) {
            String fileName = filePath.getFileName().toString();
            if (fileFilter.skipFile(fileName)) {
                continue;
            }
            if ((rejectPattern != null) && rejectPattern.matcher(fileName).matches()) {
                continue;
            }
            if (fileName.endsWith(".svd.xml")) {
                System.err.println("Merging SVD file : \"" + filePath.toString() + "\"");
                // Read device peripheral database
                DevicePeripherals devicePeripherals = new DevicePeripherals(filePath);
                devicePeripherals.optimise();
                // Create merged SVD file
                merger.writeDeviceToSVD(devicePeripherals);
            }
        }
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(java.nio.file.Path) Pattern(java.util.regex.Pattern) DevicePeripherals(net.sourceforge.usbdm.peripheralDatabase.DevicePeripherals)

Example 8 with DevicePeripherals

use of net.sourceforge.usbdm.peripheralDatabase.DevicePeripherals in project usbdm-eclipse-plugins by podonoghue.

the class CreateDeviceEditorSkeleton method getPeripherals.

public static Map<String, String> getPeripherals(String name) {
    final Path path = Paths.get("C:/Users/podonoghue/Documents/Development/USBDM/usbdm-eclipse-makefiles-build/PackageFiles/Stationery/Device.SVD/Internal/");
    HashMap<String, String> map = new HashMap<String, String>();
    SVDIdentifier svdId = new SVDIdentifier(path.resolve(name));
    DevicePeripherals devicePeripherals;
    try {
        devicePeripherals = svdId.getDevicePeripherals();
        for (Peripheral peripheral : devicePeripherals.getPeripherals()) {
            String filename;
            String pName = peripheral.getName();
            while (peripheral.getDerivedFrom() != null) {
                peripheral = peripheral.getDerivedFrom();
            }
            filename = peripheral.getSourceFilename();
            // System.err.println(String.format("Peripheral %-20s %-20s", pName, filename));
            map.put(pName, filename.toLowerCase());
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return map;
}
Also used : Path(java.nio.file.Path) Peripheral(net.sourceforge.usbdm.peripheralDatabase.Peripheral) HashMap(java.util.HashMap) DevicePeripherals(net.sourceforge.usbdm.peripheralDatabase.DevicePeripherals) SVDIdentifier(net.sourceforge.usbdm.peripheralDatabase.SVDIdentifier)

Example 9 with DevicePeripherals

use of net.sourceforge.usbdm.peripheralDatabase.DevicePeripherals in project usbdm-eclipse-plugins by podonoghue.

the class UsbdmDeviceSelectionPage_2 method getDevicePeripherals.

DevicePeripherals getDevicePeripherals(final Device device) {
    DevicePeripheralsFactory factory = new DevicePeripheralsFactory();
    DevicePeripherals devicePeripherals = factory.getDevicePeripherals(device.getName());
    if (devicePeripherals == null) {
        devicePeripherals = factory.getDevicePeripherals(device.getSubFamily());
    }
    return devicePeripherals;
}
Also used : DevicePeripherals(net.sourceforge.usbdm.peripheralDatabase.DevicePeripherals) DevicePeripheralsFactory(net.sourceforge.usbdm.peripheralDatabase.DevicePeripheralsFactory)

Example 10 with DevicePeripherals

use of net.sourceforge.usbdm.peripheralDatabase.DevicePeripherals in project usbdm-eclipse-plugins by podonoghue.

the class UsbdmDevicePeripheralsModel method loadDeviceModel.

/**
 * Creates the tree entries for a device's peripherals
 *
 * @param deviceModel               Model to load into
 * @param svdId                     Identifies device peripherals to be loaded into model
 * @param gdbInterface              GDB interface to associate with model
 *
 * @throws IllegalArgumentException
 * @throws RegisterException
 */
public static void loadDeviceModel(DeviceModel deviceModel, SVDIdentifier svdId, GdbCommonInterface gdbInterface) throws IllegalArgumentException, RegisterException {
    deviceModel.fChildren.clear();
    if ((svdId == null) || !svdId.isValid()) {
        deviceModel.setName("No device loaded");
        throw new IllegalArgumentException("svdId is null or invalid: " + svdId.toString());
    }
    DevicePeripherals devicePeripherals = null;
    try {
        devicePeripherals = svdId.getDevicePeripherals();
    } catch (Exception e) {
        // Must be valid
        e.printStackTrace();
    }
    deviceModel.setName(devicePeripherals.getName());
    if (gdbInterface != null) {
        gdbInterface.setLittleEndian(devicePeripherals.getCpu().getEndian().equalsIgnoreCase("little"));
    }
    String cpuName = devicePeripherals.getCpu().getName();
    if (cpuName.startsWith("CM")) {
        deviceModel.setInterfaceType(InterfaceType.T_ARM);
    } else if (cpuName.startsWith("CFV1")) {
        deviceModel.setInterfaceType(InterfaceType.T_CFV1);
    } else if (cpuName.startsWith("CFV2") || cpuName.startsWith("CFV3") || cpuName.startsWith("CFV4")) {
        deviceModel.setInterfaceType(InterfaceType.T_CFVX);
    } else {
        throw new IllegalArgumentException("unexpected value from devicePeripherals.getCpu().getName()");
    }
    // Add the peripherals
    for (Peripheral peripheral : devicePeripherals.getPeripherals()) {
        if (isExcludedPeripheral(peripheral.getName())) {
            continue;
        }
        createPeripheralModel(deviceModel, peripheral, gdbInterface);
    }
}
Also used : Peripheral(net.sourceforge.usbdm.peripheralDatabase.Peripheral) DevicePeripherals(net.sourceforge.usbdm.peripheralDatabase.DevicePeripherals) RegisterException(net.sourceforge.usbdm.peripheralDatabase.RegisterException)

Aggregations

DevicePeripherals (net.sourceforge.usbdm.peripheralDatabase.DevicePeripherals)17 Path (java.nio.file.Path)8 IPath (org.eclipse.core.runtime.IPath)5 DevicePeripheralsFactory (net.sourceforge.usbdm.peripheralDatabase.DevicePeripheralsFactory)4 IOException (java.io.IOException)3 PrintWriter (java.io.PrintWriter)2 HashMap (java.util.HashMap)2 Pattern (java.util.regex.Pattern)2 PeripheralWithState (net.sourceforge.usbdm.deviceEditor.peripherals.PeripheralWithState)2 ProcessProjectActions (net.sourceforge.usbdm.deviceEditor.peripherals.ProcessProjectActions)2 WriteFamilyCpp (net.sourceforge.usbdm.deviceEditor.peripherals.WriteFamilyCpp)2 UsbdmException (net.sourceforge.usbdm.jni.UsbdmException)2 DeviceFileList (net.sourceforge.usbdm.peripheralDatabase.DeviceFileList)2 DeviceSvdInfo (net.sourceforge.usbdm.peripheralDatabase.DeviceFileList.DeviceSvdInfo)2 Peripheral (net.sourceforge.usbdm.peripheralDatabase.Peripheral)2 SVDIdentifier (net.sourceforge.usbdm.peripheralDatabase.SVDIdentifier)2 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 StringWriter (java.io.StringWriter)1 ArrayList (java.util.ArrayList)1