Esempio n. 1
0
void __VERIFIER_atomic_take_snapshot(int readerstart1, int readerstart2) {
  /* Snapshot reader state. */
  __atomic_begin();
  readerstart1 = readerprogress1;
  readerstart2 = readerprogress2;
  __atomic_end();
}
/**
 * \brief Configures the given timer to the given mode with the given duration
 * \param id Id of the timer which should be configured
 * \param mode Mode can be TIMER_PERIODIC, TIMER_ONESHOT or TIMER_STOP
 * \param duration Run time of the timer in ms
 * \param handler Interrupts handler which should be called after an interrupt
 * \note Only TIMER0 and TIMER2 are supported
 * 
 */
void configure_timer(uint8_t id, uint8_t mode, uint16_t duration, void (*handler)(void))
{
	__atomic_start();
	if(id == TIMER0) {
		if(mode == TIMER_STOP) {
			//disable clock
			TCCR0 &= ~((1<<CS2)|(1<<CS1)|(1<<CS0)); 
			//disable interrupt
			TIMSK &= ~(1<<OCIE0);
		} else {
			//prescaler 64, ctc
			TCCR0 |= ((1<<CS2)|(1<<WGM1));
			TCCR0 &= ~((1<<CS1)|(1<<CS0)|(1<<WGM0));

			TCNT0 = 0x00;
			OCR0 = TIMER_OCR;
			TIMER0_MODE = mode;
			TIMER0_act = 0;

			//set timer run time
			setDuration(duration, id);

			//if interrupt handler is not NULL
			if(handler != NULL) {
				timer_0_handler = handler;
				//enable interrupt
				TIMSK |= (1<<OCIE0);
			}
		}
	}
	else if(id == TIMER2) {
		if(mode == TIMER_STOP) {
			//disable clock
			TCCR2 &= ~((1<<CS2)|(1<<CS1)|(1<<CS0));
			//disable interrupt
			TIMSK &= ~(1<<OCIE2);
		} else {
			//prescaler 64, ctc
			TCCR2 |= ((1<<CS1)|(1<<CS0)|(1<<WGM1));
			TCCR2 &= ~((1<<CS2)|(1<<WGM0));

			TCNT2 = 0x00;
			OCR2 = TIMER_OCR;
			TIMER2_MODE = mode;
			TIMER2_act = 0;

			//set timer run time
			setDuration(duration, id);

			//if interrupt handler is not NULL
			if(handler != NULL) {
				timer_2_handler = handler;
				//enable interrupt
				TIMSK |= (1<<OCIE2);
			}
		}
	}
	__atomic_end();
}
Esempio n. 3
0
void __VERIFIER_atomic_check_progress2(int readerstart2) {
  __atomic_begin();
  if (__nondet_bool()) {
    assume(readerstart2 == 1 && readerprogress2 == 1);
    __error();
  }
  __atomic_end();
  return;
}
Esempio n. 4
0
void __VERIFIER_atomic_check_progress1(int readerstart1) {
  /* Verify reader progress. */
  __atomic_begin();
  if (__nondet_bool()) {
    assume(readerstart1 == 1 && readerprogress1 == 1);
    __error();
  }
  __atomic_end();
}
void __VERIFIER_atomic_assert(int r) {
  __atomic_begin();
  assert(r && isEmpty());
  __atomic_end();
}
Esempio n. 6
0
void __VERIFIER_atomic_use_done(int myidx) {
  __atomic_begin();
  if (myidx <= 0) { ctr1--; }
  else { ctr2--; }
  __atomic_end();
}
Esempio n. 7
0
void __VERIFIER_atomic_use2(int myidx) {
  __atomic_begin();
  assume(myidx >= 1 && ctr2>0);
  ctr2++;
  __atomic_end();
}
Esempio n. 8
0
void __VERIFIER_atomic_use1(int myidx) {
  __atomic_begin();
  assume(myidx <= 0 && ctr1>0);
  ctr1++;
  __atomic_end();
}