Skip to content

mru00/hla

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hla - high level atmel programming

Abstract

hla aims to be a simple high level / domain specific language, aimed at (really) simple atmel development tasks.

1. Overview

1.1. targets

Controller selection

targets ATMEGA8

1.2. uses

The controller is setup via

uses ...

instructions.

Example:

uses ADC
uses UART

1.3. Io pins

io pulse      is INPUT  on A.1
io direction  is OUTPUT on A.2

1.4. Named conditions

Since all variables are global, it is easy to name such a condition and reuse that anywhere where a condition would be allowed.

1.5. Variables

Variables only exist globally.

Variables must be declared:

var name is u8

1.6. Instructions

when condition do ... done
set  output|variable value
increment variable
decrement variable

1.7. Processes

On top level, 'processes' exist. these processes run quasi-parallel. each such has a trigger

1.7.1. initially

is executed when the device is reset.

initially do
done

1.7.2. on - interrupts

on INT0 do
done

1.7.3. when - input condition

when direction = high do
done

1.7.4. always

always do
done

2. Example program

targets ATTINY10

uses Io
uses Condition
uses Proc
uses Always
uses Statements
uses Loops
uses Lowlevel

io pulse      is INPUT  on A.1
io direction  is OUTPUT on A.2

var counter  is u8

condition endpoint_reached is counter = 100

initially do
	set counter 0
	set direction low
	callc exit
done


when pulse = high do
	increment counter
	while pulse = high do
		set counter 1
	done
done

when endpoint_reached  do
	invert direction
	set counter 0
done

when counter = 10  do
	invert direction
	set counter 0
done

on INT0 do
	set counter 0
done


always do
	invert direction
done

3. Implementation

Parser is implemented in 'python'. The parser is maintained in a different project, 'dynparser': https://github.com/mru00/dynparser

C code is generated using 'mako templates'.

The resulting file would look like this:

#include <avr.h>


/*not implemented : <class 'modBase.Target'>*/



static u8 counter;

ISR(INT0) {
    counter = 0;
}

void main() {


        counter = 0;
      direction = low;
/*not implemented : <class 'modLowlevel.CallC'>*/


  for(;;) {

      if ( pulse == high ) {
          counter++;
          while ( pulse == high ) {
              counter = 1;
          }
      }


      if ( counter == 100 ) {
          direction = ! direction;
          counter = 0;
      }


      if ( counter == 10 ) {
          direction = ! direction;
          counter = 0;
      }

  }

}

About

high level programming for microcontrollers [atmel]

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published