【AT-START-F425测评】+RT-Thread移植到AT32F425
<p><font size="4"><font style="overflow-wrap:break-word; word-break:break-all; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial"><strong style="overflow-wrap:break-word; word-break:break-all; font-weight:700">1、准备好一个keil 工程</strong></font></font><br style="overflow-wrap:break-word; word-break:break-all; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial" /><br style="overflow-wrap:break-word; word-break:break-all; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial" />
<strong style="overflow-wrap:break-word; word-break:break-all; font-weight:700; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-size:16px; font-style:normal; font-variant-ligatures:normal; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial"><font size="4"><font style="overflow-wrap:break-word; word-break:break-all">2、点击“Manage Run-Time Environment”</font></font></strong><br style="overflow-wrap:break-word; word-break:break-all; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial" />
<br style="overflow-wrap:break-word; word-break:break-all; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial" />
<br style="overflow-wrap:break-word; word-break:break-all; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial" />
<strong style="overflow-wrap:break-word; word-break:break-all; font-weight:700; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-size:16px; font-style:normal; font-variant-ligatures:normal; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial"><font size="4"><font style="overflow-wrap:break-word; word-break:break-all">3、在“Manage Run-Time Environment”中勾选kernel和shell</font></font></strong><br style="overflow-wrap:break-word; word-break:break-all; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial" />
<br style="overflow-wrap:break-word; word-break:break-all; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial" />
<br style="overflow-wrap:break-word; word-break:break-all; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial" />
<font size="4"><font style="overflow-wrap:break-word; word-break:break-all; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial"><strong style="overflow-wrap:break-word; word-break:break-all; font-weight:700">4、勾选之后,在工程目录中,可以看到多了RTOS一项,里面是RT-Thread的相关代码</strong></font></font><br style="overflow-wrap:break-word; word-break:break-all; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial" />
<br style="overflow-wrap:break-word; word-break:break-all; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial" />
<font size="4"><font style="overflow-wrap:break-word; word-break:break-all; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial"><strong style="overflow-wrap:break-word; word-break:break-all; font-weight:700">5、FinSH配置,在rtconfig.h中使能FinSH,可以使用配置向导,也可以使用代码</strong></font></font><br style="overflow-wrap:break-word; word-break:break-all; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial" />
<br style="overflow-wrap:break-word; word-break:break-all; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial" />
<strong style="overflow-wrap:break-word; word-break:break-all; font-weight:700; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-size:16px; font-style:normal; font-variant-ligatures:normal; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial"><font size="4"><font style="overflow-wrap:break-word; word-break:break-all">6、控制台使能,在rtconfig.h中使能控制台,可以使用配置向导,也可以使用代码</font></font></strong><br style="overflow-wrap:break-word; word-break:break-all; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial" />
<br style="overflow-wrap:break-word; word-break:break-all; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial" />
<br style="overflow-wrap:break-word; word-break:break-all; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial" />
<font size="4"><font style="overflow-wrap:break-word; word-break:break-all; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial"><strong style="overflow-wrap:break-word; word-break:break-all; font-weight:700">7、”系统时钟节拍配置报错,#error "TODO 1: OS Tick Configuration."</strong></font></font><br style="overflow-wrap:break-word; word-break:break-all; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial" />
<br style="overflow-wrap:break-word; word-break:break-all; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial" />
<strong style="overflow-wrap:break-word; word-break:break-all; font-weight:700; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-size:16px; font-style:normal; font-variant-ligatures:normal; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial"><font size="4"><font style="overflow-wrap:break-word; word-break:break-all">8、配置系统时钟节拍</font></font></strong><br style="overflow-wrap:break-word; word-break:break-all; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial" />
<span style="font-size:16px; text-align:start"><span style="color:#444444"><span style="font-family:Tahoma, "Microsoft Yahei", Simsun"><span style="font-style:normal"><span style="font-variant-ligatures:normal"><span style="font-weight:400"><span style="white-space:normal"><span style="background-color:#f2f9fd"><span style="text-decoration-thickness:initial"><span style="text-decoration-style:initial"><span style="text-decoration-color:initial"><span style="display:inline !important"><span style="float:none">在void rt_hw_board_init(void)函数中,设置使用systick为系统时钟。</span></span></span></span></span></span></span></span></span></span></span></span></span><br style="overflow-wrap:break-word; word-break:break-all; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial" />
<br style="overflow-wrap:break-word; word-break:break-all; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial" />
<strong style="overflow-wrap:break-word; word-break:break-all; font-weight:700; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-size:16px; font-style:normal; font-variant-ligatures:normal; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial"><font size="4"><font style="overflow-wrap:break-word; word-break:break-all">9、串口初始化报错,“"TODO 2: Enable the hardware uart and config baudrate."”</font></font></strong><br style="overflow-wrap:break-word; word-break:break-all; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial" />
<br style="overflow-wrap:break-word; word-break:break-all; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial" />
<strong style="overflow-wrap:break-word; word-break:break-all; font-weight:700; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-size:16px; font-style:normal; font-variant-ligatures:normal; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial"><font size="4"><font style="overflow-wrap:break-word; word-break:break-all">10、配置串口</font></font></strong><br style="overflow-wrap:break-word; word-break:break-all; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial" />
<br style="overflow-wrap:break-word; word-break:break-all; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial" />
<span style="font-size:16px; text-align:start"><span style="color:#444444"><span style="font-family:Tahoma, "Microsoft Yahei", Simsun"><span style="font-style:normal"><span style="font-variant-ligatures:normal"><span style="font-weight:400"><span style="white-space:normal"><span style="background-color:#f2f9fd"><span style="text-decoration-thickness:initial"><span style="text-decoration-style:initial"><span style="text-decoration-color:initial"><span style="display:inline !important"><span style="float:none">在uart_init函数中,调用串口初始化的函数即可。</span></span></span></span></span></span></span></span></span></span></span></span></span></p>
<div class="code_div" style="text-align:start">
<div class="code_tools" style="text-align:center; padding:2px; width:40px; margin-top:5px; margin-right:5px; margin-bottom:5px; margin-left:5px"><span style="font-size:16px"><span style="overflow-wrap:break-word"><span style="word-break:break-all"><span style="position:relative"><span style="color:#444444"><span style="font-family:Tahoma, "Microsoft Yahei", Simsun"><span style="font-style:normal"><span style="font-variant-ligatures:normal"><span style="font-weight:400"><span style="white-space:normal"><span style="background-color:#f2f9fd"><span style="text-decoration-thickness:initial"><span style="text-decoration-style:initial"><span style="text-decoration-color:initial"><span style="background:#778899"><span style="overflow-wrap:break-word"><span style="word-break:break-all"><span style="float:right"><span style="position:absolute"><span style="right:0px"><span style="transition-duration:0.3s"><a onclick="copycode($('code_Mvd'));" style="overflow-wrap:break-word; word-break:break-all; color:white; text-decoration:none; cursor:pointer">复制</a></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></div>
</div>
<pre>
<code class="language-cpp">void SerialInit(void)
{
gpio_init_type gpio_init_struct;
crm_periph_clock_enable(CRM_USART1_PERIPH_CLOCK, TRUE);
#if 1
/* enable the usart1 and gpio clock */
crm_periph_clock_enable(CRM_GPIOB_PERIPH_CLOCK, TRUE);
gpio_default_para_init(&gpio_init_struct);
/* configure the usart1 tx/rx pin */
gpio_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER;
gpio_init_struct.gpio_out_type= GPIO_OUTPUT_PUSH_PULL;
gpio_init_struct.gpio_mode = GPIO_MODE_MUX;
gpio_init_struct.gpio_pins = GPIO_PINS_6 | GPIO_PINS_7;
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
gpio_init(GPIOB, &gpio_init_struct);
/* config usart1 iomux */
gpio_pin_mux_config(GPIOB, GPIO_PINS_SOURCE6, GPIO_MUX_0);
gpio_pin_mux_config(GPIOB, GPIO_PINS_SOURCE7, GPIO_MUX_0);
#else
/* enable the usart1 and gpio clock */
crm_periph_clock_enable(CRM_GPIOA_PERIPH_CLOCK, TRUE);
gpio_default_para_init(&gpio_init_struct);
/* configure the usart1 tx/rx pin */
gpio_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER;
gpio_init_struct.gpio_out_type= GPIO_OUTPUT_PUSH_PULL;
gpio_init_struct.gpio_mode = GPIO_MODE_MUX;
gpio_init_struct.gpio_pins = GPIO_PINS_9 ;
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
gpio_init(GPIOA, &gpio_init_struct);
gpio_init_struct.gpio_pins =GPIO_PINS_10;
gpio_init(GPIOA, &gpio_init_struct);
/* config usart1 iomux */
gpio_pin_mux_config(GPIOA, GPIO_PINS_SOURCE9, GPIO_MUX_1);
gpio_pin_mux_config(GPIOA, GPIO_PINS_SOURCE10, GPIO_MUX_1);
#endif
/* configure usart1 param */
usart_init(USART1, 115200, USART_DATA_8BITS, USART_STOP_1_BIT);
usart_parity_selection_config(USART1, USART_PARITY_NONE);
usart_hardware_flow_control_set(USART1,USART_HARDWARE_FLOW_NONE);
usart_transmitter_enable(USART1, TRUE);
usart_receiver_enable(USART1, TRUE);
usart_enable(USART1, TRUE);
}</code></pre>
<p><br style="overflow-wrap:break-word; word-break:break-all; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial" />
<br style="overflow-wrap:break-word; word-break:break-all; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial" />
<font size="4"><font style="overflow-wrap:break-word; word-break:break-all; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial"><strong style="overflow-wrap:break-word; word-break:break-all; font-weight:700">11、串口输出报错,“"TODO 3: Output the string 'str' through the uart."”</strong></font></font><br style="overflow-wrap:break-word; word-break:break-all; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial" />
<br style="overflow-wrap:break-word; word-break:break-all; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial" />
<strong style="overflow-wrap:break-word; word-break:break-all; font-weight:700; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-size:16px; font-style:normal; font-variant-ligatures:normal; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial"><font size="4"><font style="overflow-wrap:break-word; word-break:break-all">12、配置串口输出</font></font></strong></p>
<pre>
<code class="language-cpp">void rt_hw_console_output(const char *str)
{
//#error "TODO 3: Output the string 'str' through the uart."
rt_size_t i = 0, size = 0;
char a = '\r';
size = rt_strlen(str);
for (i = 0; i < size; i++)
{
if (*(str + i) == '\n')
{
usart_data_transmit(USART1, (uint32_t )a);
while((usart_flag_get(USART1, USART_TDC_FLAG) == RESET));
}
usart_data_transmit(USART1, (uint32_t)*(str + i));
while((usart_flag_get(USART1, USART_TDC_FLAG) == RESET));
}
}</code></pre>
<p><br style="overflow-wrap:break-word; word-break:break-all; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial" />
<strong style="overflow-wrap:break-word; word-break:break-all; font-weight:700; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-size:16px; font-style:normal; font-variant-ligatures:normal; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial"><font size="4"><font style="overflow-wrap:break-word; word-break:break-all">13、串口输入报错,“#error "TODO 4: Read a char from the uart and assign it to 'ch'."”</font></font></strong><br style="overflow-wrap:break-word; word-break:break-all; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial" />
<br style="overflow-wrap:break-word; word-break:break-all; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial" />
<strong style="overflow-wrap:break-word; word-break:break-all; font-weight:700; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-size:16px; font-style:normal; font-variant-ligatures:normal; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial"><font size="4"><font style="overflow-wrap:break-word; word-break:break-all">14、配置串口输入</font></font></strong></p>
<div class="code_div" style="text-align:start">
<div class="code_tools" style="text-align:center; padding:2px; width:40px; margin-top:5px; margin-right:5px; margin-bottom:5px; margin-left:5px"><span style="font-size:16px"><span style="overflow-wrap:break-word"><span style="word-break:break-all"><span style="position:relative"><span style="color:#444444"><span style="font-family:Tahoma, "Microsoft Yahei", Simsun"><span style="font-style:normal"><span style="font-variant-ligatures:normal"><span style="font-weight:400"><span style="white-space:normal"><span style="background-color:#f2f9fd"><span style="text-decoration-thickness:initial"><span style="text-decoration-style:initial"><span style="text-decoration-color:initial"><span style="background:#778899"><span style="overflow-wrap:break-word"><span style="word-break:break-all"><span style="float:right"><span style="position:absolute"><span style="right:0px"><span style="transition-duration:0.3s"><a onclick="copycode($('code_caf'));" style="overflow-wrap:break-word; word-break:break-all; color:white; text-decoration:none; cursor:pointer">复制</a></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></div>
</div>
<pre>
<code>RT_WEAK char rt_hw_console_getchar(void)
{
/* Note: the initial value of ch must < 0 */
//#error "TODO 4: Read a char from the uart and assign it to 'ch'."
/* the initial value of ch must < 0 */
int ch = -1;
if (usart_flag_get(USART1, USART_RDBF_FLAG) != RESET)
{
ch = usart_data_receive(USART1);
}
else
{
rt_thread_mdelay(10);
}
return ch;
}</code></pre>
<p><br style="overflow-wrap:break-word; word-break:break-all; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial" />
<strong style="overflow-wrap:break-word; word-break:break-all; font-weight:700; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-size:16px; font-style:normal; font-variant-ligatures:normal; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial"><font size="4"><font style="overflow-wrap:break-word; word-break:break-all">15、HardFault_Handler和PendSV_Handler重复定义</font></font></strong><br style="overflow-wrap:break-word; word-break:break-all; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial" />
<span style="font-size:16px; text-align:start"><span style="color:#444444"><span style="font-family:Tahoma, "Microsoft Yahei", Simsun"><span style="font-style:normal"><span style="font-variant-ligatures:normal"><span style="font-weight:400"><span style="white-space:normal"><span style="background-color:#f2f9fd"><span style="text-decoration-thickness:initial"><span style="text-decoration-style:initial"><span style="text-decoration-color:initial"><span style="display:inline !important"><span style="float:none">在at32f425_int.c中屏蔽掉即可,这两个中断RT-Thread已经处理了。</span></span></span></span></span></span></span></span></span></span></span></span></span><br style="overflow-wrap:break-word; word-break:break-all; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial" />
<br style="overflow-wrap:break-word; word-break:break-all; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial" />
<strong style="overflow-wrap:break-word; word-break:break-all; font-weight:700; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-size:16px; font-style:normal; font-variant-ligatures:normal; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial"><font size="4"><font style="overflow-wrap:break-word; word-break:break-all">16、Systick中断回调处理</font></font></strong><br style="overflow-wrap:break-word; word-break:break-all; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial" />
<span style="font-size:16px; text-align:start"><span style="color:#444444"><span style="font-family:Tahoma, "Microsoft Yahei", Simsun"><span style="font-style:normal"><span style="font-variant-ligatures:normal"><span style="font-weight:400"><span style="white-space:normal"><span style="background-color:#f2f9fd"><span style="text-decoration-thickness:initial"><span style="text-decoration-style:initial"><span style="text-decoration-color:initial"><span style="display:inline !important"><span style="float:none">配置了Systick为系统的时钟,需要需要在Systick中处理系统的回调函数</span></span></span></span></span></span></span></span></span></span></span></span></span></p>
<pre>
<code>void SysTick_Handler(void)
{
void rt_os_tick_callback(void);
rt_os_tick_callback();
}</code></pre>
<div class="code_div" style="text-align:start">
<div class="code_tools" style="text-align:center; padding:2px; width:40px; margin-top:5px; margin-right:5px; margin-bottom:5px; margin-left:5px"><span style="font-size:16px"><span style="overflow-wrap:break-word"><span style="word-break:break-all"><span style="position:relative"><span style="color:#444444"><span style="font-family:Tahoma, "Microsoft Yahei", Simsun"><span style="font-style:normal"><span style="font-variant-ligatures:normal"><span style="font-weight:400"><span style="white-space:normal"><span style="background-color:#f2f9fd"><span style="text-decoration-thickness:initial"><span style="text-decoration-style:initial"><span style="text-decoration-color:initial"><span style="background:#778899"><span style="overflow-wrap:break-word"><span style="word-break:break-all"><span style="float:right"><span style="position:absolute"><span style="right:0px"><span style="transition-duration:0.3s"><a onclick="copycode($('code_Kka'));" style="overflow-wrap:break-word; word-break:break-all; color:white; text-decoration:none; cursor:pointer">复制</a></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></div>
</div>
<p><br style="overflow-wrap:break-word; word-break:break-all; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial" />
<strong style="overflow-wrap:break-word; word-break:break-all; font-weight:700; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-size:16px; font-style:normal; font-variant-ligatures:normal; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial"><font size="4"><font style="overflow-wrap:break-word; word-break:break-all">17、创建一个led线程</font></font></strong></p>
<div class="code_div" style="text-align:start">
<div class="code_tools" style="text-align:center; padding:2px; width:40px; margin-top:5px; margin-right:5px; margin-bottom:5px; margin-left:5px"><span style="font-size:16px"><span style="overflow-wrap:break-word"><span style="word-break:break-all"><span style="position:relative"><span style="color:#444444"><span style="font-family:Tahoma, "Microsoft Yahei", Simsun"><span style="font-style:normal"><span style="font-variant-ligatures:normal"><span style="font-weight:400"><span style="white-space:normal"><span style="background-color:#f2f9fd"><span style="text-decoration-thickness:initial"><span style="text-decoration-style:initial"><span style="text-decoration-color:initial"><span style="background:#778899"><span style="overflow-wrap:break-word"><span style="word-break:break-all"><span style="float:right"><span style="position:absolute"><span style="right:0px"><span style="transition-duration:0.3s"><a onclick="copycode($('code_l89'));" style="overflow-wrap:break-word; word-break:break-all; color:white; text-decoration:none; cursor:pointer">复制</a></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></div>
</div>
<pre>
<code class="language-cpp">static rt_thread_t led_thread = RT_NULL;
void LedInit(void)
{
gpio_init_type gpio_init_struct;
/* enable the led clock */
crm_periph_clock_enable(CRM_GPIOC_PERIPH_CLOCK, TRUE);
/* set default parameter */
gpio_default_para_init(&gpio_init_struct);
/* configure the led gpio */
gpio_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER;
gpio_init_struct.gpio_out_type= GPIO_OUTPUT_PUSH_PULL;
gpio_init_struct.gpio_mode = GPIO_MODE_OUTPUT;
gpio_init_struct.gpio_pins = GPIO_PINS_2|GPIO_PINS_3|GPIO_PINS_5;
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
gpio_init(GPIOC, &gpio_init_struct);
}
static void led_thread_entry(void *parameter)
{
while (1)
{
gpio_bits_write(GPIOC, GPIO_PINS_2|GPIO_PINS_3|GPIO_PINS_5, (confirm_state)!gpio_output_data_bit_read(GPIOC, GPIO_PINS_2|GPIO_PINS_3|GPIO_PINS_5));
rt_thread_mdelay(1000);
rt_kprintf("led blink\r\n");
}
}
void LedThreadStart(void)
{
led_thread = rt_thread_create( "led", /*线程名字*/
led_thread_entry,/*线程入口函数*/
RT_NULL,/*线程入口函数参数*/
256, /*线程栈大小*/
4 , /*线程优先级*/
20); /*线程时间片*/
rt_thread_startup (led_thread);
}</code></pre>
<p><br style="overflow-wrap:break-word; word-break:break-all" />
<font size="4"><font style="overflow-wrap:break-word; word-break:break-all; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial"><strong style="overflow-wrap:break-word; word-break:break-all; font-weight:700">18、硬件初始化</strong></font></font><br style="overflow-wrap:break-word; word-break:break-all; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial" />
<br style="overflow-wrap:break-word; word-break:break-all; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial" />
<span style="font-size:16px; text-align:start"><span style="color:#444444"><span style="font-family:Tahoma, "Microsoft Yahei", Simsun"><span style="font-style:normal"><span style="font-variant-ligatures:normal"><span style="font-weight:400"><span style="white-space:normal"><span style="background-color:#f2f9fd"><span style="text-decoration-thickness:initial"><span style="text-decoration-style:initial"><span style="text-decoration-color:initial"><span style="display:inline !important"><span style="float:none">在rt_hw_board_init函数中包含led初始化函数。</span></span></span></span></span></span></span></span></span></span></span></span></span><br style="overflow-wrap:break-word; word-break:break-all; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial" />
<br style="overflow-wrap:break-word; word-break:break-all" />
<strong style="overflow-wrap:break-word; word-break:break-all; font-weight:700; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-size:16px; font-style:normal; font-variant-ligatures:normal; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial">19、在main函数中调用启动led线程</strong></p>
<pre>
<code>int main(void)
{
LedThreadStart();
return 0;
}</code></pre>
<div class="code_div" style="text-align:start">
<div class="code_tools" style="text-align:center; padding:2px; width:40px; margin-top:5px; margin-right:5px; margin-bottom:5px; margin-left:5px"><span style="font-size:16px"><span style="overflow-wrap:break-word"><span style="word-break:break-all"><span style="position:relative"><span style="color:#444444"><span style="font-family:Tahoma, "Microsoft Yahei", Simsun"><span style="font-style:normal"><span style="font-variant-ligatures:normal"><span style="font-weight:400"><span style="white-space:normal"><span style="background-color:#f2f9fd"><span style="text-decoration-thickness:initial"><span style="text-decoration-style:initial"><span style="text-decoration-color:initial"><span style="background:#778899"><span style="overflow-wrap:break-word"><span style="word-break:break-all"><span style="float:right"><span style="position:absolute"><span style="right:0px"><span style="transition-duration:0.3s"><a onclick="copycode($('code_kDT'));" style="overflow-wrap:break-word; word-break:break-all; color:white; text-decoration:none; cursor:pointer">复制</a></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></div>
</div>
<p><br style="overflow-wrap:break-word; word-break:break-all" />
<font size="4"><font style="overflow-wrap:break-word; word-break:break-all; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial"><strong style="overflow-wrap:break-word; word-break:break-all; font-weight:700">20、现象</strong></font></font><br style="overflow-wrap:break-word; word-break:break-all; color:#444444; font-family:Tahoma, "Microsoft Yahei", Simsun; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#f2f9fd; text-decoration-thickness:initial; text-decoration-style:initial; text-decoration-color:initial" />
</p>
<p>讲解的挺详细的!感谢分享</p>
<div class="quote">
<blockquote><font size="2"><a href="forum.php?mod=redirect&goto=findpost&pid=3144938&ptid=1204276" target="_blank"><font color="#999999">wangerxian 发表于 2022-5-23 18:51</font></a></font> 讲解的挺详细的!感谢分享</blockquote>
</div>
<p><img height="32" src="https://bbs.eeworld.com.cn/static/editor/plugins/hkemoji/sticker/facebook/handshake.gif" width="32" /></p>
页:
[1]