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