测试下按键功能,板卡上的LED201指示灯指示按键的状态。
一、开发环境2studio
瑞萨的集成开发环境e2studio软件按照下面连接进行下载及安装。
https://github.com/renesas/cpk_examples/blob/main/cpkcor_ra8d1b/docs/02_unbox.md
一、创建项目文件
1.1、安装软件库
1.1.1、导入软件库
1.1.2、选择pack包(上面链接有下载地址)
安装完成提示
1.2、创建项目工程
1.2.1、选择RA系列,我这里值安装了一个pack包,只有这一个选项。
1.2.2、创建的项目名称
1.2.3、选择开发板对应的型号
1.2.4、选择不带RTOS的工程
1.2.5、选择LED例程
创建工程完成。
二、代码
修改例程,测试按键输入。
2.1、hal_entry.c
/*
* 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;
/*******************************************************************************************************************//**
* [url=home.php?mod=space&uid=159083]@brief[/url] 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.
*
* @param[in] event 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);
}
}
2.2、源代码
三、运行结果
通过上面简单的程序来测试下修复的按键,按下指示灯亮,松开指示灯灭。