use of net.sourceforge.usbdm.peripheralDatabase.Peripheral 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.Peripheral 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