What is Mara ?

atmega8

Mara is a programming language dedicated to 8bit ATMEL AVR microcontrollers with a focus on simplicity and productivity.
It provides to AVR architecture some features that high-level programming languages have introduced on 32/64 bits processors, such as classes and type inference.
Thus, the goal of this project is to simplify the programming of these microcontrollers for all those who do not wish to use (or learn) the C or assembly language.

Some features of Mara :

A simple Mara syntax example:


##
## Program tested on an Atmega328p
## with a LED connected on PB5 pin.
##
## CPU frequency : 16 Mhz
##

# Include standard library
using string

# Function declaration
func print(s)
  for i <- 0 to s.length() - 1 do
    waitfor not (@UCSR0A bitand UDRE0)
    @UDR0 <- s[i]
  done
end

# Setting up the microcontroller
setup
  # Variables declaration
  var buff <- new string(256)
  var tick <- true
  var suffix <- none
  var nsuffix <- none

  # Set PB5 as an output
  @DDRB <- DDB5

  # Set timer1
  @TCCR1B <- CS11 CS10
  @TIMSK1 <- TOIE1

  # Set UART (115200 bauds 8N1)
  @UBRR0H:UBRR0L <- 16
  @UCSR0A <- U2X0
  @UCSR0B <- TXEN0
  @UCSR0C <- UCSZ01 UCSZ00

  # Enable interrupts
  sei
end

# Timer1 overflow ISR
interrupt TIMER1_OVF
  @PORTB ^^ PORTB5
  tick <- false
end

# Repeat forever
loop
  suffix <- "s"
  for i <- 99 downto 1 do
    nsuffix <- i - 2 and i - 1 ? "s" : ""
    buff.format("%d bottle%s of beer on the wall, %d bottle%s of beer.\n\r" \
                "Take one down and pass it around, %d bottle%s of beer " \
                "on the wall.\n\n\r", \
                {i; suffix; i; suffix; i - 1; nsuffix})
    print(buff)
    waitfor tick
    tick <- true
    suffix <- nsuffix
  done

  buff.write("No more bottles of beer on the wall, no more bottles of beer." \
             "\n\rGo to the store and buy some more, 99 bottles of beer" \
             "on the wall.\n\n\r")
  print(buff)
  waitfor tick
  tick <- true
end

Changelog

Revision 13 (2013-08-29)

Revision 8 (2013-04-29)

Revision 5 (2013-04-15)