Hi Hongwei,
On Sat, Sep 13, 2014 at 4:05 AM, gmhwxi <gmh...@gmail.com> wrote:
> The macdef code in your DATS-files should probably all be moved into
> SATS-files.
Following?
$ grep macdef serial_ats/DATS/hardware_serial.dats | head -5
macdef hserial = $extval(cPtr0(hardware_serial), "(&Serial)")
macdef F_CPU = $extval(ulint, "F_CPU")
macdef rx_buffer = $extval(cPtr0(ring_buffer), "&rx_buffer")
macdef tx_buffer = $extval(cPtr0(ring_buffer), "&tx_buffer")
macdef ADDR_UBRRH = $extval(ptr, "&ADDR_UBRRH")
But they are only for using in hardware_serial.dats, and not for main.dats...
I think they are private and not public.
> The functions in DATS-files can be written as templates. So you don't need
> to generate libarduino.a.
I should change all functions into template function?
Now I compile DATS files as following.
$ pwd
/home/kiwamu/src/arduino-mega2560-ats/lcd_ats
$ make
$ find . -name "*.o"
./wiring_analog.o
./wiring_digital.o
./DATS/lcd_dats.o
./DATS/main_dats.o
In the case, libarduino.a is a bad idea?
BTW, is template really good for embedded application?
Arduino Uno board only has 32kB ROM and 2kB RAM.
And lcd_open function is large function.
I think space-efficient is very important in embedded application such
like Linux kernel.
Now, lcd.{sats,dats} user is only one, as main.dats.
However, theother.dats may staload lcd.{sats,dats} in the future?
In the case, I think there are two lcd_open instances.
After seeing the following code: local |
var _global_lcd_struct: LCD_struct |
in |
... end I think it makes sense to introduce a template fun{} lcd_get (): LCD // or use LCD_unintized Use lcd_get to implement lcd_open. You can implement lcd_get in main.dats if you like. |
var _global_lcd_struct: LCD_struct
implement lcd_get<> () = $UN.castvwtp0 (addr@_global_lcd_struct)