blob: 75211de9c51d0657a91e9863f3ed28aa605ad629 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
/*
* Copyright (c) 2006-2023, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2021-01-28 flybreak first version
* 2023-01-22 rose_man add RT_USING_SMP
* 2025-08-04 hydevcode first version
*/
#include <rthw.h>
#include <rtthread.h>
#include <stdio.h>
#include "board.h"
#include <pico/bootrom.h>
#include <pico/stdlib.h>
#include <hardware/clocks.h>
#include <hardware/structs/systick.h>
#include <drv_uart.h>
#define PLL_SYS_KHZ (150 * 1000)
void SysTick_Handler(void)
{
rt_interrupt_enter();
rt_tick_increase();
rt_interrupt_leave();
}
uint32_t systick_config(uint32_t ticks)
{
if ((ticks - 1UL) > M33_SYST_RVR_RELOAD_BITS)
{
return (1UL); /* Reload value impossible */
}
systick_hw->rvr = (uint32_t)(ticks - 1UL); /* set reload register */
systick_hw->csr = M33_SYST_CSR_CLKSOURCE_BITS |
M33_SYST_CSR_TICKINT_BITS |
M33_SYST_CSR_ENABLE_BITS; /* Enable SysTick IRQ and SysTick Timer */
}
#include "pico/runtime.h"
void rt_hw_board_init()
{
#ifdef RT_USING_HEAP
rt_system_heap_init(HEAP_BEGIN, HEAP_END);
#endif
set_sys_clock_khz(PLL_SYS_KHZ, true);
alarm_pool_init_default();
systick_config(clock_get_hz(clk_sys) / RT_TICK_PER_SECOND);
#ifdef RT_USING_COMPONENTS_INIT
rt_components_board_init();
#endif
#ifdef RT_USING_SERIAL
stdio_init_all();
rt_hw_uart_init();
#endif
#ifdef RT_USING_CONSOLE
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
#endif
}
|