Apply ATOMIC macros in a number of other obvious places.

This commit is contained in:
Markus Hitter 2013-07-21 23:07:59 +02:00
parent 69da7c5b15
commit 47a5252230
2 changed files with 20 additions and 29 deletions

View File

@ -27,12 +27,9 @@ static void clock_250ms(void) {
power_off(); power_off();
} }
else { else {
uint8_t save_reg = SREG; ATOMIC_START
cli(); psu_timeout++;
CLI_SEI_BUG_MEMORY_BARRIER(); ATOMIC_END
psu_timeout++;
MEMORY_BARRIER();
SREG = save_reg;
} }
} }

View File

@ -116,14 +116,11 @@ void enqueue_home(TARGET *t, uint8_t endstop_check, uint8_t endstop_stop_cond) {
mb_head = h; mb_head = h;
uint8_t save_reg = SREG; uint8_t isdead;
cli();
CLI_SEI_BUG_MEMORY_BARRIER();
uint8_t isdead = (movebuffer[mb_tail].live == 0); ATOMIC_START
isdead = (movebuffer[mb_tail].live == 0);
MEMORY_BARRIER(); ATOMIC_END
SREG = save_reg;
if (isdead) { if (isdead) {
next_move(); next_move();
@ -173,19 +170,16 @@ void queue_flush() {
// Since the timer interrupt is disabled before this function // Since the timer interrupt is disabled before this function
// is called it is not strictly necessary to write the variables // is called it is not strictly necessary to write the variables
// inside an interrupt disabled block... // inside an interrupt disabled block...
uint8_t save_reg = SREG; ATOMIC_START
cli();
CLI_SEI_BUG_MEMORY_BARRIER();
// flush queue // flush queue
mb_tail = mb_head; mb_tail = mb_head;
movebuffer[mb_head].live = 0; movebuffer[mb_head].live = 0;
// disable timer // disable timer
setTimer(0); setTimer(0);
MEMORY_BARRIER(); ATOMIC_END
SREG = save_reg;
} }
/// wait for queue to empty /// wait for queue to empty