45
APPLICATION NOTE R20AN0385EG0100 Rev.1.00 Page 1 of 42 March 21, 2016 RX64M Group Cam it! - RX64M Camera Solution Kit Introduction The Cam it! - RX64M Camera Solution Kit demonstrates the Renesas RX64M interfaced with a color CMOS Camera module. Preprogrammed firmware provides human detection, image correction and movement detection. The user interface is a webpage displaying JPEG encoded images, served over a wired Ethernet connection. The Cam it! - RX64M Camera Solution Kit is supplied with pre-programmed firmware. This Application Note covers setting up the e 2 studio development environment and using an E1 debugger. Please complete steps in R20UT3523EG Cam it! - RX64M Camera Solution Kit Quick Start Guide to have a connection and be familiar with the kit’s operation. This document describes the source code used to generate the demonstration application. The software including pre-built libraries can be downloaded from: http//www.renesas.eu/rxcam-it Target Device RX64M Development environment IDE: e2 studio v4.2.0.012 Compiler: Renesas RXC Toolchain v2.03.00 Hardware: YCAM-IT-RX64M R20AN0385EG0100 Rev.1.00 March 21, 2016

RX64M Group Application Note Cam it! - RX64M Camera Solution Kit · PDF file · 2016-05-16Please complete steps in R20UT3523EG Cam it! - RX64M Camera Solution Kit Quick Start Guide

  • Upload
    lykhanh

  • View
    214

  • Download
    1

Embed Size (px)

Citation preview

Page 1: RX64M Group Application Note Cam it! - RX64M Camera Solution Kit · PDF file · 2016-05-16Please complete steps in R20UT3523EG Cam it! - RX64M Camera Solution Kit Quick Start Guide

APPLICATION NOTE

R20AN0385EG0100 Rev.1.00 Page 1 of 42 March 21, 2016

RX64M Group Cam it! - RX64M Camera Solution Kit

Introduction The Cam it! - RX64M Camera Solution Kit demonstrates the Renesas RX64M interfaced with a color CMOS Camera module. Preprogrammed firmware provides human detection, image correction and movement detection. The user interface is a webpage displaying JPEG encoded images, served over a wired Ethernet connection.

The Cam it! - RX64M Camera Solution Kit is supplied with pre-programmed firmware. This Application Note covers setting up the e2 studio development environment and using an E1 debugger.

Please complete steps in R20UT3523EG Cam it! - RX64M Camera Solution Kit Quick Start Guide to have a connection and be familiar with the kit’s operation.

This document describes the source code used to generate the demonstration application.

The software including pre-built libraries can be downloaded from: http//www.renesas.eu/rxcam-it

Target Device RX64M

Development environment IDE: e2 studio v4.2.0.012 Compiler: Renesas RXC Toolchain v2.03.00 Hardware: YCAM-IT-RX64M

R20AN0385EG0100 Rev.1.00

March 21, 2016

Page 2: RX64M Group Application Note Cam it! - RX64M Camera Solution Kit · PDF file · 2016-05-16Please complete steps in R20UT3523EG Cam it! - RX64M Camera Solution Kit Quick Start Guide

RX64M Group

R20AN0385EG0100 Rev.1.00 Page 2 of 42 March 21, 2016

Contents

1. Setting up the Development Enviornment .................................................................... 3 1.1 Obtain an E1 Debugger .............................................................................................................. 3 1.2 e2 studio and Compiler Package ............................................................................................... 3 1.3 Downloading the Cam-it! Project .............................................................................................. 3

2. Connecting the E1 Debugger ........................................................................................ 4

3. Importing, Programming and Debug ............................................................................ 4 3.1 Importing project in to e2 studio ................................................................................................ 4 3.2 Building and debugging the project ......................................................................................... 5

4. Project Modular Framework .......................................................................................... 7 4.1 Middleware and pre-built libraries ............................................................................................. 7 4.2 Renesas Firmware Integration Technology (FIT)..................................................................... 8

5. Demonstration Project ................................................................................................... 9 5.1 User files ...................................................................................................................................... 9 5.2 Main Module process flow ....................................................................................................... 11

6. Web Server ................................................................................................................... 12 6.1 Performance Overview ............................................................................................................. 12 6.2 Operation Summary .................................................................................................................. 12 6.3 CGI Functionality ...................................................................................................................... 12 6.4 Configuration ............................................................................................................................. 12 6.5 Web server file list .................................................................................................................... 13 6.6 Web Server API Reference ....................................................................................................... 14 6.7 File System Functions .............................................................................................................. 15 6.8 User-defined function reference (system timer -related) ...................................................... 23 6.9 Sample CGI function ................................................................................................................. 25

7. Web camera specification............................................................................................ 26 7.1 Outline of performance ............................................................................................................. 26 7.2 Outline of operation .................................................................................................................. 26 7.3 Configuration ............................................................................................................................. 27 7.4 File list ........................................................................................................................................ 27 7.5 Camera API Reference .............................................................................................................. 28

8. Image processing specification .................................................................................. 34 8.1 Performance Overview ............................................................................................................. 34 8.2 Configuration ............................................................................................................................. 35 8.3 File List ....................................................................................................................................... 35 8.4 API Reference ............................................................................................................................ 35

Page 3: RX64M Group Application Note Cam it! - RX64M Camera Solution Kit · PDF file · 2016-05-16Please complete steps in R20UT3523EG Cam it! - RX64M Camera Solution Kit Quick Start Guide

RX64M Group

R20AN0385EG0100 Rev.1.00 Page 3 of 42 March 21, 2016

1. Setting up the Development Environment 1.1 Obtain an E1 Debugger To allow the debugging and downloading of firmware an E1 Debugger must be used.

This can be obtained from your local Renesas Sales Office (contact details on the last page).

The part number for the E1 debugger required is R0E000010KCE00.

1.2 e2 studio and Compiler Package e2 studio is Renesas’ Eclipsed based Integrated Development Environment.

Various compiler and tool chains are available for e2 studio, these are provided as a separate installer.

1.2.1 Downloading and Installing e2 studio 1. Download e2 studio:

e2 studio can be obtained from the ‘Downloads’ tab on the following web page:

http://www.renesas.eu/e2studio

Offline (full installer package) and Web installer versions are available. The Cam it! Kit has been developed using e2 studio version 4.

2. Launch the downloaded installer and follow the on-screen instructions.

3. Windows™ 7 / 8 / 8.1 users may see the “User Account Control” dialog box. If applicable, enter the administrator password and click ‘Yes’.

Note: The Windows driver signing or Windows Security dialogs boxes may be displayed. Please accept the driver to continue.

1.2.2 Downloading and Installing RX Family Compiler Package 1. Download and install the ‘[Evaluation Software] RX Family C/C++ Compiler Package V2 (without IDE)’

This can be found on the same download page as e2 studio, shown in section 1.2.2.

The Cam-it! Kit has been developed using Compiler Package version 2.03.00.

This compiler package installs a fully featured, evaluation version of the RX Family Compiler Package.

After a period of 60-Days from the first build, the size of linkable object is reduced to 128 KB. After this 60-Day trial a full version of the RX Family C/C++ Compiler Package must be purchased from your local Renesas sales office (contact details on the last page).

1.3 Downloading the Cam-it! Project Along with this document was packaged a zip file (rx64m_gr_kaede_Hi_Solution.zip) and this file contains code and pre-built libraries required to reproduce this sample.

If required this package can be downloaded from the following website: http//www.renesas.eu/rxcam-it

Page 4: RX64M Group Application Note Cam it! - RX64M Camera Solution Kit · PDF file · 2016-05-16Please complete steps in R20UT3523EG Cam it! - RX64M Camera Solution Kit Quick Start Guide

RX64M Group

R20AN0385EG0100 Rev.1.00 Page 4 of 42 March 21, 2016

2. Connecting the E1 Debugger 1. Ensure the Cam-It! Kit is powered OFF.

2. Connect the E1 debugger module to CN6 on the Cam-It! Kit. Note the orientation of Pin 1 of CN6 and the E1 Debugger:

3. Connecting the E1 to a spare USB port on the development PC

4. The green ‘ACT’ LED on the E1 debugger will flash.

5. The E1 debugger drivers will now be installed. Note that, this may take up to a minute and administrator privileges will be required.

Windows™ 7 Windows™ 8 / 8.1 “Device driver software installed successfully” pop-up will appear in the Windows™ toolbar and installation will complete.

An icon will appear in the Windows™ toolbar and installation will complete.

6. The green ‘ACT’ LED on the E1 debugger will illuminate constantly.

3. Importing, Programming and Debug This section provides a guide to importing, programming and debugging the project for the Cam-it! Kit

3.1 Importing project in to e2 studio 1. Start e2 studio (skip this step if already open):

WindowsTM 7: Start Menu > All Programs > Renesas Electronics e2studio > e2 studio

WindowsTM 8 / 8.1: From Apps View, click ‘e2 studio’ icon.

2. In the ‘Select a workspace’ folder that appears, browse a suitable location and enter a folder name to save your new workspace to. Click OK to continue. In this example the work space is called ‘Cam_it’.

3. In the e2 studio welcome screen, click the ‘Go to the workbench’ arrow icon, on the far right

4. Right-click in the project explorer window, and select ‘Import’.

Pin 1

Pin 1

Figure 2-1 Hardware Connection

Page 5: RX64M Group Application Note Cam it! - RX64M Camera Solution Kit · PDF file · 2016-05-16Please complete steps in R20UT3523EG Cam it! - RX64M Camera Solution Kit Quick Start Guide

RX64M Group

R20AN0385EG0100 Rev.1.00 Page 5 of 42 March 21, 2016

5. Under ‘Select an Import Source’ select General > Existing Projects into Workspace, and click ‘Next’.

6. Select the archive file option.

7. Click the ‘Browse’ button, and locate the folder the Cam-it! Project (‘rx64m_gr_kaede_Hi_Solution’) was extracted to in section 1.3 and click ‘OK’.

8. In the Projects view confirm that the project ‘rx64m_gr_kaede_hi_Solution’ is selected and click ‘Finish’.

3.2 Building and debugging the project 1. Select the “rx64m_gr_kaede_Hi_Solution” project by left clicking on it, then click the arrow next to build

button (hammer icon), and select ‘Debug’ from the drop down menu.

2. e2 studio will now build the project. Once this is finished, debugging can be started by clicking the arrow next to debug button (bug icon), and selecting ‘Debug Configurations…’.

3. Click the entry ‘Renesas GDB Hardware Debugging’

4. Select the ‘rx64m_gr_kaede_Hi_Solution HardwareDebug’ configuration.

5. Click the ‘Debugger’ tab, then the ‘Connection Settings’ secondary tab. Review the settings, pay attention to the highlighted items and ensure all entries match the screenshot below.

Figure 3-1 Debug connection configuration dialog

Page 6: RX64M Group Application Note Cam it! - RX64M Camera Solution Kit · PDF file · 2016-05-16Please complete steps in R20UT3523EG Cam it! - RX64M Camera Solution Kit Quick Start Guide

RX64M Group

R20AN0385EG0100 Rev.1.00 Page 6 of 42 March 21, 2016

6. Click the ‘Debug’ button to download the code to the target, and begin debugging.

7. A firewall warning may be displayed for ‘e2-server-gdb.exe’. Select the check-box for ‘Private networks, such as my home or work network’, and click ‘Allow access’.

8. Enter User Account Control (UAC) administrator password and click ‘Yes’ (if required).

9. e2 studio may ask you to ‘Confirm Perspective Switch’, click ‘Yes’.

10. Once the code has been downloaded, click the ‘Resume’ button to run the code up to the first line of the main function, main().

Click ‘Resume’ again to start execution of the main code.

11. Click the ‘Suspend’ button. The program will stop and the source code will be opened at the current program counter. Note: the application uses many library functions, ‘No source available’ warnings may be displayed if the program is suspended while executing library functions.

12. To disconnect from the target board, click the ‘Disconnect’ button on the toolbar:

13. Select the C/C++ perspective (at the top right) to return to the editor view.

Page 7: RX64M Group Application Note Cam it! - RX64M Camera Solution Kit · PDF file · 2016-05-16Please complete steps in R20UT3523EG Cam it! - RX64M Camera Solution Kit Quick Start Guide

RX64M Group

R20AN0385EG0100 Rev.1.00 Page 7 of 42 March 21, 2016

4. Project Modular Framework The following section provide an overview of the software framework.

Figure 4-1 Simplified Project Module Table

4.1 Middleware and pre-built libraries The following middleware is required for this application.

Type Function Folder Name Version Comment

Middleware Image processer image_proc 1.00 Image Processing Routines: Human Detection, Movement Detection, Image correction etc. Function APIs are supplied as header source files. The implementation is provided as a pre-compiled Motorola binary file.

Middleware JPEG encoder jpeg_encoder_rx 1.00 JPEG Encoding Libraries, used to generate the images streamed to the web browser interface.

Table 1 – Middleware modules

Middleware is provided pre-built for the target processor and source code is not provided.

Page 8: RX64M Group Application Note Cam it! - RX64M Camera Solution Kit · PDF file · 2016-05-16Please complete steps in R20UT3523EG Cam it! - RX64M Camera Solution Kit Quick Start Guide

RX64M Group

R20AN0385EG0100 Rev.1.00 Page 8 of 42 March 21, 2016

4.2 Renesas Firmware Integration Technology (FIT) The Cam-IT! Project makes significant use of Renesas Firmware Integration Technology.

Firmware Integration Technology is a completely new concept that emphasizes the simplification of embedding of peripheral function module drivers and improvement of portability between RX microcontrollers with the aim of lightening the burden of program development and software resource management in software development using the RX Family.

FIT consists of a Board Support Package (BSP), peripheral function modules, middleware modules, and interface modules.

BSP: Module that performs initial MCU settings, clock settings, board settings, and so on

Peripheral function modules: Drivers that control the peripheral functions of a RX microcontroller

Middleware modules: Middleware function such as TCP/IP and file system

Interface modules: Common interfaces such as POSIX API

FIT integrates closely with e2 studio. Using this feature, FIT modules can be embedded with ease into projects generated in e2 studio. FIT modules also support CS+.

Further information about FIT can be found on the Renesas website: http://www.renesas.eu/products/mpumcu/rx/child/fit

The following table shows all the FIT Modules used in this application:

Module Type Module Name Description FIT module name Version Board Support Package

BSP Module Board Support Package (BSP module)

r_bsp 2.60

Device Driver CMT Driver Compare and Match Timer (CMT) r_cmt_rx 2.30

Device Driver DMACA Driver DMA controller (DMAC) r_dmaca_rx 1.01

Device Driver DTC Driver Data Trasfer Cointroller (DTC) r_dtc_rx 2.00

Device Driver Ethernet Driver Device Driver Ethernet Driver Ethernet controller

r_ether_rx 1.00

Device Driver SCI IIC Driver SCI IIC Driver SCI simple IIC driver r_sci_iic_rx 1.30

Device Driver PDC Driver Driver parallel data capture (PDC) r_pdc_rx 1.00

Device Driver RTC Driver Real time clock driver r_rtc_rx 2.10 Middleware Ether Driver Interface M3S-T4-Tiny interface conversion

module r_t4_driver_rx64m 1.00

Middleware M3S-T4-Tiny TCP/IP protocol stack library (M3S-T4-Tiny)

r_t4_rx 2.00

Application HTTP Server HTTP server r_t4_http_server_rx 1.03

Table 2 FIT modules

Each FIT Module folder in the project contains a ‘doc’ sub-folder which contains User’s Manuals, Application Notes and further information pertinent to that module.

Page 9: RX64M Group Application Note Cam it! - RX64M Camera Solution Kit · PDF file · 2016-05-16Please complete steps in R20UT3523EG Cam it! - RX64M Camera Solution Kit Quick Start Guide

RX64M Group

R20AN0385EG0100 Rev.1.00 Page 9 of 42 March 21, 2016

5. Demonstration Project This section provides an overview of the construction of the software

5.1 User files The following table gives an overview of the user code modules that have been used to create the application:

Folder File Name Simplfied description of function

src main.c Main source file

main.h Header file for main.c

img_proc.c Image processing library control API.

The image processing library initialization, human detection and movement detection are called through the API in this file.

img_proc.h Header file for img_proc.c

led.c LED Initialization and driving functions.

led.h Header file for led.c

r_dmac_apl.c DMA driver control.

Including interface API, DMA complete interrupt processing routine.

r_dmac_apl.h Header file for r_dmac_apl.c

r_dtc_apl.c DTC driver control.

Including interface API, DTC configuration.

r_dtc_apl.h Header file for r_dtc.apl.c

r_file_driver.c File system interface source file for the Web server.

r_file_driver.h Header file for r_file_driver.c

r_http_server_cgi_sample.c CGI Sample source file, invoked when a change is made from the webpage.

The web site contents is stored in the ‘contents’ folder.

r_http_server_cgi_sample.h Header file for r_http_server_cgi_sample.h

r_jpeg_enc_apl.c API for JPEG encoder library jpeg_encoder_rx, including encoding call back function.

r_jpeg_enc_apl.h Header file for r_jpeg_enc_apl.h

r_mem_sdram.c Configuration source files for external SDRAM

r_mem_sdram.h Header file for r_mem_sdram.c

r_ov7740_sensor.c Routines for interfacing with the CMOS camera module.

The camera is controlled via I2C ADDRESS 0x42.

r_ov7740_sensor.h Header file for r_ov7740_sensor.c

r_ov7740_config.h Configuration file for the OV7740 CMOS camera.

r_pdc_apl.c Abstraction API for the FIT module "r_pdc_rx".

Contains callback routine to handle the frame finished interrupt, generated after each frame captured by the CMOS camera module.

r_pdc_apl.h Header file for r_pdc_apl.h

r_reg_user.c Common user functions grouped together for ease to maintain.

r_reg_user.h Header file for r_reg_user.c

Page 10: RX64M Group Application Note Cam it! - RX64M Camera Solution Kit · PDF file · 2016-05-16Please complete steps in R20UT3523EG Cam it! - RX64M Camera Solution Kit Quick Start Guide

RX64M Group

R20AN0385EG0100 Rev.1.00 Page 10 of 42 March 21, 2016

r_sci_iic_apl.c The source files for the simple IIC driver control. Abstracts the FIT module ‘r_sci_iic_rx’

r_sci_iic_apl.h Header file for r_sci_iic_apl.c

r_sys_time.c The source files for the real time interface. Abstracts the FIT module ‘r_rtc_rx’

r_sys_time.h Header file for r_sys_time.c

Table 3 User code modules

Page 11: RX64M Group Application Note Cam it! - RX64M Camera Solution Kit · PDF file · 2016-05-16Please complete steps in R20UT3523EG Cam it! - RX64M Camera Solution Kit Quick Start Guide

RX64M Group

R20AN0385EG0100 Rev.1.00 Page 11 of 42 March 21, 2016

5.2 Main Module process flow

Table 4 User code process flow

Initialise_sdram()

R_PDC_ReceiveAgain()

R_PDC_ReceiveAgain()

R_IIC_AplInit()

R_DMAC_Init()

R_PDC_AplInit()

R_JPEG_CompressInit()

R_ETHER_Initial()

lan_open()

tcpudp_get_ramsize()

tcpudp_open()

R_OV7740_SensorInit()

R_DMACA_Open()

R_DMAC_Ch0Init()

R_PDC_APLCreate()

img_mdl_proc_init()

R_ETHER_LinkProcess()

main

Page 12: RX64M Group Application Note Cam it! - RX64M Camera Solution Kit · PDF file · 2016-05-16Please complete steps in R20UT3523EG Cam it! - RX64M Camera Solution Kit Quick Start Guide

RX64M Group

R20AN0385EG0100 Rev.1.00 Page 12 of 42 March 21, 2016

6. Web Server 6.1 Performance Overview The Web server is a simple implementation adhering to HTTP/1.0 standard.

This Web server aims to show basic functionality and uses the Web server code M3S-T4-Tiny (referred to as T4). T4 has a small memory footprint, using only internal memory to implement the server functionality.

Memory Capacity

ROM footprint Approx. 6.6Kbyte

RAM footprint Approx. 36 Kbyte

10 Kbyte overhead

5Kbyte per connection

No. concurrent connections 5

CGI Functionality Remote calling of functions from web browser.

Fixed IP address 192.168.1.3

Table 5 Web Server footprint

The Web server is not suitable for use on a direct connection to the internet, it does not feature authentication or protection against denial of service attacks (such as SYN-Flood). The sample application assumes it is connected to a LAN, such as an office network, where malicious users/attackers are not present.

Files served by the Web server is limited to short file names.

6.2 Operation Summary The Web server is implemented using non-blocking calls for easy integration in to embedded applications. The function R_httpd() invokes processing needed for the Web server and needs to be called regularly.

_process_tcpip() is called regularly to process TCP/IP protocol data and is called regularly as part of timer interrupt function and also called when an interrupt is serviced by the lower level Ethernet driver.

The table below outlines the API for the T4 TCP/IP protocol stack.

Function Name Description

tcp_acp_cep Waits for connection request (passive open) tcp_con_cep Requests connection (active open) tcp_sht_cep Completes transmission tcp_cls_cep Closes communication endpoint node tcp_snd_cep Transmits data tcp_rcv_dat Receives data tcpudp_get_ramsize Gets work memory usage size _process_tcpip Processes cyclic startup TCP/IP protocol tcpudp_open Opens T4 library tcpudp_close Closes T4 library

Table 6 TCP/IP API protocol

6.3 CGI Functionality The Web server has a simple GCI (Common Gateway Interface) function. This allows a ‘C’ function to be called when a pre-defined URL is requested by the user.

6.4 Configuration The behaviour of the Web server can be customised by changing the macro defined in r_t4_http_server_rx_config.h.

Page 13: RX64M Group Application Note Cam it! - RX64M Camera Solution Kit · PDF file · 2016-05-16Please complete steps in R20UT3523EG Cam it! - RX64M Camera Solution Kit Quick Start Guide

RX64M Group

R20AN0385EG0100 Rev.1.00 Page 13 of 42 March 21, 2016

• Server header field: HTTPD_VERSION_CODE Specify the data to be stored in the Server header field to be sent to the Web browser

• root directory: ROOT_DIR Specify which directory on the external memory is the root directory. Example: #define ROOT_DIR "" #define ROOT_DIR "user" #define ROOT_DIR "user / root_dir"

• Show / Hide index page: INDEXES Specifies the behavior when a user browses to a directory. ‘1’, Web server responds with the contents of a directory. ‘0’, Web server responds with the files specified in DEFAULT_FILE_NAME.

• File and response in the case of the index page hide: DEFAULT_FILE_NAME This file will be sent if ‘0’ is set for the INDEXES define. If this file is not found, the Web server will respond with a 404 Not Found.

• The number of the corresponding Content-Type: MAX_EXTENSION Size of the file extension list to be stored in external memory.

• The corresponding Content-Type: EXTENSION_TYPE_TABLE_LIST Extension list of files to be stored in external memory. When transferring a file extension that is not defined here, the extensions defined at the top of the list will be used.

• The number of registered CGI files: MAX_CGI_FILE

• Internal ‘C’ functions and the corresponding CGI file name table: CGI_FILE_NAME_TABLE_LIST

• New line code used to generate the index page: LF_CODE

• The maximum number of simultaneous clients: TCP_CEP_NUM This MUST match this with the number of communication endpoints that are defined in the config_tcpudp.c.

• The maximum number of files that can be displayed on the index page: MAX_FILE_LIST This MUST NOT exceed BODY_BUF_SIZE.

• Receive buffer size: RCV_BUF_SIZE

• Transmit buffer size for the header field: HDR_BUF_SIZE

• Transmit buffer size for the body field: BODY_BUF_SIZE

• Fixed IP address

This address is fixed in the application software file /rx64m_gr_kaede_Hi_Solution/r_t4_rx/src/config_tcpudp.c (line 156)

/rx64m_gr_kaede_Hi_Solution/src/r_http_server_cgi_sample.c lines (350 & 355)

The cgi_sample_function() shall need to be updated to match changes in the fixed ip address to ensure the correct operation of the page refresh function.

6.5 Web server file list Folder Name File Name Overview

r_t4_http_server_rx/src r_http_server.c Web server source file

Page 14: RX64M Group Application Note Cam it! - RX64M Camera Solution Kit · PDF file · 2016-05-16Please complete steps in R20UT3523EG Cam it! - RX64M Camera Solution Kit Quick Start Guide

RX64M Group

R20AN0385EG0100 Rev.1.00 Page 14 of 42 March 21, 2016

r_http_server_config.c Web server configuration source file

r_http_server_config.h Web server configuration header file

Table 7 Web Server

6.6 Web Server API Reference Interface File r_t4_http_server_rx/r_t4_http_server_rx_if.h

6.6.1 Function R_httpd Description

Manages the communication anchor necessary for HTTP communication.

This function only manages the communication anchor, T4 communicates are automatically driven by interrupts.

The application will poll this function. Usage

#include “r_t4_http_server_rx_if.h” void R_httpd (void);

Parameters

None

Return Value

None

Remark

None

6.6.2 Function R_httpd_pending_release_request Description

Please refer to Function cgi_sample_function for use.

The application will call this function.

Usage

#include “r_t4_http_server_rx_if.h” void R_httpd_pending_release_request (ID cepid); Parameters

cepid Input Communication anchor ID

Return Value

None

Remark

None

Page 15: RX64M Group Application Note Cam it! - RX64M Camera Solution Kit · PDF file · 2016-05-16Please complete steps in R20UT3523EG Cam it! - RX64M Camera Solution Kit Quick Start Guide

RX64M Group

R20AN0385EG0100 Rev.1.00 Page 15 of 42 March 21, 2016

6.6.3 Function R_T4_HTTP_SERVER_GetVersion Description

Returns the version of the Web server installed

The first two bytes are the major version numbers, and the following two bytes are the minor version numbers. For instance, when the version is 4.25, the return value becomes ‘0x00040019'.

The application will call this function.

Usage

#include “r_t4_http_server_rx_if.h” uint32_t R_T4_HTTP_SERVER_GetVersion (void);

Parameters

None

Return Value

Version of the Web server.

Remark

None

6.7 File System Functions This Web server calls these function. The user appropriately defines the content of the processing of this function according to the filesystem. Moreover, the Web server can acquire information on the extrinsic memory by using this data structure body. Note: Functions shown in grey are not used buy the Web server.

Function Functional overview Function Functional overview

change_dir() Change working directory file_write() Writing to file

file_close() Close file get_file_info() Get file information

file_delete() Delete File get_file_list_info() Get file list

file_open() Open file get_file_size() Get file size

file_read() Read from File make_dir() Create Directory

file_rename() Changing the file name remove_dir() Removing a directory

file_exist() Confirm the presence or absence of file

Table 8 File API

6.7.1 Data structure body

Time and date structure: typedef struct date_info_ { uint16_t year; // 2011, 2012, ... uint8_t month[4]; // Jan, Feb, Mar, ... uint8_t day; // 1-31 uint8_t day_of_the_week[4]; // Sun, Mon, Tus, ... uint16_t hour; // 0-23 uint16_t min; // 0-59 uint16_t sec; // 0-59 }DATE_INFO;

Page 16: RX64M Group Application Note Cam it! - RX64M Camera Solution Kit · PDF file · 2016-05-16Please complete steps in R20UT3523EG Cam it! - RX64M Camera Solution Kit Quick Start Guide

RX64M Group

R20AN0385EG0100 Rev.1.00 Page 16 of 42 March 21, 2016

File information structure: typedef struct file_list_ { uint8_t file_name[13]; uint32_t file_size; uint32_t file_attr; DATE_INFO date_info; }FILE_LIST; Macro Definitions: #define FILE_WRITE (0x10) #define FILE_READ (0x01) /* File attribute bits for FILE_LIST->file_attr */ #define FILE_ATTR_RDO (0x01) /* Read only */ #define FILE_ATTR_HID (0x02) /* Hidden */ #define FILE_ATTR_SYS (0x04) /* System */ #define FILE_ATTR_VOL (0x08) /* Volume label */ #define FILE_ATTR_DIR (0x10) /* Directory */ #define FILE_ATTR_ARC (0x20) /* Archive */

6.7.2 Function change_dir Description

Sets the working directory to the path specified.

The directory path is specified in the full path.

The application does not use this function. Usage

#include <stdint.h> #include “r_file_driver.h” int32 change_dir (uint8_t *dir_path);

Parameters

dir_path Input Full path to the directory to be working directory

Return Value

-1 Path specified does not exist.

0 Directory Successfully Changed

Remark

dir_path must finish with a ‘/’ character

Page 17: RX64M Group Application Note Cam it! - RX64M Camera Solution Kit · PDF file · 2016-05-16Please complete steps in R20UT3523EG Cam it! - RX64M Camera Solution Kit Quick Start Guide

RX64M Group

R20AN0385EG0100 Rev.1.00 Page 17 of 42 March 21, 2016

6.7.3 Function file_close Description

Closes a previously opened file.

The application will call this function. Usage

#include <stdint.h> #include “r_file_driver.h” int32 file_close (int32_t file_id);

Parameters

file_id Input ID of the file to close

Return Value

-1 Error

0 Success

Remark

None

6.7.4 Function file_delete Description

Deletes the specified file.

The application does not use this function. Usage

#include <stdint.h> #include “r_file_driver.h” int32 file_delete (uint8_t *dir_path); Parameters

file_path Input Full path for file to be deleted

Return Value

-1 Error

0 Success

Remark

File path must be full path to file.

Page 18: RX64M Group Application Note Cam it! - RX64M Camera Solution Kit · PDF file · 2016-05-16Please complete steps in R20UT3523EG Cam it! - RX64M Camera Solution Kit Quick Start Guide

RX64M Group

R20AN0385EG0100 Rev.1.00 Page 18 of 42 March 21, 2016

6.7.5 Function file_open Description

Opens the file specified.

Return value provides a file ID that is used in subsequent accesses.

The application will call this function. Usage

#include <stdint.h> #include “r_file_driver.h” int32 file_open (uint8_t *file_path, uint8_t mode_flag);

Parameters

file_path Input Full path for file to be opened

mode_flag Input Mode in which to open file(FILE_WRITE or FILE_READ)

Return Value

-1 Error

>0 ID of file opened (ID = 0 for 1st file, 1 for 2nd file etc.)

Remark

File path must be full path to file.

6.7.6 Function file_read Description

Reads a number of bytes from the file into the buffer.

The application will call this function. Usage

int32 file_read (int32_t file_id, uint8_t *buf, int32_t read_size); Parameters

file_id Input File ID from which to read data

buf Output Buffer in which data form file is read

read_size Input Number of bytes to read Return Value

-1 Error

>0 number of bytes read.

Remark

None

Page 19: RX64M Group Application Note Cam it! - RX64M Camera Solution Kit · PDF file · 2016-05-16Please complete steps in R20UT3523EG Cam it! - RX64M Camera Solution Kit Quick Start Guide

RX64M Group

R20AN0385EG0100 Rev.1.00 Page 19 of 42 March 21, 2016

6.7.7 Function file_rename Description

Changes the name of a specified file.

The application does not use this function. Usage

#include <stdint.h> #include “r_file_driver.h” int32 file_rename (uint8_t *old_name, uint8_t *new_name);

Parameters

old_name Input Original file name to be changed

new_name Input Name after change

Return Value

-1 Error

0 Success

Remark

File path must be full path to file.

6.7.8 Function file_exist Description

Verifies the existence of specified file.

The application does not use this function. Usage

#include <stdint.h> #include “r_file_driver.h” int32 file_exist (uint8_t *file_path); Parameters

file_path Input Full path for file to be checked

Return Value

-1 Error

0 Success

Remark

File path must be full path to file.

Page 20: RX64M Group Application Note Cam it! - RX64M Camera Solution Kit · PDF file · 2016-05-16Please complete steps in R20UT3523EG Cam it! - RX64M Camera Solution Kit Quick Start Guide

RX64M Group

R20AN0385EG0100 Rev.1.00 Page 20 of 42 March 21, 2016

6.7.9 Function file_write Description

Writes a specified number of bytes from a buffer to a previously opened file.

The application does not use this function. Usage

#include <stdint.h> #include “r_file_driver.h” int32 file_write(int32_t file_id, uint8_t *buf, int32_t write_size); Parameters file_id Input File ID to which data will be written

buf Input Buffer containing data to write

write_size Input Number of bytes to write

Return Value

-1 Error

0 Success

Remark

File id must point to a valid opened file.

6.7.10 Function get_file_info Description

Gets time and date information for a specified file ID.

The application will call this function. Usage

#include <stdint.h> #include “r_file_driver.h” int32 get_file_info (int32_t file_id, DATE_INFO *date_info); Parameters

file_id Input File ID for the file being queries date_info Output Pointer to a DATE_INFO structure to be populated Return Value

-1 Error

0 Success

Remark

None

Page 21: RX64M Group Application Note Cam it! - RX64M Camera Solution Kit · PDF file · 2016-05-16Please complete steps in R20UT3523EG Cam it! - RX64M Camera Solution Kit Quick Start Guide

RX64M Group

R20AN0385EG0100 Rev.1.00 Page 21 of 42 March 21, 2016

6.7.11 Function get_file_list_info Description

Gets information about the files in a specified directory.

Each file in the directory populates details in a FILE_LIST structure.

The application does not use this function. Usage

#include <stdint.h> #include “r_file_driver.h” int32 get_file_list_info (uint8_t *dir_path, FILE_LIST *file_list, uint32_t num_file_list, int32_t read_index); Parameters dir_path Input Path to the directy to get the listing from file_list Output Pointer to an array of FILE_LIST structures num_file_list Input Maximum number of files to get information for read_index Input Start position to start getting file information Return Value

-1 Error

>0 Number of file_list entries populated

Remark

If the returned value is smaller than num_file_list, no further file entries are available in the directory.

If the returned value and num_file_list are the same, further file entries are available.

The additional files entries can be read by a further call, with read_index set to the last.

dir_path must finish with a ‘/’ character.

6.7.12 Function get_file_size Description

Returns the size, in bytes of a specified file ID.

The application does not use this function. Usage

#include <stdint.h> #include “r_file_driver.h” int32 get_file_ size (int32_t file_id); Parameters file_id Input ID value of the file to be read

Return Value

-1 Error

0 or More File Size (bytes)

Remark

None

Page 22: RX64M Group Application Note Cam it! - RX64M Camera Solution Kit · PDF file · 2016-05-16Please complete steps in R20UT3523EG Cam it! - RX64M Camera Solution Kit Quick Start Guide

RX64M Group

R20AN0385EG0100 Rev.1.00 Page 22 of 42 March 21, 2016

6.7.13 Function make_dir Description

This function creates a directory specified in the argument.

Directory path is specified as the full path.

The application does not use this function. Usage

#include <stdint.h> #include “r_file_driver.h” int32 make_dir (uint8_t *dir_path);

Parameters dir_path Input Full path of the directory to create

Return Value

-1 Error

0 Success

Remark

dir_path must finish with a ‘/’ character.

6.7.14 Function remove_dir Description

This function deletes the directory specified by the argument.

Directory path specified in the full path.

The application does not use this function.

Usage

#include <stdint.h> #include “r_file_driver.h” int32 remove_dir(uint8_t *dir_path);

Parameters dir_path Input Full path of the directory to remove

Return Value

-1 Error

0 Success

Remark

dir_path must finish with a ‘/’ character.

Page 23: RX64M Group Application Note Cam it! - RX64M Camera Solution Kit · PDF file · 2016-05-16Please complete steps in R20UT3523EG Cam it! - RX64M Camera Solution Kit Quick Start Guide

RX64M Group

R20AN0385EG0100 Rev.1.00 Page 23 of 42 March 21, 2016

6.8 User-defined function reference (system timer -related) Web server calls this function group. The user defines the system timer.

Function Name Overview

get_sys_time() Top address acquisition of the system timer Table 9 Time API

6.8.1 Data structure System timer structure:

typedef struct sys_time_ { uint32_t sec; uint32_t min; uint32_t hour; uint32_t day; uint32_t month; uint32_t year; }SYS_TIME;

6.8.2 Function start_system_time Description

This function starts system timer to a known time and date.

Known time 9:00:00 on Jan 1st 2015

The application will call this function. Usage

#include "r_rtc_rx_if.h" #include "r_sys_time.h" int32 void start_system_time( void );

Parameters None

Return Value

None

Remark

Must be called before get_sys_time().

Page 24: RX64M Group Application Note Cam it! - RX64M Camera Solution Kit · PDF file · 2016-05-16Please complete steps in R20UT3523EG Cam it! - RX64M Camera Solution Kit Quick Start Guide

RX64M Group

R20AN0385EG0100 Rev.1.00 Page 24 of 42 March 21, 2016

6.8.3 Function stop_system_time Description

This function stops system timer.

The application will call this function. Usage

#include "r_rtc_rx_if.h" #include "r_sys_time.h" int32 void start_system_time( void );

Parameters None

Return Value

None

Remark

None

6.8.4 Function get_sys_time Description

This function gets the current time.

The application will call this function. Usage

#include <stdint.h> #include “r_file_driver.h” SYS_TIME *get_sys_time (void);

Parameters None

Return Value

-1 Error

0 Success

Remark

Must be call start_system_time() before use.

Page 25: RX64M Group Application Note Cam it! - RX64M Camera Solution Kit · PDF file · 2016-05-16Please complete steps in R20UT3523EG Cam it! - RX64M Camera Solution Kit Quick Start Guide

RX64M Group

R20AN0385EG0100 Rev.1.00 Page 25 of 42 March 21, 2016

6.9 Sample CGI function 6.9.1 Function cgi_sample_function Description

CGI functions are defined in the CGI_FILE_NAME_TABLE_LIST macro of "R_t4_http_server_config.h".

When URL of the CGI file defined with the Web server is requested, the second element of CGI_FILE_NAME_TABLE_LIST (CGI function pointer) is called.

The operation of HTTPd changes depending on the return value of the CGI function:

case: Normal termination

CGI process finishes in this function.

case: Internal error

CGI process errors occur in this function.

case: CGI pending

CGI process does not finish in this function.

The third element (cgi function pointer) of CGI_FILE_NAME_TABLE_LIST will be called when user calls R_httpd_pending_release_request () in finishing CGI process.

The application will call this function. Usage

#include <stdint.h> #include "r_t4_itcpip.h" #include "r_t4_http_server_rx_config.h" #include "r_t4_http_server_rx_if.h" #include "r_http_server_cgi_sample.h" uint32_t cgi_sample_function(ID cepid, void *res_info)

Parameters cepid Input Communication endpoint established with peer ID.

res_info Input (HTTPD_RESOURCE_INFO*)res_info->param

Parameters included in there the URL requested by the Web browser

Output (HTTPD_RESOURCE_INFO*)res_info->res.body

HTML string to return as a response

Output (HTTPD_RESOURCE_INFO*)res_info->res.body_size

The length of the HTML string

Return Value

-1 Internal error -2 CGI response pending 0 Successful completion

Remark

None

Page 26: RX64M Group Application Note Cam it! - RX64M Camera Solution Kit · PDF file · 2016-05-16Please complete steps in R20UT3523EG Cam it! - RX64M Camera Solution Kit Quick Start Guide

RX64M Group

R20AN0385EG0100 Rev.1.00 Page 26 of 42 March 21, 2016

7. Web camera specification

7.1 Outline of performance The captured image from the camera module of the Cam-it! kit, once transmitted over Ethernet, is displayed in a frame that can be viewed on the client web browser.

Table 10 Viewing of camera image

Parameter Specification ROM Size

1. Camera module control

2. I mage capture

3. JPEG encoding

Total: Aprox 15.1k bytes

~0.7k bytes

~3.0k bytes

~11.4k bytes RAM size

1. Camera module control

2. I mage capture

3. JPEG encoding

4. JPEG File Storage

Total: Aprox 257k byte (stack excluded)

~5k bytes

~50k bytes

~1.7k bytes

~200k bytes Image size (final) QVGA(320x240)YCbCr4:2:2

Uptake period (At the time of image processing function off)

120-130 msec

Uptake period (Image processing functions on-time)

500 msec

Table 11 Camera performance

7.2 Outline of operation The image data is acquired from the camera module with a parallel data capture unit (PDC), a module within the RX64M. The pixel clock is approximately 15MHz. The data of 640x480 YCbCr 4:2:2 is acquired according to the operational mode at 320x240 YCbCr 4:2:2. The acquisition timing depends on the JPEG encode and processing time and is not related to the frame rate of the camera. This will change according to the image processing mode etc. and the update cycle of the Web browser.

Ethernet Hub

Client PC

Camera View

Of Room

Shown on

Client PC

Page 27: RX64M Group Application Note Cam it! - RX64M Camera Solution Kit · PDF file · 2016-05-16Please complete steps in R20UT3523EG Cam it! - RX64M Camera Solution Kit Quick Start Guide

RX64M Group

R20AN0385EG0100 Rev.1.00 Page 27 of 42 March 21, 2016

7.3 Configuration 7.3.1 r_pdc_rx_config.h The image data acquisition rate of the camera module can be changed through the macro definitions in the configuration file: r_pdc_rx_config.h. PCKO Frequency Division Ratio Select: PDC_CFG_PCKO_DIV Note, the input clock for the camera module used in the Cam-it! kit rated at 6-27MHz.

7.3.2 r_ov7740_sensor.h Resolution of the camera can be changed in this header file. Horizontal resolution: IMG_SENSOR_OUTPUT_WIDTH Vertical resolution: IMG_SENSOR_OUTPUT_HEIGHT

7.3.3 r_jpeg_enc_apl.h JPEG encoding parameters such as size, quality and storage buffer can be changed in this header file. Quality setting: 1-128: JPEG_QUALITY The higher the value, the higher the JPEG quality (and the larger the JPEG file size) The color format: JPEG_OUTPUT_FMT Defines the color format of the encoded JPEG file, JPEGE_OUT_YCC422 or JPEGE_OUT_YCC420. JPEG Output File buffer: JPEG_OUTPUT_AREA_SIZE Size (bytes) of the buffer to receive the encoded output image. 7.3.4 r_pdc_apl.h Number of image blocks: D_PDC_MAX_PICTURE_BLOCK Defiles the number of picture blocks in the Cam-it! kit this is fixed at three blocks (= three frames).

7.4 File list Folder Filename Overview r_ov7740_sensor.c Camera module control source file r_ov7740_sensor.h Camera module control header r_ov7740_config.h Camera module initialization register values r_jpeg_enc_apl.c JPEG encoding control source file r_jpeg_enc_apl.h JPEG encoding control header file r_pdc_apl.c Parallel data capture controller source file r_pdc_apl.h Parallel data capture controller header file

Table 12 Camera user files

Page 28: RX64M Group Application Note Cam it! - RX64M Camera Solution Kit · PDF file · 2016-05-16Please complete steps in R20UT3523EG Cam it! - RX64M Camera Solution Kit Quick Start Guide

RX64M Group

R20AN0385EG0100 Rev.1.00 Page 28 of 42 March 21, 2016

7.5 Camera API Reference 7.5.1 Function R_OV7740_SensorInit Description

This function initializes the image sensor in the camera module.

The application will call this function. Usage

#include “r_ov7740_sensor.h” uint8_t R_OV7740_SensorInit( void ) Parameters

None Return Value

None

Remark

Must be called before R_OV7740_SensorWrite()or R_OV7740_SensorWrite().

Slave address of the target device, is defined by "IMG_SENSOR_SLV_ADDRESS" in r_ov7740_sensor.h. The default register values are stored in r_ov7740_config.h.

7.5.2 Function R_OV7740_SensorWrite Description

This function writes a value to a single image sensor register within the camera module.

This function is called from the Web browser using the CGI feature.

Usage

#include “r_ov7740_sensor.h” uint8_t R_OV7740_SensorWrite (uint8_t reg_adr, uint8_t reg_data, uint32_t size) Parameters reg_adr Input Register address

reg_data Input Data to write

size Input Write Data size (bytes) (use 1 byte for ov7740)

Return Value

1

Remark

Must call R_OV7740_SensorInit()before use.

Slave address of the target device, is defined by "IMG_SENSOR_SLV_ADDRESS" in r_ov7740_sensor.h.

Page 29: RX64M Group Application Note Cam it! - RX64M Camera Solution Kit · PDF file · 2016-05-16Please complete steps in R20UT3523EG Cam it! - RX64M Camera Solution Kit Quick Start Guide

RX64M Group

R20AN0385EG0100 Rev.1.00 Page 29 of 42 March 21, 2016

7.5.3 Function R_OV7740_SensorRead Description

This function requests a read of the selected register from the CMOS camera.

This function is called from the Web browser using the CGI feature.

Usage

#include “r_ov7740_sensor.h” uint8_t R_OV7740_SensorRead (uint8_t reg_adr, uint8_t reg_data, uint32_t size) Parameters reg_adr Input Register address

reg_data Input Data to write

size Input Read Data size (bytes) (use 1 byte for ov7740)

Return Value

1

Remark

Must call R_OV7740_SensorInit()before use.

Slave address of the target device, is defined by "IMG_SENSOR_SLV_ADDRESS" in r_ov7740_sensor.h.

7.5.4 Function R_JPEG_CompressInit Description

Perform the initialization of the JPEG encoding library.

The application will call this function. Usage

#include “r_jpeg_enc_apl.h” uint8_t R_JPEG_CompressInit (void) Parameters None

Return Value

None

Remark

Should call this function during application initialization.

Page 30: RX64M Group Application Note Cam it! - RX64M Camera Solution Kit · PDF file · 2016-05-16Please complete steps in R20UT3523EG Cam it! - RX64M Camera Solution Kit Quick Start Guide

RX64M Group

R20AN0385EG0100 Rev.1.00 Page 30 of 42 March 21, 2016

7.5.5 Function R_JPEG_CompressImage Description

Calls the JPEG encoding library to compress target image.

The application will call this function. Usage

#include “r_jpeg_enc_apl.h” uint8_t R_JPEG_CompressImage (struct r_jpeg_encode_t *jpeg_info) Parameters jpeg_info Input/Output Structure containing source and destination image description

Return Value

0 Successful completion

>0 Error Remark

Must call R_JPEG_CompressInit()before use.

7.5.6 R_JPEG_GetOutputAdr Description

If multiple storage areas for JPEG encoding is used, this function returns the start address of the specified storage area.

The application will call this function.

Usage

#include “r_jpeg_enc_apl.h” uint8_t R_JPEG_GetOutputAdr (uint8_t area_num) Parameters area_num Input Storage area number of JPEG files

Return Value

Start address of the specified area Remark

Must call R_JPEG_CompressInit()before use.

In the Cam-it! Demonstration, two storage areas are used for encoded JPEG data.

The JPEG encoding timing is not synchronized with images captured by the camera, two storage areas are used to prevent access to a buffer while encoding is in progress.

Page 31: RX64M Group Application Note Cam it! - RX64M Camera Solution Kit · PDF file · 2016-05-16Please complete steps in R20UT3523EG Cam it! - RX64M Camera Solution Kit Quick Start Guide

RX64M Group

R20AN0385EG0100 Rev.1.00 Page 31 of 42 March 21, 2016

7.5.7 R_JPEG_GetOutputAreaNum Description

Returns the number of storage areas used by the JPEG encoding library.

The application will call this function.

Usage

#include “r_jpeg_enc_apl.h” uint8_t R_JPEG_GetOutputAreaNum (void) Parameters None

Return Value

Number of Storage Areas Remark

Must call R_JPEG_CompressInit() before use.

In the Cam-it! Demonstration, two storage areas are used for encoded JPEG data. The JPEG encoding timing is not synchronized with images captured by the camera, two storage areas are used to prevent access to a buffer while encoding is in progress.

7.5.8 R_JPEG_GetOutputSize Description

Returns the number of storage areas used by the JPEG encoding library.

The application will call this function.

Usage

#include “r_jpeg_enc_apl.h” uint8_t R_JPEG_GetOutputSize (void) Parameters None

Return Value

JPEG size afrer compress processing

Remark

Must call R_JPEG_CompressInit()before use.

Must call R_JPEG_CompressImage()before use.

Page 32: RX64M Group Application Note Cam it! - RX64M Camera Solution Kit · PDF file · 2016-05-16Please complete steps in R20UT3523EG Cam it! - RX64M Camera Solution Kit Quick Start Guide

RX64M Group

R20AN0385EG0100 Rev.1.00 Page 32 of 42 March 21, 2016

7.5.9 R_JPEG_SetQualityData Description

Returns the number of storage areas used by the JPEG encoding library.

The application will call this function.

Usage

#include “r_jpeg_enc_apl.h” uint8_t R_JPEG_GetOutputSize (void) Parameters data Input New setting for data quality range 0 - 128

Return Value

None

Remark

Must call R_JPEG_CompressInit()before use.

7.5.10 R_PDC_AplInit Description

Performs stage 1 of the initialization of the PDC unit.

Stage 2 of this initialization shall be performed by the R_PDC_AplCreate() function.

The application will call this function.

Usage

#include “r_pdc_apl.h” void R_PDC_AplInit (void) Parameters None

Return Value

None

Remark

Must call R_PDC_AplCreate()after use.

Page 33: RX64M Group Application Note Cam it! - RX64M Camera Solution Kit · PDF file · 2016-05-16Please complete steps in R20UT3523EG Cam it! - RX64M Camera Solution Kit Quick Start Guide

RX64M Group

R20AN0385EG0100 Rev.1.00 Page 33 of 42 March 21, 2016

7.5.11 R_PDC_AplCreate Description

Performs stage 2 of the initialization of the PDC unit.

Stage 1 of this initialization shall be performed by the R_PDC_AplInit() function.

The application will call this function.

Usage

#include “r_pdc_apl.h” void R_PDC_AplCreate (void) Parameters None

Return Value

None

Remark

Must call R_PDC_AplInit()before use.

7.5.12 R_PDC_GetCaptureBufAdr Description

This function gets the image input address for the source picture.

The application will call this function.

Usage

#include “r_pdc_apl.h” uint8_t *R_PDC_GetCaptureBufAdr (void) Parameters None

Return Value

Input address for the source picture.

Remark

Must call R_PDC_AplInit()before use.

Must call R_PDC_AplCreate()before use.

Page 34: RX64M Group Application Note Cam it! - RX64M Camera Solution Kit · PDF file · 2016-05-16Please complete steps in R20UT3523EG Cam it! - RX64M Camera Solution Kit Quick Start Guide

RX64M Group

R20AN0385EG0100 Rev.1.00 Page 34 of 42 March 21, 2016

7.5.13 R_PDC_ReceiveAgain Description

This function starts capture of parallel data from the camera module (image data).

The application will call this function.

Usage

#include “r_pdc_apl.h” uint8_t *R_PDC_ReceiveAgain (uint8_t continue_flag) Parameters continue_flag Input control the data destination address

0 : dst_addr reset

1 : dst_addr continue

Return Value

Input address for the source picture.

Remark

Must call R_PDC_AplInit()before use.

Must call R_PDC_AplCreate()before use.

After calling this function the PDC will capture a single frame from the camera module.

Subsequent calls to this function will capture a further frame.

Actual capture start timing is synchronized with the V-SYNC signal.

8. Image processing specification

8.1 Performance Overview

The Cam-it! application showcases the following features of the image processing library: Human detection, Movement detection and Distortion correction.

The image processing code is supplied as a pre-compiled binary file. This provides a demonstration that shows the performance of the image processing but may not be suitable for inclusion in a final application. For details about obtaining the source code for the Image Processing library, please contact your local Renesas Sales office. Contact details can be found at the end of this application note.

Memory Performance

ROM size 65KByte RAM size Internal: 135KByte (excluding stack)

External: 3.5MByte Table 13 Memory use

Page 35: RX64M Group Application Note Cam it! - RX64M Camera Solution Kit · PDF file · 2016-05-16Please complete steps in R20UT3523EG Cam it! - RX64M Camera Solution Kit Quick Start Guide

RX64M Group

R20AN0385EG0100 Rev.1.00 Page 35 of 42 March 21, 2016

No Function Function name Overview 1 Human detection

function Human highlight function

When a human is detected in the image the body outline is highlighted on the displayed image.

2 Human counting function

The captured image is divided into nine areas, this function outputs the number of humans detected in each area.

3 Motion detection function

Image comparison function

Three images are continuously compared, any points of movement in the image is highlighted.

4 Distortion correction function

Image correction function Compensates for optical distortion caused by camera module and optics. Performs coordinate transformation of the image based in inputted correction values.

Table 14 Image processing functions

8.2 Configuration None

8.3 File List The file list of image processing functions are shown below .

Folder File name Contents

renesas_sw_library/image_proc Mdl_IP_main.h Image processing API header

Mdl_IP_ex.h Extensions to the API header

Mdl_IP_prot.h Each mode structure definition

Table 15 Image processing API

8.4 API Reference 8.4.1 Mdl_IP_Init Description

Initializes the image processing middleware and its internal variables.

Required to be called once before image processing starts.

The application will call this function.

Usage

# include "Mdl_IP_ex.h" void Mdl_IP_Init( unsigned char *wk_adr ) Parameters wk_adr Input Start of allocated working memory buffer

Return Value

Input address for the source picture.

Remark

wk_adr: Working memory to be used in image processing in middleware. (320x240: 4 sided, 160x120: 2 surface).

8.4.2 Mdl_IP_PersonDetection

Page 36: RX64M Group Application Note Cam it! - RX64M Camera Solution Kit · PDF file · 2016-05-16Please complete steps in R20UT3523EG Cam it! - RX64M Camera Solution Kit Quick Start Guide

RX64M Group

R20AN0385EG0100 Rev.1.00 Page 36 of 42 March 21, 2016

Description

Analyses an image (parameter 1) for the presence and number of human bodies.

The application will call this function.

Usage

# include "Mdl_IP_ex.h" int Mdl_IP_PersonDetection(unsigned char *in_img, PersonDetection_Rslt *rslt, unsigned char *extension) Parameters in_img Input Source image start address

rslt Output Person detection result details

extension Output Resulting image from detection stored as yuv422 colour format.

Return Value

0 Success

-1 Not Initialized – run Mdl_IP_Init()

Remark

Must call Mdl_IP_Init()before use.

Page 37: RX64M Group Application Note Cam it! - RX64M Camera Solution Kit · PDF file · 2016-05-16Please complete steps in R20UT3523EG Cam it! - RX64M Camera Solution Kit Quick Start Guide

RX64M Group

R20AN0385EG0100 Rev.1.00 Page 37 of 42 March 21, 2016

8.4.3 Mdl_IP_PersonDetection_ParamChg Description

Sets threshold and sensitivity parameters for the person detection function Mdl_IP_PersonDetection.

The application will call this function.

Usage

# include "Mdl_IP_ex.h" int Mdl_IP_PersonDetection_ParamChg (int kind, int val) Parameters kind Input Parameter Type

val Input New Value

Return Value

Success

0 Success

-1 Not Initialized – run Mdl_IP_Init()

-2 Parameter Type Out of Range

-3 Setting Value out of Range

Remark

Must call Mdl_IP_Init()before use.

Parameter Type: 0: Person detection threshold (Range of set value: 1-9) The threshold at which a person is distinguished. The higher the number the more sensitive the detection algorithm (default value: 7) 1: Person detection sensitivity (Range of set value: 1-15) Sets the sensitivity to contrast and colors in the image. Areas of contrast are then analyzed for human presence (default value: 7)

Page 38: RX64M Group Application Note Cam it! - RX64M Camera Solution Kit · PDF file · 2016-05-16Please complete steps in R20UT3523EG Cam it! - RX64M Camera Solution Kit Quick Start Guide

RX64M Group

R20AN0385EG0100 Rev.1.00 Page 38 of 42 March 21, 2016

8.4.4 Mdl_IP_MovingDetection Description

This function takes three sequential images and executes the movement detection function from the Image Processing library.

The movement detected between the 3rd and 1st image is calculated with the results structure stored in rslt argument and the resulting image representing the detection results is stored in extension argument.

The details of how the Image Processing library performs this motion detection is not shown here, but contact your Renesas representative for the approiate documentation.

The application will call this function.

Usage

# include "Mdl_IP_ex.h" Int Mdl_IP_MovingDetection (unsigned char *in_img1, unsigned char *in_img2, unsigned char *in_img3, MovingDetection_Rslt *rslt, unsigned char *extension) Parameters in_img1 Input Source image 1 in sequence

in_img2 Input Source image 2 in sequence

in_img3 Input Source image 3 in sequence

rslt Output Person detection result details

extension Output Resulting image from detection stored as yuv422 colour format.

Return Value

Success

0 Success

-1 Not Initialized – run Mdl_IP_Init()

Remark

Must call Mdl_IP_Init()before use.

Page 39: RX64M Group Application Note Cam it! - RX64M Camera Solution Kit · PDF file · 2016-05-16Please complete steps in R20UT3523EG Cam it! - RX64M Camera Solution Kit Quick Start Guide

RX64M Group

R20AN0385EG0100 Rev.1.00 Page 39 of 42 March 21, 2016

8.4.5 Mdl_IP_MovingDetection_ParamChg Description

This function is used to set the movement detection parameters to be used by the function Mdl_IP_MovingDetection.

The application will call this function.

Usage

# include "Mdl_IP_ex.h" int Mdl_IP_MovingDetection_ParamChg (int kind, int val) Parameters kind Input Parameter Type

val Input New Value

Return Value

Success

0 Success

-1 Not Initialized – run Mdl_IP_Init()

-2 Parameter Type Out of Range

-3 Setting Value out of Range

Remark

Must call Mdl_IP_Init()before use.

Parameter Type: 0: Moving body detection threshold (Range of set value: 1-10)

The distinction threshold when the moving body is detected is specified.

Reduced the threshold when too little movement is being detected.

Increase the threshold when too liitle movement is being detected.

(default value: 4)

1: Moving body detection sensitivity (Range of set value: 1-10)

Sensitivity detects a change in brightness when the moving body is detected is specified.

Reduce setting to increase sensitivity, increase setting to decrease sensitivity.

(default value: 3).

2: Surface of processing area (Range of set value: 0-9)

3: The vicinity under processing area (Range of set value: 0-9)

4: The left side of processing area (Range of set value: 0-9)

5: The right side of processing area (Range of set value: 0-9)

The correction value from the image edge in the processing region where the moving body is detected is specified at intervals of 10%.

Page 40: RX64M Group Application Note Cam it! - RX64M Camera Solution Kit · PDF file · 2016-05-16Please complete steps in R20UT3523EG Cam it! - RX64M Camera Solution Kit Quick Start Guide

RX64M Group

R20AN0385EG0100 Rev.1.00 Page 40 of 42 March 21, 2016

8.4.6 Mdl_IP_ImgRevise Description

This function executes the distortion correction processing for the image stored at the address specified by the 1st argument (in_img) and stores the correct image in the 2nd argument

(out_img).

The application will call this function.

Usage

# include "Mdl_IP_ex.h" int Mdl_IP_ImgRevise (unsigned char *in_img,unsigned char *out_img) Parameters in_img Input Source image

out_img Output Distortion correction processing result image

Return Value

Success

0 Success

-1 Not Initialized – run Mdl_IP_Init()

Remark

Must call Mdl_IP_Init()before use.

The size of the buffer used to hold the resulting image (out_img) must match or exceed the input image (in_img) to prevent buffer overrun.

Page 41: RX64M Group Application Note Cam it! - RX64M Camera Solution Kit · PDF file · 2016-05-16Please complete steps in R20UT3523EG Cam it! - RX64M Camera Solution Kit Quick Start Guide

RX64M Group

R20AN0385EG0100 Rev.1.00 Page 41 of 42 March 21, 2016

8.4.7 Mdl_IP_ImgRevise_ParamChg Description

This function is used to set the movement detection parameters to be used by the function Mdl_IP_ImgRevise

The application will call this function.

Usage

# include "Mdl_IP_ex.h" Int Mdl_IP_ImgRevise_ParamChg (int kind, int val) Parameters kind Input Parameter Type

val Input New Value

Return Value

Success

0 Success

-1 Not Initialized – run Mdl_IP_Init()

-2 Parameter Type Out of Range

-3 Setting Value out of Range

Remark

Must call Mdl_IP_Init()before use.

Parameter Type: Type of parameter outside set value range Remark

0: Distortion correction effective/invalidity (Range of set value: 0-1)

Enable/Disable distortion correction processing.

0 when it is disabled

1 invalid when enabled.

(default value: 1)

1: Horizontal correction value (range :-127-127 of set value)

Reference point X coordinate, initial offset from image center for distorting and correction.

A negative value of offset indicates the left side of the image from the center.

A positive value of offset indicates the right side of the image from the center.

(default value :-2)

2: Vertical direction correction value (range :-127-127 of set value)

Reference point Y coordinate, initial offset from image center for distorting and correction.

A negative value of offset indicates below the image center.

A positive value of offset indicates above the image center.

(default value :-42)

Page 42: RX64M Group Application Note Cam it! - RX64M Camera Solution Kit · PDF file · 2016-05-16Please complete steps in R20UT3523EG Cam it! - RX64M Camera Solution Kit Quick Start Guide

RX64M Group

R20AN0385EG0100 Rev.1.00 Page 42 of 42 March 21, 2016

Website and Support Renesas Electronics Website

http://www.renesas.com/ Inquiries

http://www.renesas.com/contact/ All trademarks and registered trademarks are the property of their respective owners.

Page 43: RX64M Group Application Note Cam it! - RX64M Camera Solution Kit · PDF file · 2016-05-16Please complete steps in R20UT3523EG Cam it! - RX64M Camera Solution Kit Quick Start Guide

A-1

Revision History

Rev. Date Description Page Summary

1.0 21st March 2016 All 1st Version of document

Page 44: RX64M Group Application Note Cam it! - RX64M Camera Solution Kit · PDF file · 2016-05-16Please complete steps in R20UT3523EG Cam it! - RX64M Camera Solution Kit Quick Start Guide

General Precautions in the Handling of Microprocessing Unit and Microcontroller Unit Products The following usage notes are applicable to all Microprocessing unit and Microcontroller unit products from Renesas. For detailed usage notes on the products covered by this document, refer to the relevant sections of the document as well as any technical updates that have been issued for the products.

1. Handling of Unused Pins Handle unused pins in accordance with the directions given under Handling of Unused Pins in the manual. The input pins of CMOS products are generally in the high-impedance state. In operation with an

unused pin in the open-circuit state, extra electromagnetic noise is induced in the vicinity of LSI, an associated shoot-through current flows internally, and malfunctions occur due to the false recognition of the pin state as an input signal become possible. Unused pins should be handled as described under Handling of Unused Pins in the manual.

2. Processing at Power-on The state of the product is undefined at the moment when power is supplied. The states of internal circuits in the LSI are indeterminate and the states of register settings and

pins are undefined at the moment when power is supplied. In a finished product where the reset signal is applied to the external reset pin, the states of pins are not guaranteed from the moment when power is supplied until the reset process is completed. In a similar way, the states of pins in a product that is reset by an on-chip power-on reset function are not guaranteed from the moment when power is supplied until the power reaches the level at which resetting has been specified.

3. Prohibition of Access to Reserved Addresses Access to reserved addresses is prohibited. The reserved addresses are provided for the possible future expansion of functions. Do not access

these addresses; the correct operation of LSI is not guaranteed if they are accessed. 4. Clock Signals

After applying a reset, only release the reset line after the operating clock signal has become stable. When switching the clock signal during program execution, wait until the target clock signal has stabilized. When the clock signal is generated with an external resonator (or from an external oscillator)

during a reset, ensure that the reset line is only released after full stabilization of the clock signal. Moreover, when switching to a clock signal produced with an external resonator (or by an external oscillator) while program execution is in progress, wait until the target clock signal is stable.

5. Differences between Products Before changing from one product to another, i.e. to a product with a different part number, confirm that the change will not lead to problems. The characteristics of Microprocessing unit or Microcontroller unit products in the same group but

having a different part number may differ in terms of the internal memory capacity, layout pattern, and other factors, which can affect the ranges of electrical characteristics, such as characteristic values, operating margins, immunity to noise, and amount of radiated noise. When changing to a product with a different part number, implement a system-evaluation test for the given product.

Page 45: RX64M Group Application Note Cam it! - RX64M Camera Solution Kit · PDF file · 2016-05-16Please complete steps in R20UT3523EG Cam it! - RX64M Camera Solution Kit Quick Start Guide

Notice1. Descriptions of circuits, software and other related information in this document are provided only to illustrate the operation of semiconductor products and application examples. You are fully responsible for

the incorporation of these circuits, software, and information in the design of your equipment. Renesas Electronics assumes no responsibility for any losses incurred by you or third parties arising from the use

of these circuits, software, or information.

2. Renesas Electronics has used reasonable care in preparing the information included in this document, but Renesas Electronics does not warrant that such information is error free. Renesas Electronics

assumes no liability whatsoever for any damages incurred by you resulting from errors in or omissions from the information included herein.

3. Renesas Electronics does not assume any liability for infringement of patents, copyrights, or other intellectual property rights of third parties by or arising from the use of Renesas Electronics products or

technical information described in this document. No license, express, implied or otherwise, is granted hereby under any patents, copyrights or other intellectual property rights of Renesas Electronics or

others.

4. You should not alter, modify, copy, or otherwise misappropriate any Renesas Electronics product, whether in whole or in part. Renesas Electronics assumes no responsibility for any losses incurred by you or

third parties arising from such alteration, modification, copy or otherwise misappropriation of Renesas Electronics product.

5. Renesas Electronics products are classified according to the following two quality grades: "Standard" and "High Quality". The recommended applications for each Renesas Electronics product depends on

the product's quality grade, as indicated below.

"Standard": Computers; office equipment; communications equipment; test and measurement equipment; audio and visual equipment; home electronic appliances; machine tools; personal electronic

equipment; and industrial robots etc.

"High Quality": Transportation equipment (automobiles, trains, ships, etc.); traffic control systems; anti-disaster systems; anti-crime systems; and safety equipment etc.

Renesas Electronics products are neither intended nor authorized for use in products or systems that may pose a direct threat to human life or bodily injury (artificial life support devices or systems, surgical

implantations etc.), or may cause serious property damages (nuclear reactor control systems, military equipment etc.). You must check the quality grade of each Renesas Electronics product before using it

in a particular application. You may not use any Renesas Electronics product for any application for which it is not intended. Renesas Electronics shall not be in any way liable for any damages or losses

incurred by you or third parties arising from the use of any Renesas Electronics product for which the product is not intended by Renesas Electronics.

6. You should use the Renesas Electronics products described in this document within the range specified by Renesas Electronics, especially with respect to the maximum rating, operating supply voltage

range, movement power voltage range, heat radiation characteristics, installation and other product characteristics. Renesas Electronics shall have no liability for malfunctions or damages arising out of the

use of Renesas Electronics products beyond such specified ranges.

7. Although Renesas Electronics endeavors to improve the quality and reliability of its products, semiconductor products have specific characteristics such as the occurrence of failure at a certain rate and

malfunctions under certain use conditions. Further, Renesas Electronics products are not subject to radiation resistance design. Please be sure to implement safety measures to guard them against the

possibility of physical injury, and injury or damage caused by fire in the event of the failure of a Renesas Electronics product, such as safety design for hardware and software including but not limited to

redundancy, fire control and malfunction prevention, appropriate treatment for aging degradation or any other appropriate measures. Because the evaluation of microcomputer software alone is very difficult,

please evaluate the safety of the final products or systems manufactured by you.

8. Please contact a Renesas Electronics sales office for details as to environmental matters such as the environmental compatibility of each Renesas Electronics product. Please use Renesas Electronics

products in compliance with all applicable laws and regulations that regulate the inclusion or use of controlled substances, including without limitation, the EU RoHS Directive. Renesas Electronics assumes

no liability for damages or losses occurring as a result of your noncompliance with applicable laws and regulations.

9. Renesas Electronics products and technology may not be used for or incorporated into any products or systems whose manufacture, use, or sale is prohibited under any applicable domestic or foreign laws or

regulations. You should not use Renesas Electronics products or technology described in this document for any purpose relating to military applications or use by the military, including but not limited to the

development of weapons of mass destruction. When exporting the Renesas Electronics products or technology described in this document, you should comply with the applicable export control laws and

regulations and follow the procedures required by such laws and regulations.

10. It is the responsibility of the buyer or distributor of Renesas Electronics products, who distributes, disposes of, or otherwise places the product with a third party, to notify such third party in advance of the

contents and conditions set forth in this document, Renesas Electronics assumes no responsibility for any losses incurred by you or third parties as a result of unauthorized use of Renesas Electronics

products.

11. This document may not be reproduced or duplicated in any form, in whole or in part, without prior written consent of Renesas Electronics.

12. Please contact a Renesas Electronics sales office if you have any questions regarding the information contained in this document or Renesas Electronics products, or if you have any other inquiries.

(Note 1) "Renesas Electronics" as used in this document means Renesas Electronics Corporation and also includes its majority-owned subsidiaries.

(Note 2) "Renesas Electronics product(s)" means any product developed or manufactured by or for Renesas Electronics.

http://www.renesas.comRefer to "http://www.renesas.com/" for the latest and detailed information.

Renesas Electronics America Inc.2801 Scott Boulevard Santa Clara, CA 95050-2549, U.S.A.Tel: +1-408-588-6000, Fax: +1-408-588-6130Renesas Electronics Canada Limited9251 Yonge Street, Suite 8309 Richmond Hill, Ontario Canada L4C 9T3Tel: +1-905-237-2004Renesas Electronics Europe LimitedDukes Meadow, Millboard Road, Bourne End, Buckinghamshire, SL8 5FH, U.KTel: +44-1628-585-100, Fax: +44-1628-585-900Renesas Electronics Europe GmbHArcadiastrasse 10, 40472 Düsseldorf, GermanyTel: +49-211-6503-0, Fax: +49-211-6503-1327Renesas Electronics (China) Co., Ltd.Room 1709, Quantum Plaza, No.27 ZhiChunLu Haidian District, Beijing 100191, P.R.ChinaTel: +86-10-8235-1155, Fax: +86-10-8235-7679Renesas Electronics (Shanghai) Co., Ltd.Unit 301, Tower A, Central Towers, 555 Langao Road, Putuo District, Shanghai, P. R. China 200333Tel: +86-21-2226-0888, Fax: +86-21-2226-0999Renesas Electronics Hong Kong LimitedUnit 1601-1611, 16/F., Tower 2, Grand Century Place, 193 Prince Edward Road West, Mongkok, Kowloon, Hong KongTel: +852-2265-6688, Fax: +852 2886-9022Renesas Electronics Taiwan Co., Ltd.13F, No. 363, Fu Shing North Road, Taipei 10543, TaiwanTel: +886-2-8175-9600, Fax: +886 2-8175-9670Renesas Electronics Singapore Pte. Ltd.80 Bendemeer Road, Unit #06-02 Hyflux Innovation Centre, Singapore 339949Tel: +65-6213-0200, Fax: +65-6213-0300Renesas Electronics Malaysia Sdn.Bhd.Unit 1207, Block B, Menara Amcorp, Amcorp Trade Centre, No. 18, Jln Persiaran Barat, 46050 Petaling Jaya, Selangor Darul Ehsan, MalaysiaTel: +60-3-7955-9390, Fax: +60-3-7955-9510Renesas Electronics India Pvt. Ltd.No.777C, 100 Feet Road, HALII Stage, Indiranagar, Bangalore, IndiaTel: +91-80-67208700, Fax: +91-80-67208777Renesas Electronics Korea Co., Ltd.12F., 234 Teheran-ro, Gangnam-Gu, Seoul, 135-080, KoreaTel: +82-2-558-3737, Fax: +82-2-558-5141

SALES OFFICES

© 2016 Renesas Electronics Corporation. All rights reserved.Colophon 5.0