Advertisement
Guest User

Untitled

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