Question about where to put lua driver modules.

classic Classic list List threaded Threaded
3 messages Options
Mike Panetta Mike Panetta
Reply | Threaded
Open this post in threaded view
|

Question about where to put lua driver modules.

I am going to be adding I2C support to my STM3210 port this weekend so I can
start playing around with a smart battery charger/power supply I designed
and I need to know where a good place to put the lua code that drives the
chips would be.  The code will be generic (obviously) and should work on any
platform since its in lua.  Do we currently have any place for files like
this?  Should chip drivers be implemented in lua or C?  Which would be more
RAM efficient? I would imagine C would be more efficient...

Also, do we have a platform interface in mind for I2C yet?

Another question... What is the general idea behind how eLua is to be used?
I ask this because it will determine if most of the low level code (such as
peripheral and chip drivers, and possibly some algorithms) will be written
in C and just the business logic will be written in lua, or if some of the
common drivers will be written in lua wherever possible. I don't think that
this would even be a question on a larger memory system, as RAM would be
plenty, but on a 64K system, ram is tight, so we should do whatever we can
to optimise for RAM usage IMO.

My main reason for asking is, should I even write the chip drivers in lua,
or should I do them in C?  The LTC3556 (PMIC) driver will be very small, as
it is a write only device and only has 2 registers.  The bq27350 (Fuel
Gauge) driver could be quite large as it is a more complex chip with many
registers and access modes, so more then likely it should be done in C
anyway...

Anyway, I hope my questions make sense!

Thanks,
Mike
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://lists.berlios.de/pipermail/elua-dev/attachments/20081114/143c42b0/attachment.html 

BogdanM BogdanM
Reply | Threaded
Open this post in threaded view
|

Question about where to put lua driver modules.

Hi,

On Fri, Nov 14, 2008 at 3:57 PM, Mike Panetta <panetta.mike at gmail.com>wrote:

> I am going to be adding I2C support to my STM3210 port this weekend so I
> can start playing around with a smart battery charger/power supply I
> designed and I need to know where a good place to put the lua code that
> drives the chips would be.  The code will be generic (obviously) and should
> work on any platform since its in lua.  Do we currently have any place for
> files like this?  Should chip drivers be implemented in lua or C?  Which
> would be more RAM efficient? I would imagine C would be more efficient...


Currently we don't have such modules, although there will be coming,
including Dado's PID module and my (yet to be written) char LCD module. I'd
put them in a "src/common" directory, with the module code still residing in
"src/modules" (we're aiming to give the new interface to both Lua and C,
thus the separation between src/common and src/modules).


> Also, do we have a platform interface in mind for I2C yet?


Nope. My experience with I2C is quite limited, but let's discuss an
interface. If you have a first draft, please let us know.


> My main reason for asking is, should I even write the chip drivers in lua,
> or should I do them in C?  The LTC3556 (PMIC) driver will be very small, as
> it is a write only device and only has 2 registers.  The bq27350 (Fuel
> Gauge) driver could be quite large as it is a more complex chip with many
> registers and access modes, so more then likely it should be done in C
> anyway...
>
> Anyway, I hope my questions make sense!


Your question makes a lot of sense, and the answer is: it depends. In this
case, it would make more sense to write the driver itself in C for at least
two reasons:

- it's quite easy to write it in C, and by writing it in C you take less
resources from the system
- you can also offer your interface to C programs, not just to Lua programs
(as mentioned above). Of course you can later call Lua functions from your C
code if needed, but offering a direct interface is a better choice IMO.

On the other hand, the scripting webserver I wrote for eLua is written in
Lua itself, which makes much more sense for a couple of reasons:

- it must execute Lua code directly
- Lua has very strong string manipulation capabilities, which was gold for
the "scripting" part

So: in most cases the aim is to write the modules/other parts of the system
in C, unless it _really_ makes more sense to write them in Lua.

Best,
Bogdan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://lists.berlios.de/pipermail/elua-dev/attachments/20081115/772aa5bd/attachment.html 

Dado Sutter Dado Sutter
Reply | Threaded
Open this post in threaded view
|

Question about where to put lua driver modules.

In reply to this post by Mike Panetta
Hello All,

On Fri, Nov 14, 2008 at 11:57 AM, Mike Panetta <panetta.mike at gmail.com>wrote:

> I am going to be adding I2C support to my STM3210 port this weekend so I
> can start playing around with a smart battery charger/power supply I
> designed and I need to know where a good place to put the lua code that
> drives the chips would be.  The code will be generic (obviously) and should
> work on any platform since its in lua.  Do we currently have any place for
> files like this?  Should chip drivers be implemented in lua or C?  Which
> would be more RAM efficient? I would imagine C would be more efficient...


I'm having similar questions here too Mike :)
We're doing most of our (still testing) modules in C, because of efficiency,
both CPU and RAMwise but I don't see any problem in doing a lot of high
level (Lua) dev too. We were actually planning to do a version of my OLED
RIT128x96x4 display driver (actually a bind to Luminary's lib) in Lua, just
to prove the concept and test performance.

Also, do we have a platform interface in mind for I2C yet?


Not that I know but it would certainly be veeeeeeeery welcome !!! :)

Another question... What is the general idea behind how eLua is to be used?
> I ask this because it will determine if most of the low level code (such as
> peripheral and chip drivers, and possibly some algorithms) will be written
> in C and just the business logic will be written in lua, or if some of the
> common drivers will be written in lua wherever possible. I don't think that
> this would even be a question on a larger memory system, as RAM would be
> plenty, but on a 64K system, ram is tight, so we should do whatever we can
> to optimise for RAM usage IMO.


As discussed above, I think both models can be usefull and for performance
we will usually code in C.

My main reason for asking is, should I even write the chip drivers in lua,
> or should I do them in C?  The LTC3556 (PMIC) driver will be very small, as
> it is a write only device and only has 2 registers.  The bq27350 (Fuel
> Gauge) driver could be quite large as it is a more complex chip with many
> registers and access modes, so more then likely it should be done in C
> anyway...


For basic protocol and control drivers like this, where perceived
performance is important, it seems that coding in C will always be better.
But again, for RAD purposes and even for some real aplication, a Lua driver
could do the job in these fast little toys we have today :)

Anyway, I hope my questions make sense!


They surely do !!! Thankssssssssss !!!

Thanks,
> Mike


Best
Dado





>
>
> _______________________________________________
> Elua-dev mailing list
> Elua-dev at lists.berlios.de
> https://lists.berlios.de/mailman/listinfo/elua-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://lists.berlios.de/pipermail/elua-dev/attachments/20081117/7bcd0c9a/attachment.html