Giter Site home page Giter Site logo

fermarsan / aixt Goto Github PK

View Code? Open in Web Editor NEW
34.0 2.0 32.0 57.73 MB

Programming framework for microcontrollers based on a V-like language.

License: MIT License

V 87.98% C 6.22% Mermaid 0.18% C++ 5.56% Batchfile 0.06%
compiled-language microcontrollers programming-language transcompiler transpiler v-like v-programming-language vlang

aixt's Introduction

Programming Framework for Microcontrollers

Aixt is a programming framework for microcontrollers which uses a modern language syntax based on V and able to be used by low-resource devices. Aixt is composed by 3 main components:

  • The Aixt programming language based on the V language syntax.
  • The Aixt to C Transpiler, which translate the Aixt source code to C, for the specific C compiler of each microcontroller.
  • The Aixt API, which makes the programming easy by standardizing the setup and I/O functions.

This diagram shows the Aixt blocks and their interactions:

stateDiagram-v2

    Aixt: Aixt (V-based)
    state Aixt {
        source: Source code

        API: Microcontroller API    
        state API {
            PICs: PIC
            ATM: AT
            ESP
            RP2040
            PSoC
            others2: ...
            NXT: NXT brick
        }
    }



    Aixt2C: Transpiler
    state Aixt2C {
        state V {
            Transpiler: Transpiler
        }
        
        state TOML {
            setup: Setup file
        }
    }

    C: C
    state C {
        Tr_Code: Transpiled code
    }

    state Compiler {
        XC8
        XC16
        Arduino
        GCC
        others: ...
        nbc: nbc (NXC)
    }

    state machine {
        BF: Binary file
    }

    source --> Aixt2C
    API --> Aixt2C
    Aixt2C --> C
    C --> Compiler
    Compiler --> machine

Aixt is designed as modular as possible to facilitate the incorporation of new devices and boards. This is mainly possible by using a configuration file (in TOML format) instead of creating new source code for each new device. That .TOML file contains the specific parameters of each device, board or compiler such as: variable types, initialization commands, compiler paths, etc.

Aixt to C Transpiler

The transpiler is written in V and uses V's native compiler facilities to transpile from V to C. This is implemented in the folders \aixt_build and \aixt_cgen, and the main source code is the aixt.v file. It generates code for 3 different backends:

  • c: for the microcontroller native C compiler
  • nxc: for the NXC compiler (LEGO Mindstorms NXT)
  • arduino: for the Arduino IDE WIP...

Aixt Language

Aixt programing language implements a subset of the V language. The main differences are show as follows:

feature V Aixt
variables immutable by default mutable by default
strings dynamic-sized dynamic-sized (only if supported)
arrays dynamic-sized dynamic-sized (only if supported)
default integers size 32 bits depends on the device
structs allow functions (object-oriented) don't allow functions (only structured)
functions multiple return values only one return value
C-style preprocessor commands only V specific ones and #include support any command starting with #
C.functions() need to explicitly include the C file auto include function.c for C.function()

Example with main function

/* Turning ON by 5.5 seconds the onboard LED 10 in the Explorer16 
board with a PIC24FJ microcontroller (XC16 compiler) */
import time { sleep_ms }
import pin { high, low }

fn main() {
    high(led10)    //turn ON the LED 10 (PORTA7)
    sleep_ms(5500)
    low(led10)
}

Example without main function (Script mode)

// Blinking LEDs on the Seeeduino XIAO-SAM21 board (Arduino backend)
import time
import pin

pin.setup(2, pin.output)
pin.setup(3, pin.output)

for i in 0 .. 10 { // 10 times
	pin.high(2)
	time.sleep_ms(250)
	pin.low(2)
	time.sleep_ms(250)
}

for {
	pin.high(3)
	time.sleep(1)
	pin.low(3)
	time.sleep(2)
}

Aixt API

The Aixt API is inspired by Micropython, Arduino and Tinygo. The API for all the ports includes at least functions for:

  • Digital input/output
  • Analog inputs (ADC)
  • PWM outputs
  • Serial port (UART)

Using Aixt

Installing Aixt from source

git clone https://github.com/fermarsan/aixt.git
cd aixt
make # make.bat on Windows

Running Aixt

run it in a Linux-based system as:

./aixt <command> <device_or_board> <source_file>

or in Windows:

aixt.exe <command> <device_or_board> <source_file>

Running examples:

./aixt -t Emulator test.v
./aixt -b NXT ports/NXT/projects/1_motor_forward.v

Project's name

The project's name is inspired in Veasel, the Weasel pet of V Language, and at the same time is a tribute to Ticuna people who live in the Amazon forest between the borders of Colombia, Brasil and Perú. Weasels are mustelids just like otters, so the name Aixt comes from Aixtü, which is a way to say otter in Ticuna language.

Have questions?

Nice, you can contact me via mail.

Email: [email protected]

Want to contribute?

Cool, go ahead and make the contributions you want, then submit a new pull request

The microcontroller or board that you use is not listed here and you know how to program it in C?... You can easily add it to Aixt, please check CONTRIBUTING.md.

Take a look at TODO.md to find a task for you.

Please check CONTRIBUTING.md to learn how you can contribute.

License

The Aixt project is licensed under the MIT, which is attached in this repository.

aixt's People

Contributors

affajardod avatar ander1420 avatar anderssoncga avatar blackleencazz avatar calucas1 avatar caroalexander avatar cesarroa53 avatar crisgarz avatar danielavg1984 avatar fabizz2024 avatar fermarsan avatar fuzzy avatar gaitanbrayan avatar jancarlo1 avatar jataveral avatar jcguzmanz avatar lpinto96 avatar nelsonporras99 avatar profesanta avatar roa53 avatar sebastian-g-nodemcu avatar sebastiantriv avatar stiven121212 avatar yahirgracia0927 avatar ymreyes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  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.