13 #define AMI601_NB_CHAN 6
20 #define AMI601_SENDING_REQ 1
21 #define AMI601_WAITING_MEASURE 2
22 #define AMI601_READING_MEASURE 3
23 #define AMI601_DATA_AVAILABLE 4
28 #define AMI601_SLAVE_ADDR 0x60
29 #define AMI601_IT TIR_MR1I
30 #define AMI601_ISR() {}
33 #define AMI601Event(_handler) { \
34 if (ami601_status == AMI601_DATA_AVAILABLE) \
38 #define AMI601Event(_handler) { \
39 switch (ami601_status) { \
40 case AMI601_SENDING_REQ : \
41 if ( ami601_i2c_trans.status == I2CTransSuccess ) { \
42 ami601_status = AMI601_WAITING_MEASURE; \
45 case AMI601_WAITING_MEASURE : \
46 ami601_status = AMI601_READING_MEASURE; \
47 ami601_i2c_trans.type = I2CTransRx; \
48 ami601_i2c_trans.len_r = 15; \
49 i2c_submit(&i2c1, &ami601_i2c_trans); \
51 case AMI601_READING_MEASURE : \
52 if ( ami601_i2c_trans.status == I2CTransSuccess ) { \
53 ami601_foo1 = ami601_i2c_trans.buf[0]; \
54 ami601_foo2 = ami601_i2c_trans.buf[1]; \
55 ami601_foo3 = ami601_i2c_trans.buf[2]; \
57 for (i=0; i< AMI601_NB_CHAN; i++) { \
58 ami601_values[i] = ami601_i2c_trans.buf[3 + 2 * i]; \
59 ami601_values[i] += ami601_i2c_trans.buf[3 + 2 * i + 1] * 256; \
61 ami601_status = AMI601_DATA_AVAILABLE; \
void ami601_scale_measures(void)
struct i2c_transaction ami601_i2c_trans
volatile uint8_t ami601_status
uint16_t ami601_values[AMI601_NB_CHAN]
I2C transaction structure.
void ami601_periodic(void)
volatile uint32_t ami601_nb_err
Architecture independent I2C (Inter-Integrated Circuit Bus) API.