board.cpp 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #include "board.h"
  2. #include "gpio.h"
  3. #include "main.h"
  4. extern "C" void SystemClock_Config(void);
  5. extern "C" int64_t get_current_time(void);
  6. void Board::init_start() {
  7. /* Reset of all peripherals, Initializes the Flash interface and the Systick.
  8. */
  9. LL_APB4_GRP1_EnableClock(LL_APB4_GRP1_PERIPH_SYSCFG);
  10. /* System interrupt init*/
  11. NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
  12. /* Update the time base */
  13. /* Configure the system clock */
  14. SystemClock_Config();
  15. MX_GPIO_Init();
  16. /* Enable I-Cache---------------------------------------------------------*/
  17. SCB_EnableICache();
  18. /* Enable D-Cache---------------------------------------------------------*/
  19. SCB_EnableDCache();
  20. }
  21. void Board::enable_interrupts() {}
  22. void Board::enable_timer() { SysTick_Config(SystemCoreClock / 1000); }
  23. rl::TimePoint Board::get_now() { return get_current_time(); }
  24. void Board::toggle_led() { LL_GPIO_TogglePin(LD1_GPIO_Port, LD1_Pin); }
  25. void Board::delay() {
  26. auto end = get_current_time() + 1000;
  27. while (get_current_time() < end);
  28. }