Skip to content

harp-tech/generators

Repository files navigation

Harp.Generators

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.

Installing

Installation can be done through the Harp.Generators NuGet package.

dotnet new install Harp.Generators

Editing device metadata

  1. Install Visual Studio Code
  2. 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: Event

Generating device interface code

A 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();

Generating device firmware code

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();

Contributing

Bug reports and contributions are welcome at the GitHub repository.

License

Harp.Generators is released as open-source under the MIT license.

About

Provides automatic generation of firmware and Bonsai interface code for Harp devices

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors