Lcd companion boards support (VKLCD50RTA & VKLCD70RT)
What is this ?
This is a demo program using Renesas RGA library & USB Camera to demonstrate VK-RZ/A1H's companion boards workability.
Supported companion Boards:
VKLCD50RTA
VKLCD70RT
How to Configure ?
You can choose which display is installed by altering the lcd_panel.h file
Leave the active one & comment out the others:
#define LCD_VDC5_CH0_PANEL LCD_CH0_PANEL_VKLCD50RTA //#define LCD_VDC5_CH0_PANEL LCD_CH0_PANEL_VKLCD70RT
You can alter the whole demo with your pictures if you like:
How to compile ?
- The Demo can be compiled in 3 modes:
- I. Execution from the internal 10-MB on-chip SRAM.
- II. Execution from the on-board serial FALSH in dual (32-MB) mode.
- After import in the online compiler just leave only the VKRZA1H_DOUBLE.sct & delete all others linker files in the TOOLCHAIN_ARM_STD folder.
- Drag & drop the result binary in MBED disk, (previously inited in double flash mode)
- III. Execution from the on-board serial FALSH in single (16-MB) mode.
- After import in the online compiler just leave only the VKRZA1H_SINGLE.sct & delete all others linker files in the TOOLCHAIN_ARM_STD folder.
- Drag & drop the result binary in MBED disk, (previously inited in single flash mode )
Quick presentation:
Other demos ?
More demos you can find on our FTP
hal/api/CThunk.h@0:6435b67ad23c, 2017-02-16 (annotated)
- Committer:
- tvendov
- Date:
- Thu Feb 16 10:23:48 2017 +0000
- Revision:
- 0:6435b67ad23c
Initial lcd support (VKLCD50RTA & VKLCD70RT companion boards)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tvendov | 0:6435b67ad23c | 1 | /* General C++ Object Thunking class |
tvendov | 0:6435b67ad23c | 2 | * |
tvendov | 0:6435b67ad23c | 3 | * - allows direct callbacks to non-static C++ class functions |
tvendov | 0:6435b67ad23c | 4 | * - keeps track for the corresponding class instance |
tvendov | 0:6435b67ad23c | 5 | * - supports an optional context parameter for the called function |
tvendov | 0:6435b67ad23c | 6 | * - ideally suited for class object receiving interrupts (NVIC_SetVector) |
tvendov | 0:6435b67ad23c | 7 | * |
tvendov | 0:6435b67ad23c | 8 | * Copyright (c) 2014-2015 ARM Limited |
tvendov | 0:6435b67ad23c | 9 | * |
tvendov | 0:6435b67ad23c | 10 | * Licensed under the Apache License, Version 2.0 (the "License"); |
tvendov | 0:6435b67ad23c | 11 | * you may not use this file except in compliance with the License. |
tvendov | 0:6435b67ad23c | 12 | * You may obtain a copy of the License at |
tvendov | 0:6435b67ad23c | 13 | * |
tvendov | 0:6435b67ad23c | 14 | * http://www.apache.org/licenses/LICENSE-2.0 |
tvendov | 0:6435b67ad23c | 15 | * |
tvendov | 0:6435b67ad23c | 16 | * Unless required by applicable law or agreed to in writing, software |
tvendov | 0:6435b67ad23c | 17 | * distributed under the License is distributed on an "AS IS" BASIS, |
tvendov | 0:6435b67ad23c | 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
tvendov | 0:6435b67ad23c | 19 | * See the License for the specific language governing permissions and |
tvendov | 0:6435b67ad23c | 20 | * limitations under the License. |
tvendov | 0:6435b67ad23c | 21 | */ |
tvendov | 0:6435b67ad23c | 22 | |
tvendov | 0:6435b67ad23c | 23 | /* General C++ Object Thunking class |
tvendov | 0:6435b67ad23c | 24 | * |
tvendov | 0:6435b67ad23c | 25 | * - allows direct callbacks to non-static C++ class functions |
tvendov | 0:6435b67ad23c | 26 | * - keeps track for the corresponding class instance |
tvendov | 0:6435b67ad23c | 27 | * - supports an optional context parameter for the called function |
tvendov | 0:6435b67ad23c | 28 | * - ideally suited for class object receiving interrupts (NVIC_SetVector) |
tvendov | 0:6435b67ad23c | 29 | */ |
tvendov | 0:6435b67ad23c | 30 | |
tvendov | 0:6435b67ad23c | 31 | #ifndef __CTHUNK_H__ |
tvendov | 0:6435b67ad23c | 32 | #define __CTHUNK_H__ |
tvendov | 0:6435b67ad23c | 33 | |
tvendov | 0:6435b67ad23c | 34 | #define CTHUNK_ADDRESS 1 |
tvendov | 0:6435b67ad23c | 35 | |
tvendov | 0:6435b67ad23c | 36 | #if (defined(__CORTEX_M3) || defined(__CORTEX_M4) || defined(__thumb2__)) && ! defined(__CORTEX_A9) |
tvendov | 0:6435b67ad23c | 37 | #define CTHUNK_VARIABLES volatile uint32_t code[1] |
tvendov | 0:6435b67ad23c | 38 | /** |
tvendov | 0:6435b67ad23c | 39 | * CTHUNK disassembly for Cortex-M3/M4 (thumb2): |
tvendov | 0:6435b67ad23c | 40 | * * ldm.w pc,{r0,r1,r2,pc} |
tvendov | 0:6435b67ad23c | 41 | * |
tvendov | 0:6435b67ad23c | 42 | * This instruction loads the arguments for the static thunking function to r0-r2, and |
tvendov | 0:6435b67ad23c | 43 | * branches to that function by loading its address into PC. |
tvendov | 0:6435b67ad23c | 44 | * |
tvendov | 0:6435b67ad23c | 45 | * This is safe for both regular calling and interrupt calling, since it only touches scratch registers |
tvendov | 0:6435b67ad23c | 46 | * which should be saved by the caller, and are automatically saved as part of the IRQ context switch. |
tvendov | 0:6435b67ad23c | 47 | */ |
tvendov | 0:6435b67ad23c | 48 | #define CTHUNK_ASSIGMENT m_thunk.code[0] = 0x8007E89F |
tvendov | 0:6435b67ad23c | 49 | |
tvendov | 0:6435b67ad23c | 50 | #elif defined(__CORTEX_M0PLUS) || defined(__CORTEX_M0) || defined(__CORTEX_A9) |
tvendov | 0:6435b67ad23c | 51 | /* |
tvendov | 0:6435b67ad23c | 52 | * CTHUNK disassembly for Cortex M0 (thumb): |
tvendov | 0:6435b67ad23c | 53 | * * push {r0,r1,r2,r3,r4,lr} save touched registers and return address |
tvendov | 0:6435b67ad23c | 54 | * * movs r4,#4 set up address to load arguments from (immediately following this code block) (1) |
tvendov | 0:6435b67ad23c | 55 | * * add r4,pc set up address to load arguments from (immediately following this code block) (2) |
tvendov | 0:6435b67ad23c | 56 | * * ldm r4!,{r0,r1,r2,r3} load arguments for static thunk function |
tvendov | 0:6435b67ad23c | 57 | * * blx r3 call static thunk function |
tvendov | 0:6435b67ad23c | 58 | * * pop {r0,r1,r2,r3,r4,pc} restore scratch registers and return from function |
tvendov | 0:6435b67ad23c | 59 | */ |
tvendov | 0:6435b67ad23c | 60 | #define CTHUNK_VARIABLES volatile uint32_t code[3] |
tvendov | 0:6435b67ad23c | 61 | #define CTHUNK_ASSIGMENT do { \ |
tvendov | 0:6435b67ad23c | 62 | m_thunk.code[0] = 0x2404B51F; \ |
tvendov | 0:6435b67ad23c | 63 | m_thunk.code[1] = 0xCC0F447C; \ |
tvendov | 0:6435b67ad23c | 64 | m_thunk.code[2] = 0xBD1F4798; \ |
tvendov | 0:6435b67ad23c | 65 | } while (0) |
tvendov | 0:6435b67ad23c | 66 | |
tvendov | 0:6435b67ad23c | 67 | #else |
tvendov | 0:6435b67ad23c | 68 | #error "Target is not currently suported." |
tvendov | 0:6435b67ad23c | 69 | #endif |
tvendov | 0:6435b67ad23c | 70 | |
tvendov | 0:6435b67ad23c | 71 | /* IRQ/Exception compatible thunk entry function */ |
tvendov | 0:6435b67ad23c | 72 | typedef void (*CThunkEntry)(void); |
tvendov | 0:6435b67ad23c | 73 | |
tvendov | 0:6435b67ad23c | 74 | /** |
tvendov | 0:6435b67ad23c | 75 | * Class for created a pointer with data bound to it |
tvendov | 0:6435b67ad23c | 76 | * |
tvendov | 0:6435b67ad23c | 77 | * @Note Synchronization level: Not protected |
tvendov | 0:6435b67ad23c | 78 | */ |
tvendov | 0:6435b67ad23c | 79 | template<class T> |
tvendov | 0:6435b67ad23c | 80 | class CThunk |
tvendov | 0:6435b67ad23c | 81 | { |
tvendov | 0:6435b67ad23c | 82 | public: |
tvendov | 0:6435b67ad23c | 83 | typedef void (T::*CCallbackSimple)(void); |
tvendov | 0:6435b67ad23c | 84 | typedef void (T::*CCallback)(void* context); |
tvendov | 0:6435b67ad23c | 85 | |
tvendov | 0:6435b67ad23c | 86 | inline CThunk(T *instance) |
tvendov | 0:6435b67ad23c | 87 | { |
tvendov | 0:6435b67ad23c | 88 | init(instance, NULL, NULL); |
tvendov | 0:6435b67ad23c | 89 | } |
tvendov | 0:6435b67ad23c | 90 | |
tvendov | 0:6435b67ad23c | 91 | inline CThunk(T *instance, CCallback callback) |
tvendov | 0:6435b67ad23c | 92 | { |
tvendov | 0:6435b67ad23c | 93 | init(instance, callback, NULL); |
tvendov | 0:6435b67ad23c | 94 | } |
tvendov | 0:6435b67ad23c | 95 | |
tvendov | 0:6435b67ad23c | 96 | ~CThunk() { |
tvendov | 0:6435b67ad23c | 97 | |
tvendov | 0:6435b67ad23c | 98 | } |
tvendov | 0:6435b67ad23c | 99 | |
tvendov | 0:6435b67ad23c | 100 | inline CThunk(T *instance, CCallbackSimple callback) |
tvendov | 0:6435b67ad23c | 101 | { |
tvendov | 0:6435b67ad23c | 102 | init(instance, (CCallback)callback, NULL); |
tvendov | 0:6435b67ad23c | 103 | } |
tvendov | 0:6435b67ad23c | 104 | |
tvendov | 0:6435b67ad23c | 105 | inline CThunk(T &instance, CCallback callback) |
tvendov | 0:6435b67ad23c | 106 | { |
tvendov | 0:6435b67ad23c | 107 | init(instance, callback, NULL); |
tvendov | 0:6435b67ad23c | 108 | } |
tvendov | 0:6435b67ad23c | 109 | |
tvendov | 0:6435b67ad23c | 110 | inline CThunk(T &instance, CCallbackSimple callback) |
tvendov | 0:6435b67ad23c | 111 | { |
tvendov | 0:6435b67ad23c | 112 | init(instance, (CCallback)callback, NULL); |
tvendov | 0:6435b67ad23c | 113 | } |
tvendov | 0:6435b67ad23c | 114 | |
tvendov | 0:6435b67ad23c | 115 | inline CThunk(T &instance, CCallback callback, void* context) |
tvendov | 0:6435b67ad23c | 116 | { |
tvendov | 0:6435b67ad23c | 117 | init(instance, callback, context); |
tvendov | 0:6435b67ad23c | 118 | } |
tvendov | 0:6435b67ad23c | 119 | |
tvendov | 0:6435b67ad23c | 120 | inline void callback(CCallback callback) |
tvendov | 0:6435b67ad23c | 121 | { |
tvendov | 0:6435b67ad23c | 122 | m_callback = callback; |
tvendov | 0:6435b67ad23c | 123 | } |
tvendov | 0:6435b67ad23c | 124 | |
tvendov | 0:6435b67ad23c | 125 | inline void callback(CCallbackSimple callback) |
tvendov | 0:6435b67ad23c | 126 | { |
tvendov | 0:6435b67ad23c | 127 | m_callback = (CCallback)callback; |
tvendov | 0:6435b67ad23c | 128 | } |
tvendov | 0:6435b67ad23c | 129 | |
tvendov | 0:6435b67ad23c | 130 | inline void context(void* context) |
tvendov | 0:6435b67ad23c | 131 | { |
tvendov | 0:6435b67ad23c | 132 | m_thunk.context = (uint32_t)context; |
tvendov | 0:6435b67ad23c | 133 | } |
tvendov | 0:6435b67ad23c | 134 | |
tvendov | 0:6435b67ad23c | 135 | inline void context(uint32_t context) |
tvendov | 0:6435b67ad23c | 136 | { |
tvendov | 0:6435b67ad23c | 137 | m_thunk.context = context; |
tvendov | 0:6435b67ad23c | 138 | } |
tvendov | 0:6435b67ad23c | 139 | |
tvendov | 0:6435b67ad23c | 140 | inline uint32_t entry(void) |
tvendov | 0:6435b67ad23c | 141 | { |
tvendov | 0:6435b67ad23c | 142 | return (((uint32_t)&m_thunk)|CTHUNK_ADDRESS); |
tvendov | 0:6435b67ad23c | 143 | } |
tvendov | 0:6435b67ad23c | 144 | |
tvendov | 0:6435b67ad23c | 145 | /* get thunk entry point for connecting rhunk to an IRQ table */ |
tvendov | 0:6435b67ad23c | 146 | inline operator CThunkEntry(void) |
tvendov | 0:6435b67ad23c | 147 | { |
tvendov | 0:6435b67ad23c | 148 | return (CThunkEntry)entry(); |
tvendov | 0:6435b67ad23c | 149 | } |
tvendov | 0:6435b67ad23c | 150 | |
tvendov | 0:6435b67ad23c | 151 | /* get thunk entry point for connecting rhunk to an IRQ table */ |
tvendov | 0:6435b67ad23c | 152 | inline operator uint32_t(void) |
tvendov | 0:6435b67ad23c | 153 | { |
tvendov | 0:6435b67ad23c | 154 | return entry(); |
tvendov | 0:6435b67ad23c | 155 | } |
tvendov | 0:6435b67ad23c | 156 | |
tvendov | 0:6435b67ad23c | 157 | /* simple test function */ |
tvendov | 0:6435b67ad23c | 158 | inline void call(void) |
tvendov | 0:6435b67ad23c | 159 | { |
tvendov | 0:6435b67ad23c | 160 | (((CThunkEntry)(entry()))()); |
tvendov | 0:6435b67ad23c | 161 | } |
tvendov | 0:6435b67ad23c | 162 | |
tvendov | 0:6435b67ad23c | 163 | private: |
tvendov | 0:6435b67ad23c | 164 | T* m_instance; |
tvendov | 0:6435b67ad23c | 165 | volatile CCallback m_callback; |
tvendov | 0:6435b67ad23c | 166 | |
tvendov | 0:6435b67ad23c | 167 | // TODO: this needs proper fix, to refactor toolchain header file and all its use |
tvendov | 0:6435b67ad23c | 168 | // PACKED there is not defined properly for IAR |
tvendov | 0:6435b67ad23c | 169 | #if defined (__ICCARM__) |
tvendov | 0:6435b67ad23c | 170 | typedef __packed struct |
tvendov | 0:6435b67ad23c | 171 | { |
tvendov | 0:6435b67ad23c | 172 | CTHUNK_VARIABLES; |
tvendov | 0:6435b67ad23c | 173 | volatile uint32_t instance; |
tvendov | 0:6435b67ad23c | 174 | volatile uint32_t context; |
tvendov | 0:6435b67ad23c | 175 | volatile uint32_t callback; |
tvendov | 0:6435b67ad23c | 176 | volatile uint32_t trampoline; |
tvendov | 0:6435b67ad23c | 177 | } CThunkTrampoline; |
tvendov | 0:6435b67ad23c | 178 | #else |
tvendov | 0:6435b67ad23c | 179 | typedef struct |
tvendov | 0:6435b67ad23c | 180 | { |
tvendov | 0:6435b67ad23c | 181 | CTHUNK_VARIABLES; |
tvendov | 0:6435b67ad23c | 182 | volatile uint32_t instance; |
tvendov | 0:6435b67ad23c | 183 | volatile uint32_t context; |
tvendov | 0:6435b67ad23c | 184 | volatile uint32_t callback; |
tvendov | 0:6435b67ad23c | 185 | volatile uint32_t trampoline; |
tvendov | 0:6435b67ad23c | 186 | } __attribute__((__packed__)) CThunkTrampoline; |
tvendov | 0:6435b67ad23c | 187 | #endif |
tvendov | 0:6435b67ad23c | 188 | |
tvendov | 0:6435b67ad23c | 189 | static void trampoline(T* instance, void* context, CCallback* callback) |
tvendov | 0:6435b67ad23c | 190 | { |
tvendov | 0:6435b67ad23c | 191 | if(instance && *callback) { |
tvendov | 0:6435b67ad23c | 192 | (static_cast<T*>(instance)->**callback)(context); |
tvendov | 0:6435b67ad23c | 193 | } |
tvendov | 0:6435b67ad23c | 194 | } |
tvendov | 0:6435b67ad23c | 195 | |
tvendov | 0:6435b67ad23c | 196 | volatile CThunkTrampoline m_thunk; |
tvendov | 0:6435b67ad23c | 197 | |
tvendov | 0:6435b67ad23c | 198 | inline void init(T *instance, CCallback callback, void* context) |
tvendov | 0:6435b67ad23c | 199 | { |
tvendov | 0:6435b67ad23c | 200 | /* remember callback - need to add this level of redirection |
tvendov | 0:6435b67ad23c | 201 | as pointer size for member functions differs between platforms */ |
tvendov | 0:6435b67ad23c | 202 | m_callback = callback; |
tvendov | 0:6435b67ad23c | 203 | |
tvendov | 0:6435b67ad23c | 204 | /* populate thunking trampoline */ |
tvendov | 0:6435b67ad23c | 205 | CTHUNK_ASSIGMENT; |
tvendov | 0:6435b67ad23c | 206 | m_thunk.context = (uint32_t)context; |
tvendov | 0:6435b67ad23c | 207 | m_thunk.instance = (uint32_t)instance; |
tvendov | 0:6435b67ad23c | 208 | m_thunk.callback = (uint32_t)&m_callback; |
tvendov | 0:6435b67ad23c | 209 | m_thunk.trampoline = (uint32_t)&trampoline; |
tvendov | 0:6435b67ad23c | 210 | |
tvendov | 0:6435b67ad23c | 211 | #if defined(__CORTEX_A9) |
tvendov | 0:6435b67ad23c | 212 | /* Data cache clean */ |
tvendov | 0:6435b67ad23c | 213 | /* Cache control */ |
tvendov | 0:6435b67ad23c | 214 | { |
tvendov | 0:6435b67ad23c | 215 | uint32_t start_addr = (uint32_t)&m_thunk & 0xFFFFFFE0; |
tvendov | 0:6435b67ad23c | 216 | uint32_t end_addr = (uint32_t)&m_thunk + sizeof(m_thunk); |
tvendov | 0:6435b67ad23c | 217 | uint32_t addr; |
tvendov | 0:6435b67ad23c | 218 | |
tvendov | 0:6435b67ad23c | 219 | /* Data cache clean and invalid */ |
tvendov | 0:6435b67ad23c | 220 | for (addr = start_addr; addr < end_addr; addr += 0x20) { |
tvendov | 0:6435b67ad23c | 221 | __v7_clean_inv_dcache_mva((void *)addr); |
tvendov | 0:6435b67ad23c | 222 | } |
tvendov | 0:6435b67ad23c | 223 | /* Instruction cache invalid */ |
tvendov | 0:6435b67ad23c | 224 | __v7_inv_icache_all(); |
tvendov | 0:6435b67ad23c | 225 | __ca9u_inv_tlb_all(); |
tvendov | 0:6435b67ad23c | 226 | __v7_inv_btac(); |
tvendov | 0:6435b67ad23c | 227 | } |
tvendov | 0:6435b67ad23c | 228 | #endif |
tvendov | 0:6435b67ad23c | 229 | __ISB(); |
tvendov | 0:6435b67ad23c | 230 | __DSB(); |
tvendov | 0:6435b67ad23c | 231 | } |
tvendov | 0:6435b67ad23c | 232 | }; |
tvendov | 0:6435b67ad23c | 233 | |
tvendov | 0:6435b67ad23c | 234 | #endif/*__CTHUNK_H__*/ |
tvendov | 0:6435b67ad23c | 235 |