[fpc-devel] [fpc-pascal] ENC28J60 Ethernet Controller AVR/ARM	Driver
    Dimitrios Chr. Ioannidis 
    d.ioannidis at nephelae.eu
       
    Wed Jun  5 08:21:32 CEST 2019
    
    
  
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,
-- 
Dimitrios Chr. Ioannidis
    
    
More information about the fpc-devel
mailing list