Giter Site home page Giter Site logo

sup3legacy / arlustre Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 143 KB

Arduino interface for the Heptagon synchronous dataflow-oriented language written in Zig.

License: GNU Affero General Public License v3.0

Makefile 0.94% Zig 97.69% Nix 1.37%
heptagon zig synchronous-programming dataflow-programming arduino-uno arduino-library

arlustre's Introduction

(WIP)

Arlustre

Arduino interface for the Heptagon synchronous language written in Zig. It should provide a kinda-low-level interface to any heptagon program, through the custom Heptagon Zig backend. The whole low-level Arduino core-library is implemented using Zig. โš ๏ธ Only works for the standard Arduino Uno board.

Non-exhaustive list of functionning features:

  • Very simple Zig backend, not extensively tested (all operations on arrays are not supported for now)
  • Zig Arduino Libcore with custom bootstraping stack, interrupts, Serial, GPIO
  • Interface to Heptagon for both GPIO allocation/read/write operatiosn as well as printing (more to come)

Achievements

Things I have achieved so far :

  • Arduino libcore covering a not-to-bad proportion of the features available on the Arduino Uno platform (GPIO, Serial, some basic timer interrupts so far)
  • Automated build using zig build
  • Small Lustre interface containing GPIO-{declaration, read, write}.
  • Lustre test program showing a proof-of-concept with LEDs, timers, a potentiometer and a button.

How to use

Programming

The program's main logic is located in the src/top.lus Lustre file. The interface is defined in src/interface.epi. Both files should not be moved or renamed, as the build system is quite rudimentary and assumes the existence of these files at these locations.

src/lib contains the Arduino libcore in pure Zig. It contains all basic fonctionnalities regarding MMIO, GPIO, interrupts, timers and the Serial interface. The src/libz/interrupt.zig file contains bindings to src/main.zig for the moment but this should be removed and replaced by a runtime ISR declaration during the booting process, thus making the Libz intrinsically independant from the application.

build.zig is the building script.

boot.zig is the entry point of the program. It handles both the clearing of ths .bss segment and the data-loading from Flash to RAM.

start.zig defines the main function : bootstrap where all interrupts and timers should be initialized. This function is called by _start after the booting proccess and, in this particular application, resets the state of the Lustre program.

main.zig is automatically generated but modified a bit by hand (TODO make this fully automatic) and defines global reset and step functions to drive the entire transpilled Lustre program.

top.zig is automatically generated by heptc from top.lus. It contains all the Lustre logic, i.e. the "heart of the program", everything else being only the booting process and auxiliary functions.

Prerequisites

  • ocaml and some other opam libraries to compile my custom fork of heptagon (available as a submodule).
  • zig version >= 0.8 (source available on Github or via some shady repackers s.a. snap or flatpak or through the AUR). Do note that Zig is still in pre-1.0 version so it tends to be not so stable now and then. If a strange behaviour is encountered, do try another (maybe more recent or more stable) release.
  • screen
  • avrdude
  • avr-gcc for the linking process
  • (optional) avr-objdump needed to use zig build objdump

How to compile

  • make root directory. This should compile the modified version of heptc, run it on the test Lustre program and build the generated Zig code.
  • in the src subdirectory :
    • zig heptc : runs heptc on interface.epi and top.lus and moves the generated top.zig in ./src
    • zig build : Both transpiles the Lustre program and builds the resulting Zig program into an Arduino-compatible binary
    • zig build upload : does everything mentionned before (heptc, compiles the Zig program) and uploads the program to the Arduino using a generic port using avrdude (TODO add port as an optional argument)
    • zig screen : does everything above + opens a screen session with the arduino on the same port (TODO add port as an optional argument)

Acknowledgments

Thanks to FireFox317 for their Arduino Zig basis.

Thanks to Silversquirl for their help with linker issues.

arlustre's People

Contributors

sup3legacy avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.