GR-MANGO sample using mbed-os library from my repository.
sample_programs/sample_22_hdmi_disp_ssif.cpp@0:b4c1e32627f2, 2020-10-12 (annotated)
- Committer:
- RyoheiHagimoto
- Date:
- Mon Oct 12 02:25:49 2020 +0000
- Revision:
- 0:b4c1e32627f2
replaced mbed-os library
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| RyoheiHagimoto | 0:b4c1e32627f2 | 1 | /******************************************************************************* |
| RyoheiHagimoto | 0:b4c1e32627f2 | 2 | * DISCLAIMER |
| RyoheiHagimoto | 0:b4c1e32627f2 | 3 | * This software is supplied by Renesas Electronics Corporation and is only |
| RyoheiHagimoto | 0:b4c1e32627f2 | 4 | * intended for use with Renesas products. No other uses are authorized. This |
| RyoheiHagimoto | 0:b4c1e32627f2 | 5 | * software is owned by Renesas Electronics Corporation and is protected under |
| RyoheiHagimoto | 0:b4c1e32627f2 | 6 | * all applicable laws, including copyright laws. |
| RyoheiHagimoto | 0:b4c1e32627f2 | 7 | * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING |
| RyoheiHagimoto | 0:b4c1e32627f2 | 8 | * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT |
| RyoheiHagimoto | 0:b4c1e32627f2 | 9 | * LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE |
| RyoheiHagimoto | 0:b4c1e32627f2 | 10 | * AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. |
| RyoheiHagimoto | 0:b4c1e32627f2 | 11 | * TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS |
| RyoheiHagimoto | 0:b4c1e32627f2 | 12 | * ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE |
| RyoheiHagimoto | 0:b4c1e32627f2 | 13 | * FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR |
| RyoheiHagimoto | 0:b4c1e32627f2 | 14 | * ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE |
| RyoheiHagimoto | 0:b4c1e32627f2 | 15 | * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. |
| RyoheiHagimoto | 0:b4c1e32627f2 | 16 | * Renesas reserves the right, without notice, to make changes to this software |
| RyoheiHagimoto | 0:b4c1e32627f2 | 17 | * and to discontinue the availability of this software. By using this software, |
| RyoheiHagimoto | 0:b4c1e32627f2 | 18 | * you agree to the additional terms and conditions found by accessing the |
| RyoheiHagimoto | 0:b4c1e32627f2 | 19 | * following link: |
| RyoheiHagimoto | 0:b4c1e32627f2 | 20 | * http://www.renesas.com/disclaimer |
| RyoheiHagimoto | 0:b4c1e32627f2 | 21 | * |
| RyoheiHagimoto | 0:b4c1e32627f2 | 22 | * Copyright (C) 2019 Renesas Electronics Corporation. All rights reserved. |
| RyoheiHagimoto | 0:b4c1e32627f2 | 23 | *******************************************************************************/ |
| RyoheiHagimoto | 0:b4c1e32627f2 | 24 | #include "sample_select.h" |
| RyoheiHagimoto | 0:b4c1e32627f2 | 25 | |
| RyoheiHagimoto | 0:b4c1e32627f2 | 26 | #if (SAMPLE_PROGRAM_NO == 22) |
| RyoheiHagimoto | 0:b4c1e32627f2 | 27 | // SAMPLE_PROGRAM_NO 22 : HDMI output & SSIF wav playback Sample |
| RyoheiHagimoto | 0:b4c1e32627f2 | 28 | // |
| RyoheiHagimoto | 0:b4c1e32627f2 | 29 | // Requirements |
| RyoheiHagimoto | 0:b4c1e32627f2 | 30 | // RZ/A2M Evaluation Board Kit : Display Output Board |
| RyoheiHagimoto | 0:b4c1e32627f2 | 31 | // SBEV-RZ/A2M : LVDS To HDMI Board |
| RyoheiHagimoto | 0:b4c1e32627f2 | 32 | // SEMB1402 : LVDS To HDMI Board |
| RyoheiHagimoto | 0:b4c1e32627f2 | 33 | |
| RyoheiHagimoto | 0:b4c1e32627f2 | 34 | #if defined(TARGET_SEMB1402) || defined(TARGET_RZ_A2M_SBEV) |
| RyoheiHagimoto | 0:b4c1e32627f2 | 35 | #error "Audio is not supported." |
| RyoheiHagimoto | 0:b4c1e32627f2 | 36 | #endif |
| RyoheiHagimoto | 0:b4c1e32627f2 | 37 | |
| RyoheiHagimoto | 0:b4c1e32627f2 | 38 | #include "mbed.h" |
| RyoheiHagimoto | 0:b4c1e32627f2 | 39 | #include "FATFileSystem.h" |
| RyoheiHagimoto | 0:b4c1e32627f2 | 40 | #include "SdUsbConnect.h" |
| RyoheiHagimoto | 0:b4c1e32627f2 | 41 | #include "EasyPlayback.h" |
| RyoheiHagimoto | 0:b4c1e32627f2 | 42 | #include "EasyDec_WavCnv2ch.h" |
| RyoheiHagimoto | 0:b4c1e32627f2 | 43 | #include "EasyAttach_CameraAndLCD.h" |
| RyoheiHagimoto | 0:b4c1e32627f2 | 44 | #include "dcache-control.h" |
| RyoheiHagimoto | 0:b4c1e32627f2 | 45 | #include "AsciiFont.h" |
| RyoheiHagimoto | 0:b4c1e32627f2 | 46 | |
| RyoheiHagimoto | 0:b4c1e32627f2 | 47 | static EasyPlayback AudioPlayer; |
| RyoheiHagimoto | 0:b4c1e32627f2 | 48 | |
| RyoheiHagimoto | 0:b4c1e32627f2 | 49 | #define FILE_NAME_LEN (64) |
| RyoheiHagimoto | 0:b4c1e32627f2 | 50 | #define MOUNT_NAME "storage" |
| RyoheiHagimoto | 0:b4c1e32627f2 | 51 | |
| RyoheiHagimoto | 0:b4c1e32627f2 | 52 | static InterruptIn skip_btn(USER_BUTTON0); |
| RyoheiHagimoto | 0:b4c1e32627f2 | 53 | |
| RyoheiHagimoto | 0:b4c1e32627f2 | 54 | static void skip_btn_fall(void) { |
| RyoheiHagimoto | 0:b4c1e32627f2 | 55 | AudioPlayer.skip(); |
| RyoheiHagimoto | 0:b4c1e32627f2 | 56 | } |
| RyoheiHagimoto | 0:b4c1e32627f2 | 57 | |
| RyoheiHagimoto | 0:b4c1e32627f2 | 58 | /*! Frame buffer stride: Frame buffer stride should be set to a multiple of 32 or 128 |
| RyoheiHagimoto | 0:b4c1e32627f2 | 59 | in accordance with the frame buffer burst transfer mode. */ |
| RyoheiHagimoto | 0:b4c1e32627f2 | 60 | #define VIDEO_PIXEL_HW (640) |
| RyoheiHagimoto | 0:b4c1e32627f2 | 61 | #define VIDEO_PIXEL_VW (480) |
| RyoheiHagimoto | 0:b4c1e32627f2 | 62 | |
| RyoheiHagimoto | 0:b4c1e32627f2 | 63 | #define DATA_SIZE_PER_PIC (1u) |
| RyoheiHagimoto | 0:b4c1e32627f2 | 64 | #define FRAME_BUFFER_STRIDE (((VIDEO_PIXEL_HW * DATA_SIZE_PER_PIC) + 31u) & ~31u) |
| RyoheiHagimoto | 0:b4c1e32627f2 | 65 | #define FRAME_BUFFER_HEIGHT (VIDEO_PIXEL_VW) |
| RyoheiHagimoto | 0:b4c1e32627f2 | 66 | |
| RyoheiHagimoto | 0:b4c1e32627f2 | 67 | #define DRP_FLG_CAMER_IN (0x00000100) |
| RyoheiHagimoto | 0:b4c1e32627f2 | 68 | |
| RyoheiHagimoto | 0:b4c1e32627f2 | 69 | static DisplayBase Display; |
| RyoheiHagimoto | 0:b4c1e32627f2 | 70 | static uint8_t fbuf_clat8[FRAME_BUFFER_STRIDE * FRAME_BUFFER_HEIGHT]__attribute((aligned(32))); |
| RyoheiHagimoto | 0:b4c1e32627f2 | 71 | static uint8_t fbuf_overlay[FRAME_BUFFER_STRIDE * FRAME_BUFFER_HEIGHT]__attribute((section("NC_BSS"),aligned(32))); |
| RyoheiHagimoto | 0:b4c1e32627f2 | 72 | static Thread drpTask(osPriorityHigh); |
| RyoheiHagimoto | 0:b4c1e32627f2 | 73 | static Thread hdmiTask(osPriorityHigh); |
| RyoheiHagimoto | 0:b4c1e32627f2 | 74 | |
| RyoheiHagimoto | 0:b4c1e32627f2 | 75 | static const uint32_t clut_data_resut[] = {0x00000000, 0xff00ff00}; // ARGB8888 |
| RyoheiHagimoto | 0:b4c1e32627f2 | 76 | |
| RyoheiHagimoto | 0:b4c1e32627f2 | 77 | static void IntCallbackFunc_Vfield(DisplayBase::int_type_t int_type) { |
| RyoheiHagimoto | 0:b4c1e32627f2 | 78 | drpTask.flags_set(DRP_FLG_CAMER_IN); |
| RyoheiHagimoto | 0:b4c1e32627f2 | 79 | } |
| RyoheiHagimoto | 0:b4c1e32627f2 | 80 | |
| RyoheiHagimoto | 0:b4c1e32627f2 | 81 | static void Start_LCD_Display(void) { |
| RyoheiHagimoto | 0:b4c1e32627f2 | 82 | DisplayBase::rect_t rect; |
| RyoheiHagimoto | 0:b4c1e32627f2 | 83 | DisplayBase::clut_t clut_param; |
| RyoheiHagimoto | 0:b4c1e32627f2 | 84 | |
| RyoheiHagimoto | 0:b4c1e32627f2 | 85 | rect.vs = 0; |
| RyoheiHagimoto | 0:b4c1e32627f2 | 86 | rect.vw = VIDEO_PIXEL_VW; |
| RyoheiHagimoto | 0:b4c1e32627f2 | 87 | rect.hs = 0; |
| RyoheiHagimoto | 0:b4c1e32627f2 | 88 | rect.hw = VIDEO_PIXEL_HW; |
| RyoheiHagimoto | 0:b4c1e32627f2 | 89 | Display.Graphics_Read_Setting( |
| RyoheiHagimoto | 0:b4c1e32627f2 | 90 | DisplayBase::GRAPHICS_LAYER_0, |
| RyoheiHagimoto | 0:b4c1e32627f2 | 91 | (void *)fbuf_clat8, |
| RyoheiHagimoto | 0:b4c1e32627f2 | 92 | FRAME_BUFFER_STRIDE, |
| RyoheiHagimoto | 0:b4c1e32627f2 | 93 | DisplayBase::GRAPHICS_FORMAT_CLUT8, |
| RyoheiHagimoto | 0:b4c1e32627f2 | 94 | DisplayBase::WR_RD_WRSWA_32_16_8BIT, |
| RyoheiHagimoto | 0:b4c1e32627f2 | 95 | &rect |
| RyoheiHagimoto | 0:b4c1e32627f2 | 96 | ); |
| RyoheiHagimoto | 0:b4c1e32627f2 | 97 | Display.Graphics_Start(DisplayBase::GRAPHICS_LAYER_0); |
| RyoheiHagimoto | 0:b4c1e32627f2 | 98 | |
| RyoheiHagimoto | 0:b4c1e32627f2 | 99 | memset(fbuf_overlay, 0, sizeof(fbuf_overlay)); |
| RyoheiHagimoto | 0:b4c1e32627f2 | 100 | clut_param.color_num = sizeof(clut_data_resut) / sizeof(uint32_t); |
| RyoheiHagimoto | 0:b4c1e32627f2 | 101 | clut_param.clut = clut_data_resut; |
| RyoheiHagimoto | 0:b4c1e32627f2 | 102 | |
| RyoheiHagimoto | 0:b4c1e32627f2 | 103 | rect.vs = 0; |
| RyoheiHagimoto | 0:b4c1e32627f2 | 104 | rect.vw = VIDEO_PIXEL_VW; |
| RyoheiHagimoto | 0:b4c1e32627f2 | 105 | rect.hs = 0; |
| RyoheiHagimoto | 0:b4c1e32627f2 | 106 | rect.hw = VIDEO_PIXEL_HW; |
| RyoheiHagimoto | 0:b4c1e32627f2 | 107 | Display.Graphics_Read_Setting( |
| RyoheiHagimoto | 0:b4c1e32627f2 | 108 | DisplayBase::GRAPHICS_LAYER_2, |
| RyoheiHagimoto | 0:b4c1e32627f2 | 109 | (void *)fbuf_overlay, |
| RyoheiHagimoto | 0:b4c1e32627f2 | 110 | FRAME_BUFFER_STRIDE, |
| RyoheiHagimoto | 0:b4c1e32627f2 | 111 | DisplayBase::GRAPHICS_FORMAT_CLUT8, |
| RyoheiHagimoto | 0:b4c1e32627f2 | 112 | DisplayBase::WR_RD_WRSWA_32_16_8BIT, |
| RyoheiHagimoto | 0:b4c1e32627f2 | 113 | &rect, |
| RyoheiHagimoto | 0:b4c1e32627f2 | 114 | &clut_param |
| RyoheiHagimoto | 0:b4c1e32627f2 | 115 | ); |
| RyoheiHagimoto | 0:b4c1e32627f2 | 116 | Display.Graphics_Start(DisplayBase::GRAPHICS_LAYER_2); |
| RyoheiHagimoto | 0:b4c1e32627f2 | 117 | |
| RyoheiHagimoto | 0:b4c1e32627f2 | 118 | ThisThread::sleep_for(50); |
| RyoheiHagimoto | 0:b4c1e32627f2 | 119 | EasyAttach_LcdBacklight(true); |
| RyoheiHagimoto | 0:b4c1e32627f2 | 120 | } |
| RyoheiHagimoto | 0:b4c1e32627f2 | 121 | |
| RyoheiHagimoto | 0:b4c1e32627f2 | 122 | static void drp_task(void) { |
| RyoheiHagimoto | 0:b4c1e32627f2 | 123 | int i = 0; |
| RyoheiHagimoto | 0:b4c1e32627f2 | 124 | char str[64]; |
| RyoheiHagimoto | 0:b4c1e32627f2 | 125 | |
| RyoheiHagimoto | 0:b4c1e32627f2 | 126 | AsciiFont ascii_font(fbuf_overlay, VIDEO_PIXEL_HW, VIDEO_PIXEL_VW, FRAME_BUFFER_STRIDE, DATA_SIZE_PER_PIC); |
| RyoheiHagimoto | 0:b4c1e32627f2 | 127 | |
| RyoheiHagimoto | 0:b4c1e32627f2 | 128 | EasyAttach_Init(Display); |
| RyoheiHagimoto | 0:b4c1e32627f2 | 129 | Start_LCD_Display(); |
| RyoheiHagimoto | 0:b4c1e32627f2 | 130 | // Interrupt callback function setting (Field end signal for recording function in scaler 0) |
| RyoheiHagimoto | 0:b4c1e32627f2 | 131 | Display.Graphics_Irq_Handler_Set(DisplayBase::INT_TYPE_S0_VFIELD, 0, IntCallbackFunc_Vfield); |
| RyoheiHagimoto | 0:b4c1e32627f2 | 132 | |
| RyoheiHagimoto | 0:b4c1e32627f2 | 133 | while (true) { |
| RyoheiHagimoto | 0:b4c1e32627f2 | 134 | sprintf(str, "HDMI TEST %d", i); |
| RyoheiHagimoto | 0:b4c1e32627f2 | 135 | ascii_font.DrawStr(str, 5, 5 + (AsciiFont::CHAR_PIX_HEIGHT + 1) * 0, 1, 2); |
| RyoheiHagimoto | 0:b4c1e32627f2 | 136 | i++; |
| RyoheiHagimoto | 0:b4c1e32627f2 | 137 | ThisThread::sleep_for(1000); |
| RyoheiHagimoto | 0:b4c1e32627f2 | 138 | } |
| RyoheiHagimoto | 0:b4c1e32627f2 | 139 | } |
| RyoheiHagimoto | 0:b4c1e32627f2 | 140 | |
| RyoheiHagimoto | 0:b4c1e32627f2 | 141 | int main(void) { |
| RyoheiHagimoto | 0:b4c1e32627f2 | 142 | DIR * d; |
| RyoheiHagimoto | 0:b4c1e32627f2 | 143 | struct dirent * p; |
| RyoheiHagimoto | 0:b4c1e32627f2 | 144 | char file_path[sizeof("/" MOUNT_NAME "/") + FILE_NAME_LEN]; |
| RyoheiHagimoto | 0:b4c1e32627f2 | 145 | SdUsbConnect storage(MOUNT_NAME); |
| RyoheiHagimoto | 0:b4c1e32627f2 | 146 | |
| RyoheiHagimoto | 0:b4c1e32627f2 | 147 | // Start DRP task |
| RyoheiHagimoto | 0:b4c1e32627f2 | 148 | drpTask.start(callback(drp_task)); |
| RyoheiHagimoto | 0:b4c1e32627f2 | 149 | |
| RyoheiHagimoto | 0:b4c1e32627f2 | 150 | // decoder setting |
| RyoheiHagimoto | 0:b4c1e32627f2 | 151 | AudioPlayer.add_decoder<EasyDec_WavCnv2ch>(".wav"); |
| RyoheiHagimoto | 0:b4c1e32627f2 | 152 | AudioPlayer.add_decoder<EasyDec_WavCnv2ch>(".WAV"); |
| RyoheiHagimoto | 0:b4c1e32627f2 | 153 | |
| RyoheiHagimoto | 0:b4c1e32627f2 | 154 | AudioPlayer.outputVolume(0.5); |
| RyoheiHagimoto | 0:b4c1e32627f2 | 155 | |
| RyoheiHagimoto | 0:b4c1e32627f2 | 156 | // button setting |
| RyoheiHagimoto | 0:b4c1e32627f2 | 157 | skip_btn.fall(&skip_btn_fall); |
| RyoheiHagimoto | 0:b4c1e32627f2 | 158 | |
| RyoheiHagimoto | 0:b4c1e32627f2 | 159 | while (1) { |
| RyoheiHagimoto | 0:b4c1e32627f2 | 160 | // connect wait |
| RyoheiHagimoto | 0:b4c1e32627f2 | 161 | storage.wait_connect(); |
| RyoheiHagimoto | 0:b4c1e32627f2 | 162 | |
| RyoheiHagimoto | 0:b4c1e32627f2 | 163 | // file search |
| RyoheiHagimoto | 0:b4c1e32627f2 | 164 | d = opendir("/" MOUNT_NAME "/"); |
| RyoheiHagimoto | 0:b4c1e32627f2 | 165 | if (d != NULL) { |
| RyoheiHagimoto | 0:b4c1e32627f2 | 166 | while ((p = readdir(d)) != NULL) { |
| RyoheiHagimoto | 0:b4c1e32627f2 | 167 | size_t len = strlen(p->d_name); |
| RyoheiHagimoto | 0:b4c1e32627f2 | 168 | if (len < FILE_NAME_LEN) { |
| RyoheiHagimoto | 0:b4c1e32627f2 | 169 | // make file path |
| RyoheiHagimoto | 0:b4c1e32627f2 | 170 | sprintf(file_path, "/%s/%s", MOUNT_NAME, p->d_name); |
| RyoheiHagimoto | 0:b4c1e32627f2 | 171 | printf("%s\r\n", file_path); |
| RyoheiHagimoto | 0:b4c1e32627f2 | 172 | |
| RyoheiHagimoto | 0:b4c1e32627f2 | 173 | // playback |
| RyoheiHagimoto | 0:b4c1e32627f2 | 174 | AudioPlayer.play(file_path); |
| RyoheiHagimoto | 0:b4c1e32627f2 | 175 | } |
| RyoheiHagimoto | 0:b4c1e32627f2 | 176 | } |
| RyoheiHagimoto | 0:b4c1e32627f2 | 177 | closedir(d); |
| RyoheiHagimoto | 0:b4c1e32627f2 | 178 | } |
| RyoheiHagimoto | 0:b4c1e32627f2 | 179 | } |
| RyoheiHagimoto | 0:b4c1e32627f2 | 180 | } |
| RyoheiHagimoto | 0:b4c1e32627f2 | 181 | |
| RyoheiHagimoto | 0:b4c1e32627f2 | 182 | #endif |