paparazzi-commits
[Top][All Lists]
Advanced

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

[paparazzi-commits] [5785] breaking I2C xxx


From: antoine drouin
Subject: [paparazzi-commits] [5785] breaking I2C xxx
Date: Thu, 02 Sep 2010 15:27:46 +0000

Revision: 5785
          http://svn.sv.gnu.org/viewvc/?view=rev&root=paparazzi&revision=5785
Author:   poine
Date:     2010-09-02 15:27:46 +0000 (Thu, 02 Sep 2010)
Log Message:
-----------
breaking I2C xxx

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

Modified: paparazzi3/trunk/sw/airborne/i2c.h
===================================================================
--- paparazzi3/trunk/sw/airborne/i2c.h  2010-09-02 14:56:18 UTC (rev 5784)
+++ paparazzi3/trunk/sw/airborne/i2c.h  2010-09-02 15:27:46 UTC (rev 5785)
@@ -11,11 +11,11 @@
   I2CTransTxRx 
 };
 
-enum I2CTransactionResult {  
+enum I2CTransactionStatus {  
   I2CTransPending, 
   I2CTransRunning, 
   I2CTransSuccess, 
-  I2CTransFailed 
+  I2CTransFailed
 };
 
 enum I2CStatus { 
@@ -44,10 +44,10 @@
   uint8_t  len_w;
   bool_t   stop_after_transmit;
   volatile uint8_t  buf[I2C_BUF_LEN];
-  volatile enum I2CTransactionResult result;
+  volatile enum I2CTransactionStatus status;
 };
 
-#define I2C_TRANSACTION_QUEUE_LEN 4
+#define I2C_TRANSACTION_QUEUE_LEN 8
 
 struct i2c_periph {
   /* circular buffer holding transactions */
@@ -57,6 +57,7 @@
   /* internal state of the peripheral */
   volatile enum I2CStatus status;
   volatile uint8_t idx_buf;
+  void* reg_addr;
 };
 
 
@@ -247,18 +248,10 @@
 
 #ifdef USE_I2C2
 
+extern struct i2c_periph i2c2;
 
-//extern struct i2c i2c2;
-
 extern void i2c2_init(void);
-//extern void i2c2_receive(uint8_t slave_addr, uint8_t len, volatile bool_t* 
finished);
-//extern void i2c2_transmit(uint8_t slave_addr, uint8_t len, volatile bool_t* 
finished);
-//extern void i2c2_transceive(uint8_t slave_addr, uint8_t len_w, uint16_t 
len_r, volatile bool_t* finished);
 
-extern struct i2c_periph i2c2;
-
-
-
 #endif /* USE_I2C2 */
 
 extern void   i2c_init(struct i2c_periph* p);

Modified: paparazzi3/trunk/sw/airborne/stm32/i2c_hw.c
===================================================================
--- paparazzi3/trunk/sw/airborne/stm32/i2c_hw.c 2010-09-02 14:56:18 UTC (rev 
5784)
+++ paparazzi3/trunk/sw/airborne/stm32/i2c_hw.c 2010-09-02 15:27:46 UTC (rev 
5785)
@@ -262,6 +262,8 @@
 
 
 void i2c2_hw_init(void) {
+  
+  i2c2.reg_addr = I2C2;
 
   /* zeros error counter */
   ZEROS_ERR_COUNTER(i2c2_errors);
@@ -316,7 +318,7 @@
 
 
 
-static inline void on_status_start_requested(uint32_t event);
+static inline void on_status_start_requested(const struct i2c_transaction* 
trans, uint32_t event);
 static inline void on_status_addr_wr_sent(uint32_t event);
 static inline void on_status_sending_byte(uint32_t event);
 //static inline void on_status_sending_last_byte(uint32_t event);
@@ -338,9 +340,8 @@
  * Start Requested
  *
  */
-static inline void on_status_start_requested(uint32_t event) {
+static inline void on_status_start_requested(const struct i2c_transaction* 
trans, uint32_t event) {
   if (event & I2C_FLAG_SB) {
-    struct i2c_transaction* trans = i2c2.trans[i2c2.trans_extract_idx];
     if(trans->type == I2CTransRx) {
       I2C_Send7bitAddress(I2C2, trans->slave_addr, I2C_Direction_Receiver);
       i2c2.status = I2CAddrRdSent;
@@ -450,7 +451,7 @@
   }
   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->result = I2CTransSuccess;
+  trans->status = I2CTransSuccess;
   i2c2.status = I2CIdle;
 }
 
@@ -562,16 +563,17 @@
 void i2c2_ev_irq_handler(void) {
   //  DEBUG_S4_ON();
   uint32_t event = I2C_GetLastEvent(I2C2);
+  struct i2c_transaction* trans = i2c2.trans[i2c2.trans_extract_idx];
   //#if 0
   //  if (i2c2_errors.irq_cnt < 16) {
-    i2c2_errors.event_chain[i2c2_errors.irq_cnt] = event;
-    i2c2_errors.status_chain[i2c2_errors.irq_cnt] = i2c2.status;
-    i2c2_errors.irq_cnt++;
-    //  } else { while (1);}
-    //#endif
+  i2c2_errors.event_chain[i2c2_errors.irq_cnt] = event;
+  i2c2_errors.status_chain[i2c2_errors.irq_cnt] = i2c2.status;
+  i2c2_errors.irq_cnt++;
+  //  } else { while (1);}
+  //#endif
   switch (i2c2.status) {
   case I2CStartRequested:
-    on_status_start_requested(event);
+    on_status_start_requested(trans, event);
     break;
   case I2CAddrWrSent:
     on_status_addr_wr_sent(event);
@@ -621,7 +623,7 @@
 
 #define I2C2_ABORT_AND_RESET() {                                       \
     struct i2c_transaction* trans = i2c2.trans[i2c2.trans_extract_idx];        
\
-    trans->result = I2CTransFailed;                                    \
+    trans->status = I2CTransFailed;                                    \
     i2c2.status = I2CFailed;                                           \
     I2C_ITConfig(I2C2, I2C_IT_EVT | I2C_IT_BUF | I2C_IT_ERR, DISABLE); \
     I2C_Cmd(I2C2, DISABLE);                                            \
@@ -807,11 +809,11 @@
 
 bool_t i2c_submit(struct i2c_periph* p, struct i2c_transaction* t) {
   p->trans[p->trans_insert_idx] = t;
-  t->result = I2CTransPending;
+  t->status = I2CTransPending;
   p->idx_buf = 0;
   p->status = I2CStartRequested;
   I2C_ZERO_EVENTS();
-  I2C_ITConfig(I2C2, I2C_IT_EVT, ENABLE);
-  I2C_GenerateSTART(I2C2, ENABLE);
+  I2C_ITConfig(p->reg_addr, I2C_IT_EVT, ENABLE);
+  I2C_GenerateSTART(p->reg_addr, ENABLE);
   return TRUE;
 }




reply via email to

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