[x] Modify the command line interface of omicrob to be able to set the device to compile for
[x] Update the avrlib.c library to take into account multiple devices
[x] Update the Avr module
[x] Reimplement the LiquidCrystal module, using the new Avr interface
[x] Update the simulator
[x] Test everything very carefully
[x] Reimplement the serial lib for every device
Abstract
I improved my work on a way to compile for different Avr devices (see #6). Previously, omicrob needed to be reconfigured (and recompiled) when targeting different devices. Now devices can be choosen when executing omicrob to compile a program.
The device omicrob compiles (or flashes) for can be set using the -device parameter. Available devices can be listed using the -list-devices parameter. The current available devices are the Arduboy, the Arduino Uno and the Arduino Mega (same as before). The default selected device is the Arduboy.
Interfaces
From a user point a view, the interface doesn't really change much : PINs and registers, as well as some the functions write_register, read_register, set_bit, clear_bit and delay are still exposed through the Avr module. The [...]_of_pin functions, as well as the pin_mode, digital_read and digital_write functions are exposed through sub-modules following the signature AvrPins. The correct sub-module (depending on the device selected) is automatically opened when compiling a program using omicrob. Therefore, backward compatibility with previously written program should theoretically be preserved.
The LiquidCrystal interfaces has changed a bit. Instead of simply opening the LiquidCrystal module, users now have to create an instance of LCD using the LiquidCrystal.MakeLCD functor : the module passed to this functor must contains a pin_mode and a digital_write method (usually passing the ones automatically imported for the correct micro-controller will do the trick). See this exemple. I'm not totally convinced of this interface, so if anyone has an idea on how to make it more practical, that would be appreciated !
Future changes
It will be possible, in the future, to add other AVR devices to omicrob, by editing the files:
src/omicrob/omicrob.ml
src/omicrob/avr_config.ml
src/byterun/avr/avrlib.c
src/stdlib/avr.ml and .mli
I also hope that the generic approach used will make it easy to port omicrob to other microcontroller architectures (see PSTL project).
Tests
It should be noted that I have only yet tested these changes with an Arduino Uno (being the only device I have at hand for the time being). I'll test these changes (using simple examples, like the one from tutorial 2 : buttons) on other devices as soon as I can.
(this PR replaces #11)
TODO List
Avr
moduleLiquidCrystal
module, using the newAvr
interfaceAbstract
I improved my work on a way to compile for different Avr devices (see #6). Previously, omicrob needed to be reconfigured (and recompiled) when targeting different devices. Now devices can be choosen when executing omicrob to compile a program. The device omicrob compiles (or flashes) for can be set using the -device parameter. Available devices can be listed using the -list-devices parameter. The current available devices are the Arduboy, the Arduino Uno and the Arduino Mega (same as before). The default selected device is the Arduboy.
Interfaces
From a user point a view, the interface doesn't really change much : PINs and registers, as well as some the functions
write_register
,read_register
,set_bit
,clear_bit
anddelay
are still exposed through theAvr
module. The[...]_of_pin
functions, as well as thepin_mode
,digital_read
anddigital_write
functions are exposed through sub-modules following the signatureAvrPins
. The correct sub-module (depending on the device selected) is automatically opened when compiling a program using omicrob. Therefore, backward compatibility with previously written program should theoretically be preserved. TheLiquidCrystal
interfaces has changed a bit. Instead of simply opening theLiquidCrystal
module, users now have to create an instance ofLCD
using theLiquidCrystal.MakeLCD
functor : the module passed to this functor must contains apin_mode
and adigital_write
method (usually passing the ones automatically imported for the correct micro-controller will do the trick). See this exemple. I'm not totally convinced of this interface, so if anyone has an idea on how to make it more practical, that would be appreciated !Future changes
It will be possible, in the future, to add other AVR devices to omicrob, by editing the files:
Tests
It should be noted that I have only yet tested these changes with an Arduino Uno (being the only device I have at hand for the time being). I'll test these changes (using simple examples, like the one from tutorial 2 : buttons) on other devices as soon as I can.