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/common/InterruptManager.cpp@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 | #include "cmsis.h" |
tvendov | 0:6435b67ad23c | 2 | #if defined(NVIC_NUM_VECTORS) |
tvendov | 0:6435b67ad23c | 3 | |
tvendov | 0:6435b67ad23c | 4 | #include "InterruptManager.h" |
tvendov | 0:6435b67ad23c | 5 | #include "critical.h" |
tvendov | 0:6435b67ad23c | 6 | #include <string.h> |
tvendov | 0:6435b67ad23c | 7 | |
tvendov | 0:6435b67ad23c | 8 | #define CHAIN_INITIAL_SIZE 4 |
tvendov | 0:6435b67ad23c | 9 | |
tvendov | 0:6435b67ad23c | 10 | namespace mbed { |
tvendov | 0:6435b67ad23c | 11 | |
tvendov | 0:6435b67ad23c | 12 | typedef void (*pvoidf)(void); |
tvendov | 0:6435b67ad23c | 13 | |
tvendov | 0:6435b67ad23c | 14 | InterruptManager* InterruptManager::_instance = (InterruptManager*)NULL; |
tvendov | 0:6435b67ad23c | 15 | |
tvendov | 0:6435b67ad23c | 16 | InterruptManager* InterruptManager::get() { |
tvendov | 0:6435b67ad23c | 17 | |
tvendov | 0:6435b67ad23c | 18 | if (NULL == _instance) { |
tvendov | 0:6435b67ad23c | 19 | InterruptManager* temp = new InterruptManager(); |
tvendov | 0:6435b67ad23c | 20 | |
tvendov | 0:6435b67ad23c | 21 | // Atomically set _instance |
tvendov | 0:6435b67ad23c | 22 | core_util_critical_section_enter(); |
tvendov | 0:6435b67ad23c | 23 | if (NULL == _instance) { |
tvendov | 0:6435b67ad23c | 24 | _instance = temp; |
tvendov | 0:6435b67ad23c | 25 | } |
tvendov | 0:6435b67ad23c | 26 | core_util_critical_section_exit(); |
tvendov | 0:6435b67ad23c | 27 | |
tvendov | 0:6435b67ad23c | 28 | // Another thread got there first so delete ours |
tvendov | 0:6435b67ad23c | 29 | if (temp != _instance) { |
tvendov | 0:6435b67ad23c | 30 | delete temp; |
tvendov | 0:6435b67ad23c | 31 | } |
tvendov | 0:6435b67ad23c | 32 | |
tvendov | 0:6435b67ad23c | 33 | } |
tvendov | 0:6435b67ad23c | 34 | return _instance; |
tvendov | 0:6435b67ad23c | 35 | } |
tvendov | 0:6435b67ad23c | 36 | |
tvendov | 0:6435b67ad23c | 37 | InterruptManager::InterruptManager() { |
tvendov | 0:6435b67ad23c | 38 | // No mutex needed in constructor |
tvendov | 0:6435b67ad23c | 39 | memset(_chains, 0, NVIC_NUM_VECTORS * sizeof(CallChain*)); |
tvendov | 0:6435b67ad23c | 40 | } |
tvendov | 0:6435b67ad23c | 41 | |
tvendov | 0:6435b67ad23c | 42 | void InterruptManager::destroy() { |
tvendov | 0:6435b67ad23c | 43 | // Not a good idea to call this unless NO interrupt at all |
tvendov | 0:6435b67ad23c | 44 | // is under the control of the handler; otherwise, a system crash |
tvendov | 0:6435b67ad23c | 45 | // is very likely to occur |
tvendov | 0:6435b67ad23c | 46 | if (NULL != _instance) { |
tvendov | 0:6435b67ad23c | 47 | delete _instance; |
tvendov | 0:6435b67ad23c | 48 | _instance = (InterruptManager*)NULL; |
tvendov | 0:6435b67ad23c | 49 | } |
tvendov | 0:6435b67ad23c | 50 | } |
tvendov | 0:6435b67ad23c | 51 | |
tvendov | 0:6435b67ad23c | 52 | InterruptManager::~InterruptManager() { |
tvendov | 0:6435b67ad23c | 53 | for(int i = 0; i < NVIC_NUM_VECTORS; i++) |
tvendov | 0:6435b67ad23c | 54 | if (NULL != _chains[i]) |
tvendov | 0:6435b67ad23c | 55 | delete _chains[i]; |
tvendov | 0:6435b67ad23c | 56 | } |
tvendov | 0:6435b67ad23c | 57 | |
tvendov | 0:6435b67ad23c | 58 | bool InterruptManager::must_replace_vector(IRQn_Type irq) { |
tvendov | 0:6435b67ad23c | 59 | lock(); |
tvendov | 0:6435b67ad23c | 60 | |
tvendov | 0:6435b67ad23c | 61 | int ret = false; |
tvendov | 0:6435b67ad23c | 62 | int irq_pos = get_irq_index(irq); |
tvendov | 0:6435b67ad23c | 63 | if (NULL == _chains[irq_pos]) { |
tvendov | 0:6435b67ad23c | 64 | _chains[irq_pos] = new CallChain(CHAIN_INITIAL_SIZE); |
tvendov | 0:6435b67ad23c | 65 | _chains[irq_pos]->add((pvoidf)NVIC_GetVector(irq)); |
tvendov | 0:6435b67ad23c | 66 | ret = true; |
tvendov | 0:6435b67ad23c | 67 | } |
tvendov | 0:6435b67ad23c | 68 | unlock(); |
tvendov | 0:6435b67ad23c | 69 | return ret; |
tvendov | 0:6435b67ad23c | 70 | } |
tvendov | 0:6435b67ad23c | 71 | |
tvendov | 0:6435b67ad23c | 72 | pFunctionPointer_t InterruptManager::add_common(void (*function)(void), IRQn_Type irq, bool front) { |
tvendov | 0:6435b67ad23c | 73 | lock(); |
tvendov | 0:6435b67ad23c | 74 | int irq_pos = get_irq_index(irq); |
tvendov | 0:6435b67ad23c | 75 | bool change = must_replace_vector(irq); |
tvendov | 0:6435b67ad23c | 76 | |
tvendov | 0:6435b67ad23c | 77 | pFunctionPointer_t pf = front ? _chains[irq_pos]->add_front(function) : _chains[irq_pos]->add(function); |
tvendov | 0:6435b67ad23c | 78 | if (change) |
tvendov | 0:6435b67ad23c | 79 | NVIC_SetVector(irq, (uint32_t)&InterruptManager::static_irq_helper); |
tvendov | 0:6435b67ad23c | 80 | unlock(); |
tvendov | 0:6435b67ad23c | 81 | return pf; |
tvendov | 0:6435b67ad23c | 82 | } |
tvendov | 0:6435b67ad23c | 83 | |
tvendov | 0:6435b67ad23c | 84 | bool InterruptManager::remove_handler(pFunctionPointer_t handler, IRQn_Type irq) { |
tvendov | 0:6435b67ad23c | 85 | int irq_pos = get_irq_index(irq); |
tvendov | 0:6435b67ad23c | 86 | bool ret = false; |
tvendov | 0:6435b67ad23c | 87 | |
tvendov | 0:6435b67ad23c | 88 | lock(); |
tvendov | 0:6435b67ad23c | 89 | if (_chains[irq_pos] != NULL) { |
tvendov | 0:6435b67ad23c | 90 | if (_chains[irq_pos]->remove(handler)) { |
tvendov | 0:6435b67ad23c | 91 | ret = true; |
tvendov | 0:6435b67ad23c | 92 | } |
tvendov | 0:6435b67ad23c | 93 | } |
tvendov | 0:6435b67ad23c | 94 | unlock(); |
tvendov | 0:6435b67ad23c | 95 | |
tvendov | 0:6435b67ad23c | 96 | return ret; |
tvendov | 0:6435b67ad23c | 97 | } |
tvendov | 0:6435b67ad23c | 98 | |
tvendov | 0:6435b67ad23c | 99 | void InterruptManager::irq_helper() { |
tvendov | 0:6435b67ad23c | 100 | _chains[__get_IPSR()]->call(); |
tvendov | 0:6435b67ad23c | 101 | } |
tvendov | 0:6435b67ad23c | 102 | |
tvendov | 0:6435b67ad23c | 103 | int InterruptManager::get_irq_index(IRQn_Type irq) { |
tvendov | 0:6435b67ad23c | 104 | // Pure function - no lock needed |
tvendov | 0:6435b67ad23c | 105 | return (int)irq + NVIC_USER_IRQ_OFFSET; |
tvendov | 0:6435b67ad23c | 106 | } |
tvendov | 0:6435b67ad23c | 107 | |
tvendov | 0:6435b67ad23c | 108 | void InterruptManager::static_irq_helper() { |
tvendov | 0:6435b67ad23c | 109 | InterruptManager::get()->irq_helper(); |
tvendov | 0:6435b67ad23c | 110 | } |
tvendov | 0:6435b67ad23c | 111 | |
tvendov | 0:6435b67ad23c | 112 | void InterruptManager::lock() { |
tvendov | 0:6435b67ad23c | 113 | _mutex.lock(); |
tvendov | 0:6435b67ad23c | 114 | } |
tvendov | 0:6435b67ad23c | 115 | |
tvendov | 0:6435b67ad23c | 116 | void InterruptManager::unlock() { |
tvendov | 0:6435b67ad23c | 117 | _mutex.unlock(); |
tvendov | 0:6435b67ad23c | 118 | } |
tvendov | 0:6435b67ad23c | 119 | |
tvendov | 0:6435b67ad23c | 120 | } // namespace mbed |
tvendov | 0:6435b67ad23c | 121 | |
tvendov | 0:6435b67ad23c | 122 | #endif |
tvendov | 0:6435b67ad23c | 123 |