Beispiel #1
0
static msg_t lsm303_mag_update_thread(void *p) {
  I2CDriver *i2cp = (I2CDriver *)p;

  while (TRUE) {
    msg_t msg;

    /* Waiting for the IRQ to happen.*/

    chSysLock();
    magtp = chThdSelf();
    chSchGoSleepS(THD_STATE_SUSPENDED);
    msg = chThdSelf()->p_u.rdymsg;
    chSysUnlock();

    /* If data ready, update all axis.*/
    if (msg == LSM303_MAG_DATA_READY) {
      lsm303_mag_update(i2cp);
//      if (status_m != 0x00) {
//        lsm303_mag_update(i2cp);
//      }
    }
  }

  return RDY_OK;
}
Beispiel #2
0
Thread *magRun(SPIDriver *spip, tprio_t prio) {
	Thread *tp;

//	lsm303_mag_init(spip);
	chThdSleepMilliseconds(200);
	lsm303_mag_update(spip);
	tp = chThdCreateFromHeap(NULL, MAG_WA_SIZE, prio, lsm303_mag_update_thread, (void*) spip);
	extChannelEnable(&EXTD1, GPIOA_AM_INT2);

	return tp;
}
Beispiel #3
0
Thread *magRun(I2CDriver *i2cp, tprio_t prio) {
  Thread *tp;

  lsm303_mag_init(i2cp);
  chThdSleepMilliseconds(200);
  lsm303_mag_update(i2cp);
  tp = chThdCreateFromHeap(NULL, MAG_WA_SIZE, prio, lsm303_mag_update_thread,
                           (void*)i2cp);
  extChannelEnable(&EXTD1, AM_DRDY);

  return tp;
}