Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 4.05 KB | None | 0 0
  1. /**
  2.   ******************************************************************************
  3.   * @file    SysTick/main.c
  4.   * @author  MCD Application Team
  5.   * @version V1.0.0
  6.   * @date    15/09/2010
  7.   * @brief   Main program body.
  8.   ******************************************************************************
  9.   * @copy
  10.   *
  11.   * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
  12.   * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
  13.   * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
  14.   * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
  15.   * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
  16.   * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
  17.   *
  18.   * <h2><center>&copy; COPYRIGHT 2010 STMicroelectronics</center></h2>
  19.   */
  20.  
  21. /* Includes ------------------------------------------------------------------*/
  22. #include "main.h"
  23.  
  24. /** @addtogroup Examples
  25.   * @{
  26.   */
  27.  
  28. /* Private typedef -----------------------------------------------------------*/
  29. /* Private define ------------------------------------------------------------*/
  30.  
  31. #
  32. #define  LSE_FAIL_FLAG  0x80
  33. #
  34. #define  LSE_PASS_FLAG  0x100
  35. /* Private macro -------------------------------------------------------------*/
  36. /* Private variables ---------------------------------------------------------*/
  37. static __IO uint32_t TimingDelay;
  38. u32 KeyState = 0;
  39. /* Private function prototypes -----------------------------------------------*/
  40. void Delay(__IO uint32_t nTime);
  41.  
  42. /* Private functions ---------------------------------------------------------*/
  43.  
  44. /**
  45.   * @brief  Main program.
  46.   * @param  None
  47.   * @retval None
  48.   */
  49. int main(void)
  50. {
  51.   /*!< At this stage the microcontroller clock setting is already configured,
  52.        this is done through SystemInit() function which is called from startup
  53.        file (startup_stm32f10x_xx.s) before to branch to application main.
  54.        To reconfigure the default setting of SystemInit() function, refer to
  55.        system_stm32f10x.c file
  56.      */    
  57.  
  58.   /* Initialize Leds LD3 and LD4 mounted on STM32VLDISCOVERY board */  
  59.   STM32vldiscovery_LEDInit(LED3);
  60.   STM32vldiscovery_LEDInit(LED4);
  61.  
  62.   /*initialize button */
  63.   STM32vldiscovery_PBInit(BUTTON_USER, BUTTON_MODE_GPIO);
  64.  
  65.   /* Turn on LD3 and LD4 */
  66.   STM32vldiscovery_LEDOn(LED3);
  67.   STM32vldiscovery_LEDOn(LED4);
  68.  
  69.   /* Setup SysTick Timer for 1 msec interrupts  */
  70.   if (SysTick_Config(SystemCoreClock / 1000))
  71.   {
  72.     /* Capture error */
  73.     while (1);
  74.   }
  75.  
  76.  
  77. while(1)
  78.  
  79.   {
  80.  
  81.     if(0 == STM32vldiscovery_PBGetState(BUTTON_USER))
  82.  
  83.       {
  84.  
  85.         if(KeyState == 1)
  86.  
  87.         {
  88.  
  89.            if(0 == STM32vldiscovery_PBGetState(BUTTON_USER))
  90.  
  91.           {
  92.  
  93.             /* USER Button released */
  94.  
  95.               KeyState = 0;
  96.  
  97.             /* Turn Off LED4 */
  98.  
  99.               STM32vldiscovery_LEDOff(LED4);
  100.  
  101.           }      
  102.  
  103.         }
  104.  
  105.       }
  106.  
  107. /**
  108.   * @brief  Inserts a delay time.
  109.   * @param  nTime: specifies the delay time length, in milliseconds.
  110.   * @retval None
  111.   */
  112. void Delay(__IO uint32_t nTime);
  113. {
  114.   TimingDelay = nTime;
  115.  
  116.   while(TimingDelay != 0);
  117. }
  118.  
  119. /**
  120.   * @brief  Decrements the TimingDelay variable.
  121.   * @param  None
  122.   * @retval None
  123.   */
  124. void TimingDelay_Decrement(void)
  125. {
  126.   if (TimingDelay != 0x00)
  127.   {
  128.     TimingDelay--;
  129.   }
  130. }
  131.  
  132. #ifdef  USE_FULL_ASSERT
  133. /**
  134.   * @brief  Reports the name of the source file and the source line number
  135.   *         where the assert_param error has occurred.
  136.   * @param  file: pointer to the source file name
  137.   * @param  line: assert_param error line source number
  138.   * @retval None
  139.   */
  140. void assert_failed(uint8_t* file, uint32_t line)
  141. {
  142.   /* User can add his own implementation to report the file name and line number,
  143.      ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  144.  
  145.   /* Infinite loop */
  146.   while (1)
  147.   {
  148.   }
  149. }
  150. #endif
  151.  
  152. /**
  153.   * @}
  154.   */
  155.  
  156.  
  157.  
  158. /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement