Parcourir la source

fix(api_rt_i2c): 修复i2c储存超时bug

CN\zhangkai71 il y a 2 ans
Parent
commit
7a11939a8b

+ 0 - 2
User project/1.FrameLayer/Source/tbc.c

@@ -46,12 +46,10 @@ Revising History (ECL of this file):
  Subroutine Call: ...;
  Reference: N/A
 ****************************************************************/
-UWORD timer1cnt;
 void tbc_voUpIsr(void)
 {
     /* Uart Monitor */
     uart_voAppMonitor();
-    timer1cnt = TIMER_CNT(TIMER1);
     /* Motor Position Cal */
     if( cp_stFlg.ThetaGetModelSelect == ANG_RESOLVER )
     {

+ 1 - 1
User project/2.MotorDrive/Source/spdctrmode.c

@@ -830,7 +830,7 @@ void  scm_voSpdCtrMdDownTbc(void)
     iPwm_SetCompareGroupValues16(0, pwm_stGenOut.uwNewTIM1COMPR);
     ULONG samplingTick[2];
     samplingTick[0]=pwm_stGenOut.uwSigRTrig;
-    samplingTick[1]=pwm_stGenOut.uwRDSONTrig;
+    samplingTick[1]=pwm_stGenOut.uwRdsonTrig;
     iPwm_SyncMultiSamplingCountUp(0, &samplingTick[0], 2);
     
     

+ 0 - 8
User project/3.BasicFunction/Include/i2c_master.h

@@ -706,14 +706,6 @@
 /************************************************************************
  TypeDefs & Structure defines (N/A)
 *************************************************************************/
-typedef enum {
-    I2C_START = 0,
-    I2C_SEND_ADDRESS,
-    I2C_CLEAR_ADDRESS_FLAG,
-    I2C_TRANSMIT_DATA,
-    I2C_STOP,
-} i2c_process_enum;
-
 typedef struct
 {
     UBYTE ubTX1NPages;

+ 9 - 2
User project/3.BasicFunction/Source/canAppl.c

@@ -23,6 +23,7 @@
 #include "torquesensor.h"
 #include "user.h"
 #include "FSM_2nd.h"
+#include "fp.def"
 /******************************
  *
  *  Parameter
@@ -216,9 +217,15 @@ void Can_voInitMC_Run(void)
 	strncpy(MC_VerInfo.HW_Version, (char *)"TEST.           ", 16);
 #endif
     // Software version
-    strncpy(MC_VerInfo.FW_Version, (char *)"V0r1r9_20230607.", 16);
+    char chFwVersion[16]="V0r1r9_";
+    strncat(chFwVersion,COMMIT_TIME,9);
+    strncpy(MC_VerInfo.FW_Version, (char *)chFwVersion, 16);
+    
     // Firmware Special Info
-    strncpy(Firmware_Special, (char *)"TC00000-MC00000-V0r0.           ", 32);
+    char chFrimware[32]="TC00000-MC00000-V0r0.  ";
+    strncat(chFrimware,FINGER_PRINT,9);
+    strncpy(Firmware_Special, (char *)chFrimware, 32);
+    
     // Model name
     memcpy(MC_VerInfo.Mode, flash_stPara.ubMotorVersion, sizeof(flash_stPara.ubMotorVersion));
     // SN

+ 1 - 1
User project/4.BasicHardwSoftwLayer/2.BasicSoftwLayer/Include/user.h

@@ -110,7 +110,7 @@ Update Time
 #define M_MAX_TOR_NM        30      // unit: 0.1Nm, Max tor
 
 #elif (MOTOR_ID_SEL == MOTOR_WELLING_CITY_36V)
-#define M_POLE_PAIRS        7       // unit:Null,Pole pairs
+#define M_POLE_PAIRS        17       // unit:Null,Pole pairs
 #define M_RS_OHM            150     // unit: 0.1mOhm, Phase resistance
 #define M_MATERIAL          Al      // unit:Null
 #define M_LD_NOLOAD_MH      7650    // unit: 0.01uH, D axis inductance

+ 6 - 17
User project/5.Api_rt/api_rt_i2c.c

@@ -252,7 +252,7 @@ int iRtI2C_PageWrite2EE(uint8_t devIndex, uint16_t devAddr, uint16_t memAddr, ui
             break;
         }
 
-        if(i2cBusResetCnt > 2 )
+        if(i2cBusResetCnt > 10)
         {
             break;
         }
@@ -522,21 +522,10 @@ int iI2C_Read(uint8_t devIndex, uint16_t devAddr, uint16_t memAddr, uint8_t memA
                     /* Enable DMA0 channel5 */
                     dma_channel_enable(DMA0, DMA_CH6);
                     /* Wait until BTC bit is set */
-                    while(dma_flag_get(DMA0, DMA_CH6, DMA_FLAG_FTF) == 0 && (timeoutCnt < I2C_TIME_OUT))
-                    {
-                        timeoutCnt++;
-                    }
-
-                    if(timeoutCnt < I2C_TIME_OUT) 
-                    {
-                        timeoutCnt = 0;
-                        state = (uint8_t)I2C_STOP;
-                    } 
-                    else 
-                    {
-                        i2c_timeout_flag = 1;
-                        break;
-                    }
+                    while(dma_flag_get(DMA0, DMA_CH6, DMA_FLAG_FTF) == 0)
+                    {}
+                 
+                    state = (uint8_t)I2C_STOP;
                 }
             }
             break;
@@ -579,7 +568,7 @@ int iI2C_Read(uint8_t devIndex, uint16_t devAddr, uint16_t memAddr, uint8_t memA
             break;
         }
 
-        if(i2cBusResetCnt > 1)
+        if(i2cBusResetCnt > 10)
         {
             break;
         }

+ 6 - 0
WLMCP.ewp

@@ -2886,6 +2886,12 @@
             <file>
                 <name>$PROJ_DIR$\User project\5.Api_rt\api_rt_gpio.h</name>
             </file>
+            <file>
+                <name>$PROJ_DIR$\User project\5.Api_rt\api_rt_i2c.c</name>
+            </file>
+            <file>
+                <name>$PROJ_DIR$\User project\5.Api_rt\api_rt_i2c.h</name>
+            </file>
             <file>
                 <name>$PROJ_DIR$\User project\5.Api_rt\api_rt_pwm.c</name>
             </file>