---
title: "Create an Arduino event driven app on W55RP20-EVB-PICO"
url: "https://maker.wiznet.io/teamprof/contest/create-an-arduino-event-driven-app-on-w55rp20-evb-pico/"
markdown_url: "https://maker.wiznet.io/teamprof/contest/create-an-arduino-event-driven-app-on-w55rp20-evb-pico/md"
type: "Contests"
author: "teamprof"
author_url: "https://maker.wiznet.io/teamprof/"
original_author: "Team Prof"
license: "GNU General Public License, version 3 or later (GPL3+)"
published: "2024-10-06"
language: "en"
tags: ["Arduino"]
hardware: ["WIZnet W55RP20-EVB-Pico"]
likes: 1
views: 2193
comments: 0
source: "WIZnet Makers (https://maker.wiznet.io/)"
---

# Create an Arduino event driven app on W55RP20-EVB-PICO

> Leverage ArduProf library to create a event driven application, running on W55RP20-EVB-PICO.

Original author: Team Prof

## Components

- **WIZnet W55RP20-EVB-Pico** x 1: W55RP20-EVB-PICO ([docs](https://wiznet.io/products/powered-by-raspberry-pi/w55rp20-evb-pico))
- Software: **Arduino IDE**: Arduino IDE ([docs](https://www.arduino.cc/en/software))

## Documents and links

- [Library and example code](https://github.com/teamprof/arduprof) (code)

## Article

**Introduction**

Wiznet W55RP20 chip, a System-in-Package (SiP) solution integrates WIZnet's W5500 Ethernet controller with the RP2040 microcontroller from Raspberry Pi, providing networking and processing capabilities for IoT devices and smart applications.

W55RP20-EVB-Pico is an evaluation board for W55RP20, a chip that combines W5500, a wired TCP/IP controller, and RP2040.

![](https://maker.wiznet.io/upload/ckeditor5/246511995%5F1728237712%2Epng)

This article demonstrates how to create an event driven application for W55RP20, running Arduino Mbed OS.

![](https://maker.wiznet.io/upload/ckeditor5/246511995%5F1728237112%2Epng)

**Step 1: Install Arduino Mbed OS RP2040 Board**

![](https://maker.wiznet.io/upload/ckeditor5/246511995%5F1728235973%2Epng)

**Step 2: Install ArduProf library**

![](https://maker.wiznet.io/upload/ckeditor5/246511995%5F1728236041%2Epng)

**Step 3: Create an event driven application by clicking "File" -> "Examples" -> "ArduProf" -> "basic"**

![](https://maker.wiznet.io/upload/ckeditor5/246511995%5F1728236223%2Epng)

**Step 4: Connect W55RP20-EVB-Pico and PC with a USB cableStep 5: Select "Raspberry Pi Pico - Arduino Mbed OS RP2040"**

![](https://maker.wiznet.io/upload/ckeditor5/246511995%5F1728236311%2Epng)

**Step 6: Run the basic application by clicking "Sketch" -> "Upload"**

If everything goes smooth, you should see the followings:

![](https://maker.wiznet.io/upload/ckeditor5/246511995%5F1728236494%2Epng)

**Code explanation**

Message format: Format of event message between threads is defined in the file "src/type/Message.h".
It includes fields such as "event" (signed word), "iParam" (signed word), "uParam" (unsigned word) and "lParam" (unsigned double word)

```plaintext
    typedef struct _Message
    {
        int16_t event;
        int16_t iParam;
        uint16_t uParam;
        uint32_t lParam;
    } Message;
```

post event from Arduino loop to ThreadApp
The first step to use ArduProf framework is including the "ArduProf.h" header file. Then defines "queueMain" and "threadApp" and starts them. Posting an event "EventNull" from "queueMain" to "threadApp" is simply as "queueMain.postEvent(context.threadApp, EventNull)"
Sample code is listed in file "basic.ino"

```plaintext
#define ARDUPROF_MBED
#include <ArduProf.h>

// define variable "queueMain" for Arduino thred to interact with ArduProf framework.
static QueueMain queueMain;

// define variable "threadApp" for application thread. (Define other thread as you need)
static ThreadApp threadApp;

// define variable "context" and initialize pointers to "queueMain" and "threadApp"
static AppContext context = {
    .queueMain = &queueMain,
    .threadApp = &threadApp,
};

void setup()
{
    ...
    
    // initialize queueMain
    queueMain.start(&context);

    // start threadApp
    threadApp.start(&context);
}

void loop()
{
    ...

    // delay 1s
    delay(1000);

    // post an event "EventNull" to threadApp
    queueMain.postEvent(context.threadApp, EventNull);
}
```

handling event "EventNull" in ThreadApp
There are 3 steps to handle an event. They are:
1. declare event handler
2. define event handler
3. setup event handler (map event to handler)

Sample code of declare event handler in "ThreadApp.h"

```plaintext
class ThreadApp : public ThreadBase
{
    ...

    ///////////////////////////////////////////////////////////////////////
    // declare event handler
    ///////////////////////////////////////////////////////////////////////
    __EVENT_FUNC_DECLARATION(EventNull) // void handlerEventNull(const Message &msg);

}
```

define event handler in "ThreadApp.cpp"

```plaintext
// define EventNull handler
__EVENT_FUNC_DEFINITION(QueueMain, EventNull, msg) // void QueueMain::handlerEventNull(const Message &msg)
{
    LOG_TRACE("EventNull(", msg.event, "), iParam=", msg.iParam, ", uParam=", msg.uParam, ", lParam=", msg.lParam);
}
```

setup event handler (map event to handler) in "ThreadApp.cpp"

```plaintext
ThreadApp::ThreadApp() : ...
{
    ...

    // setup event handlers
    handlerMap = {
        __EVENT_MAP(ThreadApp, EventNull), // {EventNull, &ThreadApp::handlerEventNull},
    };
}
```

Thanks for your time, hope you enjoy and create a wonderful application on W55RP20.

---

Source: https://maker.wiznet.io/teamprof/contest/create-an-arduino-event-driven-app-on-w55rp20-evb-pico/
