31 #if PERIODIC_TELEMETRY
39 #if PERIODIC_TELEMETRY
40 static void send_i2c0_err(
struct transport_tx *
trans,
struct link_device *
dev)
43 uint16_t i2c0_queue_full_cnt = i2c0.errors->queue_full_cnt;
44 uint16_t i2c0_ack_fail_cnt = i2c0.errors->ack_fail_cnt;
45 uint16_t i2c0_miss_start_stop_cnt = i2c0.errors->miss_start_stop_cnt;
46 uint16_t i2c0_arb_lost_cnt = i2c0.errors->arb_lost_cnt;
47 uint16_t i2c0_over_under_cnt = i2c0.errors->over_under_cnt;
48 uint16_t i2c0_pec_recep_cnt = i2c0.errors->pec_recep_cnt;
49 uint16_t i2c0_timeout_tlow_cnt = i2c0.errors->timeout_tlow_cnt;
50 uint16_t i2c0_smbus_alert_cnt = i2c0.errors->smbus_alert_cnt;
51 uint16_t i2c0_unexpected_event_cnt = i2c0.errors->unexpected_event_cnt;
52 uint32_t i2c0_last_unexpected_event = i2c0.errors->last_unexpected_event;
54 pprz_msg_send_I2C_ERRORS(
trans,
dev, AC_ID,
58 &i2c0_miss_start_stop_cnt,
62 &i2c0_timeout_tlow_cnt,
63 &i2c0_smbus_alert_cnt,
64 &i2c0_unexpected_event_cnt,
65 &i2c0_last_unexpected_event,
83 #if PERIODIC_TELEMETRY
84 static void send_i2c1_err(
struct transport_tx *
trans,
struct link_device *
dev)
87 uint16_t i2c1_queue_full_cnt = i2c1.errors->queue_full_cnt;
88 uint16_t i2c1_ack_fail_cnt = i2c1.errors->ack_fail_cnt;
89 uint16_t i2c1_miss_start_stop_cnt = i2c1.errors->miss_start_stop_cnt;
90 uint16_t i2c1_arb_lost_cnt = i2c1.errors->arb_lost_cnt;
91 uint16_t i2c1_over_under_cnt = i2c1.errors->over_under_cnt;
92 uint16_t i2c1_pec_recep_cnt = i2c1.errors->pec_recep_cnt;
93 uint16_t i2c1_timeout_tlow_cnt = i2c1.errors->timeout_tlow_cnt;
94 uint16_t i2c1_smbus_alert_cnt = i2c1.errors->smbus_alert_cnt;
95 uint16_t i2c1_unexpected_event_cnt = i2c1.errors->unexpected_event_cnt;
96 uint32_t i2c1_last_unexpected_event = i2c1.errors->last_unexpected_event;
98 pprz_msg_send_I2C_ERRORS(
trans,
dev, AC_ID,
100 &i2c1_queue_full_cnt,
102 &i2c1_miss_start_stop_cnt,
104 &i2c1_over_under_cnt,
106 &i2c1_timeout_tlow_cnt,
107 &i2c1_smbus_alert_cnt,
108 &i2c1_unexpected_event_cnt,
109 &i2c1_last_unexpected_event,
127 #if PERIODIC_TELEMETRY
128 static void send_i2c2_err(
struct transport_tx *
trans,
struct link_device *
dev)
131 uint16_t i2c2_queue_full_cnt = i2c2.errors->queue_full_cnt;
132 uint16_t i2c2_ack_fail_cnt = i2c2.errors->ack_fail_cnt;
133 uint16_t i2c2_miss_start_stop_cnt = i2c2.errors->miss_start_stop_cnt;
134 uint16_t i2c2_arb_lost_cnt = i2c2.errors->arb_lost_cnt;
135 uint16_t i2c2_over_under_cnt = i2c2.errors->over_under_cnt;
136 uint16_t i2c2_pec_recep_cnt = i2c2.errors->pec_recep_cnt;
137 uint16_t i2c2_timeout_tlow_cnt = i2c2.errors->timeout_tlow_cnt;
138 uint16_t i2c2_smbus_alert_cnt = i2c2.errors->smbus_alert_cnt;
139 uint16_t i2c2_unexpected_event_cnt = i2c2.errors->unexpected_event_cnt;
140 uint32_t i2c2_last_unexpected_event = i2c2.errors->last_unexpected_event;
142 pprz_msg_send_I2C_ERRORS(
trans,
dev, AC_ID,
144 &i2c2_queue_full_cnt,
146 &i2c2_miss_start_stop_cnt,
148 &i2c2_over_under_cnt,
150 &i2c2_timeout_tlow_cnt,
151 &i2c2_smbus_alert_cnt,
152 &i2c2_unexpected_event_cnt,
153 &i2c2_last_unexpected_event,
176 #if PERIODIC_TELEMETRY
177 static void send_i2c3_err(
struct transport_tx *
trans,
struct link_device *
dev)
179 uint16_t i2c3_wd_reset_cnt = i2c3.errors->wd_reset_cnt;
180 uint16_t i2c3_queue_full_cnt = i2c3.errors->queue_full_cnt;
181 uint16_t i2c3_ack_fail_cnt = i2c3.errors->ack_fail_cnt;
182 uint16_t i2c3_miss_start_stop_cnt = i2c3.errors->miss_start_stop_cnt;
183 uint16_t i2c3_arb_lost_cnt = i2c3.errors->arb_lost_cnt;
184 uint16_t i2c3_over_under_cnt = i2c3.errors->over_under_cnt;
185 uint16_t i2c3_pec_recep_cnt = i2c3.errors->pec_recep_cnt;
186 uint16_t i2c3_timeout_tlow_cnt = i2c3.errors->timeout_tlow_cnt;
187 uint16_t i2c3_smbus_alert_cnt = i2c3.errors->smbus_alert_cnt;
188 uint16_t i2c3_unexpected_event_cnt = i2c3.errors->unexpected_event_cnt;
189 uint32_t i2c3_last_unexpected_event = i2c3.errors->last_unexpected_event;
191 pprz_msg_send_I2C_ERRORS(
trans,
dev, AC_ID,
193 &i2c3_queue_full_cnt,
195 &i2c3_miss_start_stop_cnt,
197 &i2c3_over_under_cnt,
199 &i2c3_timeout_tlow_cnt,
200 &i2c3_smbus_alert_cnt,
201 &i2c3_unexpected_event_cnt,
202 &i2c3_last_unexpected_event,
219 #if PERIODIC_TELEMETRY
220 static void send_i2c4_err(
struct transport_tx *
trans,
struct link_device *
dev)
222 uint16_t i2c4_wd_reset_cnt = i2c4.errors->wd_reset_cnt;
223 uint16_t i2c4_queue_full_cnt = i2c4.errors->queue_full_cnt;
224 uint16_t i2c4_ack_fail_cnt = i2c4.errors->ack_fail_cnt;
225 uint16_t i2c4_miss_start_stop_cnt = i2c4.errors->miss_start_stop_cnt;
226 uint16_t i2c4_arb_lost_cnt = i2c4.errors->arb_lost_cnt;
227 uint16_t i2c4_over_under_cnt = i2c4.errors->over_under_cnt;
228 uint16_t i2c4_pec_recep_cnt = i2c4.errors->pec_recep_cnt;
229 uint16_t i2c4_timeout_tlow_cnt = i2c4.errors->timeout_tlow_cnt;
230 uint16_t i2c4_smbus_alert_cnt = i2c4.errors->smbus_alert_cnt;
231 uint16_t i2c4_unexpected_event_cnt = i2c4.errors->unexpected_event_cnt;
232 uint32_t i2c4_last_unexpected_event = i2c4.errors->last_unexpected_event;
234 pprz_msg_send_I2C_ERRORS(
trans,
dev, AC_ID,
236 &i2c4_queue_full_cnt,
238 &i2c4_miss_start_stop_cnt,
240 &i2c4_over_under_cnt,
242 &i2c4_timeout_tlow_cnt,
243 &i2c4_smbus_alert_cnt,
244 &i2c4_unexpected_event_cnt,
245 &i2c4_last_unexpected_event,
253 extern void send_softi2c0_err(
struct transport_tx *
trans,
struct link_device *
dev);
257 extern void send_softi2c1_err(
struct transport_tx *
trans,
struct link_device *
dev);
260 #if PERIODIC_TELEMETRY
262 struct link_device *
dev __attribute__((unused)))
264 static uint8_t _i2c_nb_cnt = 0;
265 switch (_i2c_nb_cnt) {
303 if (_i2c_nb_cnt == 7) {
312 p->trans_insert_idx = 0;
313 p->trans_extract_idx = 0;
317 #if PERIODIC_TELEMETRY
355 #ifndef I2C_BLOCKING_TIMEOUT
356 #define I2C_BLOCKING_TIMEOUT 1.f
373 if (
p->spin)
p->spin(
p);
395 if (
p->spin)
p->spin(
p);
417 if (
p->spin)
p->spin(
p);
struct i2c_errors * errors
uint16_t len_r
Number of bytes to read/receive.
volatile uint16_t wd_reset_cnt
enum I2CTransactionType type
Transaction type.
enum I2CTransactionStatus status
Transaction status.
struct i2c_transaction * trans[I2C_TRANSACTION_QUEUE_LEN]
uint8_t slave_addr
Slave address.
uint8_t len_w
Number of bytes to write/transmit.
bool i2c_blocking_transceive(struct i2c_periph *p, struct i2c_transaction *t, uint8_t s_addr, uint8_t len_w, uint16_t len_r)
Submit a write/read transaction and wait for it to complete.
bool i2c_blocking_receive(struct i2c_periph *p, struct i2c_transaction *t, uint8_t s_addr, uint16_t len)
Submit a read only transaction and wait for it to complete.
static bool i2c_submit(struct i2c_periph *p, struct i2c_transaction *t)
Submit a I2C transaction.
bool i2c_transmit(struct i2c_periph *p, struct i2c_transaction *t, uint8_t s_addr, uint8_t len)
Submit a write only transaction.
void i2c_init(struct i2c_periph *p)
Initialize I2C peripheral.
bool i2c_receive(struct i2c_periph *p, struct i2c_transaction *t, uint8_t s_addr, uint16_t len)
Submit a read only transaction.
bool i2c_blocking_transmit(struct i2c_periph *p, struct i2c_transaction *t, uint8_t s_addr, uint8_t len)
Submit a write only transaction and wait for it to complete.
bool i2c_transceive(struct i2c_periph *p, struct i2c_transaction *t, uint8_t s_addr, uint8_t len_w, uint16_t len_r)
Submit a write/read transaction.
@ I2CTransRunning
transaction is currently ongoing
@ I2CTransPending
transaction is pending in queue
@ I2CTransRx
receive only transaction
@ I2CTransTx
transmit only transaction
@ I2CTransTxRx
transmit and receive transaction
I2C transaction structure.
static void send_i2c_err(struct transport_tx *trans, struct link_device *dev)
#define I2C_BLOCKING_TIMEOUT
Default timeout for blocking I2C transactions.
Architecture independent I2C (Inter-Integrated Circuit Bus) API.
static const struct usb_device_descriptor dev
Architecture independent timing functions.
static float get_sys_time_float(void)
Get the time in seconds since startup.
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
Periodic telemetry system header (includes downlink utility and generated code).
#define DefaultPeriodic
Set default periodic telemetry.
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.