Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * Copyright (c) 2006-2019, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2017-07-24 Tanek the first version
  9. * 2018-11-12 Ernest Chen modify copyright
  10. */
  11. #include <stdint.h>
  12. #include <rthw.h>
  13. #include <rtthread.h>
  14. #include "usart.h"
  15. #include "main.h"
  16. #define _SCB_BASE (0xE000E010UL)
  17. #define _SYSTICK_CTRL (*(rt_uint32_t *)(_SCB_BASE + 0x0))
  18. #define _SYSTICK_LOAD (*(rt_uint32_t *)(_SCB_BASE + 0x4))
  19. #define _SYSTICK_VAL (*(rt_uint32_t *)(_SCB_BASE + 0x8))
  20. #define _SYSTICK_CALIB (*(rt_uint32_t *)(_SCB_BASE + 0xC))
  21. #define _SYSTICK_PRI (*(rt_uint8_t *)(0xE000ED23UL))
  22. // Updates the variable SystemCoreClock and must be called
  23. // whenever the core clock is changed during program execution.
  24. extern void SystemCoreClockUpdate(void);
  25. void SysInit(void);
  26. // Holds the system core clock, which is the system clock
  27. // frequency supplied to the SysTick timer and the processor
  28. // core clock.
  29. extern uint32_t SystemCoreClock;
  30. static uint32_t _SysTick_Config(rt_uint32_t ticks)
  31. {
  32. if ((ticks - 1) > 0xFFFFFF)
  33. {
  34. return 1;
  35. }
  36. _SYSTICK_LOAD = ticks - 1;
  37. _SYSTICK_PRI = 0xFF;
  38. _SYSTICK_VAL = 0;
  39. _SYSTICK_CTRL = 0x07;
  40. return 0;
  41. }
  42. #if defined(RT_USING_USER_MAIN) && defined(RT_USING_HEAP)
  43. #define RT_HEAP_SIZE 2048
  44. static uint32_t rt_heap[RT_HEAP_SIZE]; // heap default size: 4K(1024 * 4)
  45. RT_WEAK void *rt_heap_begin_get(void)
  46. {
  47. return rt_heap;
  48. }
  49. RT_WEAK void *rt_heap_end_get(void)
  50. {
  51. return rt_heap + RT_HEAP_SIZE;
  52. }
  53. #endif
  54. /**
  55. * This function will initial your board.
  56. */
  57. void rt_hw_board_init()
  58. {
  59. /* System Clock Update */
  60. SystemCoreClockUpdate();
  61. /* System Tick Configuration */
  62. _SysTick_Config(SystemCoreClock / RT_TICK_PER_SECOND);
  63. SysInit();
  64. /* Call components board initial (use INIT_BOARD_EXPORT()) */
  65. #ifdef RT_USING_COMPONENTS_INIT
  66. rt_components_board_init();
  67. #endif
  68. #if defined(RT_USING_USER_MAIN) && defined(RT_USING_HEAP)
  69. rt_system_heap_init(rt_heap_begin_get(), rt_heap_end_get());
  70. #endif
  71. }
  72. void SysInit(void)
  73. {
  74. HAL_Init();
  75. extern void SystemClock_Config(void);
  76. SystemClock_Config();
  77. extern void MX_GPIO_Init(void);
  78. MX_GPIO_Init();
  79. //MX_I2C1_Init();
  80. MX_USART1_UART_Init();
  81. }
  82. int main(void)
  83. {
  84. extern int elog_test(void);
  85. elog_test();
  86. //rt_kprintf("%s\n", __func__);
  87. return 0;
  88. }
  89. void SysTick_Handler(void)
  90. {
  91. /* enter interrupt */
  92. rt_interrupt_enter();
  93. rt_tick_increase();
  94. /* leave interrupt */
  95. rt_interrupt_leave();
  96. }