main.c 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /**
  2. ******************************************************************************
  3. * @file Project/STM8L15x_StdPeriph_Template/main.c
  4. * @author MCD Application Team
  5. * @version V1.6.1
  6. * @date 30-September-2014
  7. * @brief Main program body
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * <h2><center>&copy; COPYRIGHT 2014 STMicroelectronics</center></h2>
  12. *
  13. * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
  14. * You may not use this file except in compliance with the License.
  15. * You may obtain a copy of the License at:
  16. *
  17. * http://www.st.com/software_license_agreement_liberty_v2
  18. *
  19. * Unless required by applicable law or agreed to in writing, software
  20. * distributed under the License is distributed on an "AS IS" BASIS,
  21. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  22. * See the License for the specific language governing permissions and
  23. * limitations under the License.
  24. *
  25. ******************************************************************************
  26. */
  27. /* Includes ------------------------------------------------------------------*/
  28. #include "stm8l15x.h"
  29. #include "time.h"
  30. #include "led.h"
  31. #include "delay.h"
  32. /** @addtogroup STM8L15x_StdPeriph_Template
  33. * @{
  34. */
  35. /* Private typedef -----------------------------------------------------------*/
  36. /* Private define ------------------------------------------------------------*/
  37. /* Private macro -------------------------------------------------------------*/
  38. /* Private variables ---------------------------------------------------------*/
  39. /* Private function prototypes -----------------------------------------------*/
  40. /* Private functions ---------------------------------------------------------*/
  41. /**
  42. * @brief Main program.
  43. * @param None
  44. * @retval None
  45. */
  46. void main(void)
  47. {
  48. CLK->CKDIVR = (uint8_t)(CLK_SYSCLKDiv_1); //设置时钟源为1分屏,默认使用内部高速时钟源hsi
  49. tim4_config(); //初始化1ms定时器
  50. LED_Init();
  51. /* Infinite loop */
  52. while (1)
  53. {
  54. delay_ms(1000);
  55. LED1_toggle();
  56. }
  57. }
  58. #ifdef USE_FULL_ASSERT
  59. /**
  60. * @brief Reports the name of the source file and the source line number
  61. * where the assert_param error has occurred.
  62. * @param file: pointer to the source file name
  63. * @param line: assert_param error line source number
  64. * @retval None
  65. */
  66. void assert_failed(uint8_t* file, uint32_t line)
  67. {
  68. /* User can add his own implementation to report the file name and line number,
  69. ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  70. /* Infinite loop */
  71. while (1)
  72. {
  73. }
  74. }
  75. #endif
  76. /**
  77. * @}
  78. */
  79. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/