Ejemplo n.º 1
0
int main(int argc, char *argv[])
{
	struct at_pool *atp;
	struct athread *at;
	int *pid;

	plan_tests(4);

	atp = at_pool(1*1024*1024);
	assert(atp);
	pid = talloc(at_pool_ctx(atp), int);
	assert(pid);
	ok1((char *)pid >= (char *)atp->p->pool
	    && (char *)pid < (char *)atp->p->pool + atp->p->poolsize);
	at = at_run(atp, test, pid);
	assert(at);

	ok1(at_read(at) == test);
	talloc_free(at);

	ok1(*pid != 0);
	ok1(*pid != getpid());

	return exit_status();
}
Ejemplo n.º 2
0
int main(int argc, char *argv[])
{
	struct at_pool *atp;
	struct athread *at;
	int *val, i;

	plan_tests(3);

	atp = at_pool(1*1024*1024);
	assert(atp);
	val = talloc_zero(at_pool_ctx(atp), int);
	at = at_run(atp, test, val);
	assert(at);

	ok1(*val == 0);

	at_tell(at, test);

	/* We increment val, then sleep a little. */
	for (i = 0; i < NUM_RUNS; i++) {
		at_lock(val);
		(*(volatile int *)val)++;
		usleep(i * 100);
		at_unlock(val);
		usleep(i * 100);
	}
	ok1(at_read(at) == val);
	talloc_free(at);

	ok1(*val == NUM_RUNS*2);

	return exit_status();
}
Ejemplo n.º 3
0
int main(void) {
   char blah;
   
   //initialization
   gina_init();  // initialize hardware
   at_init();    // enable radio
   pwm_init();   // enable timers
   adc_init();   // init Analog-to-Digital (temp+xl)
   i2c_cfg();

   radio_cfg(); // init Radio
   imu_cfg();

   if(at_test()) {
      cmd_mode = CMD_MODE_ERROR;
   }

   cmd_mode = CMD_MODE_IMU_LOOP; //have the mote just blast data
   
   while(1) {
      //radio_cfg();
      //cmd_mode = CMD_MODE_IMU_LOOP; 
      cmd_loop();
      //Collect and send data 
      if (cmd_mode == CMD_MODE_IMU_LOOP) {
         imu_measure();
         imu_send();
         //blah=at_get_reg(RG_ANT_DIV);
         //blah+1;
      }

      //Clear out RX interrupts if we aren't expecting something
      if ((at_state!=AT_STATE_RX_READY && at_state!=AT_STATE_RX_WAITING)) { 
         at_rxmode(0);
         AT_CLR_IRQ;
      }
      PWM_WAIT;  //wait for the 3ms timer
         //Check RX
      if (at_state == AT_STATE_RX_WAITING) {
         at_read(&bytes, &len);
      }
   }
   return 0;
}