From b5b4376dbc56930769ffaba4aadd987629e34c19 Mon Sep 17 00:00:00 2001 From: patacongo Date: Tue, 7 Jun 2011 19:06:07 +0000 Subject: Add AT90USB configuration git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3678 42af7a65-404d-4744-a932-0658087f49c3 --- nuttx/arch/avr/include/avr/irq.h | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) (limited to 'nuttx/arch/avr/include') diff --git a/nuttx/arch/avr/include/avr/irq.h b/nuttx/arch/avr/include/avr/irq.h index 16966d194..c18f6c4b8 100644 --- a/nuttx/arch/avr/include/avr/irq.h +++ b/nuttx/arch/avr/include/avr/irq.h @@ -93,21 +93,51 @@ struct xcptcontext #ifndef __ASSEMBLY__ +/* Read/write the SREG */ + +static inline irqstate_t getsreg(void) +{ + irqstate_t sreg; + asm volatile ("in %0, __SREG__" : =r (sreg) :: ); + return sreg; +} + +static inline void putsreg(irqstate_t sreg) +{ + asm volatile ("out __SREG__, %s" : : "r" (sreg) : ); +} + +/* Interrupt enable/disable */ + +static inline void irqenable() +{ + asm volatile ("sei" ::); +} + +static inline void irqdisable() +{ + asm volatile ("cli" ::); +} + /* Save the current interrupt enable state & disable all interrupts */ static inline irqstate_t irqsave(void) { - /* Needs to return the current interrupt state, then disable interrupts */ -#warning "Not implemented" - return 0 + irqstate_t sreg; + asm volatile + ( + "\tin %0, __SREG__\n" + "\tcli\n + : "=&r" (sreg) :: + ); + return sreg; } /* Restore saved interrupt state */ static inline void irqrestore(irqstate_t flags) { - /* Based on the provided interrupt flags, conditionally enable interrupts */ -#warning "Not implemented" + asm volatile ("out __SREG__, %s" : : "r" (flags) : ); } #endif /* __ASSEMBLY__ */ -- cgit v1.2.3