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

/media/uploads/tvendov/front_view_hmi_50.png /media/uploads/tvendov/side_view_hmi_50.png

VKLCD70RT

/media/uploads/tvendov/front_view_hmi_70.png/media/uploads/tvendov/side_view_hmi_70.png /media/uploads/tvendov/front_view_lvds.png/media/uploads/tvendov/back_view_lvds.png


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.
      • After import in the online compiler just leave only the VKRZA1H_RAM.sct & delete all others linker files in the TOOLCHAIN_ARM_STD folder.
      • Save the result binary in the SD Card (<SD>:\vkrza1\lcd_sample ), altering vkrza1h.ini by this way
    • 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

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?

UserRevisionLine numberNew contents of line
tvendov 0:6435b67ad23c 1 // USBIsochronous.cpp
tvendov 0:6435b67ad23c 2 #include "USBHostConf.h"
tvendov 0:6435b67ad23c 3 #include "USBHost.h"
tvendov 0:6435b67ad23c 4 #include "USBIsochronous.h"
tvendov 0:6435b67ad23c 5 #if (defined(TARGET_RZ_A1H) || defined(TARGET_VK_RZ_A1H))
tvendov 0:6435b67ad23c 6 #include "ohci_wrapp_RZ_A1.h"
tvendov 0:6435b67ad23c 7 #endif
tvendov 0:6435b67ad23c 8
tvendov 0:6435b67ad23c 9 #define OR_CONTROL_PLE 0x00000004
tvendov 0:6435b67ad23c 10 #define OR_CONTROL_IE 0x00000008
tvendov 0:6435b67ad23c 11
tvendov 0:6435b67ad23c 12 //#define ISO_DEBUG 1
tvendov 0:6435b67ad23c 13 #ifdef ISO_DEBUG
tvendov 0:6435b67ad23c 14 #define ISO_DBG(x, ...) std::printf("[%s:%d]"x"\r\n", __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
tvendov 0:6435b67ad23c 15 #else
tvendov 0:6435b67ad23c 16 #define ISO_DBG(...) while(0);
tvendov 0:6435b67ad23c 17 #endif
tvendov 0:6435b67ad23c 18
tvendov 0:6435b67ad23c 19 #define TEST_ASSERT(A) while(!(A)){fprintf(stderr,"\n\n%s@%d %s ASSERT!\n\n",__PRETTY_FUNCTION__,__LINE__,#A);exit(1);};
tvendov 0:6435b67ad23c 20
tvendov 0:6435b67ad23c 21 HCITD::HCITD(IsochronousEp* obj, uint16_t FrameNumber, int FrameCount, uint16_t PacketSize) {
tvendov 0:6435b67ad23c 22 Control = 0xe0000000 | // CC ConditionCode NOT ACCESSED
tvendov 0:6435b67ad23c 23 ((FrameCount-1) << 24)| // FC FrameCount
tvendov 0:6435b67ad23c 24 TD_DELAY_INT(0) | // DI DelayInterrupt
tvendov 0:6435b67ad23c 25 FrameNumber; // SF StartingFrame
tvendov 0:6435b67ad23c 26 BufferPage0 = const_cast<uint8_t*>(buf);
tvendov 0:6435b67ad23c 27 BufferEnd = const_cast<uint8_t*>(buf) + PacketSize * FrameCount - 1;
tvendov 0:6435b67ad23c 28 Next = NULL;
tvendov 0:6435b67ad23c 29 ep = obj;
tvendov 0:6435b67ad23c 30 uint32_t addr = reinterpret_cast<uint32_t>(buf);
tvendov 0:6435b67ad23c 31 for(int i = 0; i < FrameCount; i++) {
tvendov 0:6435b67ad23c 32 uint16_t offset = addr & 0x0fff;
tvendov 0:6435b67ad23c 33 if ((addr&0xfffff000) == (reinterpret_cast<uint32_t>(BufferEnd)&0xfffff000)) {
tvendov 0:6435b67ad23c 34 offset |= 0x1000;
tvendov 0:6435b67ad23c 35 }
tvendov 0:6435b67ad23c 36 OffsetPSW[i] = 0xe000|offset;
tvendov 0:6435b67ad23c 37 addr += PacketSize;
tvendov 0:6435b67ad23c 38 }
tvendov 0:6435b67ad23c 39 }
tvendov 0:6435b67ad23c 40
tvendov 0:6435b67ad23c 41 void IsochronousEp::init(int addr, uint8_t ep, uint16_t size, uint8_t frameCount, uint8_t queueLimit) {
tvendov 0:6435b67ad23c 42 //ISO_DBG("%p FA:%d EP:%02X MPS:%d\n", this, addr, ep, size);
tvendov 0:6435b67ad23c 43 TEST_ASSERT(addr >= 1);
tvendov 0:6435b67ad23c 44 TEST_ASSERT(size >= 8 && size <= 1023);
tvendov 0:6435b67ad23c 45 m_pED = new _HCED(addr, ep, size);
tvendov 0:6435b67ad23c 46 TEST_ASSERT(m_pED);
tvendov 0:6435b67ad23c 47
tvendov 0:6435b67ad23c 48 m_pED->setFormat(); // F Format ITD
tvendov 0:6435b67ad23c 49
tvendov 0:6435b67ad23c 50 m_PacketSize = size;
tvendov 0:6435b67ad23c 51 TEST_ASSERT(frameCount >= 1 && frameCount <= 8);
tvendov 0:6435b67ad23c 52 m_FrameCount = frameCount;
tvendov 0:6435b67ad23c 53 TEST_ASSERT(queueLimit >= 1 && queueLimit <= HCITD_QUEUE_SIZE);
tvendov 0:6435b67ad23c 54 m_itd_queue_limit = queueLimit;
tvendov 0:6435b67ad23c 55
tvendov 0:6435b67ad23c 56 m_itd_queue_count = 0;
tvendov 0:6435b67ad23c 57 reset();
tvendov 0:6435b67ad23c 58 HCITD* itd = new_HCITD(this);
tvendov 0:6435b67ad23c 59 m_pED->init_queue<HCITD>(itd);
tvendov 0:6435b67ad23c 60 TEST_ASSERT(itd);
tvendov 0:6435b67ad23c 61 if (itd == NULL) {
tvendov 0:6435b67ad23c 62 return;
tvendov 0:6435b67ad23c 63 }
tvendov 0:6435b67ad23c 64 #if defined(TARGET_LPC1768)
tvendov 0:6435b67ad23c 65 _HCCA* hcca = reinterpret_cast<_HCCA*>(LPC_USB->HcHCCA);
tvendov 0:6435b67ad23c 66 #elif (defined(TARGET_RZ_A1H) || defined(TARGET_VK_RZ_A1H))
tvendov 0:6435b67ad23c 67 _HCCA* hcca = reinterpret_cast<_HCCA*>(ohciwrapp_reg_r(OHCI_REG_HCCA));
tvendov 0:6435b67ad23c 68 #endif
tvendov 0:6435b67ad23c 69 TEST_ASSERT(hcca);
tvendov 0:6435b67ad23c 70 if (hcca == NULL) {
tvendov 0:6435b67ad23c 71 return;
tvendov 0:6435b67ad23c 72 }
tvendov 0:6435b67ad23c 73 hcca->enqueue(m_pED);
tvendov 0:6435b67ad23c 74 }
tvendov 0:6435b67ad23c 75
tvendov 0:6435b67ad23c 76 void IsochronousEp::reset(int delay_ms)
tvendov 0:6435b67ad23c 77 {
tvendov 0:6435b67ad23c 78 #if defined(TARGET_LPC1768)
tvendov 0:6435b67ad23c 79 m_FrameNumber = LPC_USB->HcFmNumber + delay_ms;
tvendov 0:6435b67ad23c 80 #elif (defined(TARGET_RZ_A1H) || defined(TARGET_VK_RZ_A1H))
tvendov 0:6435b67ad23c 81 m_FrameNumber = ohciwrapp_reg_r(OHCI_REG_FMNUMBER) + delay_ms;
tvendov 0:6435b67ad23c 82 #endif
tvendov 0:6435b67ad23c 83 }
tvendov 0:6435b67ad23c 84
tvendov 0:6435b67ad23c 85 HCITD* IsochronousEp::new_HCITD(IsochronousEp* obj) {
tvendov 0:6435b67ad23c 86 HCITD* itd = new(m_PacketSize*m_FrameCount)HCITD(obj, 0, m_FrameCount, m_PacketSize);
tvendov 0:6435b67ad23c 87 if (itd == NULL) {
tvendov 0:6435b67ad23c 88 return NULL;
tvendov 0:6435b67ad23c 89 }
tvendov 0:6435b67ad23c 90 return itd;
tvendov 0:6435b67ad23c 91 }
tvendov 0:6435b67ad23c 92
tvendov 0:6435b67ad23c 93 HCITD* IsochronousEp::isochronousReceive(int timeout_ms) {
tvendov 0:6435b67ad23c 94 TEST_ASSERT(m_itd_queue_count >= 0);
tvendov 0:6435b67ad23c 95 while(m_itd_queue_count < m_itd_queue_limit) {
tvendov 0:6435b67ad23c 96 if (m_pED == NULL) {
tvendov 0:6435b67ad23c 97 ISO_DBG("m_pED is NULL");
tvendov 0:6435b67ad23c 98 break;
tvendov 0:6435b67ad23c 99 }
tvendov 0:6435b67ad23c 100 if (m_pED->Skip()) {
tvendov 0:6435b67ad23c 101 break;
tvendov 0:6435b67ad23c 102 }
tvendov 0:6435b67ad23c 103 HCITD* blank_itd = new_HCITD(this);
tvendov 0:6435b67ad23c 104 ((HCITD *)m_pED->TailTd)->SetStartingFrame(m_FrameNumber);
tvendov 0:6435b67ad23c 105 m_FrameNumber += m_FrameCount;
tvendov 0:6435b67ad23c 106 TEST_ASSERT(blank_itd);
tvendov 0:6435b67ad23c 107 if (m_pED->enqueue<HCITD>(blank_itd)) {
tvendov 0:6435b67ad23c 108 m_itd_queue_count++;
tvendov 0:6435b67ad23c 109 }
tvendov 0:6435b67ad23c 110 enable(); // Enable Periodic
tvendov 0:6435b67ad23c 111 }
tvendov 0:6435b67ad23c 112
tvendov 0:6435b67ad23c 113 HCITD* itd = get_queue_HCITD(timeout_ms);
tvendov 0:6435b67ad23c 114 if (itd) {
tvendov 0:6435b67ad23c 115 m_itd_queue_count--;
tvendov 0:6435b67ad23c 116 }
tvendov 0:6435b67ad23c 117 return itd;
tvendov 0:6435b67ad23c 118 }
tvendov 0:6435b67ad23c 119
tvendov 0:6435b67ad23c 120 int IsochronousEp::isochronousSend(uint8_t* buf, int len, int timeout_ms) {
tvendov 0:6435b67ad23c 121 //ISO_DBG("buf: %p, len: %d", buf, len);
tvendov 0:6435b67ad23c 122 HCITD* itd;
tvendov 0:6435b67ad23c 123
tvendov 0:6435b67ad23c 124 if (m_itd_queue_count >= m_itd_queue_limit) {
tvendov 0:6435b67ad23c 125 itd = get_queue_HCITD(timeout_ms);
tvendov 0:6435b67ad23c 126 } else {
tvendov 0:6435b67ad23c 127 itd = get_queue_HCITD(0);
tvendov 0:6435b67ad23c 128 }
tvendov 0:6435b67ad23c 129 if (itd) {
tvendov 0:6435b67ad23c 130 delete itd;
tvendov 0:6435b67ad23c 131 m_itd_queue_count--;
tvendov 0:6435b67ad23c 132 TEST_ASSERT(m_itd_queue_count >= 0);
tvendov 0:6435b67ad23c 133 }
tvendov 0:6435b67ad23c 134 TEST_ASSERT(m_itd_queue_count >= 0);
tvendov 0:6435b67ad23c 135 if(m_itd_queue_count < m_itd_queue_limit) {
tvendov 0:6435b67ad23c 136 if (m_pED == NULL) {
tvendov 0:6435b67ad23c 137 ISO_DBG("m_pED is NULL");
tvendov 0:6435b67ad23c 138 return 0;
tvendov 0:6435b67ad23c 139 }
tvendov 0:6435b67ad23c 140 if (m_pED->Skip()) {
tvendov 0:6435b67ad23c 141 return 0;
tvendov 0:6435b67ad23c 142 }
tvendov 0:6435b67ad23c 143 itd = new_HCITD(this);
tvendov 0:6435b67ad23c 144 TEST_ASSERT(itd);
tvendov 0:6435b67ad23c 145 //ISO_DBG("m_pED: %p itd: %p", m_pED, itd);
tvendov 0:6435b67ad23c 146 ((HCITD *)m_pED->TailTd)->SetStartingFrame(m_FrameNumber);
tvendov 0:6435b67ad23c 147 m_FrameNumber += m_FrameCount;
tvendov 0:6435b67ad23c 148 memcpy(const_cast<uint8_t*>(((HCITD *)m_pED->TailTd)->buf), buf, len);
tvendov 0:6435b67ad23c 149 if (m_pED->enqueue<HCITD>(itd)) {
tvendov 0:6435b67ad23c 150 m_itd_queue_count++;
tvendov 0:6435b67ad23c 151 }
tvendov 0:6435b67ad23c 152 enable(); // Enable Periodic
tvendov 0:6435b67ad23c 153 //ISO_DBG("m_itd_queue_count: %d", m_itd_queue_count);
tvendov 0:6435b67ad23c 154 return len;
tvendov 0:6435b67ad23c 155 }
tvendov 0:6435b67ad23c 156 return 0;
tvendov 0:6435b67ad23c 157 }
tvendov 0:6435b67ad23c 158
tvendov 0:6435b67ad23c 159 HCITD* IsochronousEp::get_queue_HCITD(int timeout_ms) {
tvendov 0:6435b67ad23c 160 osEvent evt = m_queue.get(timeout_ms);
tvendov 0:6435b67ad23c 161 if (evt.status == osEventMessage) {
tvendov 0:6435b67ad23c 162 HCITD* itd = reinterpret_cast<HCITD*>(evt.value.p);
tvendov 0:6435b67ad23c 163 TEST_ASSERT(itd);
tvendov 0:6435b67ad23c 164 return itd;
tvendov 0:6435b67ad23c 165 }
tvendov 0:6435b67ad23c 166 return NULL;
tvendov 0:6435b67ad23c 167 }
tvendov 0:6435b67ad23c 168
tvendov 0:6435b67ad23c 169 void IsochronousEp::enable() {
tvendov 0:6435b67ad23c 170 #if defined(TARGET_LPC1768)
tvendov 0:6435b67ad23c 171 LPC_USB->HcControl |= (OR_CONTROL_PLE | OR_CONTROL_IE);
tvendov 0:6435b67ad23c 172 #elif (defined(TARGET_RZ_A1H) || defined(TARGET_VK_RZ_A1H))
tvendov 0:6435b67ad23c 173 uint32_t data;
tvendov 0:6435b67ad23c 174
tvendov 0:6435b67ad23c 175 data = ohciwrapp_reg_r(OHCI_REG_CONTROL) | OR_CONTROL_PLE | OR_CONTROL_IE;
tvendov 0:6435b67ad23c 176 ohciwrapp_reg_w(OHCI_REG_CONTROL, data);
tvendov 0:6435b67ad23c 177 #endif
tvendov 0:6435b67ad23c 178 }
tvendov 0:6435b67ad23c 179
tvendov 0:6435b67ad23c 180 void IsochronousEp::disconnect() {
tvendov 0:6435b67ad23c 181 m_pED->setSkip(); // skip bit on
tvendov 0:6435b67ad23c 182 ISO_DBG("rtos-queue: %d", m_itd_queue_count);
tvendov 0:6435b67ad23c 183 int queue_count = m_itd_queue_count;
tvendov 0:6435b67ad23c 184 Timer t;
tvendov 0:6435b67ad23c 185 t.reset();
tvendov 0:6435b67ad23c 186 t.start();
tvendov 0:6435b67ad23c 187 do {
tvendov 0:6435b67ad23c 188 HCITD* itd = get_queue_HCITD(10);
tvendov 0:6435b67ad23c 189 if (itd) {
tvendov 0:6435b67ad23c 190 ISO_DBG("delete ITD:%p from rtos-queue %d ms", itd, t.read_ms());
tvendov 0:6435b67ad23c 191 delete itd;
tvendov 0:6435b67ad23c 192 queue_count--;
tvendov 0:6435b67ad23c 193 t.reset();
tvendov 0:6435b67ad23c 194 }
tvendov 0:6435b67ad23c 195 } while(t.read_ms() < 50);
tvendov 0:6435b67ad23c 196 ISO_DBG("rtos-queue: %d, %d ms", queue_count, t.read_ms());
tvendov 0:6435b67ad23c 197 TEST_ASSERT(queue_count >= 0);
tvendov 0:6435b67ad23c 198 while(1) {
tvendov 0:6435b67ad23c 199 HCITD* itd = m_pED->dequeue<HCITD>();
tvendov 0:6435b67ad23c 200 if (itd == NULL) {
tvendov 0:6435b67ad23c 201 break;
tvendov 0:6435b67ad23c 202 }
tvendov 0:6435b67ad23c 203 ISO_DBG("delete ITD:%p from ED(%p)-queue", itd, m_pED);
tvendov 0:6435b67ad23c 204 delete itd;
tvendov 0:6435b67ad23c 205 TEST_ASSERT(queue_count > 0);
tvendov 0:6435b67ad23c 206 queue_count--;
tvendov 0:6435b67ad23c 207 }
tvendov 0:6435b67ad23c 208 TEST_ASSERT(queue_count == 0);
tvendov 0:6435b67ad23c 209 HCITD* tail = reinterpret_cast<HCITD*>(m_pED->TailTd);
tvendov 0:6435b67ad23c 210 ISO_DBG("delete ITD:%p from ED(%p)-tail", tail, m_pED);
tvendov 0:6435b67ad23c 211 TEST_ASSERT(tail);
tvendov 0:6435b67ad23c 212 delete tail;
tvendov 0:6435b67ad23c 213 m_pED->init_queue<HCITD>(NULL);
tvendov 0:6435b67ad23c 214
tvendov 0:6435b67ad23c 215 #if defined(TARGET_LPC1768)
tvendov 0:6435b67ad23c 216 _HCCA* hcca = reinterpret_cast<_HCCA*>(LPC_USB->HcHCCA);
tvendov 0:6435b67ad23c 217 #elif (defined(TARGET_RZ_A1H) || defined(TARGET_VK_RZ_A1H))
tvendov 0:6435b67ad23c 218 _HCCA* hcca = reinterpret_cast<_HCCA*>(ohciwrapp_reg_r(OHCI_REG_HCCA));
tvendov 0:6435b67ad23c 219 #endif
tvendov 0:6435b67ad23c 220 TEST_ASSERT(hcca);
tvendov 0:6435b67ad23c 221 hcca->dequeue(m_pED);
tvendov 0:6435b67ad23c 222 ISO_DBG("delete ED:%p", m_pED);
tvendov 0:6435b67ad23c 223 delete m_pED;
tvendov 0:6435b67ad23c 224 m_pED = NULL;
tvendov 0:6435b67ad23c 225 }