Example programs for GR-MANGO

Dependencies:   opencv-lib mbed-http

This is a collection of sample programs that work on RZ/A2M boards. You can try Mbed OS for RZ/A2M with GR-MANGO board.

Overview

Sample program files are located under the sample_programs folder. You can try each sample program by changing the following macro in sample_select.h.

insample_select.h

#define SAMPLE_PROGRAM_NO  0
No.Program fileDescription
0sample_00_led_rtc_analogin.cppDigitalOut, InterruptIn, RTC, Timer and AnalogIn
1sample_01_flash_write.cppFlashAPI sample
2sample_02_ssif_loop_back.cppSSIF loop back sample
4sample_04_ssif_wav_playback.cppSSIF wav playback sample (use USB memory or SD card)
7sample_07_usb_func_serial.cppUSBSerial (CDC) sample
8sample_08_usb_func_mouse.cppUSBMouse sample
9sample_09_usb_func_keyboard.cppUSBKeyboard sample
10sample_10_usb_func_midi.cppUSBMIDI sample
11sample_11_usb_func_audio_1.cppUSBAudio sample
12sample_12_usb_func_audio_2.cppUSBAudio and SSIF sample
13sample_13_ether_http.cppEther HTTP sample
14sample_14_ether_https.cppEther HTTPS sample
16sample_16_usb_func_msd_1.cppUSBMSD and FlashAPI sample
17sample_17_usb_func_msd_2.cppUSBMSD and FlashAPI sample advanced version
18sample_18_mipi_drp_lcd.cppMIPI, DRP and LCD sample
19sample_19_mipi_drp_diplayapp.cppMIPI, DRP and USBSerial (CDC) sample (use "DisplayApp")
20sample_20_drp_dynamic_loading.cppDRP Dynamic Loading Sample
21sample_21_deep_standby_alarm.cppDeep standby and RTC alarm sample
22sample_22_hdmi_disp_ssif.cppHDMI output and SSIF wav playback Sample
23sample_23_mipi_hdmi.cppHDMI output and MIPI Sample
24sample_24_facedetection.cppHDMI output and face detection using OpenCV
25sample_25_hdmi_mouse.cppHDMI output and Mouse Sample

Notice

sample_24_facedetection.cpp only can be compiled with GNU Compiler Collection.

About sample_24_facedetection.cpp, this is a demonstration that can detect the face of a person without a mask. It will surround the face of a person without a mask with a red rectangle and sound alarm at the same time. To use OpenCV for face recognition, you need to prepare the followings:
・USB drive or SD card
・ Raspberry Pi Camera Module V2
・ HDMI monitor

Perform the following steps to complete face recognition sample.
1. Copy the lbpcascade_frontalface.xml to the root folder of USB drive or SD card and save it.
2. Copy the alarm.wav to the root folder of USB drive or SD card and save it.
3. Set "camera-type" value to "CAMERA_RASPBERRY_PI_832X480" in mbed_app.json

About custom boot loaders

This sample uses custom bootloader revision 5, and you can drag & drop the "xxxx_application.bin" file to write the program. Please see here for the detail.

How to write program

When using DAPLink, please use xxxx.bin as following.

  1. Connect the micro USB type B terminal to the PC using a USB cable.
  2. You can find the MBED directory.
  3. Drag & drop xxxx.bin to the MBED directory.
  4. When writing is completed, press the reset button.

When using custom bootloader, please use xxxx_application.bin as following.

  1. Connect the USB type C terminal to the PC using a USB cable.
  2. Hold down USB0 and press the reset button.
  3. You can find the GR-MANG directory.
  4. Drag & drop xxxx_application.bin to the GR-MANGO directory.

When writing is completed, press the reset button.

Attention!

For the first time only, you need to write a custom bootloader using DAPLink.

Terminal setting

If you want to confirm the serial communication the terminal soft on your PC, please specify the below values. You can change the baud rate by platform.stio-baud-rate of mbed_app.json.

Baud rate115,200
Data8bit
Paritynone
Stop1bit
Flow controlnone
Committer:
luyao@os.mbed.com
Date:
Thu Mar 04 18:22:21 2021 +0900
Revision:
16:f4798796b4a2
Parent:
1:13d09ce5b51a
Modified EP952 Parameters.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 1 /*******************************************************************************
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 2 * DISCLAIMER
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 3 * This software is supplied by Renesas Electronics Corporation and is only
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 4 * intended for use with Renesas products. No other uses are authorized. This
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 5 * software is owned by Renesas Electronics Corporation and is protected under
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 6 * all applicable laws, including copyright laws.
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 7 * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 8 * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 9 * LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 10 * AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 11 * TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 12 * ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 13 * FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 14 * ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 15 * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 16 * Renesas reserves the right, without notice, to make changes to this software
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 17 * and to discontinue the availability of this software. By using this software,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 18 * you agree to the additional terms and conditions found by accessing the
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 19 * following link:
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 20 * http://www.renesas.com/disclaimer
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 21 *
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 22 * Copyright (C) 2019 Renesas Electronics Corporation. All rights reserved.
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 23 *******************************************************************************/
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 24 #include "sample_select.h"
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 25 #include "mbed.h"
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 26
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 27 #define DEBUG_BAUDRATE 115200
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 28
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 29 #if (SAMPLE_PROGRAM_NO == 23)
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 30 // SAMPLE_PROGRAM_NO 23 : HDMI output & MIPI Sample
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 31 //
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 32 // Please set the value of "camera-type" in "mbed_app.json" to null or "CAMERA_RASPBERRY_PI".
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 33 //
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 34 // "camera-type":{
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 35 // "help": "Please see EasyAttach_CameraAndLCD/README.md",
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 36 // "value": null
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 37 // },
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 38 //
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 39 // or
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 40 //
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 41 // "camera-type":{
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 42 // "help": "Please see EasyAttach_CameraAndLCD/README.md",
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 43 // "value": "CAMERA_RASPBERRY_PI"
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 44 // },
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 45 //
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 46 // Requirements
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 47 // RZ/A2M Evaluation Board Kit : Display Output Board
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 48 // SBEV-RZ/A2M : LVDS To HDMI Board
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 49 // SEMB1402 : LVDS To HDMI Board
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 50
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 51 #if !defined(TARGET_RZ_A2XX)
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 52 #error "DRP and MIPI are not supported."
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 53 #endif
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 54 #if MBED_CONF_APP_CAMERA_TYPE != CAMERA_RASPBERRY_PI
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 55 #error Please set the value of "camera-type" in "mbed_app.json" to "CAMERA_RASPBERRY_PI" and build.
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 56 #endif
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 57
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 58 #include "mbed.h"
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 59 #include "EasyAttach_CameraAndLCD.h"
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 60 #include "AsciiFont.h"
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 61 #include "r_dk2_if.h"
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 62 #include "r_drp_simple_isp.h"
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 63
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 64 /*! Frame buffer stride: Frame buffer stride should be set to a multiple of 32 or 128
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 65 in accordance with the frame buffer burst transfer mode. */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 66 #define VIDEO_PIXEL_HW LCD_PIXEL_WIDTH
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 67 #define VIDEO_PIXEL_VW LCD_PIXEL_HEIGHT
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 68
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 69 #define FRAME_BUFFER_STRIDE (((VIDEO_PIXEL_HW * 1) + 31u) & ~31u)
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 70 #define FRAME_BUFFER_STRIDE_2 (((VIDEO_PIXEL_HW * 2) + 31u) & ~31u)
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 71 #define FRAME_BUFFER_HEIGHT (VIDEO_PIXEL_VW)
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 72
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 73 #define OVL_WIDTH (AsciiFont::CHAR_PIX_WIDTH * 2 * 11)
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 74 #define OVL_STRIDE (((OVL_WIDTH * 1) + 31u) & ~31u)
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 75 #define OVL_HEIGHT (AsciiFont::CHAR_PIX_HEIGHT * 2)
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 76
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 77 #define DRP_FLG_CAMER_IN (0x00000100)
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 78
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 79 #define WB_DAYLIGHT (0)
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 80 #define WB_CLOUDY (1)
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 81 #define WB_FLUORESCENT (2)
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 82 #define WB_TUNGSTEN (3)
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 83
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 84 static DisplayBase Display;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 85 static uint8_t fbuf_bayer[FRAME_BUFFER_STRIDE * FRAME_BUFFER_HEIGHT]__attribute((aligned(128)));
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 86 static uint8_t fbuf_yuv[FRAME_BUFFER_STRIDE_2 * FRAME_BUFFER_HEIGHT]__attribute((aligned(32)));
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 87 static uint8_t fbuf_overlay[OVL_STRIDE * OVL_HEIGHT]__attribute((section("NC_BSS"),aligned(32)));
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 88
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 89 static r_drp_simple_isp_t param_isp __attribute((section("NC_BSS")));
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 90 static uint8_t drp_lib_id[R_DK2_TILE_NUM] = {0};
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 91 static Thread drpTask(osPriorityHigh);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 92 static uint32_t isp_wb_mode_req;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 93 static uint32_t isp_wb_mode;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 94
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 95 static const uint32_t clut_data_resut[] = {0x00000000, 0xff00ff00}; // ARGB8888
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 96
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 97 static void IntCallbackFunc_Vfield(DisplayBase::int_type_t int_type) {
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 98 drpTask.flags_set(DRP_FLG_CAMER_IN);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 99 }
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 100
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 101 static void cb_drp_finish(uint8_t id) {
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 102 // do nothing
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 103 }
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 104
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 105 static void Start_Video_Camera(void) {
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 106 // Video capture setting (progressive form fixed)
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 107 Display.Video_Write_Setting(
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 108 DisplayBase::VIDEO_INPUT_CHANNEL_0,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 109 DisplayBase::COL_SYS_NTSC_358,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 110 (void *)fbuf_bayer,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 111 FRAME_BUFFER_STRIDE,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 112 DisplayBase::VIDEO_FORMAT_RAW8,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 113 DisplayBase::WR_RD_WRSWA_NON,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 114 VIDEO_PIXEL_VW,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 115 VIDEO_PIXEL_HW
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 116 );
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 117 EasyAttach_CameraStart(Display, DisplayBase::VIDEO_INPUT_CHANNEL_0);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 118 }
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 119
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 120 static void Start_LCD_Display(void) {
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 121 DisplayBase::rect_t rect;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 122 DisplayBase::clut_t clut_param;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 123
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 124 rect.vs = 0;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 125 rect.vw = VIDEO_PIXEL_VW;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 126 rect.hs = 0;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 127 rect.hw = VIDEO_PIXEL_HW;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 128 Display.Graphics_Read_Setting(
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 129 DisplayBase::GRAPHICS_LAYER_0,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 130 (void *)fbuf_yuv,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 131 FRAME_BUFFER_STRIDE_2,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 132 DisplayBase::GRAPHICS_FORMAT_YCBCR422,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 133 DisplayBase::WR_RD_WRSWA_32_16_8BIT,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 134 &rect
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 135 );
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 136 Display.Graphics_Start(DisplayBase::GRAPHICS_LAYER_0);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 137
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 138 memset(fbuf_overlay, 0, sizeof(fbuf_overlay));
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 139 clut_param.color_num = sizeof(clut_data_resut) / sizeof(uint32_t);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 140 clut_param.clut = clut_data_resut;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 141
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 142 rect.vs = 5;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 143 rect.vw = OVL_HEIGHT;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 144 rect.hs = 5;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 145 rect.hw = OVL_WIDTH;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 146 Display.Graphics_Read_Setting(
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 147 DisplayBase::GRAPHICS_LAYER_2,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 148 (void *)fbuf_overlay,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 149 OVL_STRIDE,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 150 DisplayBase::GRAPHICS_FORMAT_CLUT8,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 151 DisplayBase::WR_RD_WRSWA_32_16_8BIT,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 152 &rect,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 153 &clut_param
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 154 );
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 155 Display.Graphics_Start(DisplayBase::GRAPHICS_LAYER_2);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 156
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 157 ThisThread::sleep_for(50);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 158 EasyAttach_LcdBacklight(true);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 159 }
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 160
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 161 static void button_fall(void) {
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 162 if (isp_wb_mode_req < WB_TUNGSTEN) {
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 163 isp_wb_mode_req++;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 164 } else {
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 165 isp_wb_mode_req = WB_DAYLIGHT;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 166 }
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 167 }
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 168
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 169 static void drp_task(void) {
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 170 AsciiFont ascii_font(fbuf_overlay, OVL_WIDTH, OVL_HEIGHT, OVL_STRIDE, 1);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 171 char str[64];
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 172
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 173 EasyAttach_Init(Display);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 174 Start_LCD_Display();
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 175 // Interrupt callback function setting (Field end signal for recording function in scaler 0)
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 176 Display.Graphics_Irq_Handler_Set(DisplayBase::INT_TYPE_S0_VFIELD, 0, IntCallbackFunc_Vfield);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 177 Start_Video_Camera();
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 178
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 179 R_DK2_Initialize();
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 180
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 181 /* Load DRP Library */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 182 /* +-----------------------+ */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 183 /* tile 0 | | */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 184 /* + + */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 185 /* tile 1 | | */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 186 /* + + */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 187 /* tile 2 | | */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 188 /* + SimpleIsp bayer2yuv_6 + */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 189 /* tile 3 | | */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 190 /* + + */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 191 /* tile 4 | | */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 192 /* + + */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 193 /* tile 5 | | */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 194 /* +-----------------------+ */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 195 R_DK2_Load(g_drp_lib_simple_isp_bayer2yuv_6,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 196 R_DK2_TILE_0,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 197 R_DK2_TILE_PATTERN_6, NULL, &cb_drp_finish, drp_lib_id);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 198 R_DK2_Activate(0, 0);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 199
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 200 memset(&param_isp, 0, sizeof(param_isp));
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 201 param_isp.src = (uint32_t)fbuf_bayer;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 202 param_isp.dst = (uint32_t)fbuf_yuv;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 203 param_isp.width = VIDEO_PIXEL_HW;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 204 param_isp.height = VIDEO_PIXEL_VW;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 205 param_isp.gain_r = 0x1266;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 206 param_isp.gain_g = 0x0CB0;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 207 param_isp.gain_b = 0x1359;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 208
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 209 isp_wb_mode_req = WB_DAYLIGHT;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 210 isp_wb_mode = WB_DAYLIGHT;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 211 sprintf(str, "Daylight");
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 212 ascii_font.DrawStr(str, 0, 0 + (AsciiFont::CHAR_PIX_HEIGHT + 1) * 0, 1, 2);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 213
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 214 InterruptIn button(USER_BUTTON0);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 215 button.fall(&button_fall);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 216
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 217 while (true) {
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 218 ThisThread::flags_wait_all(DRP_FLG_CAMER_IN);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 219 if (isp_wb_mode_req != isp_wb_mode) {
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 220 isp_wb_mode = isp_wb_mode_req;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 221 switch (isp_wb_mode) {
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 222 case WB_DAYLIGHT:
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 223 param_isp.gain_r = 0x1266;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 224 param_isp.gain_g = 0x0CB0;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 225 param_isp.gain_b = 0x1359;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 226 sprintf(str, "Daylight");
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 227 break;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 228 case WB_CLOUDY:
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 229 param_isp.gain_r = 0x1400;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 230 param_isp.gain_g = 0x0CB0;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 231 param_isp.gain_b = 0x11CA;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 232 sprintf(str, "Cloudy");
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 233 break;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 234 case WB_FLUORESCENT:
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 235 param_isp.gain_r = 0x1000;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 236 param_isp.gain_g = 0x0CB0;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 237 param_isp.gain_b = 0x163D;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 238 sprintf(str, "Fluorescent");
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 239 break;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 240 case WB_TUNGSTEN:
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 241 param_isp.gain_r = 0x0E66;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 242 param_isp.gain_g = 0x0CB0;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 243 param_isp.gain_b = 0x1876;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 244 sprintf(str, "Tungsten");
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 245 break;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 246 }
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 247 memset(fbuf_overlay, 0, sizeof(fbuf_overlay));
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 248 ascii_font.DrawStr(str, 0, 0 + (AsciiFont::CHAR_PIX_HEIGHT + 1) * 0, 1, 2);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 249 }
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 250 R_DK2_Start(drp_lib_id[0], (void *)&param_isp, sizeof(r_drp_simple_isp_t));
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 251 }
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 252 }
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 253
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 254 int main(void) {
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 255
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 256 // Start DRP task
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 257 drpTask.start(callback(drp_task));
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 258
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 259 ThisThread::sleep_for(osWaitForever);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 260 }
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 261
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 262 #endif