[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[paparazzi-commits] [4781]
From: |
Pascal Brisset |
Subject: |
[paparazzi-commits] [4781] |
Date: |
Fri, 02 Apr 2010 10:59:29 +0000 |
Revision: 4781
http://svn.sv.gnu.org/viewvc/?view=rev&root=paparazzi&revision=4781
Author: hecto
Date: 2010-04-02 10:59:29 +0000 (Fri, 02 Apr 2010)
Log Message:
-----------
Modified Paths:
--------------
paparazzi3/trunk/sw/airborne/modules/sensors/infrared_i2c.c
paparazzi3/trunk/sw/airborne/modules/sensors/infrared_i2c.h
Modified: paparazzi3/trunk/sw/airborne/modules/sensors/infrared_i2c.c
===================================================================
--- paparazzi3/trunk/sw/airborne/modules/sensors/infrared_i2c.c 2010-04-02
08:19:03 UTC (rev 4780)
+++ paparazzi3/trunk/sw/airborne/modules/sensors/infrared_i2c.c 2010-04-02
10:59:29 UTC (rev 4781)
@@ -23,76 +23,47 @@
#include "infrared_i2c.h"
#include "i2c.h"
-#include "uart.h"
-#include "messages.h"
-#include "downlink.h"
+#define IR_VERT_I2C_ADDR (0x68 << 1)
+#define OC_BIT (1 << 4)
-// Macros
-#define IR_VERT_I2C_ADDR 0xEA
-#define IR_VERT_I2C_REG 0x07
+#define IR_I2C_IDLE 0
+#define IR_I2C_READ_TOP 1
+#define IR_I2C_CONFIGURE_TOP 2
-#ifndef IR_IR1_SIGN
-#define IR_IR1_SIGN 1
-#endif // IR_IR1_SIGN
-
-#ifndef IR_IR2_SIGN
-#define IR_IR2_SIGN 1
-#endif // IR_IR2_SIGN
-
-#ifndef IR_TOP_SIGN
-#define IR_TOP_SIGN 1
-#endif // IR_TOP_SIGN
-
-/* Sensor installation */
-#if defined IR_HORIZ_SENSOR_ALIGNED
-/* IR1 on the lateral axis, IR2 on the longitudal axis */
-#define IR_RollOfIrs(_ir1, _ir2) (_ir1)
-#define IR_PitchOfIrs(_ir1, _ir2) (_ir2)
-#elif IR_HORIZ_SENSOR_TILTED
-/* IR1 rear-left -- front-right, IR2 rear-right -- front-left
- IR1_SIGN and IR2_SIGN give positive values when it's warm on the right side
-*/
-#define IR_RollOfIrs(_ir1, _ir2) (_ir1 + _ir2)
-#define IR_PitchOfIrs(_ir1, _ir2) (-(_ir1) + _ir2)
-#endif
-/* Vertical sensor */
-#ifndef IR_TopOfIr
-#define IR_TopOfIr(_ir) ((IR_TOP_SIGN)*(_ir))
-#endif
-
-#define IR_I2C_IDLE 0
-#define IR_I2C_READ_TOP 1
-
-// Global variables
-float ir_i2c_roll_neutral;
-float ir_i2c_pitch_neutral;
-
-int16_t ir_i2c_ir1;
-int16_t ir_i2c_ir2;
-int16_t ir_i2c_roll;
-int16_t ir_i2c_pitch;
int16_t ir_i2c_top;
// Local variables
volatile bool_t ir_i2c_done;
+bool_t ir_i2c_data_available;
static uint8_t ir_i2c_status;
+uint8_t ir_i2c_conf_word;
-void infrared_i2c_init( void ) {
- ir_i2c_roll_neutral = RadOfDeg(IR_ROLL_NEUTRAL_DEFAULT);
- ir_i2c_pitch_neutral = RadOfDeg(IR_PITCH_NEUTRAL_DEFAULT);
+#define NO_CONF_WORD 0xff
+#define ValidConfWord(_x) (_x < 0x4)
- ir_i2c_status = IR_I2C_IDLE;
- // Transmit sensor conf
- // TODO
+void infrared_i2c_init( void ) {
+ ir_i2c_done = TRUE;
+ ir_i2c_data_available = FALSE;
+ ir_i2c_status = IR_I2C_IDLE;
+ ir_i2c_conf_word = IR_I2C_DEFAULT_CONF;
}
void infrared_i2c_update( void ) {
if (ir_i2c_done && ir_i2c_status == IR_I2C_IDLE) {
- // Read next value TOP sensor
- i2c0_receive(IR_VERT_I2C_ADDR, 2, &ir_i2c_done);
- ir_i2c_status = IR_I2C_READ_TOP;
- ir_i2c_done = FALSE;
+ if (ValidConfWord(ir_i2c_conf_word)) {
+ i2c0_buf[0] = ir_i2c_conf_word | OC_BIT;
+ i2c0_transmit(IR_VERT_I2C_ADDR, 1, &ir_i2c_done);
+ ir_i2c_done = FALSE;
+ ir_i2c_status = IR_I2C_CONFIGURE_TOP;
+ ir_i2c_conf_word = NO_CONF_WORD;
+ } else {
+ // Read next value TOP sensor
+ i2c0_receive(IR_VERT_I2C_ADDR, 2, &ir_i2c_done);
+ ir_i2c_done = FALSE;
+ ir_i2c_data_available = FALSE;
+ ir_i2c_status = IR_I2C_READ_TOP;
+ }
}
}
@@ -102,10 +73,11 @@
break;
case IR_I2C_READ_TOP :
ir_i2c_top = (i2c0_buf[0]<<8) | i2c0_buf[1];
+ ir_i2c_data_available = TRUE;
ir_i2c_status = IR_I2C_IDLE;
break;
+ case IR_I2C_CONFIGURE_TOP :
+ ir_i2c_status = IR_I2C_IDLE;
+ break;
}
-
}
-
-
Modified: paparazzi3/trunk/sw/airborne/modules/sensors/infrared_i2c.h
===================================================================
--- paparazzi3/trunk/sw/airborne/modules/sensors/infrared_i2c.h 2010-04-02
08:19:03 UTC (rev 4780)
+++ paparazzi3/trunk/sw/airborne/modules/sensors/infrared_i2c.h 2010-04-02
10:59:29 UTC (rev 4781)
@@ -30,16 +30,17 @@
#include "std.h"
#include "airframe.h"
-extern float ir_i2c_roll_neutral; /* Rad */
-extern float ir_i2c_pitch_neutral; /* Rad */
-
-extern int16_t ir_i2c_ir1; /* First horizontal channel */
-extern int16_t ir_i2c_ir2; /* Second horizontal channel */
-extern int16_t ir_i2c_roll; /* averaged roll adc */
-extern int16_t ir_i2c_pitch; /* averaged pitch adc */
extern int16_t ir_i2c_top; /* averaged vertical ir adc */
+extern volatile bool_t ir_i2c_done;
+extern bool_t ir_i2c_data_available;
+extern uint8_t ir_i2c_conf_word;
extern void infrared_i2c_init( void );
extern void infrared_i2c_update( void );
+extern void infrared_i2c_event( void );
+#define infrared_i2cEvent() { if (ir_i2c_done) infrared_i2c_event(); }
+
+#define infrared_i2cDownlink() DOWNLINK_SEND_DEBUG_IR_I2C(DefaultChannel,
&ir_i2c_top)
+
#endif // INFRARED_I2C_H
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [paparazzi-commits] [4781],
Pascal Brisset <=