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:
4:2da9e0f275a1
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
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 26 #if (SAMPLE_PROGRAM_NO == 19)
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 27 // SAMPLE_PROGRAM_NO 19 : MIPI, DRP and USBSerial (CDC) sample (use "DisplayApp")
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 28 // If you want to know more about SimpleIsp, please refer to: https://github.com/d-kato/RZ_A2M_WebCamera_MIPI
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 29 //
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 30 // Converts the input image from MIPI camera to YUV image using DRP and outputs to PC display using DisplayApp.
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 31 // DisplayApp (Image display on PC display with USB connection)
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 32 // https://github.com/d-kato/mbed-gr-libs#displayapp-image-display-on-pc-display-with-usb-connection
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 33 // Please refer to the document for details. (RZ_A2M_Mbed\drp-for-mbed\r_drp\doc),
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 34 //
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 35 // Please set the value of "camera-type" in "mbed_app.json" to "CAMERA_RASPBERRY_PI".
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 36 //
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 37 // "camera-type":{
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 38 // "help": "Please see EasyAttach_CameraAndLCD/README.md",
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 39 // "value": "CAMERA_RASPBERRY_PI"
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 40 // },
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 41 // [Attention!] Delete the "OVERRIDE_CONSOLE_USBSERIAL" macro in "mbed_app.json" file if it is set.
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 42
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 43 #if !defined(TARGET_RZ_A2XX)
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 44 #error "DRP and MIPI are not supported."
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 45 #endif
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 46 #if MBED_CONF_APP_CAMERA_TYPE != CAMERA_RASPBERRY_PI
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 47 #error Please set the value of "camera-type" in "mbed_app.json" to "CAMERA_RASPBERRY_PI" and build.
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 48 #endif
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 49
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 50 #include "mbed.h"
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 51 #include "EasyAttach_CameraAndLCD.h"
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 52 #include "AsciiFont.h"
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 53 #include "r_dk2_if.h"
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 54 #include "r_drp_simple_isp.h"
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 55 #include "JPEG_Converter.h"
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 56 #include "DisplayApp.h"
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 57 #include "dcache-control.h"
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 58
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 59 /*! Frame buffer stride: Frame buffer stride should be set to a multiple of 32 or 128
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 60 in accordance with the frame buffer burst transfer mode. */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 61 #define VIDEO_PIXEL_HW (640)
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 62 #define VIDEO_PIXEL_VW (480)
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 63
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 64 #define FRAME_BUFFER_STRIDE (((VIDEO_PIXEL_HW * 1) + 31u) & ~31u)
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 65 #define FRAME_BUFFER_STRIDE_2 (((VIDEO_PIXEL_HW * 2) + 31u) & ~31u)
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 66 #define FRAME_BUFFER_HEIGHT (VIDEO_PIXEL_VW)
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 67
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 68 #define DRP_FLG_TILE_ALL (R_DK2_TILE_0 | R_DK2_TILE_1 | R_DK2_TILE_2 | R_DK2_TILE_3 | R_DK2_TILE_4 | R_DK2_TILE_5)
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 69 #define DRP_FLG_CAMER_IN (0x00000100)
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 70
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 71 #define WB_DAYLIGHT (0)
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 72 #define WB_CLOUDY (1)
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 73 #define WB_FLUORESCENT (2)
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 74 #define WB_TUNGSTEN (3)
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 75
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 76 static DisplayBase Display;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 77 static uint8_t fbuf_bayer[FRAME_BUFFER_STRIDE * FRAME_BUFFER_HEIGHT]__attribute((aligned(128)));
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 78 static uint8_t fbuf_yuv[FRAME_BUFFER_STRIDE_2 * FRAME_BUFFER_HEIGHT]__attribute((aligned(32)));
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 79 static uint8_t JpegBuffer[1024 * 64]__attribute((aligned(32)));
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 80 static DisplayApp display_app;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 81
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 82 static r_drp_simple_isp_t param_isp __attribute((section("NC_BSS")));
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 83 static uint8_t drp_lib_id[R_DK2_TILE_NUM] = {0};
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 84 static Thread drpTask(osPriorityHigh);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 85 static uint32_t isp_wb_mode_req;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 86 static uint32_t isp_wb_mode;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 87
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 88 static const uint32_t clut_data_resut[] = {0x00000000, 0xff00ff00}; // ARGB8888
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 89
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 90 static void IntCallbackFunc_Vfield(DisplayBase::int_type_t int_type) {
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 91 drpTask.flags_set(DRP_FLG_CAMER_IN);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 92 }
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 93
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 94 static void cb_drp_finish(uint8_t id) {
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 95 uint32_t tile_no;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 96 uint32_t set_flgs = 0;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 97
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 98 // Change the operation state of the DRP library notified by the argument to finish
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 99 for (tile_no = 0; tile_no < R_DK2_TILE_NUM; tile_no++) {
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 100 if (drp_lib_id[tile_no] == id) {
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 101 set_flgs |= (1 << tile_no);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 102 }
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 103 }
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 104 drpTask.flags_set(set_flgs);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 105 }
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 106
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 107 static void Start_Video_Camera(void) {
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 108 // Video capture setting (progressive form fixed)
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 109 Display.Video_Write_Setting(
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 110 DisplayBase::VIDEO_INPUT_CHANNEL_0,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 111 DisplayBase::COL_SYS_NTSC_358,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 112 (void *)fbuf_bayer,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 113 FRAME_BUFFER_STRIDE,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 114 DisplayBase::VIDEO_FORMAT_RAW8,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 115 DisplayBase::WR_RD_WRSWA_NON,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 116 VIDEO_PIXEL_VW,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 117 VIDEO_PIXEL_HW
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 118 );
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 119 EasyAttach_CameraStart(Display, DisplayBase::VIDEO_INPUT_CHANNEL_0);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 120 }
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 121
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 122 static void button_fall(void) {
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 123 if (isp_wb_mode_req < WB_TUNGSTEN) {
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 124 isp_wb_mode_req++;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 125 } else {
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 126 isp_wb_mode_req = WB_DAYLIGHT;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 127 }
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 128 }
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 129
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 130 static void drp_task(void) {
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 131 JPEG_Converter Jcu;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 132 JPEG_Converter::bitmap_buff_info_t bitmap_buff_info;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 133 JPEG_Converter::encode_options_t encode_options;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 134 size_t encode_size;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 135
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 136 EasyAttach_Init(Display);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 137 // Interrupt callback function setting (Field end signal for recording function in scaler 0)
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 138 Display.Graphics_Irq_Handler_Set(DisplayBase::INT_TYPE_S0_VFIELD, 0, IntCallbackFunc_Vfield);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 139 Start_Video_Camera();
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 140
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 141 R_DK2_Initialize();
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 142
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 143 /* Load DRP Library */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 144 /* +-----------------------+ */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 145 /* tile 0 | | */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 146 /* + + */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 147 /* tile 1 | | */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 148 /* + + */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 149 /* tile 2 | | */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 150 /* + SimpleIsp bayer2yuv_6 + */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 151 /* tile 3 | | */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 152 /* + + */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 153 /* tile 4 | | */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 154 /* + + */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 155 /* tile 5 | | */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 156 /* +-----------------------+ */
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 157 R_DK2_Load(g_drp_lib_simple_isp_bayer2yuv_6,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 158 R_DK2_TILE_0,
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 159 R_DK2_TILE_PATTERN_6, NULL, &cb_drp_finish, drp_lib_id);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 160 R_DK2_Activate(0, 0);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 161
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 162 memset(&param_isp, 0, sizeof(param_isp));
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 163 param_isp.src = (uint32_t)fbuf_bayer;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 164 param_isp.dst = (uint32_t)fbuf_yuv;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 165 param_isp.width = VIDEO_PIXEL_HW;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 166 param_isp.height = VIDEO_PIXEL_VW;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 167 param_isp.gain_r = 0x1266;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 168 param_isp.gain_g = 0x0CB0;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 169 param_isp.gain_b = 0x1359;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 170
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 171 isp_wb_mode_req = WB_DAYLIGHT;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 172 isp_wb_mode = WB_DAYLIGHT;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 173
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 174 InterruptIn button(USER_BUTTON0);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 175 button.fall(&button_fall);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 176
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 177 bitmap_buff_info.width = VIDEO_PIXEL_HW;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 178 bitmap_buff_info.height = VIDEO_PIXEL_VW;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 179 bitmap_buff_info.format = JPEG_Converter::WR_RD_YCbCr422;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 180 bitmap_buff_info.buffer_address = (void *)fbuf_yuv;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 181 encode_options.encode_buff_size = sizeof(JpegBuffer);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 182 encode_options.input_swapsetting = JPEG_Converter::WR_RD_WRSWA_32_16BIT;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 183
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 184 while (true) {
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 185 ThisThread::flags_wait_all(DRP_FLG_CAMER_IN);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 186 if (isp_wb_mode_req != isp_wb_mode) {
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 187 isp_wb_mode = isp_wb_mode_req;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 188 switch (isp_wb_mode) {
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 189 case WB_DAYLIGHT:
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 190 param_isp.gain_r = 0x1266;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 191 param_isp.gain_g = 0x0CB0;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 192 param_isp.gain_b = 0x1359;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 193 break;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 194 case WB_CLOUDY:
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 195 param_isp.gain_r = 0x1400;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 196 param_isp.gain_g = 0x0CB0;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 197 param_isp.gain_b = 0x11CA;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 198 break;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 199 case WB_FLUORESCENT:
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 200 param_isp.gain_r = 0x1000;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 201 param_isp.gain_g = 0x0CB0;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 202 param_isp.gain_b = 0x163D;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 203 break;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 204 case WB_TUNGSTEN:
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 205 param_isp.gain_r = 0x0E66;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 206 param_isp.gain_g = 0x0CB0;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 207 param_isp.gain_b = 0x1876;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 208 break;
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 209 }
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 210 }
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 211 R_DK2_Start(drp_lib_id[0], (void *)&param_isp, sizeof(r_drp_simple_isp_t));
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 212
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 213 ThisThread::flags_wait_all(DRP_FLG_TILE_ALL);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 214 dcache_invalid(JpegBuffer, sizeof(JpegBuffer));
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 215 if (Jcu.encode(&bitmap_buff_info, JpegBuffer, &encode_size, &encode_options) == JPEG_Converter::JPEG_CONV_OK) {
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 216 display_app.SendJpeg(JpegBuffer, (int)encode_size);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 217 }
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 218 }
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 219 }
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 220
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 221 int main(void) {
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 222 // Start DRP task
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 223 drpTask.start(callback(drp_task));
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 224
RyoheiHagimoto@os.mbed.com 4:2da9e0f275a1 225 ThisThread::sleep_for(osWaitForever);
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 226 }
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 227
RyoheiHagimoto@os.mbed.com 1:13d09ce5b51a 228 #endif