board.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2021-01-28 flybreak first version
  9. */
  10. #include <rthw.h>
  11. #include <rtthread.h>
  12. #include <stdio.h>
  13. #include "board.h"
  14. #include "hardware/structs/systick.h"
  15. uint8_t heap[1024 * 80];
  16. void isr_systick(void)
  17. {
  18. /* enter interrupt */
  19. rt_interrupt_enter();
  20. rt_tick_increase();
  21. /* leave interrupt */
  22. rt_interrupt_leave();
  23. }
  24. uint32_t systick_config(uint32_t ticks)
  25. {
  26. if ((ticks - 1UL) > M0PLUS_SYST_RVR_RELOAD_BITS)
  27. {
  28. return (1UL); /* Reload value impossible */
  29. }
  30. mpu_hw->rvr = (uint32_t)(ticks - 1UL); /* set reload register */
  31. mpu_hw->csr = M0PLUS_SYST_CSR_CLKSOURCE_BITS |
  32. M0PLUS_SYST_CSR_TICKINT_BITS |
  33. M0PLUS_SYST_CSR_ENABLE_BITS; /* Enable SysTick IRQ and SysTick Timer */
  34. return (0UL); /* Function successful */
  35. }
  36. void rt_hw_board_init()
  37. {
  38. /* Configure the SysTick */
  39. systick_config(frequency_count_khz(CLOCKS_FC0_SRC_VALUE_ROSC_CLKSRC)*10000/RT_TICK_PER_SECOND);
  40. rt_system_heap_init(heap, (uint8_t *)heap + sizeof(heap));
  41. stdio_init_all();
  42. rt_hw_uart_init();
  43. #ifdef RT_USING_CONSOLE
  44. rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
  45. #endif
  46. }