Provides a device and IO pin configuration metadata model and a set of T4 runtime templates supporting the automatic generation of firmware and Bonsai interface code for Harp devices.
Installation can be done through the Harp.Generators NuGet package.
dotnet new install Harp.Generators
- Install Visual Studio Code
- Install the YAML extension.
The device interface can be described using a device.yml file. A complete specification of all device registers, including bit masks, group masks, and payload formats needs to be provided.
%YAML 1.1
---
# yaml-language-server: $schema=https://harp-tech.org/draft-02/schema/device.json
device: DeviceName
whoAmI: 0000
firmwareVersion: "0.1"
hardwareTargets: "0.0"
registers:
DigitalInputs:
address: 32
type: U8
access: EventA complete reactive interface to communicate with the device can be generated from the device metadata file.
using var reader = new StreamReader("device.yml");
var parser = new MergingParser(new Parser(reader));
var deviceMetadata = MetadataDeserializer.Instance.Deserialize<DeviceInfo>(parser);
var generator = new InterfaceGenerator(deviceMetadata, "MyNamespace");
var implementation = generator.GenerateImplementation();Assuming the deviceMetadata object loaded above is available, device firmware interface stubs can be generated by providing an additional metadata file describing IO pin configuration.
...
using var reader = new StreamReader("ios.yml");
var portPinMetadata = MetadataDeserializer.Instance.Deserialize<PortPinMetadata>(reader);
var generator = new FirmwareGenerator(deviceMetadata, portPinMetadata);
var headers = generator.GenerateHeaders();
var implementation = generator.GenerateImplementation();Bug reports and contributions are welcome at the GitHub repository.
Harp.Generators is released as open-source under the MIT license.