示例#1
0
/* Evaluate a genome and set its score. */
static void eval(struct genome_st *g)
{
	int to1, to2;
	unsigned d1, d2;
	struct timeval t0, t1, t2, t3;

        /* Measure how much time we waited until the idle system
         * and the time it take the application loading animation
         * to be commenced after the click. */
	gettimeofday(&t0, NULL);
	to1 = waitidle(g->window, g->threshold, TIMEOUT);
	gettimeofday(&t1, NULL);
	click(150, 200);
	gettimeofday(&t2, NULL);
	to2 = waitdbus(30);
	gettimeofday(&t3, NULL);

        /* Calculate the score and note the results. */
	d1 = diffit(&t1, &t0);
	d2 = diffit(&t3, &t2);
	g->score = d1 + d2;
	printf( "window=%u, threshold=%f, t1=%u%s, t2=%u%s, score=%u\n",
		g->window, g->threshold,
		d1, to1 ? "" : " [timeout]",
		d2, to2 ? "" : " [timeout]",
		g->score);
} /* eval */
示例#2
0
文件: i2c.c 项目: almjunge/ottos
void i2c_read(uint32_t base, uint8_t sa, uint8_t addr, uint8_t *buffer,
                  int count) {
  waitidle(base);
  // send address with no stop
  executeStateMachine(base, 0x8601, sa, &addr, 1);
  // send rest with stop
  executeStateMachine(base, 0x8403, sa, buffer, count);
}
示例#3
0
文件: i2c.c 项目: almjunge/ottos
// address encoded in buffer
void i2c_write(uint32_t base, uint8_t sa, uint8_t *buffer, int count) {
  waitidle(base);
  executeStateMachine(base, 0x8603, sa, buffer, count);
}