23 #include "sensors/infrared_i2c.h"
26 #define IR_HOR_I2C_ADDR (0x6C << 1)
27 #define IR_VER_I2C_ADDR (0x68 << 1)
28 #define IR_SAMPLE_RATE_SELECT (0 << 2)
29 #define IR_HOR_OC_BIT (0 << 4)
30 #define IR_VER_OC_BIT (1 << 4)
31 #define IR_HOR_I2C_SELECT_IR1 (0 << 5)
32 #define IR_HOR_I2C_SELECT_IR2 (1 << 5)
33 #define IR_START_CONV (1 << 7)
36 #ifndef IR_I2C_IR1_NEUTRAL
37 #define IR_I2C_IR1_NEUTRAL 0
40 #ifndef IR_I2C_IR2_NEUTRAL
41 #define IR_I2C_IR2_NEUTRAL 0
44 #ifndef IR_I2C_TOP_NEUTRAL
45 #define IR_I2C_TOP_NEUTRAL 0
55 #define IR_I2C_READ_IR1 1
56 #define IR_I2C_IR2_SELECTED 2
57 #define IR_I2C_READ_IR2 3
58 #define IR_I2C_IR1_SELECTED 4
59 #define IR_I2C_CONFIGURE_HOR 5
63 #define NO_CONF_WORD 0xff
64 #define ValidConfWord(_x) (_x < 0x4)
103 #if ! (defined SITL || defined HITL)
131 #define FilterIR(_ir_prev, _ir_next) (((1<<ir_i2c_conf_word)*_ir_prev + _ir_next) / ((1<<ir_i2c_conf_word) + 1))
135 #if ! (defined SITL || defined HITL)
141 if (bit_is_set(irh_trans.buf[2], 7)) {
146 int16_t ir1 = (irh_trans.buf[0] << 8) | irh_trans.buf[1];
161 if (bit_is_set(irh_trans.buf[2], 7)) {
165 int16_t ir2 = (irh_trans.buf[0] << 8) | irh_trans.buf[1];
170 #ifndef IR_I2C_READ_ONLY
197 #if ! (defined SITL || defined HITL)
205 #ifndef IR_I2C_READ_ONLY
#define infrared_i2cEvent()
struct i2c_transaction irh_trans irv_trans
#define ValidConfWord(_x)
void infrared_i2c_init(void)
Initialisation.
#define IR_I2C_IR2_NEUTRAL
#define IR_HOR_I2C_SELECT_IR2
volatile uint8_t buf[I2C_BUF_LEN]
Transaction buffer With I2C_BUF_LEN number of bytes.
static uint8_t ir_i2c_hor_status
#define IR_I2C_IR1_SELECTED
struct Infrared_raw ir_i2c
#define IR_HOR_I2C_SELECT_IR1
#define IR_I2C_IR1_NEUTRAL
void infrared_update(void)
#define FilterIR(_ir_prev, _ir_next)
transaction set to done by user level
bool ir_i2c_conf_hor_done
void infrared_struct_init(void)
Initialisation of ir structure.
#define UpdateIRValue(_v)
I2C transaction structure.
enum I2CTransactionStatus status
Transaction status.
bool i2c_transmit(struct i2c_periph *p, struct i2c_transaction *t, uint8_t s_addr, uint8_t len)
Submit a write only transaction.
void infrared_i2c_update(void)
bool ir_i2c_conf_ver_done
bool ir_i2c_data_hor_available
void infrared_i2c_ver_event(void)
#define IR_I2C_CONFIGURE_HOR
bool i2c_receive(struct i2c_periph *p, struct i2c_transaction *t, uint8_t s_addr, uint16_t len)
Submit a read only transaction.
transmit only transaction
#define IR_I2C_TOP_NEUTRAL
enum I2CTransactionType type
Transaction type.
bool ir_i2c_data_ver_available
#define IR_I2C_IR2_SELECTED
void infrared_i2c_hor_event(void)
void infrared_event(void)