use of net.sourceforge.usbdm.deviceEditor.peripherals.WriteFamilyCpp in project usbdm-eclipse-plugins by podonoghue.
the class DeviceInfo method generateCppFiles.
/**
* Generate CPP files (pin_mapping.h, gpio.h)<br>
* Used for testing (files created relative to executable)
*
* @throws Exception
*/
public void generateCppFiles() throws Exception {
// Output directory for test files
Path folder = Paths.get("Testing");
// Generate device header file
Path headerfilePath = folder.resolve(UsbdmConstants.PROJECT_INCLUDE_FOLDER).resolve(getDeviceSubFamily() + ".h");
DevicePeripherals devicePeripherals = getDevicePeripherals();
devicePeripherals.writeHeaderFile(headerfilePath, new NullProgressMonitor());
// Generate pinmapping.h etc
WriteFamilyCpp writer = new WriteFamilyCpp();
writer.writeCppFiles(folder, "", this);
// Regenerate vectors.cpp
Map<String, String> variableMap = getSimpleSymbolMap();
generateVectorTable(variableMap, devicePeripherals, new NullProgressMonitor());
FileUtility.refreshFile(folder.resolve(UsbdmConstants.PROJECT_VECTOR_CPP_PATH), variableMap);
ProcessProjectActions processProjectActions = new ProcessProjectActions();
regenerateProjectFiles(processProjectActions, null, new NullProgressMonitor());
for (String key : fPeripheralsMap.keySet()) {
Peripheral p = fPeripheralsMap.get(key);
if (p instanceof PeripheralWithState) {
((PeripheralWithState) p).regenerateProjectFiles(processProjectActions, null, new NullProgressMonitor());
}
}
}
use of net.sourceforge.usbdm.deviceEditor.peripherals.WriteFamilyCpp in project usbdm-eclipse-plugins by podonoghue.
the class DeviceInfo method generateCppFiles.
/**
* Generate CPP files (pin_mapping.h, gpio.h etc) within an Eclipse C++ project
*
* @param project Destination Eclipse C++ project
* @param monitor
* @throws Exception
*/
public void generateCppFiles(IProject project, IProgressMonitor monitor) throws Exception {
SubMonitor subMonitor = SubMonitor.convert(monitor, (fPeripheralsMap.size() + 5) * 100);
// Generate device header file
Path projectDirectory = Paths.get(project.getLocation().toPortableString());
Path headerfilePath = projectDirectory.resolve(UsbdmConstants.PROJECT_INCLUDE_FOLDER).resolve(getDeviceSubFamily() + ".h");
subMonitor.subTask("Parse SVD file");
DevicePeripherals devicePeripherals = getDevicePeripherals();
subMonitor.worked(10);
devicePeripherals.writeHeaderFile(headerfilePath, subMonitor.newChild(10));
// Generate pinmapping.h etc
WriteFamilyCpp writer = new WriteFamilyCpp();
writer.writeCppFiles(project, this, subMonitor.newChild(10));
// Regenerate vectors.cpp
Map<String, String> variableMap = new HashMap<String, String>();
generateVectorTable(variableMap, devicePeripherals, subMonitor.newChild(10));
FileUtility.refreshFile(project, UsbdmConstants.PROJECT_VECTOR_CPP_PATH, variableMap, subMonitor.newChild(10));
ProcessProjectActions processProjectActions = new ProcessProjectActions();
regenerateProjectFiles(processProjectActions, project, subMonitor.newChild(10));
for (String key : fPeripheralsMap.keySet()) {
Peripheral p = fPeripheralsMap.get(key);
if (p instanceof PeripheralWithState) {
((PeripheralWithState) p).regenerateProjectFiles(processProjectActions, project, subMonitor.newChild(10));
}
}
}
use of net.sourceforge.usbdm.deviceEditor.peripherals.WriteFamilyCpp in project usbdm-eclipse-plugins by podonoghue.
the class TestCreateCpp method main.
public static void main(String[] args) throws Exception {
Path directory = Paths.get("BulkTesting");
Path dataDirectory = Paths.get("data");
// Locate header output directory
Path headerDirectory = directory.resolve("Project_Headers");
// Locate source output directory
Path sourcesDirectory = directory.resolve("Sources");
// Create output directories if needed
if (!directory.toFile().exists()) {
Files.createDirectory(directory);
}
if (!headerDirectory.toFile().exists()) {
Files.createDirectory(headerDirectory);
}
if (!sourcesDirectory.toFile().exists()) {
Files.createDirectory(sourcesDirectory);
}
DirectoryStream<Path> folderStream = Files.newDirectoryStream(dataDirectory.toAbsolutePath(), csvFilter);
for (Path filePath : folderStream) {
if (!Files.isRegularFile(filePath)) {
continue;
}
/*
* Process each input file
*/
System.err.println("Processing " + filePath.getFileName() + " ======================== ");
DeviceInfo deviceInfo = DeviceInfo.create(filePath);
WriteFamilyCpp writer = new WriteFamilyCpp();
writer.writeCppFiles(directory, deviceInfo);
}
}
Aggregations