Exemplo n.º 1
0
/**
  * @brief EXTI line detection callbacks
  * @param GPIO_Pin: Specifies the pins connected EXTI line
  * @retval None 
  */
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{

// Servicing Interrupt from PWR_ONSTAT (power off required)

  if (GPIO_Pin == ONOFF_STAT_PIN)
  {
        Stm32_Led_OFF();        

#ifdef OLED_PRESENT  // (defined in User_Configuration.h)
	// Do not send command if no OLED (else SPI hangs)

        OLED_Switch_OFF();
        Delay_ms(100); // Delay between cutting OLED VDDH (13V) and VDD (logic) 
                       // to preserve panel lifetile - as per DD160128FC-1A datasheet
	    //Caution: TimerTick involved, its IRQ priority must be high (urgent) enough
	    // in Interrupt Configuration files
#endif



        // wait as long as ONOFF is active (ie. until user has finished pushing button)
        while(HAL_GPIO_ReadPin(ONOFF_STAT_PORT, ONOFF_STAT_PIN) == GPIO_PIN_RESET);

        
	//Quickly blink LED 3 times
	Stm32_Led_ON();
        Delay_ms(100);        
	Stm32_Led_OFF();
        Delay_ms(200);      

	Stm32_Led_ON();
        Delay_ms(100);        
	Stm32_Led_OFF();
        Delay_ms(200);   

	Stm32_Led_ON();
        Delay_ms(100);        
	Stm32_Led_OFF();


        // Bye bye:  Power down VCC_NUM by resetting pin BUCK3V_ON
        GPIO_LOW(BUCK3V_ON_PORT, BUCK3V_ON_PIN);
        Delay_ms(3000);
        while(1);

  }



}
Exemplo n.º 2
0
void  Get_ZeroGauss_OffsetXY( int16_t* pMField_X_Raw_Offset, int16_t* pMField_Y_Raw_Offset )
{

#define  NUM_CALIB_CIRCLES 1   
  // Calibration performed by taking 8 measurements 45deg apart, 
  // repeated NUM_CALIB_CIRCLES times

uint8_t i;
uint8_t		MField_X_LowByte, MField_X_HighByte;
uint8_t		MField_Y_LowByte, MField_Y_HighByte;
int16_t		MField_X_Raw, MField_Y_Raw;
int32_t		MField_X_Acc = 0, MField_Y_Acc = 0;
uint16_t 	ColorSequence[8] = {RED, WHITE, GREEN, BLUE, CYAN, ORANGE, LIGHT_BLUE, YELLOW } ;  


  // Display Instructions :
  OLED_PrintString("CALIBRATION\n\n");
  OLED_PrintString("Lay La BlueFrog flat\n");
  OLED_PrintString("Then rotate it 45 deg.\n  at each change of color:");
  Delay_ms(5000);

  // Go --- 8 equally spaced magnetic field measurements, repeatable n times per #define
  for (i=0; i < 8*NUM_CALIB_CIRCLES; i++)   
  {
          OLED_Fill( X_FULL_SCREEN/2 -20, Y_FULL_SCREEN/2-20, 40, 40, ColorSequence[i] );
          Delay_ms(2500);

	  Stm32_Led_ON();

          // SINGLE SHOT conversion : CTRL_REG3 @0x22 :   
          I2C2_WriteSingleReg(LIS3MDL_CHIPID, 0x22, 0x01);  // 0b00000001

          while ( (I2C2_ReadSingleReg(LIS3MDL_CHIPID, 0x27)& 0x08) != 0x08);  
                    // read status reg until it flags new XYZ data available

	  // Accumulate Results
	  MField_X_LowByte = I2C2_ReadSingleReg(LIS3MDL_CHIPID, 0x28);
	  MField_X_HighByte = I2C2_ReadSingleReg(LIS3MDL_CHIPID, 0x29);
	  MField_X_Raw =  
	         (int16_t)( (MField_X_HighByte <<8 ) | MField_X_LowByte );
	  MField_X_Acc += (int32_t)(MField_X_Raw);
	  MField_Y_LowByte = I2C2_ReadSingleReg(LIS3MDL_CHIPID, 0x2A);
	  MField_Y_HighByte = I2C2_ReadSingleReg(LIS3MDL_CHIPID, 0x2B);
	  MField_Y_Raw =  
	         (int16_t)( (MField_Y_HighByte <<8 ) | MField_Y_LowByte );
	  MField_Y_Acc += (int32_t)(MField_Y_Raw);

	  Stm32_Led_OFF();
   }
 
   *pMField_X_Raw_Offset =  (int16_t)(MField_X_Acc / i);
   *pMField_Y_Raw_Offset =  (int16_t)(MField_Y_Acc / i);

   GUI_DispStringAt("", 10, 90);
   OLED_PrintString("THANKS,\nCALIBRATION DONE !");
   Delay_ms(2000);
   OLED_Clear();

}
Exemplo n.º 3
0
/*******************************************************************************
* Function Name  : main.
* Description    : Main routine.
* Input          : None.
* Output         : None.
* Return         : None.
*******************************************************************************/
int main(void)
{

boolean_t  Success = TRUE;

/* ================================================================ */
/* Board Initializations and Configurations except OLED             */
/* (clocks, I/Os, on-chip peripherals, on-board ICs)                */
/* ================================================================ */

   LBF_Board_Fixed_Inits();
   LBF_Board_Selective_Inits(); 
             // actions driven by User_Configuration.h

   Stm32_Led_ON();


/* ================================================================ */
/* Optional initialization of Middleware libraries :                */
/* USBD drivers, FatFS File System, STemWin GUI                     */
/* ================================================================ */

// UNCOMMENT AS NEEDED:
    // (refer to INFO.txt for details on actions performed)

    /* ... To use La BlueFrog as USB Mass Storage (Full Speed)      */
    // Delay_ms(1000);
    // Success &= LBF_LaunchUSB_MassStorage();
 
    /* ... To initialize FatFS                                      */
    /*     and mount the Data Flash as FAT File System              */
    // Success &= LBF_FatFS_Init();

    /* ... To initialize the STemWin Graphical Library              */ 
    /*     Caution: reserves some RAM - keep some for stack/heap    */
    Success &= LBF_emWin_Init();

    // ERROR HANDLER
    /* Replace by your own as wished */
    Led_StopNBlinkOnFalse (Success);
    	// stops here if one of above inits has failed

    Stm32_Led_OFF();



/* ===================================================== */
/* Application Code Below */
/* ===================================================== */


/* ==  User Declarations =============================== */

uint8_t ReadValue;



/* ==  Body     ====================================================== */

    OLED_Switch_ON();
    // Provide power (13V) to OLED panel, enable display



  /* ---     Check access to ALS/Proximity Sensor : ST VL6180X  --- */

  ReadValue = I2C2_ReadSingleReg(VL6180X_CHIPID, VL6180X_WHOAMI);
  if (ReadValue == VL6180X_WHOAMI_CONTENTS)
  { 
     OLED_PrintString("VL6180X OK \nWHO_AM_I = ");
  }
  else 
  { 
     OLED_PrintString("VL6180X FAIL \nReported WHO_AM_I = ");
  }
  OLED_PrintHex(ReadValue);
  OLED_PrintString("\n\n");


  /* ---     Check access to Magnetometer :  ST LIS3MDL   -------- */

  ReadValue = I2C2_ReadSingleReg(LIS3MDL_CHIPID, LIS3MDL_WHOAMI);
  if (ReadValue == LIS3MDL_WHOAMI_CONTENTS)
  { 
     OLED_PrintString("LIS3MDL OK \nWHO_AM_I = ");
  }
  else 
  { 
     OLED_PrintString("LIS3MDL FAIL \nReported WHO_AM_I = ");
  }
  OLED_PrintHex(ReadValue);
  OLED_PrintString("\n\n");


  /* ---     Check access to Accelerometer/Gyro :  ST LSM6DS3  ----- */

  ReadValue = I2C2_ReadSingleReg(LSM6DS3_CHIPID, LSM6DS3_WHOAMI);
  if (ReadValue == LSM6DS3_WHOAMI_CONTENTS)
  { 
     OLED_PrintString("LSM6DS3 OK \nWHO_AM_I = ");
  }
  else 
  { 
     OLED_PrintString("LSM6DS3 FAIL \nReported WHO_AM_I = ");
  }
  OLED_PrintHex(ReadValue);
  OLED_PrintString("\n\n");


  /* ---     Check access to Pressure/Temp Sensor : ST LPS25H  ----- */

  ReadValue = I2C2_ReadSingleReg(LPS25H_CHIPID, LPS25H_WHOAMI);
  if (ReadValue == LPS25H_WHOAMI_CONTENTS)
  { 
     OLED_PrintString("LPS25H OK \nWHO_AM_I = ");
  }
  else 
  { 
     OLED_PrintString("LPS25H FAIL \nReported WHO_AM_I = ");
  }
  OLED_PrintHex(ReadValue);
  OLED_PrintString("\n\n");


while(1);

}
Exemplo n.º 4
0
/*******************************************************************************
* Function Name  : main.
* Description    : Main routine.
* Input          : None.
* Output         : None.
* Return         : None.
*******************************************************************************/
int main(void)
{

boolean_t  Success = TRUE;

/* ================================================================ */
/* Board Initializations and Configurations except OLED             */
/* (clocks, I/Os, on-chip peripherals, on-board ICs)                */
/* ================================================================ */

   LBF_Board_Fixed_Inits();
   LBF_Board_Selective_Inits(); 
             // actions driven by User_Configuration.h

   Stm32_Led_ON();


/* ================================================================ */
/* Optional initialization of Middleware libraries :                */
/* USBD drivers, FatFS File System, STemWin GUI                     */
/* ================================================================ */

// UNCOMMENT AS NEEDED:
    // (refer to INFO.txt for details on actions performed)

    /* ... To use La BlueFrog as USB Mass Storage (Full Speed)      */
    // Delay_ms(1000);
    // Success &= LBF_LaunchUSB_MassStorage();
 
    /* ... To initialize FatFS                                      */
    /*     and mount the Data Flash as FAT File System              */
    // Success &= LBF_FatFS_Init();

    /* ... To initialize the STemWin Graphical Library              */ 
    /*     Caution: reserves some RAM - keep some for stack/heap    */
    Success &= LBF_emWin_Init();

    // ERROR HANDLER
    /* Replace by your own as wished */
    Led_StopNBlinkOnFalse (Success);
    	// stops here if one of above inits has failed

    Stm32_Led_OFF();



/* ===================================================== */
/* Application Code Below */
/* ===================================================== */


/* ==  User Declarations =============================== */

void  Get_ZeroGauss_OffsetXY( int16_t* pMField_X_Raw_Offset, int16_t* pMField_Y_Raw_Offset ); 
void Get_Magnetic_FieldXY( int16_t MField_X_Raw_Offset, int16_t MField_Y_Raw_Offset,
			   int16_t* pMField_X_mGauss,  int16_t* pMField_Y_mGauss);

uint8_t ReadValue;

int16_t		MField_X_Raw_Offset, MField_Y_Raw_Offset ;
int16_t		MField_X_mGauss, MField_Y_mGauss;

int32_t 	MField_X_mGauss_2 =0, MField_Y_mGauss_2 =0;
int32_t 	MField_X_mGauss_1 =0, MField_Y_mGauss_1 =0;
int32_t		MField_X_mGauss_Filtd, MField_Y_mGauss_Filtd;
int32_t         Field_Magnitude;

int32_t 	X_Gfx_Vector, Y_Gfx_Vector;
int32_t 	X_Previous_Gfx_Vector = 0, Y_Previous_Gfx_Vector=0;


#define  MGAUSS_MAX  450  //Max expected magnitude of magnetic field to display
#define  BKGND_COLOR 0x102020  // dark grey
#define  FOREGND_COLOR 0x00AAA0  // blue-green




/* ==  Body     ====================================================== */

  OLED_Switch_ON();
  // Provide power (13V) to OLED panel, enable display


 /* ---     Check access to Magnetometer :  ST LIS3MDL   -------- */

  ReadValue = I2C2_ReadSingleReg(LIS3MDL_CHIPID, LIS3MDL_WHOAMI);
  Led_StopNBlinkOnFalse ( ReadValue == LIS3MDL_WHOAMI_CONTENTS );
  

 /* ---     Configure Magnetometer     -------------------------- */

  // Define Full Scale: Reg. CTRL_REG2 @0x21
  // NB- earth magnetic field magnitude = 0.25 to 0.65 Gauss
  I2C2_WriteSingleReg(LIS3MDL_CHIPID, 0x21, 0x00);  
	// FS = 4 Gauss

  // Define XY Performance mode and ODR: Reg. CTRL_REG1 @0x20
  I2C2_WriteSingleReg(LIS3MDL_CHIPID, 0x20, 0x90);  // 0b10010000
	// Enable T° sensor
	// Low-power mode on X and Y
	// ODR = 10Hz
  // Define Z Performance mode: Reg. CTRL_REG4 @0x23
  I2C2_WriteSingleReg(LIS3MDL_CHIPID, 0x23, 0x00);  // 0b00000000

  // Calibrate to compensate Zero Gauss Offset
  Get_ZeroGauss_OffsetXY( &MField_X_Raw_Offset, &MField_Y_Raw_Offset );


 /* ---     Prepare Display of Results    -------------------------- */

   GUI_SetFont(&GUI_Font24B_ASCII);
   GUI_SetTextMode(GUI_TM_TRANS);

   GUI_SetColor(BKGND_COLOR);
   GUI_FillRect(0, 0, X_FULL_SCREEN-1, Y_FULL_SCREEN-1);

   GUI_SetColor(0xAAAA00);  
   GUI_DrawCircle(Y_FULL_SCREEN/2, Y_FULL_SCREEN/2,  (Y_FULL_SCREEN/2)-10);
   GUI_FillCircle(Y_FULL_SCREEN/2, Y_FULL_SCREEN/2,  2);



  /* ---     Start Tracking Magnetic Field     -------------------------- */

  while(1)
  {
        // --- Capture :------------------------------------------------

        // SINGLE SHOT conversion : CTRL_REG3 @0x22 :   
         I2C2_WriteSingleReg(LIS3MDL_CHIPID, 0x22, 0x01);  // 0b00000001

	// Wait until data available from Magnetometer
        do 
        {
            ReadValue = I2C2_ReadSingleReg(LIS3MDL_CHIPID, 0x27);  // Status Reg
        } while ( (ReadValue & 0x08) != 0x08);  // bit set when new XYZ data available


	// Read Results
        Get_Magnetic_FieldXY( MField_X_Raw_Offset, MField_Y_Raw_Offset,
			      &MField_X_mGauss, &MField_Y_mGauss );


	// --- Display North ------------------------------------------------

	if (MField_X_mGauss > MGAUSS_MAX)
		MField_X_mGauss = MGAUSS_MAX;
	if (MField_X_mGauss < -MGAUSS_MAX)
		MField_X_mGauss = -MGAUSS_MAX;
	if (MField_Y_mGauss > MGAUSS_MAX)
		MField_Y_mGauss = MGAUSS_MAX;
	if (MField_Y_mGauss < -MGAUSS_MAX)
		MField_Y_mGauss = -MGAUSS_MAX;

        // Filtering to limit "jitter" effect on position
        MField_X_mGauss_Filtd = (MField_X_mGauss_2 + 2*MField_X_mGauss_1 + (int32_t)MField_X_mGauss) /4;
        MField_Y_mGauss_Filtd = (MField_Y_mGauss_2 + 2*MField_Y_mGauss_1 + (int32_t)MField_Y_mGauss) /4;
        MField_X_mGauss_2 = MField_X_mGauss_1;
        MField_X_mGauss_1 = (int32_t)MField_X_mGauss;
        MField_Y_mGauss_2 = MField_Y_mGauss_1;
        MField_Y_mGauss_1 = (int32_t)MField_Y_mGauss;

        Field_Magnitude = ( MField_X_mGauss_Filtd * MField_X_mGauss_Filtd)
                         + ( MField_Y_mGauss_Filtd *  MField_Y_mGauss_Filtd);

        X_Gfx_Vector = 
	  ( ( MField_X_mGauss_Filtd + MGAUSS_MAX) * (Y_FULL_SCREEN-1) ) / (2*MGAUSS_MAX) ;
        Y_Gfx_Vector = 
	  ( (-MField_Y_mGauss_Filtd + MGAUSS_MAX) * (Y_FULL_SCREEN-1) ) / (2*MGAUSS_MAX) ;
        // Only Y_FULL_SCREEN to avoid distorsion due to shape of screen

        // Compensate for size of letter "N" displayed as its x,y correspond to top left corner
        X_Gfx_Vector -= 6;
        Y_Gfx_Vector -= 12;

        // Skip Display if vector falls out of range

        if  (Field_Magnitude <  MGAUSS_MAX*MGAUSS_MAX   )
        {
	  if ( (X_Gfx_Vector != X_Previous_Gfx_Vector) || (Y_Gfx_Vector !=  Y_Previous_Gfx_Vector) ) 
	  // Redraw only if needed
	  {
	          // Erase Previous
        	  GUI_SetColor( BKGND_COLOR );
        	  GUI_DispStringAt("N", X_Previous_Gfx_Vector, Y_Previous_Gfx_Vector);

        	  // Draw New 
        	  GUI_SetColor( FOREGND_COLOR );
        	  GUI_DispStringAt("N", X_Gfx_Vector, Y_Gfx_Vector);

                  X_Previous_Gfx_Vector = X_Gfx_Vector;
                  Y_Previous_Gfx_Vector = Y_Gfx_Vector;
	  }  // end if
        }  // end if
        Delay_ms(500);


  }  //  end while(1)


}
Exemplo n.º 5
0
/*******************************************************************************
* Function Name  : main.
* Description    : Main routine.
* Input          : None.
* Output         : None.
* Return         : None.
*******************************************************************************/
int main(void)
{

boolean_t  Success = TRUE;

/* ================================================================ */
/* Board Initializations and Configurations except OLED             */
/* (clocks, I/Os, on-chip peripherals, on-board ICs)                */
/* ================================================================ */

   LBF_Board_Fixed_Inits();
   LBF_Board_Selective_Inits(); 
             // actions driven by User_Configuration.h

   Stm32_Led_ON();

/* ================================================================ */
/* Optional initialization of Middleware libraries :                */
/* USBD drivers, FatFS File System, STemWin GUI                     */
/* ================================================================ */

    // UNCOMMENT AS NEEDED:
    // (refer to INFO.txt for details on actions performed)

    /* ... To use La BlueFrog as USB Mass Storage (Full Speed)      */
    //Delay_ms(1000);
    //Success &= LBF_LaunchUSB_MassStorage();  

    /* ... To initialize FatFS                                      */
    /*     and mount the Data Flash as FAT File System              */
    Success &= LBF_FatFS_Init();

    /* ... To initialize the STemWin Graphical Library              */ 
    /*     Caution: reserves some RAM - keep some for stack/heap    */
    // Success &= LBF_emWin_Init();

    // ERROR HANDLER
    /* Replace by your own as wished */
    Led_StopNBlinkOnFalse (Success);
    	// stops here if one of above inits has failed

    Stm32_Led_OFF();


/* ===================================================== */
/* Application Code Below */
/* ===================================================== */

// NOTE: Here, as Data Flash may not be formatted yet,
//  we don't use LBF_LaunchUSB_MassStorage in the initalization phase above


/* ==  User Declarations =============================== */

    FIL MyFile;    /* FatFS File object */
    UINT bw;       /* Number of bytes written in file */


/* ==  Body     ======================================== */

     Stm32_Led_ON();
    // Launch reformat only when any Push Button pressed
    while ( !State_Switch1_IsOn() && !State_Switch2_IsOn() );

    Stm32_Led_OFF();

    /* Create FAT volume with default cluster size */
    Success &= ( f_mkfs("", 0, 0) == FR_OK); 

    /* Create a file as new */
    Success &= ( f_open(&MyFile, "FS_Formt.log", FA_CREATE_NEW | FA_WRITE) == FR_OK);

    /* Write a message */
    Success &= ( f_write(&MyFile, "Formatted by FatFS\r\n", 20, &bw)  == FR_OK);

    /* Close the file */
    f_close(&MyFile);
 
    // Launch USB
    Success &= LBF_LaunchUSB_MassStorage();  

    /* Error handler */
    Led_StopNBlinkOnFalse (Success);


  // Done !
  Stm32_Led_ON();
  while (1);

    
}
Exemplo n.º 6
0
/*******************************************************************************
* Function Name  : main.
* Description    : Main routine.
* Input          : None.
* Output         : None.
* Return         : None.
*******************************************************************************/
int main(void)
{

boolean_t  Success = TRUE;

/* ================================================================ */
/* Board Initializations and Configurations except OLED             */
/* (clocks, I/Os, on-chip peripherals, on-board ICs)                */
/* ================================================================ */

    LBF_Board_Fixed_Inits();
    LBF_Board_Selective_Inits(); 
             // actions driven by User_Configuration.h

   Stm32_Led_ON();

/* ================================================================ */
/* Optional initialization of Middleware libraries :                */
/* USBD drivers, FatFS File System, STemWin GUI                     */
/* ================================================================ */

    // UNCOMMENT AS NEEDED:
    // (refer to INFO.txt for details on actions performed)

    /* ... To use La BlueFrog as USB Mass Storage (Full Speed)      */
    // Delay_ms(1000);
    // Success &= LBF_LaunchUSB_MassStorage();
 
    /* ... To initialize FatFS                                      */
    /*     and mount the Data Flash as FAT File System              */
    // Success &= LBF_FatFS_Init();

    /* ... To initialize the STemWin Graphical Library              */ 
    /*     Caution: reserves some RAM - keep some for stack/heap    */
    //Success &= LBF_emWin_Init();

    // ERROR HANDLER
    /* Replace by your own as wished */
    Led_StopNBlinkOnFalse (Success);
    	// stops here if one of above inits has failed

    Stm32_Led_OFF();




/* ===================================================== */
/* Application Code Below */
/* ===================================================== */


/* ==  User Declarations =============================== */

// REMINDER :
// Usage of pins of extension connector as GPIO, PWM etc
// to be specified in User_Configuration.h

// On EXtension Connector Position 2:
// Global Enable for MC33926 carrier board 
#define MC33926_EN_LOW()           GPIO_LOW(CONN_POS2_PORT, CONN_POS2_PIN)
#define MC33926_EN_HIGH()          GPIO_HIGH(CONN_POS2_PORT, CONN_POS2_PIN)

// On EXtension Connector Position 3:
// Fault Status from MC33926, active low
#define STATUS_FAULT_MC33926()     IS_GPIO_RESET(CONN_POS3_PORT, CONN_POS3_PIN)
// returns a uint8_t result

// On Extension Connector Position 5:
// Direction (Common to Motors 1 and 2)
#define MC33926_DIR_BWD()          GPIO_LOW(CONN_POS5_PORT, CONN_POS5_PIN)
#define MC33926_DIR_FWD()          GPIO_HIGH(CONN_POS5_PORT, CONN_POS5_PIN)
// On Extension Connector Position 6:
// notDirection (Common to Motors 1 and 2)
#define MC33926_nDIR_BWD()         GPIO_HIGH(CONN_POS6_PORT, CONN_POS6_PIN)
#define MC33926_nDIR_FWD()         GPIO_LOW(CONN_POS6_PORT, CONN_POS6_PIN)
// !!!!!!!!  MCU must drive both DIR and nDIR 


// On Extension Connector Position 9:
// Enable Motor 1 - PWM signal (supports up to 20KHz)

// On Extension Connector Position 10:
// Enable Motor 2 - PWM signal (supports up to 20KHz)



/* ==  Body     ======================================== */


Stm32_Led_ON();

Delay_ms(2500);

// Set Direction = Forward
MC33926_DIR_FWD();
MC33926_nDIR_FWD();

// Enable Motor Carrier
MC33926_EN_LOW();
Delay_ms(1000);
MC33926_EN_HIGH();


// Turn immedialetely off if Fault, 
   if ( STATUS_FAULT_MC33926() ) 
      {
         MC33926_EN_LOW();
	 Led_StopNBlinkOnFalse( FALSE );  //  
      }


LBF_PWM_Start( PWM4_CH3 );
LBF_PWM_Start( PWM4_CH4 );


LBF_PWM_SetPeriod_us( PWM4, 60);   // 60us period PWM = 17KHz
LBF_PWM_SetPulse_us (PWM4_CH3, 30);   // 30/60 = 50% duty cycle 
LBF_PWM_SetPulse_us (PWM4_CH4, 30);   // 30/60 = 50% duty cycle 

while(1)
{

  // Turn immedialetely off if Fault, 
   if ( STATUS_FAULT_MC33926() ) 
      {
         MC33926_EN_LOW();
	 Led_StopNBlinkOnFalse( FALSE );  //  
      }

  // Run for a while and Stop Motor
    Delay_ms( 2000 );  // run for a while and stop 
    LBF_PWM_SetPulse_us (PWM4_CH3, 0);   
    LBF_PWM_SetPulse_us (PWM4_CH4, 0);  

    Stm32_Led_ON();

    Delay_ms( 2000 );  // wait for a while and restart 
    LBF_PWM_SetPulse_us (PWM4_CH3, 30);   // 30/60 = 50% duty cycle 
    LBF_PWM_SetPulse_us (PWM4_CH4, 30);   // 30/60 = 50% duty cycle 

    Stm32_Led_OFF();

}
    

return 0;
}