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);
}
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);
}
}
}
}
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;
}
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;
}
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);
}
}
Aggregations