Skip to content

Commit f674d2a

Browse files
committed
同步 nano 3.1.5
1 parent 2188be0 commit f674d2a

File tree

435 files changed

+364063
-3614
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

435 files changed

+364063
-3614
lines changed

rt-thread/ChangeLog.md

Lines changed: 11 additions & 1191 deletions
Large diffs are not rendered by default.

rt-thread/bsp/_template/board.c

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
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+
* 2021-05-24 the first version
9+
*/
10+
11+
#include <rthw.h>
12+
#include <rtthread.h>
13+
14+
#if defined(RT_USING_USER_MAIN) && defined(RT_USING_HEAP)
15+
/*
16+
* Please modify RT_HEAP_SIZE if you enable RT_USING_HEAP
17+
* the RT_HEAP_SIZE max value = (sram size - ZI size), 1024 means 1024 bytes
18+
*/
19+
#define RT_HEAP_SIZE (15*1024)
20+
static rt_uint8_t rt_heap[RT_HEAP_SIZE];
21+
22+
RT_WEAK void *rt_heap_begin_get(void)
23+
{
24+
return rt_heap;
25+
}
26+
27+
RT_WEAK void *rt_heap_end_get(void)
28+
{
29+
return rt_heap + RT_HEAP_SIZE;
30+
}
31+
#endif
32+
33+
void rt_os_tick_callback(void)
34+
{
35+
rt_interrupt_enter();
36+
37+
rt_tick_increase();
38+
39+
rt_interrupt_leave();
40+
}
41+
42+
/**
43+
* This function will initial your board.
44+
*/
45+
void rt_hw_board_init(void)
46+
{
47+
#error "TODO 1: OS Tick Configuration."
48+
/*
49+
* TODO 1: OS Tick Configuration
50+
* Enable the hardware timer and call the rt_os_tick_callback function
51+
* periodically with the frequency RT_TICK_PER_SECOND.
52+
*/
53+
54+
/* Call components board initial (use INIT_BOARD_EXPORT()) */
55+
#ifdef RT_USING_COMPONENTS_INIT
56+
rt_components_board_init();
57+
#endif
58+
59+
#if defined(RT_USING_USER_MAIN) && defined(RT_USING_HEAP)
60+
rt_system_heap_init(rt_heap_begin_get(), rt_heap_end_get());
61+
#endif
62+
}
63+
64+
#ifdef RT_USING_CONSOLE
65+
66+
static int uart_init(void)
67+
{
68+
#error "TODO 2: Enable the hardware uart and config baudrate."
69+
return 0;
70+
}
71+
INIT_BOARD_EXPORT(uart_init);
72+
73+
void rt_hw_console_output(const char *str)
74+
{
75+
#error "TODO 3: Output the string 'str' through the uart."
76+
}
77+
78+
#endif
79+
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
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+
* 2021-05-24 the first version
9+
*/
10+
11+
#include <rthw.h>
12+
#include <rtthread.h>
13+
14+
#include "main.h"
15+
16+
#if defined(RT_USING_USER_MAIN) && defined(RT_USING_HEAP)
17+
/*
18+
* Please modify RT_HEAP_SIZE if you enable RT_USING_HEAP
19+
* the RT_HEAP_SIZE max value = (sram size - ZI size), 1024 means 1024 bytes
20+
*/
21+
#define RT_HEAP_SIZE (15*1024)
22+
static rt_uint8_t rt_heap[RT_HEAP_SIZE];
23+
24+
RT_WEAK void *rt_heap_begin_get(void)
25+
{
26+
return rt_heap;
27+
}
28+
29+
RT_WEAK void *rt_heap_end_get(void)
30+
{
31+
return rt_heap + RT_HEAP_SIZE;
32+
}
33+
#endif
34+
35+
void SysTick_Handler(void)
36+
{
37+
rt_interrupt_enter();
38+
39+
rt_tick_increase();
40+
41+
rt_interrupt_leave();
42+
}
43+
44+
/**
45+
* This function will initial your board.
46+
*/
47+
void rt_hw_board_init(void)
48+
{
49+
extern void SystemClock_Config(void);
50+
51+
HAL_Init();
52+
SystemClock_Config();
53+
SystemCoreClockUpdate();
54+
/*
55+
* 1: OS Tick Configuration
56+
* Enable the hardware timer and call the rt_os_tick_callback function
57+
* periodically with the frequency RT_TICK_PER_SECOND.
58+
*/
59+
HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/RT_TICK_PER_SECOND);
60+
61+
/* Call components board initial (use INIT_BOARD_EXPORT()) */
62+
#ifdef RT_USING_COMPONENTS_INIT
63+
rt_components_board_init();
64+
#endif
65+
66+
#if defined(RT_USING_USER_MAIN) && defined(RT_USING_HEAP)
67+
rt_system_heap_init(rt_heap_begin_get(), rt_heap_end_get());
68+
#endif
69+
}
70+
71+
#ifdef RT_USING_CONSOLE
72+
73+
static UART_HandleTypeDef UartHandle;
74+
static int uart_init(void)
75+
{
76+
/* TODO: Please modify the UART port number according to your needs */
77+
UartHandle.Instance = USART2;
78+
UartHandle.Init.BaudRate = 115200;
79+
UartHandle.Init.WordLength = UART_WORDLENGTH_8B;
80+
UartHandle.Init.StopBits = UART_STOPBITS_1;
81+
UartHandle.Init.Parity = UART_PARITY_NONE;
82+
UartHandle.Init.Mode = UART_MODE_TX_RX;
83+
UartHandle.Init.HwFlowCtl = UART_HWCONTROL_NONE;
84+
UartHandle.Init.OverSampling = UART_OVERSAMPLING_16;
85+
86+
if (HAL_UART_Init(&UartHandle) != HAL_OK)
87+
{
88+
while (1);
89+
}
90+
return 0;
91+
}
92+
INIT_BOARD_EXPORT(uart_init);
93+
94+
void rt_hw_console_output(const char *str)
95+
{
96+
rt_size_t i = 0, size = 0;
97+
char a = '\r';
98+
99+
__HAL_UNLOCK(&UartHandle);
100+
101+
size = rt_strlen(str);
102+
103+
for (i = 0; i < size; i++)
104+
{
105+
if (*(str + i) == '\n')
106+
{
107+
HAL_UART_Transmit(&UartHandle, (uint8_t *)&a, 1, 1);
108+
}
109+
HAL_UART_Transmit(&UartHandle, (uint8_t *)(str + i), 1, 1);
110+
}
111+
}
112+
#endif
113+
114+
#ifdef RT_USING_FINSH
115+
char rt_hw_console_getchar(void)
116+
{
117+
/* Note: the initial value of ch must < 0 */
118+
int ch = -1;
119+
120+
if (__HAL_UART_GET_FLAG(&UartHandle, UART_FLAG_RXNE) != RESET)
121+
{
122+
ch = UartHandle.Instance->DR & 0xff;
123+
}
124+
else
125+
{
126+
rt_thread_mdelay(10);
127+
}
128+
return ch;
129+
}
130+
#endif
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
/* RT-Thread config file */
2+
3+
#ifndef __RTTHREAD_CFG_H__
4+
#define __RTTHREAD_CFG_H__
5+
6+
// <<< Use Configuration Wizard in Context Menu >>>
7+
8+
// <h>Basic Configuration
9+
// <o>Maximal level of thread priority <8-256>
10+
// <i>Default: 32
11+
#define RT_THREAD_PRIORITY_MAX 32
12+
// <o>OS tick per second
13+
// <i>Default: 1000 (1ms)
14+
#define RT_TICK_PER_SECOND 1000
15+
// <o>Alignment size for CPU architecture data access
16+
// <i>Default: 4
17+
#define RT_ALIGN_SIZE 4
18+
// <o>the max length of object name<2-16>
19+
// <i>Default: 8
20+
#define RT_NAME_MAX 8
21+
// <c1>Using RT-Thread components initialization
22+
// <i>Using RT-Thread components initialization
23+
#define RT_USING_COMPONENTS_INIT
24+
// </c>
25+
26+
#define RT_USING_USER_MAIN
27+
28+
// <o>the stack size of main thread<1-4086>
29+
// <i>Default: 512
30+
#define RT_MAIN_THREAD_STACK_SIZE 256
31+
32+
// </h>
33+
34+
// <h>Debug Configuration
35+
// <c1>enable kernel debug configuration
36+
// <i>Default: enable kernel debug configuration
37+
//#define RT_DEBUG
38+
// </c>
39+
// <o>enable components initialization debug configuration<0-1>
40+
// <i>Default: 0
41+
#define RT_DEBUG_INIT 0
42+
// <c1>thread stack over flow detect
43+
// <i> Diable Thread stack over flow detect
44+
//#define RT_USING_OVERFLOW_CHECK
45+
// </c>
46+
// </h>
47+
48+
// <h>Hook Configuration
49+
// <c1>using hook
50+
// <i>using hook
51+
//#define RT_USING_HOOK
52+
// </c>
53+
// <c1>using idle hook
54+
// <i>using idle hook
55+
//#define RT_USING_IDLE_HOOK
56+
// </c>
57+
// </h>
58+
59+
// <e>Software timers Configuration
60+
// <i> Enables user timers
61+
#define RT_USING_TIMER_SOFT 0
62+
#if RT_USING_TIMER_SOFT == 0
63+
#undef RT_USING_TIMER_SOFT
64+
#endif
65+
// <o>The priority level of timer thread <0-31>
66+
// <i>Default: 4
67+
#define RT_TIMER_THREAD_PRIO 4
68+
// <o>The stack size of timer thread <0-8192>
69+
// <i>Default: 512
70+
#define RT_TIMER_THREAD_STACK_SIZE 512
71+
// </e>
72+
73+
// <h>IPC(Inter-process communication) Configuration
74+
// <c1>Using Semaphore
75+
// <i>Using Semaphore
76+
#define RT_USING_SEMAPHORE
77+
// </c>
78+
// <c1>Using Mutex
79+
// <i>Using Mutex
80+
//#define RT_USING_MUTEX
81+
// </c>
82+
// <c1>Using Event
83+
// <i>Using Event
84+
//#define RT_USING_EVENT
85+
// </c>
86+
// <c1>Using MailBox
87+
// <i>Using MailBox
88+
#define RT_USING_MAILBOX
89+
// </c>
90+
// <c1>Using Message Queue
91+
// <i>Using Message Queue
92+
//#define RT_USING_MESSAGEQUEUE
93+
// </c>
94+
// </h>
95+
96+
// <h>Memory Management Configuration
97+
// <c1>Memory Pool Management
98+
// <i>Memory Pool Management
99+
//#define RT_USING_MEMPOOL
100+
// </c>
101+
// <c1>Dynamic Heap Management(Algorithm: small memory )
102+
// <i>Dynamic Heap Management
103+
#define RT_USING_HEAP
104+
#define RT_USING_SMALL_MEM
105+
// </c>
106+
// <c1>using tiny size of memory
107+
// <i>using tiny size of memory
108+
//#define RT_USING_TINY_SIZE
109+
// </c>
110+
// </h>
111+
112+
// <h>Console Configuration
113+
// <c1>Using console
114+
// <i>Using console
115+
//#define RT_USING_CONSOLE
116+
// </c>
117+
// <o>the buffer size of console <1-1024>
118+
// <i>the buffer size of console
119+
// <i>Default: 128 (128Byte)
120+
#define RT_CONSOLEBUF_SIZE 256
121+
// </h>
122+
123+
// <h>FinSH Configuration
124+
// <c1>include finsh config
125+
// <i>Select this choice if you using FinSH
126+
//#include "finsh_config.h"
127+
// </c>
128+
// </h>
129+
130+
// <h>Device Configuration
131+
// <c1>using device framework
132+
// <i>using device framework
133+
//#define RT_USING_DEVICE
134+
// </c>
135+
// </h>
136+
137+
// <<< end of configuration section >>>
138+
139+
#endif

0 commit comments

Comments
 (0)