Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 4.11 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.  
  22. /* Includes ------------------------------------------------------------------*/
  23. #include "main.h"
  24.  
  25. /** @addtogroup Examples
  26.   * @{
  27.   */
  28.  
  29. /* Private typedef -----------------------------------------------------------*/
  30. /* Private define ------------------------------------------------------------*/
  31.  
  32.  
  33. #define  LSE_FAIL_FLAG  0x80
  34.  
  35. #define  LSE_PASS_FLAG  0x100
  36. /* Private macro -------------------------------------------------------------*/
  37. /* Private variables ---------------------------------------------------------*/
  38. static __IO uint32_t TimingDelay;
  39. #
  40. static __IO uint32_t nTime;
  41. u32 KeyState = 0;
  42. /* Private function prototypes -----------------------------------------------*/
  43.  
  44. void Delay(uint32_t nTime);
  45. void TimingDelay_Decrement(void);
  46.  
  47. /* Private functions ---------------------------------------------------------*/
  48.  
  49. /**
  50.   * @brief  Main program.
  51.   * @param  None
  52.   * @retval None
  53.   */
  54. int main(void)
  55. {
  56.   /*!< At this stage the microcontroller clock setting is already configured,
  57.        this is done through SystemInit() function which is called from startup
  58.        file (startup_stm32f10x_xx.s) before to branch to application main.
  59.        To reconfigure the default setting of SystemInit() function, refer to
  60.        system_stm32f10x.c file
  61.      */    
  62.  
  63.   /* Initialize Leds LD3 and LD4 mounted on STM32VLDISCOVERY board */  
  64.   STM32vldiscovery_LEDInit(LED3);
  65.   STM32vldiscovery_LEDInit(LED4);
  66.  
  67.   /*initialize button */
  68.   STM32vldiscovery_PBInit(BUTTON_USER, BUTTON_MODE_GPIO);
  69.  
  70.   /* Turn on LD3 and LD4 */
  71.   STM32vldiscovery_LEDOn(LED3);
  72.   STM32vldiscovery_LEDOn(LED4);
  73.  
  74.   /* Setup SysTick Timer for 1 msec interrupts  */
  75.   if (SysTick_Config(SystemCoreClock / 1000))
  76.   {
  77.     /* Capture error */
  78.     while (1);
  79.   }
  80.  
  81.  
  82. while(1)
  83.  
  84.   {
  85.  
  86.     if(0 == STM32vldiscovery_PBGetState(BUTTON_USER))
  87.  
  88.       {
  89.  
  90.         if(KeyState == 1)
  91.  
  92.         {
  93.  
  94.            if(0 == STM32vldiscovery_PBGetState(BUTTON_USER))
  95.  
  96.           {
  97.  
  98.             /* USER Button released */
  99.  
  100.               KeyState = 0;
  101.  
  102.             /* Turn Off LED4 */
  103.  
  104.               STM32vldiscovery_LEDOff(LED4);
  105.  
  106.           }      
  107.  
  108.         }
  109.  
  110.       }
  111.  
  112. /**
  113.   * @brief  Inserts a delay time.
  114.   * @param  nTime: specifies the delay time length, in milliseconds.
  115.   * @retval None
  116.   */
  117. void Delay(__IO uint32_t nTime);
  118. {
  119.   TimingDelay = nTime;
  120.  
  121.   while(TimingDelay != 0);
  122. }
  123.  
  124. /**
  125.   * @brief  Decrements the TimingDelay variable.
  126.   * @param  None
  127.   * @retval None
  128.   */
  129. void TimingDelay_Decrement(void)
  130. {
  131.   if (TimingDelay != 0x00)
  132.   {
  133.     TimingDelay--;
  134.   }
  135. }
  136.  
  137. #ifdef  USE_FULL_ASSERT
  138. /**
  139.   * @brief  Reports the name of the source file and the source line number
  140.   *         where the assert_param error has occurred.
  141.   * @param  file: pointer to the source file name
  142.   * @param  line: assert_param error line source number
  143.   * @retval None
  144.   */
  145. void assert_failed(uint8_t* file, uint32_t line)
  146. {
  147.   /* User can add his own implementation to report the file name and line number,
  148.      ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  149.  
  150.   /* Infinite loop */
  151.   while (1)
  152.   {
  153.   }
  154. }
  155. #endif
  156.  
  157. /**
  158.   * @}
  159.   */
  160.  
  161.  
  162.  
  163. /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement