Skip to content

Commit

Permalink
Updated the document content and release version number to 1.1.0 SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
kurisaW authored and Rbb666 committed Dec 9, 2024
1 parent 5da0cee commit f0a2ff2
Show file tree
Hide file tree
Showing 28 changed files with 256 additions and 348 deletions.
Binary file modified docs/EtherKit_User_Manual.pdf
Binary file not shown.
107 changes: 49 additions & 58 deletions projects/etherkit_driver_canfd/README.md
Original file line number Diff line number Diff line change
@@ -1,54 +1,61 @@
# RZ EtherKit Development Board CANFD Usage Instructions
# RZ EtherKit Development Board CANFD Usage Guide

**English** | **[Chinese](./README_zh.md)**

## Introduction

This example mainly introduces how to use the CANFD device on the EtherKit.
This tutorial mainly introduces how to use the CANFD device on the EtherKit.

## Hardware Description

![img](./figures/wps35.jpg)

![img](./figures/wps36.jpg)
![image-20241209161000134](figures/image-20241209161000134.png)

## Software Description

### FSP Configuration Instructions
### FSP Configuration Guide

Select the configuration.xml file under the newly created project and open it in rzn-fsp.

![image-20241209161017635](figures/image-20241209161017635.png)

Click to add a new stack, search for `canfd`, and add `r_canfd`. Here, we need to add two `canfd_stack`.

![image-20241204165134218](./figures/image-20241204165134218.png)
![image-20241209161136496](figures/image-20241209161136496.png)

![image-20241204165137649](./figures/image-20241204165137649.png)
In the basic configuration, enable the reception FIFO interrupt for `canfd0` and `canfd1` by selecting Common -> Reception -> FIFOs -> FIFO 0 / FIFO 1 -> Enable. For `canfd0`, enable FIFO 0 interrupt, and for `canfd1`, enable FIFO 1 interrupt:

![image-20241204165142223](./figures/image-20241204165142223.png)
![image-20241209161152095](figures/image-20241209161152095.png)

![image-20241204165146225](./figures/image-20241204165146225.png)
Next, we need to configure the channel, interrupt callback functions, and filter array for CANFD.

![image-20241204165151880](./figures/image-20241204165151880.png)
![image-20241209161213497](figures/image-20241209161213497.png)

![image-20241204165156803](./figures/image-20241204165156803.png)
Configure and enable the CANFD pins.

![image-20241204165200238](./figures/image-20241204165200238.png)
![image-20241209161725958](figures/image-20241209161725958.png)

![image-20241204165204684](./figures/image-20241204165204684.png)
Next, enable the interrupt configuration for the message buffer, which determines which message buffer will trigger the interrupt when transmission is complete.

![image-20241209161744841](figures/image-20241209161744841.png)

### RT-Thread Settings Configuration

![img](./figures/wps39.jpg)
Open RT-Thread Settings and enable the CANFD configuration.

![image-20241209161830340](figures/image-20241209161830340.png)

### Project Example Description

The project sends messages via `canfd0` and receives them on `canfd1`, printing the output using a serial port.
The project sends a message using `canfd0` and receives it using `canfd1`, printing the result via serial port.

#### Sending Code Example:
Example send code:

```c
int can0_sample_send(int argc, char *argv[])
{
rt_err_t res;
rt_thread_t thread;
char can_name[RT_NAME_MAX];

if (argc == 2)
{
rt_strncpy(can_name, argv[1], RT_NAME_MAX);
Expand All @@ -57,20 +64,17 @@ int can0_sample_send(int argc, char *argv[])
{
rt_strncpy(can_name, CAN0_DEV_NAME, RT_NAME_MAX);
}

/* Find CAN device */
/* Find the CAN device */
can0_dev = rt_device_find(can_name);
if (!can0_dev)
{
rt_kprintf("find %s failed!\n", can_name);
return RT_ERROR;
}

/* Open CAN device in interrupt mode for TX and RX */
/* Open the CAN device for interrupt-based receive and send */
res = rt_device_open(can0_dev, RT_DEVICE_FLAG_INT_TX | RT_DEVICE_FLAG_INT_RX);
RT_ASSERT(res == RT_EOK);

/* Create data receiving thread */
/* Create data reception thread */
thread = rt_thread_create("can0_tx", can0_tx_thread, RT_NULL, 1024, 25, 10);
if (thread != RT_NULL)
{
Expand All @@ -80,21 +84,15 @@ int can0_sample_send(int argc, char *argv[])
{
rt_kprintf("create can_rx thread failed!\n");
}

return res;
}

/* Export to msh command list */
MSH_CMD_EXPORT(can0_sample_send, can device sample);
```
CANFD1 Receive Example:
int can1_sample_receive(int argc, char *argv[])
{
rt_err_t res;
rt_thread_t thread;
char can_name[RT_NAME_MAX];
int can1_sample_receive(int argc, char *argv[])
{
rt_err_t res;
rt_thread_t thread;
char can_name[RT_NAME_MAX];
if (argc == 2)
{
rt_strncpy(can_name, argv[1], RT_NAME_MAX);
Expand All @@ -103,23 +101,20 @@ CANFD1 Receive Example:
{
rt_strncpy(can_name, CAN1_DEV_NAME, RT_NAME_MAX);
}
/* Find CAN device */
/* Find the CAN device */
can1_dev = rt_device_find(can_name);
if (!can1_dev)
{
rt_kprintf("find %s failed!\n", can_name);
return RT_ERROR;
}
/* Initialize CAN reception semaphore */
rt_sem_init(&rx_sem, "rx_sem", 0, RT_IPC_FLAG_FIFO);
/* Open CAN device in interrupt mode for TX and RX */

/* Open the CAN device for interrupt-based receive and send */
res = rt_device_open(can1_dev, RT_DEVICE_FLAG_INT_TX | RT_DEVICE_FLAG_INT_RX);
RT_ASSERT(res == RT_EOK);
/* Create data receiving thread */
/* Create data reception thread */
thread = rt_thread_create("can1_rx", can1_rx_thread, RT_NULL, 1024, 25, 10);
if (thread != RT_NULL)
{
Expand All @@ -129,29 +124,25 @@ CANFD1 Receive Example:
{
rt_kprintf("create can_rx thread failed!\n");
}
return res;
}
## Running
### Compilation & Download
**RT-Thread Studio**: Download the EtherKit resource package in the RT-Thread Studio package manager, then create a new project and compile it.
}
```
**IAR**: First, double-click `mklinks.bat` to generate links for the rt-thread and libraries folders; then use Env to generate the IAR project; finally, double-click `project.eww` to open the IAR project and compile it.
## Operation
After compilation, connect the Jlink interface of the development board to the PC, and download the firmware to the development board.
### Compilation & Download
### Running Effects
* **RT-Thread Studio**: Download the EtherKit resource package from the RT-Thread Studio package manager, then create a new project and compile.
* **IAR**: First, double-click `mklinks.bat` to generate links to the `rt-thread` and `libraries` folders. Then use Env to generate the IAR project. Finally, double-click `project.eww` to open the IAR project and compile.
Use the serial port to send the `can0_sample_send` and `can1_sample_receive` commands.
After compiling, connect the Jlink interface of the development board to the PC and download the firmware to the development board.
![image-20241125160006861](./figures/image-20241125160006861.png)
### Running Effect
## Notes
Connect `CAN0_L` to `CAN1_L`, and `CAN0_H` to `CAN1_H`, as shown in the image below:
None
![image-20241209161925885](figures/image-20241209161925885.png)
## References
Device and Driver: [CAN Device](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/programming-manual/device/can/can)
Use the serial port to send the `can0_sample_send` and `can1_sample_receive` commands for loopback testing:
![image-20241209161944662](figures/image-20241209161944662.png)
Loading

0 comments on commit f0a2ff2

Please sign in to comment.