20
Renesas DALI Framework Quick Start Guide Version: 2017, October 17

Renesas DALI Framework Quick Start Guide · RENESAS DALI FRAMEWORK QUICK START GUIDE PAGE 8 4.4 Running the Application To transfer the projects to the DK-S128 Boards, connect your

  • Upload
    others

  • View
    11

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Renesas DALI Framework Quick Start Guide · RENESAS DALI FRAMEWORK QUICK START GUIDE PAGE 8 4.4 Running the Application To transfer the projects to the DK-S128 Boards, connect your

Renesas DALI Framework Quick Start Guide

Version: 2017, October 17

Page 2: Renesas DALI Framework Quick Start Guide · RENESAS DALI FRAMEWORK QUICK START GUIDE PAGE 8 4.4 Running the Application To transfer the projects to the DK-S128 Boards, connect your

RENESAS DALI FRAMEWORK QUICK START GUIDE PAGE 2

Table of contents

1 Introduction ................................................................................................................................... 3

2 Prerequisites ................................................................................................................................. 3

3 Requirements ............................................................................................................................... 3

4 Installation and importing for e2studio .......................................................................................... 4

4.1 Installation ..................................................................................................................................... 4

4.2 Importing/Creating the Project ...................................................................................................... 5

4.3 Building the Project Files .............................................................................................................. 6

4.4 Running the Application ................................................................................................................ 8

5 Executing the demo ...................................................................................................................... 9

5.1 Preparing DK-S128 Boards .......................................................................................................... 9 5.1.1 DALI Bus ................................................................................................................................................ 9

5.1.2 RS-232 connection ................................................................................................................................. 10

5.2 Starting the Console ................................................................................................................... 11

5.3 Switch on power supply .............................................................................................................. 12

6 Next steps ................................................................................................................................... 12

6.1 Implement further DALI commands ............................................................................................ 12 6.1.1 Expand the Control Device .................................................................................................................... 12

6.1.2 Expand the Control Gear ....................................................................................................................... 14

6.2 Generating your own project ...................................................................................................... 15 6.2.1 Configuration ......................................................................................................................................... 15

6.2.2 Source code ............................................................................................................................................ 19

Page 3: Renesas DALI Framework Quick Start Guide · RENESAS DALI FRAMEWORK QUICK START GUIDE PAGE 8 4.4 Running the Application To transfer the projects to the DK-S128 Boards, connect your

RENESAS DALI FRAMEWORK QUICK START GUIDE PAGE 3

1 Introduction

The CS-Lab DALI Demo for Renesas Synergy® shows how simple it is to create DALI applications with the aid of the DALI Framework for Renesas Synergy. DALI (Digital Addressable Lighting Interface) is a worldwide standard, specified pursuant to IEC 62386.

This demo includes two e²studio Renesas Synergy Projects.

• DaliDemoMasterDK generates an application for a DALI Control Device

• DaliDemoLED1DK generates an application for a DALI Control Gear

The DALI Control Device is controlled via the console menu and is connected via the DALI bus to control the RGB LEDs on the Control Gear.

2 Prerequisites

The prerequisite for working with this demo is some experience with IDSE e²studio and the Synergy Software Package. Please familiarise yourself with the documents at https://synergygallery.renesas.com/.

3 Requirements

Use of this demo requires the following hardware:

• 1 PC with Microsoft Windows

• 2 Renesas DK-S128 Boards

• 2 Power supplies for the Renesas DK-S128 Boards

• 1 DALI power supply

• Cable for the DALI bus

• 1 USB to RS-232 adapter

Use of this demo requires the following software:

• Renesas e²studio 5.4.0.023

• Renesas Synergy Software Package (SSP) 1.3.0

• DALI Framework CMSIS Pack File for e²studio (Renesas.SynergyDaliFW.1.3.0.pack)

• DALI Demo Synergy Project files for e²studio (DaliDemoMasterDK.zip and DaliDemoLED1DK.zip)

• A console program

The full version of the software is available for download at https://synergygallery.renesas.com

Note: The documentation refers to the version numbers specified above. Newer versions of the software may be available in the Synergy Gallery.

Page 4: Renesas DALI Framework Quick Start Guide · RENESAS DALI FRAMEWORK QUICK START GUIDE PAGE 8 4.4 Running the Application To transfer the projects to the DK-S128 Boards, connect your

RENESAS DALI FRAMEWORK QUICK START GUIDE PAGE 4

4 Installation and importing for e2studio

The required software is available at https://synerygallery.renesas.com.

Download the required version of e²studio and the Synergy Software Package (SSP) from the Synergy Gallery and install them on your PC. Also download the CMSIS Pack Files for the DK-S128 Board and the DALI Framework as well as the two DALI Demo Synergy Projects from the Synergy Gallery.

4.1 Installation

First install e²studio.

• Select the Renesas Synergy device family

• Select GCC ARM Embedded 4.9 2015q3

Then install the Synergy Software Package 1.3.0.

Page 5: Renesas DALI Framework Quick Start Guide · RENESAS DALI FRAMEWORK QUICK START GUIDE PAGE 8 4.4 Running the Application To transfer the projects to the DK-S128 Boards, connect your

RENESAS DALI FRAMEWORK QUICK START GUIDE PAGE 5

4.2 Importing/Creating the Project

The DALI Demo Projects require special Support Pack File for the DALI Framework. First import the CMSIS Pack File and then the two DALI Demo Projects.

• Import the CMSIS Pack Files: Select with the menu File > Import

• Import the CMSIS Pack for the DALI Framework downloaded from the Synergy Gallery.

• Import the Synergy Projects: Select with the menu File > Import

Page 6: Renesas DALI Framework Quick Start Guide · RENESAS DALI FRAMEWORK QUICK START GUIDE PAGE 8 4.4 Running the Application To transfer the projects to the DK-S128 Boards, connect your

RENESAS DALI FRAMEWORK QUICK START GUIDE PAGE 6

• Import one after another the DaliDemoMasterDK and DaliDemoLED1DK Projects downloaded from the Synergy Gallery.

4.3 Building the Project Files

Open one after another the configuration files for the DaliDemoMasterDK and DaliDemoLED1DK Projects and the project content for the projects.

Generation of the project content copies the files required by SSP into the project.

Page 7: Renesas DALI Framework Quick Start Guide · RENESAS DALI FRAMEWORK QUICK START GUIDE PAGE 8 4.4 Running the Application To transfer the projects to the DK-S128 Boards, connect your

RENESAS DALI FRAMEWORK QUICK START GUIDE PAGE 7

Then generate the projects one after another via the Project > Build Project menu.

Note: No errors or warnings should be displayed.

Page 8: Renesas DALI Framework Quick Start Guide · RENESAS DALI FRAMEWORK QUICK START GUIDE PAGE 8 4.4 Running the Application To transfer the projects to the DK-S128 Boards, connect your

RENESAS DALI FRAMEWORK QUICK START GUIDE PAGE 8

4.4 Running the Application

To transfer the projects to the DK-S128 Boards, connect your PC to the J12 port on the board using a USB to micro-USB cable.

Note: Before transferring a project to the DK-S128 Board please close the other project (menu Project > Close Project) to avoid sending the wrong binary!

Start transferring the application to the DK-S128 Board via the Run > Debug menu. For the hardware select the setting J-Link ARM and the target hardware R7FS12878.

The application is transferred to the DK-S128 Board and the debugger stops at the application starting point (in the function Reset_Handler()).

Page 9: Renesas DALI Framework Quick Start Guide · RENESAS DALI FRAMEWORK QUICK START GUIDE PAGE 8 4.4 Running the Application To transfer the projects to the DK-S128 Boards, connect your

RENESAS DALI FRAMEWORK QUICK START GUIDE PAGE 9

Allow the application to continue to run using the Run > Resume menu (the application runs until it reaches the main( function).

After calling the Run > Resume menu item again, the application continues to run.

5 Executing the demo

To start the DALI Demo, you must first transfer the master application and the LED1 application to the appropriate DK-S128 Boards.

The DK-S128 Boards and the DALI power supply must be connected with one another via the DALI bus and the switches on the boards must be set correctly to use the DALI bus.

The DK-S128 Board with the master application must be connected to the PC via RS-232 and the switches on the board must be set correctly to use the RS-232 interface.

Note: Ensure that the correct application is transferred to the DK-S128 Boards and connect the DK-S128 Boards to the power supply only at the end.

5.1 Preparing DK-S128 Boards

5.1.1 DALI Bus

The two DK-S128 Boards and the DALI power supply must be connected with one another via the DALI bus.

For DALI communication the SW6 switch must be set (1 to 3 OFF, 4 to 8 ON) on both DK-S128 Boards.

Page 10: Renesas DALI Framework Quick Start Guide · RENESAS DALI FRAMEWORK QUICK START GUIDE PAGE 8 4.4 Running the Application To transfer the projects to the DK-S128 Boards, connect your

RENESAS DALI FRAMEWORK QUICK START GUIDE PAGE 10

5.1.2 RS-232 connection

The DK-S128 Board for the master application also uses a serial RS-232 link to the PC. Connect your USB to RS-232 adapter to port J18 on the DK-S128 Board (GND to Pin 4, RX to Pin 5 and TX to Pin 7).

Page 11: Renesas DALI Framework Quick Start Guide · RENESAS DALI FRAMEWORK QUICK START GUIDE PAGE 8 4.4 Running the Application To transfer the projects to the DK-S128 Boards, connect your

RENESAS DALI FRAMEWORK QUICK START GUIDE PAGE 11

In addition, the SW8 switch on the DK-S128 Board must be set for the RS-232 connection (1 to 3 ON, 4 OFF).

5.2 Starting the Console

Use the device manager to check which of the COM interface on the DK-S128 Board is connected to the master application.

Start your console program for this COM interface with a baud rate of 115200.

Page 12: Renesas DALI Framework Quick Start Guide · RENESAS DALI FRAMEWORK QUICK START GUIDE PAGE 8 4.4 Running the Application To transfer the projects to the DK-S128 Boards, connect your

RENESAS DALI FRAMEWORK QUICK START GUIDE PAGE 12

5.3 Switch on power supply

Connect the DK-S128 Boards to the power supply. The console window displays the prompt ‘DALI Demo>’. Enter ‘?’ and confirm with Enter to display the application help menu.

The RGB LED on the DK-S128 Board with the LED1 application illuminates with varying intensity depending on the command entered.

6 Next steps

6.1 Implement further DALI commands

Information can be checked on the connected Control Gear, e.g., whether an error is present, using the query command.

The CS-Lab DALI Stack on the Control Device sends this query command and asks the connected Control Gear for the error status.

The CS-Lab DALI Stack on the Control Gear receives this query command and asks the application for the error status before sending the result back via the DALI Bus.

6.1.1 Expand the Control Device

It is necessary to extend the master application to query the error status.

First expand the console menu command structure.

Page 13: Renesas DALI Framework Quick Start Guide · RENESAS DALI FRAMEWORK QUICK START GUIDE PAGE 8 4.4 Running the Application To transfer the projects to the DK-S128 Boards, connect your

RENESAS DALI FRAMEWORK QUICK START GUIDE PAGE 13

Create the callback function for the new console menu point and the function for sending the query.

The reply to this query is received in the callback dali_demo_lib_cb_reaction() . Create this callback to include the proper command and generate the function for output of the result.

Page 14: Renesas DALI Framework Quick Start Guide · RENESAS DALI FRAMEWORK QUICK START GUIDE PAGE 8 4.4 Running the Application To transfer the projects to the DK-S128 Boards, connect your

RENESAS DALI FRAMEWORK QUICK START GUIDE PAGE 14

Expand the console thread processing loop. The prompt is not always displayed nor the input processed as before; instead, two further states are present.

The status PROMPT_TYPE_WAIT is set when the query is sent. The status PROMPT_TYPE_RESULT is set upon receipt of the reply to the query.

In the PROMPT_TYPE_WAIT status, a point is output in the console window every 100 ticks as a life sign.

In the PROMPT_TYPE_RESULT state, the error status is output in the console window and the status is set back to PROMPT_TYPE_PROMPT so that new commands can be entered.

6.1.2 Expand the Control Gear

It is necessary to expand the LED1 application to query the error status.

Expand the callback dali_demo_lib_cb_reaction() by adding the command

DALILIB_REACT_INTERNAL_CTRL_GEAR_QUERY_LAMPFAILURE.

This command informs the application that a query regarding the lamp failure status has arrived via the DALI Bus.

Use the function dalilib_action() to forward the error status to the DALI stack.

Page 15: Renesas DALI Framework Quick Start Guide · RENESAS DALI FRAMEWORK QUICK START GUIDE PAGE 8 4.4 Running the Application To transfer the projects to the DK-S128 Boards, connect your

RENESAS DALI FRAMEWORK QUICK START GUIDE PAGE 15

It is necessary for the application to manage the error status. This is stored in the variable g_lamp_failure and is updated via the connected hardware. Use Pin 6 at Port 2 for this purpose.

Using a jumper, connect the pins GND and P2_6 (Port 2 – Pin 6) of multi-pin connector J16 to generate the error status. When the jumper is removed, the error status is no longer present.

6.2 Generating your own project

6.2.1 Configuration

Select the File > New > Synergy C Project menu, assign a name for the DALI project and select the S128 DK board.

Page 16: Renesas DALI Framework Quick Start Guide · RENESAS DALI FRAMEWORK QUICK START GUIDE PAGE 8 4.4 Running the Application To transfer the projects to the DK-S128 Boards, connect your

RENESAS DALI FRAMEWORK QUICK START GUIDE PAGE 16

On the next page, select the project template Blinky with ThreadX.

The basic framework for the project is then generated automatically by e²studio. To use the DALI framework, you now have to adapt the configuration and generate a few functions, i.e., fill them with vital content.

Open the configuration.xml file and activate the Threads tab. Rename the Blinky Thread to match your project.

Page 17: Renesas DALI Framework Quick Start Guide · RENESAS DALI FRAMEWORK QUICK START GUIDE PAGE 8 4.4 Running the Application To transfer the projects to the DK-S128 Boards, connect your

RENESAS DALI FRAMEWORK QUICK START GUIDE PAGE 17

Add to this thread the DALILIB2 Framework.

Set the framework properties (name, device type, device address and callbacks for the DALI stack).

Page 18: Renesas DALI Framework Quick Start Guide · RENESAS DALI FRAMEWORK QUICK START GUIDE PAGE 8 4.4 Running the Application To transfer the projects to the DK-S128 Boards, connect your

RENESAS DALI FRAMEWORK QUICK START GUIDE PAGE 18

Set the timer properties for the DALI framework.

Remove the component Blinky ThreadX. Your application uses the renamed thread.

Now save this configuration and generate the project content. This concludes the configuration phase. The source code for starting the DALI Framework and the callbacks for the DALI stack are still missing.

Page 19: Renesas DALI Framework Quick Start Guide · RENESAS DALI FRAMEWORK QUICK START GUIDE PAGE 8 4.4 Running the Application To transfer the projects to the DK-S128 Boards, connect your

RENESAS DALI FRAMEWORK QUICK START GUIDE PAGE 19

6.2.2 Source code

The starting point for your DALI application is the dali_thread_entry() function.

Complete the connection to the previously configured DALI Framework here. Use the open() function to initialise the DALI Framework and start the DALI Framework with the start() function.

Communication with the DALI Bus is handled by the DALI Framework. DALI Framework queries to its applications are realised via callbacks.

After starting the DALI Framework, it announces that it is ready to receive commands from your application using the dali_ready_cb() callback. You can perform any initialisations required for your application here.

Some of the commands and queries sent to your DALI device are processed directly by the DALI Framework. Some commands and queries are forwarded to your application (e.g. set LED level, query error status, ...) by the DALI Framework using the callback dali_reaction_cb(). The possible commands and queries are described in the CS-Lab DALI Stack documentation.

Page 20: Renesas DALI Framework Quick Start Guide · RENESAS DALI FRAMEWORK QUICK START GUIDE PAGE 8 4.4 Running the Application To transfer the projects to the DK-S128 Boards, connect your

RENESAS DALI FRAMEWORK QUICK START GUIDE PAGE 20

The DALI standard specifies that DALI-specific data must be stored persistently. Your application is responsible for reading and writing this data. Your application is notified of this by the DALI Framework using the functions dali_load_cb() and dali_save_cb().