paparazzi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[paparazzi-commits] [5780] breaking I2C - don't update now, work in prog


From: antoine drouin
Subject: [paparazzi-commits] [5780] breaking I2C - don't update now, work in progress
Date: Thu, 02 Sep 2010 13:24:27 +0000

Revision: 5780
          http://svn.sv.gnu.org/viewvc/?view=rev&root=paparazzi&revision=5780
Author:   poine
Date:     2010-09-02 13:24:27 +0000 (Thu, 02 Sep 2010)
Log Message:
-----------
breaking I2C - don't update now, work in progress

Modified Paths:
--------------
    paparazzi3/trunk/sw/airborne/i2c.c
    paparazzi3/trunk/sw/airborne/i2c.h
    paparazzi3/trunk/sw/airborne/stm32/i2c_hw.c

Modified: paparazzi3/trunk/sw/airborne/i2c.c
===================================================================
--- paparazzi3/trunk/sw/airborne/i2c.c  2010-09-02 11:24:32 UTC (rev 5779)
+++ paparazzi3/trunk/sw/airborne/i2c.c  2010-09-02 13:24:27 UTC (rev 5780)
@@ -179,6 +179,8 @@
   I2C_GenerateSTART(I2C2, ENABLE);
 }
 
+struct i2c_periph i2c2;
 
 
 #endif /* USE_I2C2 */
+

Modified: paparazzi3/trunk/sw/airborne/i2c.h
===================================================================
--- paparazzi3/trunk/sw/airborne/i2c.h  2010-09-02 11:24:32 UTC (rev 5779)
+++ paparazzi3/trunk/sw/airborne/i2c.h  2010-09-02 13:24:27 UTC (rev 5780)
@@ -5,12 +5,19 @@
 
 #include "i2c_hw.h"
 
-enum I2CTransaction { 
+enum I2CTransactionType { 
   I2CTransTx, 
   I2CTransRx, 
   I2CTransTxRx 
 };
 
+enum I2CTransactionResult {  
+  I2CTransPending, 
+  I2CTransRunning, 
+  I2CTransSuccess, 
+  I2CTransFailed 
+};
+
 enum I2CStatus { 
   I2CIdle, 
   I2CStartRequested,
@@ -30,18 +37,29 @@
 #define I2C_BUF_LEN 32
 #endif
 
-struct i2c {
-  volatile enum I2CStatus status;
-  volatile enum I2CTransaction transaction;
-  volatile uint8_t  slave_addr;
-  volatile uint16_t len_r;
-  volatile uint8_t  len_w;
-  volatile bool_t   stop_after_transmit;
-  volatile uint8_t  index;
-  volatile bool_t*  finished;
+struct i2c_transaction {
+  enum I2CTransactionType type;
+  uint8_t  slave_addr;
+  uint16_t len_r;
+  uint8_t  len_w;
+  bool_t   stop_after_transmit;
   volatile uint8_t  buf[I2C_BUF_LEN];
+  volatile enum I2CTransactionResult result;
 };
 
+#define I2C_TRANSACTION_QUEUE_LEN 4
+
+struct i2c_periph {
+  /* circular buffer holding transactions */
+  struct i2c_transaction* trans[I2C_TRANSACTION_QUEUE_LEN];
+  uint8_t trans_insert_index;
+  uint8_t trans_extract_index;
+  /* internal state of the peripheral */
+  volatile enum I2CStatus status;
+  volatile uint8_t idx_buf;
+};
+
+
 struct i2c_errors {
   volatile uint16_t ack_fail_cnt;
   volatile uint16_t miss_start_stop_cnt;
@@ -59,20 +77,6 @@
 };
 
 
-#define I2C_START        0x08
-#define I2C_RESTART      0x10
-#define I2C_MT_SLA_ACK   0x18
-#define I2C_MT_SLA_NACK  0x20
-#define I2C_MT_DATA_ACK  0x28
-#define I2C_MR_SLA_ACK   0x40
-#define I2C_MR_SLA_NACK  0x48
-#define I2C_MR_DATA_ACK  0x50
-#define I2C_MR_DATA_NACK 0x58
-
-
-#define I2C_IDLE 0
-#define I2C_BUSY 1
-
 #ifdef USE_I2C0
 
 extern void i2c0_init(void);
@@ -244,7 +248,7 @@
 #ifdef USE_I2C2
 
 
-extern struct i2c i2c2;
+extern struct i2c_periph i2c2;
 
 extern void i2c2_init(void);
 extern void i2c2_receive(uint8_t slave_addr, uint8_t len, volatile bool_t* 
finished);
@@ -253,5 +257,10 @@
 
 #endif /* USE_I2C2 */
 
+extern struct i2c_periph i2c2;
 
+extern void   i2c_init(struct i2c_periph* p);
+extern bool_t i2c_submit(struct i2c_periph* p, struct i2c_transaction* t);
+
+
 #endif /* I2C_H */

Modified: paparazzi3/trunk/sw/airborne/stm32/i2c_hw.c
===================================================================
--- paparazzi3/trunk/sw/airborne/stm32/i2c_hw.c 2010-09-02 11:24:32 UTC (rev 
5779)
+++ paparazzi3/trunk/sw/airborne/stm32/i2c_hw.c 2010-09-02 13:24:27 UTC (rev 
5780)
@@ -793,3 +793,15 @@
 
 
 #endif /* USE_I2C2 */
+
+
+
+void   i2c_init(struct i2c_periph* p) {
+
+
+}
+
+bool_t i2c_submit(struct i2c_periph* p, struct i2c_transaction* t) {
+
+
+}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]