【瑞萨RA8D1板卡】 按键测试
<p><span style="font-size:16px;">测试下按键功能,板卡上的LED201指示灯指示按键的状态。</span></p><p> </p>
<p><span style="font-size:16px;"><strong>一、开发环境2studio</strong></span></p>
<p> </p>
<p><span style="font-size:16px;">瑞萨的集成开发环境e2studio软件按照下面连接进行下载及安装。</span></p>
<p><span style="font-size:16px;"><a href="https://github.com/renesas/cpk_examples/blob/main/cpkcor_ra8d1b/docs/02_unbox.md" target="_blank">https://github.com/renesas/cpk_examples/blob/main/cpkcor_ra8d1b/docs/02_unbox.md</a></span></p>
<p> </p>
<p><span style="font-size:16px;"><strong>一、创建项目文件</strong></span></p>
<p> </p>
<p><span style="font-size:16px;">1.1、安装软件库</span></p>
<p> </p>
<p><span style="font-size:16px;">1.1.1、导入软件库</span></p>
<p><span style="font-size:16px;"></span></p>
<p> </p>
<p><span style="font-size:16px;">1.1.2、选择pack包(上面链接有下载地址)</span></p>
<p><span style="font-size:16px;"></span></p>
<p><span style="font-size:16px;">安装完成提示</span></p>
<p><span style="font-size:16px;"></span></p>
<p> </p>
<p><span style="font-size:16px;">1.2、创建项目工程</span></p>
<p> </p>
<p><span style="font-size:16px;">1.2.1、选择RA系列,我这里值安装了一个pack包,只有这一个选项。</span></p>
<p><span style="font-size:16px;"></span></p>
<p> </p>
<p><span style="font-size:16px;">1.2.2、创建的项目名称</span></p>
<p><span style="font-size:16px;"></span></p>
<p> </p>
<p><span style="font-size:16px;">1.2.3、选择开发板对应的型号</span></p>
<p><span style="font-size:16px;"></span></p>
<p> </p>
<p><span style="font-size:16px;">1.2.4、选择不带RTOS的工程</span></p>
<p><span style="font-size:16px;"></span></p>
<p> </p>
<p><span style="font-size:16px;"></span></p>
<p> </p>
<p><span style="font-size:16px;">1.2.5、选择LED例程</span></p>
<p><span style="font-size:16px;"></span></p>
<p><span style="font-size:16px;">创建工程完成。</span></p>
<p> </p>
<p><span style="font-size:16px;"><strong>二、代码</strong></span></p>
<p> </p>
<p><span style="font-size:16px;">修改例程,测试按键输入。</span></p>
<p> </p>
<p><span style="font-size:16px;">2.1、hal_entry.c</span></p>
<pre>
<code>/*
* Copyright (c) 2020 - 2024 Renesas Electronics Corporation and/or its affiliates
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include "hal_data.h"
#include "led/led.h"
void R_BSP_WarmStart(bsp_warm_start_event_t event);
extern bsp_leds_t g_bsp_leds;
/*******************************************************************************************************************//**
* @brief Blinky example application
*
* Blinks all leds at a rate of 1 second using the software delay function provided by the BSP.
*
**********************************************************************************************************************/
void hal_entry (void)
{
#if BSP_TZ_SECURE_BUILD
/* Enter non-secure code */
R_BSP_NonSecureEnter();
#endif
init_led();
/* Define the units to be used with the software delay function */
const bsp_delay_units_t bsp_delay_units = BSP_DELAY_UNITS_MILLISECONDS;
/* Set the blink frequency (must be <= bsp_delay_units */
const uint32_t freq_in_hz = 2;
/* Calculate the delay in terms of bsp_delay_units */
const uint32_t delay = bsp_delay_units / freq_in_hz;
while (1)
{
if(R_BSP_PinRead (BSP_IO_PORT_00_PIN_08)==0)
{
led201_on();
}
else
{
led201_off();
}
/* Delay */
R_BSP_SoftwareDelay(delay, bsp_delay_units);
}
}
/*******************************************************************************************************************//**
* This function is called at various points during the startup process.This implementation uses the event that is
* called right before main() to set up the pins.
*
* @paramevent Where at in the start up process the code is currently at
**********************************************************************************************************************/
void R_BSP_WarmStart (bsp_warm_start_event_t event)
{
if (BSP_WARM_START_RESET == event)
{
#if BSP_FEATURE_FLASH_LP_VERSION != 0
/* Enable reading from data flash. */
R_FACI_LP->DFLCTL = 1U;
/* Would normally have to wait tDSTOP(6us) for data flash recovery. Placing the enable here, before clock and
* C runtime initialization, should negate the need for a delay since the initialization will typically take more than 6us. */
#endif
}
if (BSP_WARM_START_POST_C == event)
{
/* C runtime environment and system clocks are setup. */
/* Configure pins. */
R_IOPORT_Open(&IOPORT_CFG_CTRL, &IOPORT_CFG_NAME);
}
}
</code></pre>
<p> </p>
<p><span style="font-size:16px;">2.2、源代码</span></p>
<div><span style="font-size:16px;"></span></div>
<p> </p>
<p><span style="font-size:16px;"><strong>三、运行结果</strong></span></p>
<p> </p>
<p><span style="font-size:16px;">通过上面简单的程序来测试下修复的按键,按下指示灯亮,松开指示灯灭。</span></p>
<p><span style="font-size:16px;">888092a350145fdbad2a20fd3c578fd7</span><br />
</p>
<p> </p>
<p> </p>
<p> </p>
<div style="text-align: center;">
<p> </p>
</div>
<p> </p>
页:
[1]