[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[paparazzi-commits] [5788] i2c2 now with a queue
From: |
antoine drouin |
Subject: |
[paparazzi-commits] [5788] i2c2 now with a queue |
Date: |
Thu, 02 Sep 2010 17:35:47 +0000 |
Revision: 5788
http://svn.sv.gnu.org/viewvc/?view=rev&root=paparazzi&revision=5788
Author: poine
Date: 2010-09-02 17:35:44 +0000 (Thu, 02 Sep 2010)
Log Message:
-----------
i2c2 now with a queue
Modified Paths:
--------------
paparazzi3/trunk/sw/airborne/stm32/i2c_hw.c
Modified: paparazzi3/trunk/sw/airborne/stm32/i2c_hw.c
===================================================================
--- paparazzi3/trunk/sw/airborne/stm32/i2c_hw.c 2010-09-02 16:50:14 UTC (rev
5787)
+++ paparazzi3/trunk/sw/airborne/stm32/i2c_hw.c 2010-09-02 17:35:44 UTC (rev
5788)
@@ -238,8 +238,8 @@
// 196610 30002 BUSY MSL | ADDR
//
+static void start_transaction(struct i2c_periph* p);
-
struct i2c_errors i2c2_errors;
#include "my_debug_servo.h"
@@ -445,9 +445,15 @@
}
}
I2C_ITConfig(I2C2, I2C_IT_EVT|I2C_IT_BUF, DISABLE); // should only need to
disable evt, buf already disabled
- // FIXME : lancer la transaction suivante
trans->status = I2CTransSuccess;
- i2c2.status = I2CIdle;
+
+ i2c2.trans_extract_idx =
(i2c2.trans_extract_idx+1)%I2C_TRANSACTION_QUEUE_LEN;
+ /* if we have no more transacation to process, stop here */
+ if (i2c2.trans_extract_idx == i2c2.trans_insert_idx)
+ i2c2.status = I2CIdle;
+ /* if not, start next transaction */
+ else
+ start_transaction(&i2c2);
}
/*
@@ -623,6 +629,13 @@
I2C2_APPLY_CONFIG(); \
I2C_ITConfig(I2C2, I2C_IT_ERR, ENABLE); \
\
+ i2c2.trans_extract_idx++; \
+ /* if we have no more transacation to process, stop here */
\
+ if (i2c2.trans_extract_idx == i2c2.trans_insert_idx) \
+ i2c2.status = I2CIdle; \
+ /* if not, start next transaction */ \
+ else \
+ start_transaction(&i2c2);
\
}
void i2c2_er_irq_handler(void) {
@@ -672,12 +685,32 @@
bool_t i2c_submit(struct i2c_periph* p, struct i2c_transaction* t) {
+
+ uint8_t temp;
+ temp = (p->trans_insert_idx + 1) % I2C_TRANSACTION_QUEUE_LEN;
+ if (temp == p->trans_extract_idx)
+ return FALSE; // queue full
+
+ t->status = I2CTransPending;
+
+ // FIXME : disable IRQ
+
+ /* put transacation in queue */
p->trans[p->trans_insert_idx] = t;
- t->status = I2CTransPending;
+ p->trans_insert_idx = temp;
+
+ /* if peripheral is idle, start the transaction */
+ if (p->status == I2CIdle)
+ start_transaction(p);
+
+ return TRUE;
+}
+
+
+static void start_transaction(struct i2c_periph* p) {
p->idx_buf = 0;
p->status = I2CStartRequested;
I2C_ZERO_EVENTS();
I2C_ITConfig(p->reg_addr, I2C_IT_EVT, ENABLE);
I2C_GenerateSTART(p->reg_addr, ENABLE);
- return TRUE;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [paparazzi-commits] [5788] i2c2 now with a queue,
antoine drouin <=