board.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #include <rtthread.h>
  2. #include <rthw.h>
  3. #include <nrfx_systick.h>
  4. #include "board.h"
  5. #include "drv_uart.h"
  6. void SysTick_Configuration(void)
  7. {
  8. /* Set interrupt priority */
  9. NVIC_SetPriority(SysTick_IRQn, 0xf);
  10. /* Configure SysTick to interrupt at the requested rate. */
  11. nrf_systick_load_set(SystemCoreClock / RT_TICK_PER_SECOND);
  12. nrf_systick_val_clear();
  13. nrf_systick_csr_set(NRF_SYSTICK_CSR_CLKSOURCE_CPU | NRF_SYSTICK_CSR_TICKINT_ENABLE
  14. | NRF_SYSTICK_CSR_ENABLE);
  15. }
  16. /**
  17. * This is the timer interrupt service routine.
  18. *
  19. */
  20. void SysTick_Handler(void)
  21. {
  22. /* enter interrupt */
  23. rt_interrupt_enter();
  24. rt_tick_increase();
  25. /* leave interrupt */
  26. rt_interrupt_leave();
  27. }
  28. void rt_hw_board_init(void)
  29. {
  30. // sd_power_dcdc_mode_set(NRF_POWER_DCDC_ENABLE);
  31. /* Activate deep sleep mode */
  32. SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
  33. SysTick_Configuration();
  34. #if defined(RT_USING_HEAP)
  35. rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END);
  36. #endif
  37. #ifdef RT_USING_SERIAL
  38. rt_hw_uart_init();
  39. #endif
  40. #ifdef RT_USING_CONSOLE
  41. rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
  42. #endif
  43. #ifdef RT_USING_COMPONENTS_INIT
  44. rt_components_board_init();
  45. #endif
  46. }