3      Copyright (C) Dean Camera, 2010. 
   5   dean [at] fourwalledcubicle [dot] com 
   6       www.fourwalledcubicle.com 
  10   Copyright 2010  Dean Camera (dean [at] fourwalledcubicle [dot] com) 
  12   Permission to use, copy, modify, distribute, and sell this 
  13   software and its documentation for any purpose is hereby granted 
  14   without fee, provided that the above copyright notice appear in 
  15   all copies and that both that the copyright notice and this 
  16   permission notice and warranty disclaimer appear in supporting 
  17   documentation, and that the name of the author not be used in 
  18   advertising or publicity pertaining to distribution of the 
  19   software without specific, written prior permission. 
  21   The author disclaim all warranties with regard to this 
  22   software, including all implied warranties of merchantability 
  23   and fitness.  In no event shall the author be liable for any 
  24   special, indirect or consequential damages or any damages 
  25   whatsoever resulting from loss of use, data or profits, whether 
  26   in an action of contract, negligence or other tortious action, 
  27   arising out of or in connection with the use or performance of 
  33  *  Atomic block header for the 32-bit AVRs, modelled on the 8-bit AVR's util/atomic.h 
  36  *  \note Do not include this file directly, rather include the Common.h header file instead to gain this file's 
  37  *        functionality on the 32-bit AVRs. 
  48         /* Public Interface - May be used in end-application: */ 
  50                         #define ATOMIC_BLOCK(type) for ( type, __ToDo = __iCliRetVal(); \ 
  52                         #define NONATOMIC_BLOCK(type) for ( type, __ToDo = __iSeiRetVal(); \ 
  54                         #define ATOMIC_RESTORESTATE uint8_t sreg_save \ 
  55                                 __attribute__((__cleanup__(__iRestore))) = 0 /* TODO */ 
  56                         #define ATOMIC_FORCEON uint8_t sreg_save \ 
  57                                 __attribute__((__cleanup__(__iSeiParam))) = 0 
  58                         #define NONATOMIC_RESTORESTATE uint8_t sreg_save \ 
  59                                 __attribute__((__cleanup__(__iRestore))) = 0 /* TODO */ 
  60                         #define NONATOMIC_FORCEOFF uint8_t sreg_save \ 
  61                                 __attribute__((__cleanup__(__iCliParam))) = 0 
  63         /* Private Interface - For use in library only: */ 
  64         #if !defined(__DOXYGEN__) 
  65                 /* Inline Functions: */ 
  66                         static __inline__ 
uint8_t __iSeiRetVal(void) 
  68                                 ((avr32_sr_t
*)AVR32_SR_T
)->gm 
= true; 
  72                         static __inline__ 
uint8_t __iCliRetVal(void) 
  74                                 ((avr32_sr_t
*)AVR32_SR_T
)->gm 
= false; 
  78                         static __inline__ 
void __iSeiParam(const uint8_t *__s
) 
  80                                 ((avr32_sr_t
*)AVR32_SR_T
)->gm 
= true; 
  81                                 __asm__ 
volatile ("" ::: "memory"); 
  85                         static __inline__ 
void __iCliParam(const uint8_t *__s
) 
  87                                 ((avr32_sr_t
*)AVR32_SR_T
)->gm 
= false; 
  88                                 __asm__ 
volatile ("" ::: "memory"); 
  92                         static __inline__ 
void __iRestore(const uint8_t *__s
) 
  94                                 ((avr32_sr_t
*)AVR32_SR_T
)->gm 
= *__s
; 
  95                                 __asm__ 
volatile ("" ::: "memory");