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 file | Description |
---|---|---|
0 | sample_00_led_rtc_analogin.cpp | DigitalOut, InterruptIn, RTC, Timer and AnalogIn |
1 | sample_01_flash_write.cpp | FlashAPI sample |
2 | sample_02_ssif_loop_back.cpp | SSIF loop back sample |
4 | sample_04_ssif_wav_playback.cpp | SSIF wav playback sample (use USB memory or SD card) |
7 | sample_07_usb_func_serial.cpp | USBSerial (CDC) sample |
8 | sample_08_usb_func_mouse.cpp | USBMouse sample |
9 | sample_09_usb_func_keyboard.cpp | USBKeyboard sample |
10 | sample_10_usb_func_midi.cpp | USBMIDI sample |
11 | sample_11_usb_func_audio_1.cpp | USBAudio sample |
12 | sample_12_usb_func_audio_2.cpp | USBAudio and SSIF sample |
13 | sample_13_ether_http.cpp | Ether HTTP sample |
14 | sample_14_ether_https.cpp | Ether HTTPS sample |
16 | sample_16_usb_func_msd_1.cpp | USBMSD and FlashAPI sample |
17 | sample_17_usb_func_msd_2.cpp | USBMSD and FlashAPI sample advanced version |
18 | sample_18_mipi_drp_lcd.cpp | MIPI, DRP and LCD sample |
19 | sample_19_mipi_drp_diplayapp.cpp | MIPI, DRP and USBSerial (CDC) sample (use "DisplayApp") |
20 | sample_20_drp_dynamic_loading.cpp | DRP Dynamic Loading Sample |
21 | sample_21_deep_standby_alarm.cpp | Deep standby and RTC alarm sample |
22 | sample_22_hdmi_disp_ssif.cpp | HDMI output and SSIF wav playback Sample |
23 | sample_23_mipi_hdmi.cpp | HDMI output and MIPI Sample |
24 | sample_24_facedetection.cpp | HDMI output and face detection using OpenCV |
25 | sample_25_hdmi_mouse.cpp | HDMI 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.
- Connect the
micro USB type B terminal
to the PC using a USB cable. - You can find the
MBED
directory. - Drag & drop
xxxx.bin
to theMBED
directory. - When writing is completed, press the reset button.
When using custom bootloader
, please use xxxx_application.bin
as following.
- Connect the
USB type C terminal
to the PC using a USB cable. - Hold down
USB0
and press the reset button. - You can find the
GR-MANG
directory. - 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 rate | 115,200 |
Data | 8bit |
Parity | none |
Stop | 1bit |
Flow control | none |
sample_programs/sample_05_spdif_wav_playback.cpp@1:13d09ce5b51a, 2020-09-15 (annotated)
- Committer:
- RyoheiHagimoto@os.mbed.com
- Date:
- Tue Sep 15 10:28:22 2020 +0900
- Revision:
- 1:13d09ce5b51a
Copied from https://github.com/renesas-rz/RZ_A2M_Mbed_samples.
Who changed what in which revision?
User | Revision | Line number | New 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 == 5) |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 27 | // SAMPLE_PROGRAM_NO 5 : SPDIF wav playback sample (use USB memory or SD card) |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 28 | // |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 29 | // This sample will play a ".wav" file of the SD root folder. |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 30 | // Wav file format : RIFF format, 1ch or 2ch, 44.1kHz, 16bits |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 31 | // In case of SAMPLE_PROGRAM_NO=5 : |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 32 | // Since TARGET_RZ_A2M_EVB has no connector and no suitable AUDIO_CLK has been entered, only pseudo-evaluation is executed. |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 33 | // - Audio data is output from the PC_5 terminal. |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 34 | // - Since AUDIO_CLK on the board is 11.2896 MHz, it operates at half the actual speed. |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 35 | // - The AUDIO_CLK frequency required is 512 times as large as the sample frequency for audio data. |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 36 | // (fs=44.1kHz : AUDIO_CLK=22.5792MHz, fs=48kHz : AUDIO_CLK=24.5760MHz) |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 37 | |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 38 | #if !defined(TARGET_RZ_A2M_EVB) |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 39 | #error "SPDIF is not supported." |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 40 | #endif |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 41 | |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 42 | #include "mbed.h" |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 43 | #include "FATFileSystem.h" |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 44 | #include "SdUsbConnect.h" |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 45 | #include "EasyPlayback.h" |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 46 | #include "EasyDec_WavCnv2ch.h" |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 47 | |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 48 | static EasyPlayback AudioPlayer(EasyPlayback::AUDIO_TPYE_SPDIF); |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 49 | |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 50 | #define FILE_NAME_LEN (64) |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 51 | #define MOUNT_NAME "storage" |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 52 | |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 53 | static InterruptIn skip_btn(USER_BUTTON0); |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 54 | |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 55 | static void skip_btn_fall(void) { |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 56 | AudioPlayer.skip(); |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 57 | } |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 58 | |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 59 | int main() { |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 60 | DIR * d; |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 61 | struct dirent * p; |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 62 | char file_path[sizeof("/" MOUNT_NAME "/") + FILE_NAME_LEN]; |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 63 | SdUsbConnect storage(MOUNT_NAME); |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 64 | |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 65 | // decoder setting |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 66 | AudioPlayer.add_decoder<EasyDec_WavCnv2ch>(".wav"); |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 67 | AudioPlayer.add_decoder<EasyDec_WavCnv2ch>(".WAV"); |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 68 | |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 69 | // button setting |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 70 | skip_btn.fall(&skip_btn_fall); |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 71 | |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 72 | while (1) { |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 73 | // connect wait |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 74 | storage.wait_connect(); |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 75 | |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 76 | // file search |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 77 | d = opendir("/" MOUNT_NAME "/"); |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 78 | if (d != NULL) { |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 79 | while ((p = readdir(d)) != NULL) { |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 80 | size_t len = strlen(p->d_name); |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 81 | if (len < FILE_NAME_LEN) { |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 82 | // make file path |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 83 | sprintf(file_path, "/%s/%s", MOUNT_NAME, p->d_name); |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 84 | printf("%s\r\n", file_path); |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 85 | |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 86 | // playback |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 87 | AudioPlayer.play(file_path); |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 88 | } |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 89 | } |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 90 | closedir(d); |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 91 | } |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 92 | } |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 93 | } |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 94 | |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 95 | #endif |