STM32F10x_StdPeriph_Examples/SysTick/main.c

Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    SysTick/main.c 
00004   * @author  MCD Application Team
00005   * @version V3.4.0
00006   * @date    10/15/2010
00007   * @brief   Main program body.
00008   ******************************************************************************
00009   * @copy
00010   *
00011   * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
00012   * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
00013   * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
00014   * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
00015   * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
00016   * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
00017   *
00018   * <h2><center>&copy; COPYRIGHT 2010 STMicroelectronics</center></h2>
00019   */ 
00020 
00021 /* Includes ------------------------------------------------------------------*/
00022 #include "main.h"
00023 
00024 /** @addtogroup STM32F10x_StdPeriph_Examples
00025   * @{
00026   */
00027 
00028 /** @addtogroup SysTick
00029   * @{
00030   */ 
00031 
00032 /* Private typedef -----------------------------------------------------------*/
00033 /* Private define ------------------------------------------------------------*/
00034 /* Private macro -------------------------------------------------------------*/
00035 /* Private variables ---------------------------------------------------------*/
00036 static __IO uint32_t TimingDelay;
00037 
00038 /* Private function prototypes -----------------------------------------------*/
00039 void Delay(__IO uint32_t nTime);
00040 
00041 /* Private functions ---------------------------------------------------------*/
00042 
00043 /**
00044   * @brief  Main program.
00045   * @param  None
00046   * @retval None
00047   */
00048 int main(void)
00049 {
00050   /*!< At this stage the microcontroller clock setting is already configured, 
00051        this is done through SystemInit() function which is called from startup
00052        file (startup_stm32f10x_xx.s) before to branch to application main.
00053        To reconfigure the default setting of SystemInit() function, refer to
00054        system_stm32f10x.c file
00055      */     
00056 
00057   /* Initialize Leds mounted on STM3210X-EVAL board */
00058   STM_EVAL_LEDInit(LED1);
00059   STM_EVAL_LEDInit(LED2);
00060   STM_EVAL_LEDInit(LED3);
00061   STM_EVAL_LEDInit(LED4);
00062 
00063   /* Turn on LED1 and LED3 */
00064   STM_EVAL_LEDOn(LED1);
00065   STM_EVAL_LEDOn(LED3);
00066 
00067   /* Setup SysTick Timer for 1 msec interrupts  */
00068   if (SysTick_Config(SystemCoreClock / 1000))
00069   { 
00070     /* Capture error */ 
00071     while (1);
00072   }
00073 
00074   while (1)
00075   {
00076     /* Toggle LED2 and LED4 */
00077     STM_EVAL_LEDToggle(LED2);
00078     STM_EVAL_LEDToggle(LED4);
00079 
00080     /* Insert 50 ms delay */
00081     Delay(50);
00082 
00083     /* Toggle LED1 and LED3 */
00084     STM_EVAL_LEDToggle(LED1);
00085     STM_EVAL_LEDToggle(LED3);
00086 
00087     /* Insert 100 ms delay */
00088     Delay(100);
00089   }
00090 }
00091 
00092 /**
00093   * @brief  Inserts a delay time.
00094   * @param  nTime: specifies the delay time length, in milliseconds.
00095   * @retval None
00096   */
00097 void Delay(__IO uint32_t nTime)
00098 { 
00099   TimingDelay = nTime;
00100 
00101   while(TimingDelay != 0);
00102 }
00103 
00104 /**
00105   * @brief  Decrements the TimingDelay variable.
00106   * @param  None
00107   * @retval None
00108   */
00109 void TimingDelay_Decrement(void)
00110 {
00111   if (TimingDelay != 0x00)
00112   { 
00113     TimingDelay--;
00114   }
00115 }
00116 
00117 #ifdef  USE_FULL_ASSERT
00118 /**
00119   * @brief  Reports the name of the source file and the source line number
00120   *         where the assert_param error has occurred.
00121   * @param  file: pointer to the source file name
00122   * @param  line: assert_param error line source number
00123   * @retval None
00124   */
00125 void assert_failed(uint8_t* file, uint32_t line)
00126 { 
00127   /* User can add his own implementation to report the file name and line number,
00128      ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
00129 
00130   /* Infinite loop */
00131   while (1)
00132   {
00133   }
00134 }
00135 #endif
00136 
00137 /**
00138   * @}
00139   */
00140 
00141 /**
00142   * @}
00143   */
00144 
00145 /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
STM32F10x Standard Peripherals Library: Footer

 

 

 

      For complete documentation on STM32(CORTEX M3) 32-bit Microcontrollers platform visit  www.st.com/STM32