[fpc-devel] [fpc-pascal] ENC28J60 Ethernet Controller AVR/ARM Driver
Jeppe Johansen
jeppe at j-software.dk
Wed Jun 5 16:27:22 CEST 2019
On 6/5/19 8:21 AM, Dimitrios Chr. Ioannidis via fpc-devel wrote:
> Hi Jeppe,
>
> Στις 2/6/2019 5:46 μ.μ., ο Jeppe Johansen έγραψε:
>> On 6/1/19 3:37 PM, Dimitrios Chr. Ioannidis via fpc-pascal wrote:
>
> < snip >
>
>>> As I'm not a compiler guy, isthe "volatile" intrinsic supported in
>>> AVR platform ( I didn't find it in intrinsics unit ) ?
>>>
>> 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.
>>
>> 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:
>>
>> procedure AtomicWnrite(var value: word; new_value: word); inline;
>> var
>> b: Byte;
>> begin
>> b:=avr_save;
>> value:=new_value;
>> avr_restore(b);
>> end;
>>
>> function AtomicRead(var value: word): word; inline;
>> var
>> b: Byte;
>> begin
>> b:=avr_save;
>> AtomicRead:=value;
>> avr_restore(b);
>> end;
>
> Can I use those inside an interrupt handler ? What about nested
> interrupts ?
>
> regards,
>
Yes, avr_save returns the initial state of SREG, and then disables
interrupts.
More information about the fpc-devel
mailing list