Przeglądaj źródła

1.增加右灯
2.尾灯模式增加模式7和模式8
模式7,开机低亮,刹车高亮
模式8,仅开灯高亮

CN\houcf5 7 miesięcy temu
rodzic
commit
c239b41de6

+ 1 - 1
1.FrameLayer/Source/main.c

@@ -193,7 +193,7 @@ int  main(void)
 
 //LED pwm 开始计数
    // DL_TimerG_startCounter(TIMG12);
-  //  DL_TimerG_startCounter(PWM_R_INST);
+    DL_TimerG_startCounter(PWM_R_INST);
     DL_TimerG_startCounter(PWM_F_INST);
     DL_TimerG_startCounter(PWM_B_L_INST);
 

+ 1 - 1
2.MotorDrive/Source/alarm.c

@@ -1097,7 +1097,7 @@ void alm_voReset(ALM_IN *in, ALM_RESET_COF *coef)
         {
             MCU_BRKIN_FLG_CLR; /* Clear TIME0 break flag */
             MCU_POEN_FLG_EN;   /* Enable TIME0 Channel outputs */
-            DL_GPIO_clearPins(GPIOA, DL_GPIO_PIN_31);
+           // DL_GPIO_clearPins(GPIOA, DL_GPIO_PIN_31);
             alm_unCode.bit.IPMFlt = FALSE;
           //  IO_FTESTLED_OFF();//   DL_TimerG_setCaptureCompareValue(PWM_F_INST, 0, GPIO_PWM_F_C1_IDX); //指示 test
 

+ 5 - 1
3.BasicFunction/Include/bikelight.h

@@ -173,7 +173,11 @@ typedef enum
 
     five_byte = 5,
 
-    six_byte = 6
+    six_byte = 6,
+
+    seven_byte = 7,
+
+    eight_byte = 8
 
 } LED_TYPE_STR;
 

+ 81 - 45
3.BasicFunction/Source/bikelight.c

@@ -380,6 +380,40 @@ else
               }
               break;
         }
+        case seven_byte:
+            if(Brate_Sta==TRUE)//开机低亮,刹车高亮
+                {
+                  BikeLedGloFun.blBike_BackLedSta=TRUE;
+                }
+                else
+                {
+                    BikeLedCheck_B.uwLedAddcnt++;
+                        if(BikeLedCheck_B.uwLedAddcnt > BikeLedAddCycle)
+                        {
+                            BikeLedCheck_B.uwLedAddcnt=0;
+                        }
+                        if(BikeLedCheck_B.uwLedAddcnt<BikeLedAddDuty)
+                        {
+                            BikeLedGloFun.blBike_BackLedSta=TRUE;
+                        }
+                        else
+                        {
+                            BikeLedGloFun.blBike_BackLedSta=FALSE;
+                         }
+
+                }
+            break;
+
+        case eight_byte:
+            if (switchAction == 1)//仪表开灯亮,仪表关灯灭
+                    {
+                        BikeLedGloFun.blBike_BackLedSta=TRUE;
+                    }
+                  else
+                  {
+                      BikeLedGloFun.blBike_BackLedSta=FALSE;
+                  }
+                    break;
     default:
              break;
 
@@ -396,7 +430,8 @@ else
               BikeLedCheck_B.uwBike_LedCheckLowTime=0;//检测过流IO出现低电平次数
               BikeLedCheck_B.blBike_ForwardLedStart=TRUE; //前灯允许开灯启动,总开关
               BikeLedCheck_B.blBike_LedCurErr=FALSE;
-              DL_TimerG_startCounter(PWM_B_L_INST);
+            //  DL_TimerG_startCounter(PWM_B_L_INST);
+              DL_Timer_overrideCCPOut(PWM_B_L_INST, DL_TIMER_FORCE_OUT_DISABLED, DL_TIMER_FORCE_CMPL_OUT_DISABLED, GPIO_PWM_B_L_C1_IDX);
               GPIOB->POLARITY15_0 &= ~(DL_GPIO_PIN_15_EDGE_FALL |DL_GPIO_PIN_15_EDGE_RISE);
               GPIOB->POLARITY15_0  |=DL_GPIO_PIN_15_EDGE_RISE;
 
@@ -495,45 +530,45 @@ else
 
     //------------右灯处理------
 
-//    if(switchAction==1) //
-//       {
-//           if(BikeLedCheck_R.uwBike_keyLedHighSta==0)
-//             {
-//                 BikeLedCheck_R.uwBike_keyLedHighSta=1;
-//                 BikeLedCheck_R.uwBike_OpenLedEn=0;//开灯瞬间处理标志
-//                 BikeLedCheck_R.uwBike_LedOffErrCnt=0;  //10秒一检测计时
-//                 BikeLedCheck_R.uwBike_OpenPreTime=0; //开灯瞬间5ms内处理计数
-//                 BikeLedCheck_R.uwBike_LedCheckLowTime=0;//检测过流IO出现低电平次数
-//                 BikeLedCheck_R.blBike_ForwardLedStart=TRUE; //前灯允许开灯启动,总开关
-//                 BikeLedCheck_R.blBike_LedCurErr=FALSE;
-//                 DL_TimerG_startCounter(PWM_R_INST);
-//                 GPIOB->POLARITY15_0 &= ~(DL_GPIO_PIN_8_EDGE_RISE |DL_GPIO_PIN_8_EDGE_FALL);
-//                 GPIOB->POLARITY15_0  |=DL_GPIO_PIN_8_EDGE_RISE;
-//
-//             }
-//
-//             if((BikeLedCheck_R.uwBike_OpenLedEn==0) &&(BikeLedCheck_R.blBike_ForwardLedStart==TRUE)) //开灯检测,过流后每隔10秒检测1次
-//             {
-//              LED_EnableDeal(&BikeLedCheck_R,switchAction,R_PWM_byte);
-//             }
-//             else
-//             {
-//                 GPIOB->POLARITY15_0 &= ~(DL_GPIO_PIN_8_EDGE_RISE |DL_GPIO_PIN_8_EDGE_FALL);
-//                 GPIOB->POLARITY15_0  |=DL_GPIO_PIN_8_EDGE_FALL;
-//             }
-//
-//             BikeLedCheck_R.uwBike_keyLedLowSta=1;
-//       }
-//       else
-//       {
-//           BikeLedCheck_R.uwBike_keyLedHighSta=0;
-//           if(BikeLedCheck_R.uwBike_keyLedLowSta!=0)
-//              {
-//               BikeLedCheck_R.uwBike_keyLedLowSta=0;
-//                  BikeLedCheck_R.uwBikeLight_PWM=0;
-//                  DL_TimerG_setCaptureCompareValue(PWM_R_INST, BikeLedCheck_R.uwBikeLight_PWM, GPIO_PWM_R_C1_IDX);//max=2304
-//              }
-//       }
+    if(switchAction==1) //
+       {
+           if(BikeLedCheck_R.uwBike_keyLedHighSta==0)
+             {
+                 BikeLedCheck_R.uwBike_keyLedHighSta=1;
+                 BikeLedCheck_R.uwBike_OpenLedEn=0;//开灯瞬间处理标志
+                 BikeLedCheck_R.uwBike_LedOffErrCnt=0;  //10秒一检测计时
+                 BikeLedCheck_R.uwBike_OpenPreTime=0; //开灯瞬间5ms内处理计数
+                 BikeLedCheck_R.uwBike_LedCheckLowTime=0;//检测过流IO出现低电平次数
+                 BikeLedCheck_R.blBike_ForwardLedStart=TRUE; //前灯允许开灯启动,总开关
+                 BikeLedCheck_R.blBike_LedCurErr=FALSE;
+                 DL_TimerG_startCounter(PWM_R_INST);
+                 GPIOB->POLARITY15_0 &= ~(DL_GPIO_PIN_8_EDGE_RISE |DL_GPIO_PIN_8_EDGE_FALL);
+                 GPIOB->POLARITY15_0  |=DL_GPIO_PIN_8_EDGE_RISE;
+
+             }
+
+             if((BikeLedCheck_R.uwBike_OpenLedEn==0) &&(BikeLedCheck_R.blBike_ForwardLedStart==TRUE)) //开灯检测,过流后每隔10秒检测1次
+             {
+              LED_EnableDeal(&BikeLedCheck_R,switchAction,R_PWM_byte);
+             }
+             else
+             {
+                 GPIOB->POLARITY15_0 &= ~(DL_GPIO_PIN_8_EDGE_RISE |DL_GPIO_PIN_8_EDGE_FALL);
+                 GPIOB->POLARITY15_0  |=DL_GPIO_PIN_8_EDGE_FALL;
+             }
+
+             BikeLedCheck_R.uwBike_keyLedLowSta=1;
+       }
+       else
+       {
+           BikeLedCheck_R.uwBike_keyLedHighSta=0;
+           if(BikeLedCheck_R.uwBike_keyLedLowSta!=0)
+              {
+               BikeLedCheck_R.uwBike_keyLedLowSta=0;
+                  BikeLedCheck_R.uwBikeLight_PWM=0;
+                  DL_TimerG_setCaptureCompareValue(PWM_R_INST, BikeLedCheck_R.uwBikeLight_PWM, GPIO_PWM_R_C1_IDX);//max=2304
+              }
+       }
     //------------左灯处理------
 
       if(switchAction==1) //
@@ -547,7 +582,8 @@ else
                    BikeLedCheck_L.uwBike_LedCheckLowTime=0;//检测过流IO出现低电平次数
                    BikeLedCheck_L.blBike_ForwardLedStart=TRUE; //前灯允许开灯启动,总开关
                    BikeLedCheck_L.blBike_LedCurErr=FALSE;
-                   DL_TimerG_startCounter(PWM_B_L_INST);
+                   //DL_TimerG_startCounter(PWM_B_L_INST);
+                   DL_Timer_overrideCCPOut(PWM_B_L_INST, DL_TIMER_FORCE_OUT_DISABLED, DL_TIMER_FORCE_CMPL_OUT_DISABLED, GPIO_PWM_B_L_C0_IDX);
                    GPIOA->POLARITY15_0 &= ~(DL_GPIO_PIN_3_EDGE_RISE |DL_GPIO_PIN_3_EDGE_FALL);
                    GPIOA->POLARITY15_0  |=DL_GPIO_PIN_3_EDGE_RISE;
 
@@ -727,10 +763,10 @@ if(mode==F_PWM_byte)
   {
       DL_TimerG_setCaptureCompareValue(PWM_B_L_INST, p->uwBikeLight_PWM, GPIO_PWM_B_L_C0_IDX);//max=2304
   }
-//  else if(mode==R_PWM_byte)
-//   {
-//       DL_TimerG_setCaptureCompareValue(PWM_R_INST, p->uwBikeLight_PWM, GPIO_PWM_R_C1_IDX);//max=2304
-//   }
+  else if(mode==R_PWM_byte)
+   {
+       DL_TimerG_setCaptureCompareValue(PWM_R_INST, p->uwBikeLight_PWM, GPIO_PWM_R_C1_IDX);//max=2304
+   }
 
 
 }

+ 32 - 30
m0g3507_int.c

@@ -555,7 +555,7 @@ void MOTOR_PWM_INST_IRQHandler(void) //void TMR1_BRK_OVF_TRG_HALL_IRQHandler(voi
 
     case DL_TIMER_IIDX_FAULT:
         FCnt++;
-        DL_GPIO_setPins(GPIOA, DL_GPIO_PIN_31);
+        //DL_GPIO_setPins(GPIOA, DL_GPIO_PIN_31);
         DL_Timer_overrideCCPOut(MOTOR_PWM_INST, DL_TIMER_FORCE_OUT_LOW, DL_TIMER_FORCE_CMPL_OUT_LOW, DL_TIMER_CC_0_INDEX);
         DL_Timer_overrideCCPOut(MOTOR_PWM_INST, DL_TIMER_FORCE_OUT_LOW, DL_TIMER_FORCE_CMPL_OUT_LOW, DL_TIMER_CC_1_INDEX);
          DL_Timer_overrideCCPOut(MOTOR_PWM_INST, DL_TIMER_FORCE_OUT_LOW, DL_TIMER_FORCE_CMPL_OUT_LOW, DL_TIMER_CC_2_INDEX);
@@ -1088,12 +1088,13 @@ void GROUP1_IRQHandler(void) //void TMR3_GLOBAL_IRQHandler(void)
      uint32_t gpioB = DL_GPIO_getEnabledInterruptStatus(
          GPIOB, DL_GPIO_PIN_3 | DL_GPIO_PIN_2| DL_GPIO_PIN_8| DL_GPIO_PIN_15);
 
-
+//B_LED
     if ((gpioB & DL_GPIO_PIN_15) ==  DL_GPIO_PIN_15)
     {
         if(BikeLedCheck_B.uwBike_OpenLedEn!=0)
          {
-             DL_TimerG_stopCounter(PWM_B_L_INST);
+            // DL_TimerG_stopCounter(PWM_B_L_INST);
+            DL_Timer_overrideCCPOut(PWM_B_L_INST, DL_TIMER_FORCE_OUT_LOW, DL_TIMER_FORCE_CMPL_OUT_LOW, GPIO_PWM_B_L_C1_IDX);
             BikeLedCheck_B.uwBikeLight_PWM=0;
               DL_TimerG_setCaptureCompareValue(PWM_B_L_INST, 0, GPIO_PWM_B_L_C1_IDX);//max=2304
                CLMPF++;
@@ -1119,38 +1120,39 @@ void GROUP1_IRQHandler(void) //void TMR3_GLOBAL_IRQHandler(void)
     }
 
         //R_LED
-//     if ((gpioB & DL_GPIO_PIN_8) ==  DL_GPIO_PIN_8)
-//          {
-//             if(BikeLedCheck_R.uwBike_OpenLedEn!=0)
-//                  {
-//                      DL_TimerG_stopCounter(PWM_R_INST);
-//                      BikeLedCheck_R.uwBikeLight_PWM=0;
-//                       DL_TimerG_setCaptureCompareValue(PWM_R_INST, 0, GPIO_PWM_R_C1_IDX);//max=2304
-//                     //  CLMPF++;
-//                  }
-//                  else
-//                  {
-//                      if(BikeLedCheck_R.uwBike_OpenPreTime<=2)
-//                      {
-//                          BikeLedCheck_R.uwBike_OpenPreTime=2;
-//                        //  CMPF++;
-//                          BikeLedCheck_R.uwBikeLight_PWM=691;//LIGHT_SECTPWM;
-//                          DL_TimerG_setCaptureCompareValue(PWM_R_INST, BikeLedCheck_R.uwBikeLight_PWM, GPIO_PWM_R_C1_IDX);//max=2304
-//                      }
-//
-//
-//                  }
-//              BikeLedCheck_R.blBike_LedCurErr=TRUE;
-//
-//            //  CHMPF++;
-//              DL_GPIO_clearInterruptStatus(GPIOB, DL_GPIO_PIN_8);
-//          }
+     if ((gpioB & DL_GPIO_PIN_8) ==  DL_GPIO_PIN_8)
+          {
+             if(BikeLedCheck_R.uwBike_OpenLedEn!=0)
+                  {
+                      DL_TimerG_stopCounter(PWM_R_INST);
+                      BikeLedCheck_R.uwBikeLight_PWM=0;
+                       DL_TimerG_setCaptureCompareValue(PWM_R_INST, 0, GPIO_PWM_R_C1_IDX);//max=2304
+                     //  CLMPF++;
+                  }
+                  else
+                  {
+                      if(BikeLedCheck_R.uwBike_OpenPreTime<=2)
+                      {
+                          BikeLedCheck_R.uwBike_OpenPreTime=2;
+                        //  CMPF++;
+                          BikeLedCheck_R.uwBikeLight_PWM=691;//LIGHT_SECTPWM;
+                          DL_TimerG_setCaptureCompareValue(PWM_R_INST, BikeLedCheck_R.uwBikeLight_PWM, GPIO_PWM_R_C1_IDX);//max=2304
+                      }
+
+
+                  }
+              BikeLedCheck_R.blBike_LedCurErr=TRUE;
+
+            //  CHMPF++;
+              DL_GPIO_clearInterruptStatus(GPIOB, DL_GPIO_PIN_8);
+          }
 //-L-LED
      if ((gpioA & DL_GPIO_PIN_3) ==  DL_GPIO_PIN_3)
          {
              if(BikeLedCheck_L.uwBike_OpenLedEn!=0)
               {
-                  DL_TimerG_stopCounter(PWM_B_L_INST);
+                //  DL_TimerG_stopCounter(PWM_B_L_INST);
+                 DL_Timer_overrideCCPOut(PWM_B_L_INST, DL_TIMER_FORCE_OUT_LOW, DL_TIMER_FORCE_CMPL_OUT_LOW, GPIO_PWM_B_L_C0_IDX);
                   BikeLedCheck_L.uwBikeLight_PWM=0;
                    DL_TimerG_setCaptureCompareValue(PWM_B_L_INST, 0, GPIO_PWM_B_L_C0_IDX);//max=2304
                   // CLMPF++;

+ 15 - 6
mspm0g3507.syscfg

@@ -22,7 +22,6 @@ const GPIO1         = GPIO.addInstance();
 const GPIO2         = GPIO.addInstance();
 const GPIO3         = GPIO.addInstance();
 const GPIO4         = GPIO.addInstance();
-const GPIO5         = GPIO.addInstance();
 const MATHACL       = scripting.addModule("/ti/driverlib/MATHACL");
 const MCAN          = scripting.addModule("/ti/driverlib/MCAN", {}, false);
 const MCAN1         = MCAN.addInstance();
@@ -33,6 +32,7 @@ const PWM           = scripting.addModule("/ti/driverlib/PWM", {}, false);
 const PWM1          = PWM.addInstance();
 const PWM2          = PWM.addInstance();
 const PWM3          = PWM.addInstance();
+const PWM4          = PWM.addInstance();
 const SYSCTL        = scripting.addModule("/ti/driverlib/SYSCTL");
 const SYSTICK       = scripting.addModule("/ti/driverlib/SYSTICK");
 const TIMER         = scripting.addModule("/ti/driverlib/TIMER", {}, false);
@@ -228,11 +228,6 @@ GPIO4.associatedPins[2].interruptEn = true;
 GPIO4.associatedPins[2].polarity    = "RISE";
 GPIO4.associatedPins[2].pin.$assign = "PA3";
 
-GPIO5.$name                         = "GPIO_GRP_31";
-GPIO5.port                          = "PORTA";
-GPIO5.associatedPins[0].$name       = "PIN_0";
-GPIO5.associatedPins[0].pin.$assign = "PA31";
-
 MCAN1.$name                    = "MCAN0";
 MCAN1.desiredNomRate           = 250;
 MCAN1.fdMode                   = false;
@@ -402,6 +397,20 @@ PWM3.ccp1PinConfig.onlyInternalResistor = scripting.forceWrite(false);
 PWM3.ccp1PinConfig.passedPeripheralType = scripting.forceWrite("Digital");
 PWM3.ccp1PinConfig.$name                = "ti_driverlib_gpio_GPIOPinGeneric26";
 
+PWM4.$name                              = "PWM_R";
+PWM4.ccIndex                            = [1];
+PWM4.clockDivider                       = 2;
+PWM4.timerCount                         = 2304;
+PWM4.pwmMode                            = "EDGE_ALIGN_UP";
+PWM4.peripheral.$assign                 = "TIMG12";
+PWM4.peripheral.ccp1Pin.$assign         = "PA31";
+PWM4.ccp1PinConfig.$name                = "ti_driverlib_gpio_GPIOPinGeneric7";
+PWM4.ccp1PinConfig.direction            = scripting.forceWrite("OUTPUT");
+PWM4.ccp1PinConfig.hideOutputInversion  = scripting.forceWrite(false);
+PWM4.ccp1PinConfig.onlyInternalResistor = scripting.forceWrite(false);
+PWM4.ccp1PinConfig.passedPeripheralType = scripting.forceWrite("Digital");
+PWM4.PWM_CHANNEL_1.$name                = "ti_driverlib_pwm_PWMTimerCC4";
+
 SYSCTL.clockTreeEn           = true;
 SYSCTL.forceDefaultClkConfig = true;