Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions bsp/renesas/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,13 @@ RA 系列 BSP 目前支持情况如下表所示:
| [BSP 制作教程](docs/RA系列BSP制作教程.md) | 讲解 RA 系列 BSP 的制作方法,以及在制作 BSP 和提交 BSP 时应当遵守的规范 |
| [外设驱动添加指南](docs/RA系列外设驱动添加指南.md) | 讲解 BSP 添加更多设备驱动的方法 |

English documents:

| **BSP Tutorial** | **Introduction** |
|:-------------------- |:------------------------------------------------- |
| [BSP Peripheral Driver Tutorial of RA Series](docs/BSP_Peripheral_Driver_Tutorial_of_RA_Series.md) | Explains how to use more peripheral drivers on the BSP |
| [Introduction to RA Series Drives](docs/Introduction_to_RA_Series_Drives.md) | Explains the support of RA series BSP drivers and how to develop applications using the driver framework |
| [RA Series Uses FSP to Configure Peripheral Drivers](docs/RA_Series_Uses_FSP_to_Configure_Peripheral_Drivers.md) | Introduces how to add and configure peripherals using the FSP tool |
| **BSP Production and Submission** | **Introduction** |
| [Building a BSP for the RA Series Dev Board](docs/Building_a_BSP_for_the_RA_Series_Dev_Board.md) | Explains how the RA series BSPs are created and the specifications to be followed when creating and submitting BSPs |
| [Peripheral Driver Addition Guide of RA Series](docs/Peripheral_Driver_Addition_Guide_of_RA_Series.md) | Explains how to add more device drivers to BSP |
90 changes: 90 additions & 0 deletions bsp/renesas/docs/BSP_Peripheral_Driver_Tutorial_of_RA_Series.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# BSP Peripheral Driver Tutorial of RA Series

## 1. Introduction

This document is for developers who need more board resources on RT-Thread RTOS. By configuring the BSP with the ENV tool, more onboard resources can be turned on and more advanced functions can be realized.

The main contents are following:
1. How to use more onboard resources on the development board
2. How to use more on-chip resources
3. How to add more on-chip resource options

## 2. Prerequisites

- Learn how to use the ENV tool, refer to: [RT-Thread env programming manual](https://www.rt-thread.org/document/site/programming-manual/env/env/)
- Familiar with the use of the [FSP](https://www2.renesas.cn/jp/zh/software-tool/flexible-software-package-fsp) configuration tool

## 3. How to Use More Peripheral Resources

There are generally many peripheral resources on-board, such as SPI, SDIO, ADC, etc., but these peripherals' driver are not enabled by default in the BSP project. RT-Thread provides ENV tools to enable or disable BSP peripheral drivers. This article takes the SPI driver on the RA6M4-CPK development board as an example to show step by step how to use the ENV tool to configure the BSP.

### 3.1 Open The Configuration Tool

Open the menuconfig configuration window in the BSP directory.

![image-20220218162910778](figures_en/menuconfig_ra6m4cpk.png)

The configuration window that opens is as follows:
![config1](figures_en/config1.png)

Move the cursor with the up and down keys on the keyboard, select `Hardware Drivers Config` and press Enter to enter the hardware driver configuration menu.

### 3.2 Enter The Hardware Driver Configuration Menu

There are three options in the hardware configuration menu, namely **on-board peripheral configuration menu**, **on-chip peripheral configuration menu** and **extension module configuration menu**, use the down button to switch to on-chip peripherals, Press Enter to enter the configuration menu.

![Hardware driver configuration menu](figures_en/config2.png)

### 3.3 Enable The SPI Flash Option in The Onboard Peripheral Configuration Menu

![image-20220218163357420](figures_en/menuconfig_spi.png)

![image-20220218163714429](figures_en/menuconfig_spi1.png)



### 3.4 Save and Exit

Move the cursor to the right to select Save and press Enter, then press Esc to exit the configuration tool.

![Save and exit](figures_en/save.png)

### 3.5 Generate MDK5 Project

Enter the command `scons --target=mdk5` to regenerate the MDK5 project.

![image-20220218164532436](figures_en/scons_mdk5.png)

### 3.6 Add SPI Peripheral to FSP

![image-20220218171841353](figures_en/fsp_spi.png)

![image-20220218172446068](figures_en/fsp_spi1.png)

Configure the SPI1 pins in Pins. **Note: The SSLx chip select pin is set to None, the chip select pin is controlled by software in the driver. **

Configuration completes, save and exit FSP.

![image-20220218174145848](figures_en/fsp_spi2.png)

### 3.7 Test Verification
Back to the generated MDK5 project and do the compilation. If a new file is added to the project after the FSP configuration is completed, it will not be added immediately. It needs to be compiled once. If the following prompt pops up, select "Yes" and then compile again.

![image-20220218174811328](figures_en/mdk_build.png)

After the compilation is successful, click the debug button to download and enter the debug page.

![image-20220218175442360](figures_en/mdk_build1.png)

### 3.8 Check Execution Result
After the program runs, enter the command `list_device` to see the bus device named spi1, and the SPI1 bus is ready to use.

![image-20220218175926965](figures_en/run_spi1.png)

## 4. Summarize
This article uses SPI as an example to introduce the operation flow of peripheral drivers. For how to use and configure other types of peripherals, please refer to: [RA series use FSP to configure peripheral drivers.md](RA series use FSP to configure peripheral drivers.md )

When developers need to use unenabled peripherals, they only need to enable the related peripherals in the ENV tool, and then add them in the FSP. The corresponding driver files will be added to the regenerated project.


This tutorial translated by [Josh Zou](https://github.com/Firmament-Autopilot)
Loading