GR-MANGO sample using mbed-os library from my repository.
sample_programs/sample_22_hdmi_disp_ssif.cpp
- Committer:
- RyoheiHagimoto
- Date:
- 2020-10-12
- Revision:
- 0:b4c1e32627f2
File content as of revision 0:b4c1e32627f2:
/*******************************************************************************
* DISCLAIMER
* This software is supplied by Renesas Electronics Corporation and is only
* intended for use with Renesas products. No other uses are authorized. This
* software is owned by Renesas Electronics Corporation and is protected under
* all applicable laws, including copyright laws.
* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
* Renesas reserves the right, without notice, to make changes to this software
* and to discontinue the availability of this software. By using this software,
* you agree to the additional terms and conditions found by accessing the
* following link:
* http://www.renesas.com/disclaimer
*
* Copyright (C) 2019 Renesas Electronics Corporation. All rights reserved.
*******************************************************************************/
#include "sample_select.h"
#if (SAMPLE_PROGRAM_NO == 22)
// SAMPLE_PROGRAM_NO 22 : HDMI output & SSIF wav playback Sample
//
// Requirements
// RZ/A2M Evaluation Board Kit : Display Output Board
// SBEV-RZ/A2M : LVDS To HDMI Board
// SEMB1402 : LVDS To HDMI Board
#if defined(TARGET_SEMB1402) || defined(TARGET_RZ_A2M_SBEV)
#error "Audio is not supported."
#endif
#include "mbed.h"
#include "FATFileSystem.h"
#include "SdUsbConnect.h"
#include "EasyPlayback.h"
#include "EasyDec_WavCnv2ch.h"
#include "EasyAttach_CameraAndLCD.h"
#include "dcache-control.h"
#include "AsciiFont.h"
static EasyPlayback AudioPlayer;
#define FILE_NAME_LEN (64)
#define MOUNT_NAME "storage"
static InterruptIn skip_btn(USER_BUTTON0);
static void skip_btn_fall(void) {
AudioPlayer.skip();
}
/*! Frame buffer stride: Frame buffer stride should be set to a multiple of 32 or 128
in accordance with the frame buffer burst transfer mode. */
#define VIDEO_PIXEL_HW (640)
#define VIDEO_PIXEL_VW (480)
#define DATA_SIZE_PER_PIC (1u)
#define FRAME_BUFFER_STRIDE (((VIDEO_PIXEL_HW * DATA_SIZE_PER_PIC) + 31u) & ~31u)
#define FRAME_BUFFER_HEIGHT (VIDEO_PIXEL_VW)
#define DRP_FLG_CAMER_IN (0x00000100)
static DisplayBase Display;
static uint8_t fbuf_clat8[FRAME_BUFFER_STRIDE * FRAME_BUFFER_HEIGHT]__attribute((aligned(32)));
static uint8_t fbuf_overlay[FRAME_BUFFER_STRIDE * FRAME_BUFFER_HEIGHT]__attribute((section("NC_BSS"),aligned(32)));
static Thread drpTask(osPriorityHigh);
static Thread hdmiTask(osPriorityHigh);
static const uint32_t clut_data_resut[] = {0x00000000, 0xff00ff00}; // ARGB8888
static void IntCallbackFunc_Vfield(DisplayBase::int_type_t int_type) {
drpTask.flags_set(DRP_FLG_CAMER_IN);
}
static void Start_LCD_Display(void) {
DisplayBase::rect_t rect;
DisplayBase::clut_t clut_param;
rect.vs = 0;
rect.vw = VIDEO_PIXEL_VW;
rect.hs = 0;
rect.hw = VIDEO_PIXEL_HW;
Display.Graphics_Read_Setting(
DisplayBase::GRAPHICS_LAYER_0,
(void *)fbuf_clat8,
FRAME_BUFFER_STRIDE,
DisplayBase::GRAPHICS_FORMAT_CLUT8,
DisplayBase::WR_RD_WRSWA_32_16_8BIT,
&rect
);
Display.Graphics_Start(DisplayBase::GRAPHICS_LAYER_0);
memset(fbuf_overlay, 0, sizeof(fbuf_overlay));
clut_param.color_num = sizeof(clut_data_resut) / sizeof(uint32_t);
clut_param.clut = clut_data_resut;
rect.vs = 0;
rect.vw = VIDEO_PIXEL_VW;
rect.hs = 0;
rect.hw = VIDEO_PIXEL_HW;
Display.Graphics_Read_Setting(
DisplayBase::GRAPHICS_LAYER_2,
(void *)fbuf_overlay,
FRAME_BUFFER_STRIDE,
DisplayBase::GRAPHICS_FORMAT_CLUT8,
DisplayBase::WR_RD_WRSWA_32_16_8BIT,
&rect,
&clut_param
);
Display.Graphics_Start(DisplayBase::GRAPHICS_LAYER_2);
ThisThread::sleep_for(50);
EasyAttach_LcdBacklight(true);
}
static void drp_task(void) {
int i = 0;
char str[64];
AsciiFont ascii_font(fbuf_overlay, VIDEO_PIXEL_HW, VIDEO_PIXEL_VW, FRAME_BUFFER_STRIDE, DATA_SIZE_PER_PIC);
EasyAttach_Init(Display);
Start_LCD_Display();
// Interrupt callback function setting (Field end signal for recording function in scaler 0)
Display.Graphics_Irq_Handler_Set(DisplayBase::INT_TYPE_S0_VFIELD, 0, IntCallbackFunc_Vfield);
while (true) {
sprintf(str, "HDMI TEST %d", i);
ascii_font.DrawStr(str, 5, 5 + (AsciiFont::CHAR_PIX_HEIGHT + 1) * 0, 1, 2);
i++;
ThisThread::sleep_for(1000);
}
}
int main(void) {
DIR * d;
struct dirent * p;
char file_path[sizeof("/" MOUNT_NAME "/") + FILE_NAME_LEN];
SdUsbConnect storage(MOUNT_NAME);
// Start DRP task
drpTask.start(callback(drp_task));
// decoder setting
AudioPlayer.add_decoder<EasyDec_WavCnv2ch>(".wav");
AudioPlayer.add_decoder<EasyDec_WavCnv2ch>(".WAV");
AudioPlayer.outputVolume(0.5);
// button setting
skip_btn.fall(&skip_btn_fall);
while (1) {
// connect wait
storage.wait_connect();
// file search
d = opendir("/" MOUNT_NAME "/");
if (d != NULL) {
while ((p = readdir(d)) != NULL) {
size_t len = strlen(p->d_name);
if (len < FILE_NAME_LEN) {
// make file path
sprintf(file_path, "/%s/%s", MOUNT_NAME, p->d_name);
printf("%s\r\n", file_path);
// playback
AudioPlayer.play(file_path);
}
}
closedir(d);
}
}
}
#endif