<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
On 6/1/19 3:37 PM, Dimitrios Chr. Ioannidis via fpc-pascal wrote:<br>
<blockquote type="cite"
cite="mid:7d59afc4-a6d8-1967-dd7b-3c13c8f77e8c@nephelae.eu">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<p><tt>Hi,</tt></p>
<p><tt> I started to write a driver ( <a
class="moz-txt-link-freetext"
href="https://github.com/dioannidis/fp_ethernet_enc28j60.git"
moz-do-not-send="true">https://github.com/dioannidis/fp_ethernet_enc28j60.git</a>
) for this chip ( ENC28J60 Ethernet Controller ) first for the
</tt><tt><tt> AVR platform, </tt>( heavily inspired from the
UIPEthernet library ( <a class="moz-txt-link-freetext"
href="https://github.com/UIPEthernet/UIPEthernet.git"
moz-do-not-send="true">https://github.com/UIPEthernet/UIPEthernet.git</a>
)) and I want to ask the community, of course, is there anyone
that already done it ? <br>
</tt></p>
<p><tt> My goal is to made the free pascal users able to use a
very low cost solution Arduino Nano / UNO development board
with a ENC28J60 module for a little IoT ( and not only ) fun,
learning e.t.c. ...<br>
</tt></p>
<p><tt> I managed to configure the chip and the driver receives
packets ( </tt><tt><span class="pl-c">broadcast packets </span>configured
to allow only ARP ). <br>
</tt></p>
<p><tt> Now, because I'm not embedded developer I'm thinking that
I would need help / advices to take some decisions so here I
am. <br>
</tt></p>
<p><tt> First and more important, in the new FPC version, will
the AVR platform review / resolve the following issues : <br>
</tt></p>
<tt> "AVR - incorrect stack error checking" (<a
class="moz-txt-link-freetext"
href="https://bugs.freepascal.org/view.php?id=35332"
moz-do-not-send="true">https://bugs.freepascal.org/view.php?id=35332</a>)
</tt><br>
</blockquote>
<tt>It should work now. Looking into whether it will make sense to
just use up all the space of non-data as suggested in the related
issue.</tt><br>
<blockquote type="cite"
cite="mid:7d59afc4-a6d8-1967-dd7b-3c13c8f77e8c@nephelae.eu"> <tt>
"AVR - Assembler routines for 8, 16 & 32 bit unsigned div
(code contribution)" ( <a class="moz-txt-link-freetext"
href="https://bugs.freepascal.org/view.php?id=32103"
moz-do-not-send="true">https://bugs.freepascal.org/view.php?id=32103</a>
)</tt><br>
</blockquote>
<tt>Fixed as well.</tt><br>
<blockquote type="cite"
cite="mid:7d59afc4-a6d8-1967-dd7b-3c13c8f77e8c@nephelae.eu"> <tt>
"</tt><tt>AVR - invalid address used when evaluating a variable
in gdb" ( <a class="moz-txt-link-freetext"
href="https://bugs.freepascal.org/view.php?id=33914"
moz-do-not-send="true">https://bugs.freepascal.org/view.php?id=33914</a>
)</tt><br>
</blockquote>
<tt>Looking into this.</tt><br>
<blockquote type="cite"
cite="mid:7d59afc4-a6d8-1967-dd7b-3c13c8f77e8c@nephelae.eu"> <tt>
"AVR - Incorrect SPI clock rate bit constant names in some
microcontroller units" ( <a class="moz-txt-link-freetext"
href="https://bugs.freepascal.org/view.php?id=32339"
moz-do-not-send="true">https://bugs.freepascal.org/view.php?id=32339</a>
) </tt><br>
<tt> and add support for the</tt><tt> avrxmega3 subarch, atmega
3208, 3209, 4808, 4809 ( from Christo Crause's repository <a
class="moz-txt-link-freetext"
href="https://github.com/ccrause/freepascal.git"
moz-do-not-send="true">https://github.com/ccrause/freepascal.git</a>
) ?</tt>
<p><tt> Except from Laksen's ethernet stack ( <a
class="moz-txt-link-freetext"
href="https://github.com/Laksen/fp-ethernet.git"
moz-do-not-send="true">https://github.com/Laksen/fp-ethernet.git</a>
) is there other, more lightweight, ethernet stack library
written in Object Pascal ?<br>
</tt></p>
</blockquote>
<tt>Not sure, but I doubt it. But how much more lightweight do you
need it to be? ;)</tt><br>
<blockquote type="cite"
cite="mid:7d59afc4-a6d8-1967-dd7b-3c13c8f77e8c@nephelae.eu">
<p><tt> </tt></p>
<p><tt> As I'm not a compiler guy, is</tt><tt><tt> the "volatile"
intrinsic supported in AVR platform ( I didn't find it in
intrinsics unit ) ?</tt></tt></p>
</blockquote>
<tt>It's supported, but it does not do anything at all. At least not
now, and I don't think that will change. All global variable or
pointer accesses are considered volatile to my knowledge.<br>
</tt>
<p><tt>But volatile in FPC does not guarantee any atomic access. So
this would need to be by you. If what you need is just atomic
access, then simple functions like these generate optimal code:</tt></p>
<tt>procedure AtomicWnrite(var value: word; new_value: word);
inline;<br>
var<br>
b: Byte;<br>
begin<br>
b:=avr_save;<br>
value:=new_value;<br>
avr_restore(b);<br>
end;<br>
<br>
function AtomicRead(var value: word): word; inline;<br>
var<br>
b: Byte;<br>
begin<br>
b:=avr_save;<br>
AtomicRead:=value;<br>
avr_restore(b);<br>
end;</tt><br>
<blockquote type="cite"
cite="mid:7d59afc4-a6d8-1967-dd7b-3c13c8f77e8c@nephelae.eu">
<p><tt> In FPC embedded world/platforms, is the Object approach
more SRAM hungry ( my tests are inconclusive ) from the
procedure / function approach ?<br>
</tt></p>
<p><tt> What's more embedded "friendly" ?</tt></p>
</blockquote>
If used sensibly they should be more or less equal in size, but you
will see some extra overhead with objects. Mostly due to needing
passing the pointer to the object as an argument. But you also gain
some level of abstraction. So it's a tradeoff.<br>
<blockquote type="cite"
cite="mid:7d59afc4-a6d8-1967-dd7b-3c13c8f77e8c@nephelae.eu">
<p><tt>this :<br>
</tt></p>
<p><tt>interface</tt></p>
<tt>type</tt><br>
<tt> TUART = Object<br>
private<br>
FBaudRate: DWord;<br>
function Divider: Integer;<br>
public<br>
procedure Init(const ABaudRate: DWord = 57600);<br>
procedure SendChar(c: char);<br>
function ReadChar: char;<br>
procedure SendString(s: ShortString);<br>
procedure SendStringLn(s: ShortString = '');<br>
end;</tt>
<p><tt>or this :</tt></p>
<tt>interface<br>
</tt><br>
<tt> var</tt><br>
<tt> FBaudRate: DWord;</tt><br>
<tt> function Divider: Integer;</tt><br>
<tt> procedure Init(const ABaudRate: DWord = 57600);</tt><br>
<tt> procedure SendChar(c: char);</tt><br>
<tt> function ReadChar: char;</tt><br>
<tt> procedure SendString(s: ShortString);</tt><br>
<p><tt> procedure SendStringLn(s: ShortString = '');</tt></p>
<p><tt><br>
</tt></p>
<p><tt>And of course anyone who wants to help is welcome .<br>
</tt></p>
<p><tt>regards,</tt></p>
<p><tt>-- <br>
</tt></p>
<p><tt>Dimitrios Chr. Ioannidis<br>
</tt></p>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
fpc-pascal maillist - <a class="moz-txt-link-abbreviated" href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a>
<a class="moz-txt-link-freetext" href="http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal">http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal</a></pre>
</blockquote>
</body>
</html>