/*#*
*#* $Log$
+ *#* Revision 1.12 2004/12/13 12:07:06 bernie
+ *#* DISABLE_IRQSAVE/ENABLE_IRQRESTORE: Convert to IRQ_SAVE_DISABLE/IRQ_RESTORE.
+ *#*
*#* Revision 1.11 2004/12/08 09:11:53 bernie
*#* Rename time_t to mtime_t.
*#*
#define IS_BUZZER_ON (PORTG & BV(PG0))
/*!
- * Buzzer manipulation macros
+ * \name Buzzer manipulation macros.
*
* \note Some PORTG functions are being used from
* interrupt code, so we must be careful to
* avoid race conditions.
+ * \{
*/
- #define BUZZER_ON \
- do { \
- cpuflags_t _flags; \
- DISABLE_IRQSAVE(_flags); \
- PORTG |= BV(PG0); \
- ENABLE_IRQRESTORE(_flags); \
- } while (0)
-
- #define BUZZER_OFF \
- do { \
- cpuflags_t _flags; \
- DISABLE_IRQSAVE(_flags); \
- PORTG &= ~BV(PG0); \
- ENABLE_IRQRESTORE(_flags); \
- } while (0)
-
- #define BUZZER_INIT \
- do { \
- cpuflags_t _flags; \
- DISABLE_IRQSAVE(_flags); \
- PORTG &= ~BV(PG0); \
- DDRG |= BV(PG0); \
- ENABLE_IRQRESTORE(_flags); \
- } while (0)
+ #define BUZZER_ON ATOMIC(PORTG |= BV(PG0))
+ #define BUZZER_OFF ATOMIC(PORTG &= ~BV(PG0))
+ #define BUZZER_INIT ATOMIC(PORTG &= ~BV(PG0); DDRG |= BV(PG0);)
+ /*\}*/
#elif defined(__IAR_SYSTEMS_ICC) || defined(__IAR_SYSTEMS_ICC__) /* 80C196 */
void buz_beep(mtime_t time)
{
cpuflags_t flags;
+ IRQ_SAVE_DISABLE(flags);
/* Remove the software interrupt if it was already queued */
- DISABLE_IRQSAVE(flags);
if (buz_timer_running)
timer_abort(&buz_timer);
buz_timer.delay = time;
timer_add(&buz_timer);
- ENABLE_IRQRESTORE(flags);
+ IRQ_RESTORE(flags);
}
void buz_repeat_stop(void)
{
cpuflags_t flags;
- DISABLE_IRQSAVE(flags);
+ IRQ_SAVE_DISABLE(flags);
/* Remove the software interrupt if it was already queued */
if (buz_timer_running)
buz_repeat_interval = 0;
BUZZER_OFF;
- ENABLE_IRQRESTORE(flags);
+ IRQ_RESTORE(flags);
}
/*#*
*#* $Log$
+ *#* Revision 1.14 2004/12/13 12:07:06 bernie
+ *#* DISABLE_IRQSAVE/ENABLE_IRQRESTORE: Convert to IRQ_SAVE_DISABLE/IRQ_RESTORE.
+ *#*
*#* Revision 1.13 2004/11/16 20:58:51 bernie
*#* Add write verify.
*#*
#include <mware/byteorder.h> /* cpu_to_be16() */
#include <debug.h>
#include <hw.h>
+#include <cpu.h> // IRQ_SAVE_DISABLE(), IRQ_RESTORE()
#include <config.h> // CONFIG_EEPROM_VERIFY
#include <macros.h> // MIN()
void eeprom_init(void)
{
cpuflags_t flags;
- DISABLE_IRQSAVE(flags);
+ IRQ_SAVE_DISABLE(flags);
/*
* This is pretty useless according to AVR's datasheet,
TWSR = 0;
TWCR = BV(TWEN);
- ENABLE_IRQRESTORE(flags);
+ IRQ_RESTORE(flags);
}
/*#*
*#* $Log$
+ *#* Revision 1.21 2004/12/13 12:07:06 bernie
+ *#* DISABLE_IRQSAVE/ENABLE_IRQRESTORE: Convert to IRQ_SAVE_DISABLE/IRQ_RESTORE.
+ *#*
*#* Revision 1.20 2004/12/13 11:51:43 bernie
*#* Fix a latent bug with reentrant serial IRQs.
*#*
struct AvrSerial *hw = (struct AvrSerial *)_hw;
cpuflags_t flags;
- DISABLE_IRQSAVE(flags);
+ IRQ_SAVE_DISABLE(flags);
/* Send data only if the SPI is not already transmitting */
if (!hw->sending && !fifo_isempty(&ser_spi->txfifo))
SPDR = fifo_pop(&ser_spi->txfifo);
}
- ENABLE_IRQRESTORE(flags);
+ IRQ_RESTORE(flags);
}
static void spi_setbaudrate(UNUSED(struct SerialHardware *, _hw), UNUSED(unsigned long, rate))
/*#*
*#* $Log$
+ *#* Revision 1.23 2004/12/13 12:07:06 bernie
+ *#* DISABLE_IRQSAVE/ENABLE_IRQRESTORE: Convert to IRQ_SAVE_DISABLE/IRQ_RESTORE.
+ *#*
*#* Revision 1.22 2004/12/08 09:12:09 bernie
*#* Rename time_t to mtime_t.
*#*
Timer *node;
cpuflags_t flags;
- DISABLE_IRQSAVE(flags);
+ IRQ_SAVE_DISABLE(flags);
/* Calculate expiration time for this timer */
timer->tick = _clock + timer->delay;
/* Enqueue timer request into the list */
INSERTBEFORE(&timer->link, &node->link);
- ENABLE_IRQRESTORE(flags);
+ IRQ_RESTORE(flags);
}
/*!
- * Remove a timer from the timer queue before it has expired
+ * Remove a timer from the timer queue before it has expired.
*/
Timer *timer_abort(Timer *timer)
{
- cpuflags_t flags;
- DISABLE_IRQSAVE(flags);
- REMOVE(&timer->link);
- ENABLE_IRQRESTORE(flags);
+ ATOMIC(REMOVE(&timer->link));
return timer;
}
/*!
- * Wait for the specified amount of time (expressed in ms)
+ * Wait for the specified amount of time (expressed in ms).
*/
void timer_delay(mtime_t time)
{
#ifndef CONFIG_TIMER_DISABLE_UDELAY
/*!
- * Wait for the specified amount of time (expressed in microseconds)
+ * Wait for the specified amount of time (expressed in microseconds).
*
* \bug In AVR arch the maximum amount of time that can be used as
* delay could be very limited, depending on the hardware timer
/*#*
*#* $Log$
+ *#* Revision 1.22 2004/12/13 12:07:06 bernie
+ *#* DISABLE_IRQSAVE/ENABLE_IRQRESTORE: Convert to IRQ_SAVE_DISABLE/IRQ_RESTORE.
+ *#*
*#* Revision 1.21 2004/12/09 08:35:21 bernie
*#* Replace IPTR with iptr_t.
*#*
INLINE mtime_t timer_ticks(void)
{
mtime_t result;
- cpuflags_t flags;
- DISABLE_IRQSAVE(flags);
- result = _clock;
- ENABLE_IRQRESTORE(flags);
+ ATOMIC(result = _clock);
return result;
}
/*#*
*#* $Log$
+ *#* Revision 1.21 2004/12/13 12:07:06 bernie
+ *#* DISABLE_IRQSAVE/ENABLE_IRQRESTORE: Convert to IRQ_SAVE_DISABLE/IRQ_RESTORE.
+ *#*
*#* Revision 1.20 2004/11/16 20:59:46 bernie
*#* Include <avr/io.h> explicitly.
*#*
static void timer_hw_init(void)
{
cpuflags_t flags;
- DISABLE_IRQSAVE(flags);
+ IRQ_SAVE_DISABLE(flags);
/* Reset Timer flags */
TIFR = BV(OCF0) | BV(TOV0);
TIMSK &= ~BV(TOIE0);
TIMSK |= BV(OCIE0);
- ENABLE_IRQRESTORE(flags);
+ IRQ_RESTORE(flags);
}
//! Frequency of the hardware high precision timer
static void timer_hw_init(void)
{
cpuflags_t flags;
- DISABLE_IRQSAVE(flags);
+ IRQ_SAVE_DISABLE(flags);
/* Reset Timer overflow flag */
TIFR |= BV(TOV1);
/* Enable timer interrupt: Timer/Counter1 Overflow */
TIMSK |= BV(TOIE1);
- ENABLE_IRQRESTORE(flags);
+ IRQ_RESTORE(flags);
}
//! Frequency of the hardware high precision timer
static void timer_hw_init(void)
{
cpuflags_t flags;
- DISABLE_IRQSAVE(flags);
+ IRQ_SAVE_DISABLE(flags);
/* Reset Timer flags */
TIFR = BV(OCF2) | BV(TOV2);
TIMSK &= ~BV(TOIE2);
TIMSK |= BV(OCIE2);
- ENABLE_IRQRESTORE(flags);
+ IRQ_RESTORE(flags);
}
//! Frequency of the hardware high precision timer
/*#*
*#* $Log$
+ *#* Revision 1.23 2004/12/13 12:07:06 bernie
+ *#* DISABLE_IRQSAVE/ENABLE_IRQRESTORE: Convert to IRQ_SAVE_DISABLE/IRQ_RESTORE.
+ *#*
*#* Revision 1.22 2004/12/13 11:51:08 bernie
*#* DISABLE_INTS/ENABLE_INTS: Convert to IRQ_DISABLE/IRQ_ENABLE.
*#*
CPU_PUSH_WORD(proc->stack, CPU_REG_INIT_VALUE(i));
/* Add to ready list */
- DISABLE_IRQSAVE(flags);
- SCHED_ENQUEUE(proc);
- ENABLE_IRQRESTORE(flags);
+ ATOMIC(SCHED_ENQUEUE(proc));
#if CONFIG_KERN_MONITOR
monitor_add(proc, name, stack_base, stacksize);
old_process = CurrentProcess;
/* Poll on the ready queue for the first ready process */
- DISABLE_IRQSAVE(flags);
+ IRQ_SAVE_DISABLE(flags);
while (!(CurrentProcess = (struct Process *)REMHEAD(&ProcReadyList)))
{
/*
SCHEDULER_IDLE;
IRQ_DISABLE;
}
- ENABLE_IRQRESTORE(flags);
+ IRQ_RESTORE(flags);
/*
* Optimization: don't switch contexts when the active
/* Just like proc_schedule, this function must not have auto variables. */
static cpuflags_t flags;
- DISABLE_IRQSAVE(flags);
+ IRQ_SAVE_DISABLE(flags);
SCHED_ENQUEUE(CurrentProcess);
- ENABLE_IRQRESTORE(flags);
+ IRQ_RESTORE(flags);
proc_schedule();
}
/*#*
*#* $Log$
+ *#* Revision 1.10 2004/12/13 12:07:06 bernie
+ *#* DISABLE_IRQSAVE/ENABLE_IRQRESTORE: Convert to IRQ_SAVE_DISABLE/IRQ_RESTORE.
+ *#*
*#* Revision 1.9 2004/12/08 08:57:35 bernie
*#* Rename sigset_t to sigmask_t.
*#*
#include "hw.h"
#include <debug.h>
-// FIXME
#if CONFIG_KERN_SIGNALS
/*!
sigmask_t result;
cpuflags_t flags;
- DISABLE_IRQSAVE(flags);
+ IRQ_SAVE_DISABLE(flags);
result = CurrentProcess->sig_recv & sigs;
CurrentProcess->sig_recv &= ~sigs;
- ENABLE_IRQRESTORE(flags);
+ IRQ_RESTORE(flags);
+
return result;
}
sigmask_t result;
cpuflags_t flags;
- DISABLE_IRQSAVE(flags);
+ IRQ_SAVE_DISABLE(flags);
/* Loop until we get at least one of the signals */
while (!(result = CurrentProcess->sig_recv & sigs))
/* Signals found: clear them and return */
CurrentProcess->sig_recv &= ~sigs;
- ENABLE_IRQRESTORE(flags);
+
+ IRQ_RESTORE(flags);
return result;
}
void sig_signal(Process *proc, sigmask_t sigs)
{
cpuflags_t flags;
- DISABLE_IRQSAVE(flags);
+ IRQ_SAVE_DISABLE(flags);
/* Set the signals */
proc->sig_recv |= sigs;
SCHED_ENQUEUE(proc);
}
- ENABLE_IRQRESTORE(flags);
+ IRQ_RESTORE(flags);
}
#endif /* CONFIG_KERN_SIGNALS */