Пример #1
0
Файл: wmp.c Проект: bobbens/LACE
static int wmp_done( event_t *evt )
{
   char buf[6];
   event_t wmp_evt;

   /* Failure. */
   if (!evt->i2c.ok) {
      wmp_err();
      event_setCallback( EVENT_TYPE_I2C, NULL );
      return 1;
   }

   /* Get the data read. */
   i2cm_read( buf, sizeof(buf) );

   /* Convert to 16 bit ints. */
   wmp_buf[ WMP_YAW ]     = ((uint16_t)buf[3] << 6) + buf[0];
   wmp_buf[ WMP_PITCH ]   = ((uint16_t)buf[4] << 6) + buf[1];
   wmp_buf[ WMP_ROLL ]    = ((uint16_t)buf[5] << 6) + buf[2];

   /* Disable callback. */
   event_setCallback( EVENT_TYPE_I2C, NULL );

   /* Generate event. */
   wmp_evt.type         = EVENT_TYPE_CUSTOM;
   wmp_evt.custom.id    = WMP_EVENT_DATA;
   wmp_evt.custom.data  = ((buf[3] & 0x02) << 2) + buf[4];
   event_push( &wmp_evt );

   /* Destroy the event. */
   return 1;
}
Пример #2
0
// ceci sous entend qu' a chaque lecture on incremente le pointeur de
// donnee vers le tableau read_tab
 void i2cm_read_multiple(uint8_t adress, uint8_t *trame, uint8_t argc)
 {
  uint8_t idx, cpt;
  i2cm_flush( adress);
    
  wait_ms(1);
  
  for (idx = 0; idx < argc; idx ++)
            trame[idx]= i2cm_read(adress);
  
 }