Paparazzi UAS
v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
ami601.h
Go to the documentation of this file.
1
#ifndef AMI601_H
2
#define AMI601_H
3
4
#include "
std.h
"
5
#include "
mcu_periph/i2c.h
"
6
7
extern
void
ami601_init
(
void
);
8
9
extern
void
ami601_read
(
void
);
10
extern
void
ami601_periodic
(
void
);
11
extern
void
ami601_scale_measures
(
void
);
12
13
#define AMI601_NB_CHAN 6
14
extern
uint16_t
ami601_values
[
AMI601_NB_CHAN
];
15
extern
uint8_t
ami601_foo1
;
16
extern
uint8_t
ami601_foo2
;
17
extern
uint8_t
ami601_foo3
;
18
19
#define AMI601_IDLE 0
20
#define AMI601_SENDING_REQ 1
21
#define AMI601_WAITING_MEASURE 2
22
#define AMI601_READING_MEASURE 3
23
#define AMI601_DATA_AVAILABLE 4
24
extern
volatile
uint8_t
ami601_status
;
25
extern
struct
i2c_transaction
ami601_i2c_trans
;
26
extern
volatile
uint32_t
ami601_nb_err
;
27
28
#define AMI601_SLAVE_ADDR 0x60
29
#define AMI601_IT TIR_MR1I
30
#define AMI601_ISR() {}
31
32
#ifdef SITL
33
#define AMI601Event(_handler) { \
34
if (ami601_status == AMI601_DATA_AVAILABLE) \
35
_handler(); \
36
}
37
#else
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; \
43
} \
44
break; \
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); \
50
break; \
51
case AMI601_READING_MEASURE : \
52
if ( ami601_i2c_trans.status == I2CTransSuccess ) { \
53
ami601_foo1 = ami601_i2c_trans.buf[0];
/* AA ? */
\
54
ami601_foo2 = ami601_i2c_trans.buf[1];
/* 55 ? */
\
55
ami601_foo3 = ami601_i2c_trans.buf[2];
/* ERR ? */
\
56
uint8_t i; \
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; \
60
} \
61
ami601_status = AMI601_DATA_AVAILABLE; \
62
_handler(); \
63
} \
64
break; \
65
default: \
66
break; \
67
} \
68
}
69
#endif
70
71
72
73
#endif
/* AMI601_H */
uint16_t
unsigned short uint16_t
Definition:
types.h:16
ami601_values
uint16_t ami601_values[AMI601_NB_CHAN]
Definition:
ami601.c:6
ami601_nb_err
volatile uint32_t ami601_nb_err
Definition:
ami601.c:10
uint32_t
unsigned long uint32_t
Definition:
types.h:18
ami601_foo2
uint8_t ami601_foo2
Definition:
ami601.c:4
ami601_foo3
uint8_t ami601_foo3
Definition:
ami601.c:5
std.h
ami601_read
void ami601_read(void)
Definition:
ami601.c:26
uint8_t
unsigned char uint8_t
Definition:
types.h:14
ami601_i2c_trans
struct i2c_transaction ami601_i2c_trans
Definition:
ami601.c:9
i2c_transaction
I2C transaction structure.
Definition:
i2c.h:93
ami601_status
volatile uint8_t ami601_status
Definition:
ami601.c:8
ami601_foo1
uint8_t ami601_foo1
Definition:
ami601.c:3
AMI601_NB_CHAN
#define AMI601_NB_CHAN
Definition:
ami601.h:13
ami601_scale_measures
void ami601_scale_measures(void)
ami601_init
void ami601_init(void)
Definition:
ami601.c:12
i2c.h
ami601_periodic
void ami601_periodic(void)
sw
airborne
peripherals
ami601.h
Generated on Tue Feb 1 2022 13:51:17 for Paparazzi UAS by
1.8.17