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 /* mbed USBHost Library
tvendov 0:6435b67ad23c 2 * Copyright (c) 2006-2013 ARM Limited
tvendov 0:6435b67ad23c 3 *
tvendov 0:6435b67ad23c 4 * Licensed under the Apache License, Version 2.0 (the "License");
tvendov 0:6435b67ad23c 5 * you may not use this file except in compliance with the License.
tvendov 0:6435b67ad23c 6 * You may obtain a copy of the License at
tvendov 0:6435b67ad23c 7 *
tvendov 0:6435b67ad23c 8 * http://www.apache.org/licenses/LICENSE-2.0
tvendov 0:6435b67ad23c 9 *
tvendov 0:6435b67ad23c 10 * Unless required by applicable law or agreed to in writing, software
tvendov 0:6435b67ad23c 11 * distributed under the License is distributed on an "AS IS" BASIS,
tvendov 0:6435b67ad23c 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
tvendov 0:6435b67ad23c 13 * See the License for the specific language governing permissions and
tvendov 0:6435b67ad23c 14 * limitations under the License.
tvendov 0:6435b67ad23c 15 */
tvendov 0:6435b67ad23c 16
tvendov 0:6435b67ad23c 17 #include "USBHostHub.h"
tvendov 0:6435b67ad23c 18
tvendov 0:6435b67ad23c 19 #if MAX_HUB_NB
tvendov 0:6435b67ad23c 20
tvendov 0:6435b67ad23c 21 #include "USBHost.h"
tvendov 0:6435b67ad23c 22 #include "dbg.h"
tvendov 0:6435b67ad23c 23
tvendov 0:6435b67ad23c 24 #define GET_STATUS 0x00
tvendov 0:6435b67ad23c 25 #define CLEAR_FEATURE 0x01
tvendov 0:6435b67ad23c 26 #define GET_STATE 0x02
tvendov 0:6435b67ad23c 27 #define SET_FEATURE 0x03
tvendov 0:6435b67ad23c 28 #define GET_DESCRIPTOR 0x06
tvendov 0:6435b67ad23c 29
tvendov 0:6435b67ad23c 30 #define PORT_CONNECTION_FEATURE (0x00)
tvendov 0:6435b67ad23c 31 #define PORT_ENABLE_FEATURE (0x01)
tvendov 0:6435b67ad23c 32 #define PORT_RESET_FEATURE (0x04)
tvendov 0:6435b67ad23c 33 #define PORT_POWER_FEATURE (0x08)
tvendov 0:6435b67ad23c 34
tvendov 0:6435b67ad23c 35 #define C_PORT_CONNECTION_FEATURE (16)
tvendov 0:6435b67ad23c 36 #define C_PORT_ENABLE_FEATURE (17)
tvendov 0:6435b67ad23c 37 #define C_PORT_RESET_FEATURE (20)
tvendov 0:6435b67ad23c 38
tvendov 0:6435b67ad23c 39 #define PORT_CONNECTION (1 << 0)
tvendov 0:6435b67ad23c 40 #define PORT_ENABLE (1 << 1)
tvendov 0:6435b67ad23c 41 #define PORT_SUSPEND (1 << 2)
tvendov 0:6435b67ad23c 42 #define PORT_OVER_CURRENT (1 << 3)
tvendov 0:6435b67ad23c 43 #define PORT_RESET (1 << 4)
tvendov 0:6435b67ad23c 44 #define PORT_POWER (1 << 8)
tvendov 0:6435b67ad23c 45 #define PORT_LOW_SPEED (1 << 9)
tvendov 0:6435b67ad23c 46
tvendov 0:6435b67ad23c 47 #define C_PORT_CONNECTION (1 << 16)
tvendov 0:6435b67ad23c 48 #define C_PORT_ENABLE (1 << 17)
tvendov 0:6435b67ad23c 49 #define C_PORT_SUSPEND (1 << 18)
tvendov 0:6435b67ad23c 50 #define C_PORT_OVER_CURRENT (1 << 19)
tvendov 0:6435b67ad23c 51 #define C_PORT_RESET (1 << 20)
tvendov 0:6435b67ad23c 52
tvendov 0:6435b67ad23c 53 USBHostHub::USBHostHub() {
tvendov 0:6435b67ad23c 54 host = NULL;
tvendov 0:6435b67ad23c 55 init();
tvendov 0:6435b67ad23c 56 }
tvendov 0:6435b67ad23c 57
tvendov 0:6435b67ad23c 58 void USBHostHub::init() {
tvendov 0:6435b67ad23c 59 dev_connected = false;
tvendov 0:6435b67ad23c 60 dev = NULL;
tvendov 0:6435b67ad23c 61 int_in = NULL;
tvendov 0:6435b67ad23c 62 dev_connected = false;
tvendov 0:6435b67ad23c 63 hub_intf = -1;
tvendov 0:6435b67ad23c 64 hub_device_found = false;
tvendov 0:6435b67ad23c 65 nb_port = 0;
tvendov 0:6435b67ad23c 66 hub_characteristics = 0;
tvendov 0:6435b67ad23c 67
tvendov 0:6435b67ad23c 68 for (int i = 0; i < MAX_HUB_PORT; i++) {
tvendov 0:6435b67ad23c 69 device_children[i] = NULL;
tvendov 0:6435b67ad23c 70 }
tvendov 0:6435b67ad23c 71 }
tvendov 0:6435b67ad23c 72
tvendov 0:6435b67ad23c 73 void USBHostHub::setHost(USBHost * host_) {
tvendov 0:6435b67ad23c 74 host = host_;
tvendov 0:6435b67ad23c 75 }
tvendov 0:6435b67ad23c 76
tvendov 0:6435b67ad23c 77 bool USBHostHub::connected()
tvendov 0:6435b67ad23c 78 {
tvendov 0:6435b67ad23c 79 return dev_connected;
tvendov 0:6435b67ad23c 80 }
tvendov 0:6435b67ad23c 81
tvendov 0:6435b67ad23c 82 bool USBHostHub::connect(USBDeviceConnected * dev)
tvendov 0:6435b67ad23c 83 {
tvendov 0:6435b67ad23c 84 if (dev_connected) {
tvendov 0:6435b67ad23c 85 return true;
tvendov 0:6435b67ad23c 86 }
tvendov 0:6435b67ad23c 87
tvendov 0:6435b67ad23c 88 if(host->enumerate(dev, this)) {
tvendov 0:6435b67ad23c 89 init();
tvendov 0:6435b67ad23c 90 return false;
tvendov 0:6435b67ad23c 91 }
tvendov 0:6435b67ad23c 92
tvendov 0:6435b67ad23c 93 if (hub_device_found) {
tvendov 0:6435b67ad23c 94 this->dev = dev;
tvendov 0:6435b67ad23c 95
tvendov 0:6435b67ad23c 96 int_in = dev->getEndpoint(hub_intf, INTERRUPT_ENDPOINT, IN);
tvendov 0:6435b67ad23c 97
tvendov 0:6435b67ad23c 98 if (!int_in) {
tvendov 0:6435b67ad23c 99 init();
tvendov 0:6435b67ad23c 100 return false;
tvendov 0:6435b67ad23c 101 }
tvendov 0:6435b67ad23c 102
tvendov 0:6435b67ad23c 103 USB_INFO("New HUB: VID:%04x PID:%04x [dev: %p - intf: %d]", dev->getVid(), dev->getPid(), dev, hub_intf);
tvendov 0:6435b67ad23c 104 dev->setName("Hub", hub_intf);
tvendov 0:6435b67ad23c 105 host->registerDriver(dev, hub_intf, this, &USBHostHub::disconnect);
tvendov 0:6435b67ad23c 106
tvendov 0:6435b67ad23c 107 int_in->attach(this, &USBHostHub::rxHandler);
tvendov 0:6435b67ad23c 108
tvendov 0:6435b67ad23c 109 // get HUB descriptor
tvendov 0:6435b67ad23c 110 host->controlRead( dev,
tvendov 0:6435b67ad23c 111 USB_DEVICE_TO_HOST | USB_REQUEST_TYPE_CLASS,
tvendov 0:6435b67ad23c 112 GET_DESCRIPTOR,
tvendov 0:6435b67ad23c 113 0x29 << 8, 0, buf, sizeof(HubDescriptor));
tvendov 0:6435b67ad23c 114 nb_port = buf[2];
tvendov 0:6435b67ad23c 115 hub_characteristics = buf[3];
tvendov 0:6435b67ad23c 116
tvendov 0:6435b67ad23c 117 USB_DBG("Hub has %d port", nb_port);
tvendov 0:6435b67ad23c 118
tvendov 0:6435b67ad23c 119 for (uint8_t j = 1; j <= nb_port; j++) {
tvendov 0:6435b67ad23c 120 setPortFeature(PORT_POWER_FEATURE, j);
tvendov 0:6435b67ad23c 121 }
tvendov 0:6435b67ad23c 122 wait_ms(buf[5]*2);
tvendov 0:6435b67ad23c 123
tvendov 0:6435b67ad23c 124 host->interruptRead(dev, int_in, buf, 1, false);
tvendov 0:6435b67ad23c 125 dev_connected = true;
tvendov 0:6435b67ad23c 126 return true;
tvendov 0:6435b67ad23c 127 }
tvendov 0:6435b67ad23c 128
tvendov 0:6435b67ad23c 129 return false;
tvendov 0:6435b67ad23c 130 }
tvendov 0:6435b67ad23c 131
tvendov 0:6435b67ad23c 132 void USBHostHub::disconnect() {
tvendov 0:6435b67ad23c 133 init();
tvendov 0:6435b67ad23c 134 }
tvendov 0:6435b67ad23c 135
tvendov 0:6435b67ad23c 136 /*virtual*/ void USBHostHub::setVidPid(uint16_t vid, uint16_t pid)
tvendov 0:6435b67ad23c 137 {
tvendov 0:6435b67ad23c 138 // we don't check VID/PID for MSD driver
tvendov 0:6435b67ad23c 139 }
tvendov 0:6435b67ad23c 140
tvendov 0:6435b67ad23c 141 /*virtual*/ bool USBHostHub::parseInterface(uint8_t intf_nb, uint8_t intf_class, uint8_t intf_subclass, uint8_t intf_protocol) //Must return true if the interface should be parsed
tvendov 0:6435b67ad23c 142 {
tvendov 0:6435b67ad23c 143 if ((hub_intf == -1) &&
tvendov 0:6435b67ad23c 144 (intf_class == HUB_CLASS) &&
tvendov 0:6435b67ad23c 145 (intf_subclass == 0) &&
tvendov 0:6435b67ad23c 146 (intf_protocol == 0)) {
tvendov 0:6435b67ad23c 147 hub_intf = intf_nb;
tvendov 0:6435b67ad23c 148 return true;
tvendov 0:6435b67ad23c 149 }
tvendov 0:6435b67ad23c 150 return false;
tvendov 0:6435b67ad23c 151 }
tvendov 0:6435b67ad23c 152
tvendov 0:6435b67ad23c 153 /*virtual*/ bool USBHostHub::useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir) //Must return true if the endpoint will be used
tvendov 0:6435b67ad23c 154 {
tvendov 0:6435b67ad23c 155 if (intf_nb == hub_intf) {
tvendov 0:6435b67ad23c 156 if ((type == INTERRUPT_ENDPOINT) && (dir == IN)) {
tvendov 0:6435b67ad23c 157 hub_device_found = true;
tvendov 0:6435b67ad23c 158 return true;
tvendov 0:6435b67ad23c 159 }
tvendov 0:6435b67ad23c 160 }
tvendov 0:6435b67ad23c 161 return false;
tvendov 0:6435b67ad23c 162 }
tvendov 0:6435b67ad23c 163
tvendov 0:6435b67ad23c 164 void USBHostHub::deviceConnected(USBDeviceConnected * dev) {
tvendov 0:6435b67ad23c 165 device_children[dev->getPort() - 1] = dev;
tvendov 0:6435b67ad23c 166 }
tvendov 0:6435b67ad23c 167
tvendov 0:6435b67ad23c 168 void USBHostHub::deviceDisconnected(USBDeviceConnected * dev) {
tvendov 0:6435b67ad23c 169 device_children[dev->getPort() - 1] = NULL;
tvendov 0:6435b67ad23c 170 }
tvendov 0:6435b67ad23c 171
tvendov 0:6435b67ad23c 172 void USBHostHub::hubDisconnected() {
tvendov 0:6435b67ad23c 173 for (uint8_t i = 0; i < MAX_HUB_PORT; i++) {
tvendov 0:6435b67ad23c 174 if (device_children[i] != NULL) {
tvendov 0:6435b67ad23c 175 host->freeDevice(device_children[i]);
tvendov 0:6435b67ad23c 176 }
tvendov 0:6435b67ad23c 177 }
tvendov 0:6435b67ad23c 178 }
tvendov 0:6435b67ad23c 179
tvendov 0:6435b67ad23c 180 void USBHostHub::rxHandler() {
tvendov 0:6435b67ad23c 181 uint32_t status;
tvendov 0:6435b67ad23c 182 if (int_in) {
tvendov 0:6435b67ad23c 183 if (int_in->getState() == USB_TYPE_IDLE) {
tvendov 0:6435b67ad23c 184 for (int port = 1; port <= nb_port; port++) {
tvendov 0:6435b67ad23c 185 status = getPortStatus(port);
tvendov 0:6435b67ad23c 186 USB_DBG("[hub handler hub: %d] status port %d [hub: %p]: 0x%X", dev->getHub(), port, dev, status);
tvendov 0:6435b67ad23c 187
tvendov 0:6435b67ad23c 188 // if connection status has changed
tvendov 0:6435b67ad23c 189 if (status & C_PORT_CONNECTION) {
tvendov 0:6435b67ad23c 190 if (status & PORT_CONNECTION) {
tvendov 0:6435b67ad23c 191 USB_DBG("[hub handler hub: %d - port: %d] new device connected", dev->getHub(), port);
tvendov 0:6435b67ad23c 192 host->deviceConnected(dev->getHub() + 1, port, status & PORT_LOW_SPEED, this);
tvendov 0:6435b67ad23c 193 } else {
tvendov 0:6435b67ad23c 194 USB_DBG("[hub handler hub: %d - port: %d] device disconnected", dev->getHub(), port);
tvendov 0:6435b67ad23c 195 host->deviceDisconnected(dev->getHub() + 1, port, this, 0);
tvendov 0:6435b67ad23c 196 }
tvendov 0:6435b67ad23c 197
tvendov 0:6435b67ad23c 198 clearPortFeature(C_PORT_CONNECTION_FEATURE, port);
tvendov 0:6435b67ad23c 199 }
tvendov 0:6435b67ad23c 200
tvendov 0:6435b67ad23c 201 if (status & C_PORT_RESET) {
tvendov 0:6435b67ad23c 202 clearPortFeature(C_PORT_RESET_FEATURE, port);
tvendov 0:6435b67ad23c 203 }
tvendov 0:6435b67ad23c 204
tvendov 0:6435b67ad23c 205 if (status & C_PORT_ENABLE) {
tvendov 0:6435b67ad23c 206 clearPortFeature(C_PORT_ENABLE_FEATURE, port);
tvendov 0:6435b67ad23c 207 }
tvendov 0:6435b67ad23c 208
tvendov 0:6435b67ad23c 209 if ((status & PORT_OVER_CURRENT)) {
tvendov 0:6435b67ad23c 210 USB_ERR("OVER CURRENT DETECTED\r\n");
tvendov 0:6435b67ad23c 211 clearPortFeature(PORT_OVER_CURRENT, port);
tvendov 0:6435b67ad23c 212 host->deviceDisconnected(dev->getHub() + 1, port, this, 0);
tvendov 0:6435b67ad23c 213 }
tvendov 0:6435b67ad23c 214 }
tvendov 0:6435b67ad23c 215 }
tvendov 0:6435b67ad23c 216 host->interruptRead(dev, int_in, buf, 1, false);
tvendov 0:6435b67ad23c 217 }
tvendov 0:6435b67ad23c 218 }
tvendov 0:6435b67ad23c 219
tvendov 0:6435b67ad23c 220 void USBHostHub::portReset(uint8_t port) {
tvendov 0:6435b67ad23c 221 // reset port
tvendov 0:6435b67ad23c 222 uint32_t status;
tvendov 0:6435b67ad23c 223 USB_DBG("reset port %d on hub: %p [this: %p]", port, dev, this)
tvendov 0:6435b67ad23c 224 setPortFeature(PORT_RESET_FEATURE, port);
tvendov 0:6435b67ad23c 225 #if defined(TARGET_RZ_A1H)
tvendov 0:6435b67ad23c 226 Thread::wait(50); // Reset release waiting for Hi-Speed check.
tvendov 0:6435b67ad23c 227 #endif
tvendov 0:6435b67ad23c 228 while(1) {
tvendov 0:6435b67ad23c 229 status = getPortStatus(port);
tvendov 0:6435b67ad23c 230 if (status & (PORT_ENABLE | PORT_RESET))
tvendov 0:6435b67ad23c 231 break;
tvendov 0:6435b67ad23c 232 if (status & PORT_OVER_CURRENT) {
tvendov 0:6435b67ad23c 233 USB_ERR("OVER CURRENT DETECTED\r\n");
tvendov 0:6435b67ad23c 234 clearPortFeature(PORT_OVER_CURRENT, port);
tvendov 0:6435b67ad23c 235 host->deviceDisconnected(dev->getHub() + 1, port, this, 0);
tvendov 0:6435b67ad23c 236 break;
tvendov 0:6435b67ad23c 237 }
tvendov 0:6435b67ad23c 238 Thread::wait(10);
tvendov 0:6435b67ad23c 239 }
tvendov 0:6435b67ad23c 240 }
tvendov 0:6435b67ad23c 241
tvendov 0:6435b67ad23c 242 void USBHostHub::setPortFeature(uint32_t feature, uint8_t port) {
tvendov 0:6435b67ad23c 243 host->controlWrite( dev,
tvendov 0:6435b67ad23c 244 USB_HOST_TO_DEVICE | USB_REQUEST_TYPE_CLASS | USB_RECIPIENT_INTERFACE | USB_RECIPIENT_ENDPOINT,
tvendov 0:6435b67ad23c 245 SET_FEATURE,
tvendov 0:6435b67ad23c 246 feature,
tvendov 0:6435b67ad23c 247 port,
tvendov 0:6435b67ad23c 248 NULL,
tvendov 0:6435b67ad23c 249 0);
tvendov 0:6435b67ad23c 250 }
tvendov 0:6435b67ad23c 251
tvendov 0:6435b67ad23c 252 void USBHostHub::clearPortFeature(uint32_t feature, uint8_t port) {
tvendov 0:6435b67ad23c 253 host->controlWrite( dev,
tvendov 0:6435b67ad23c 254 USB_HOST_TO_DEVICE | USB_REQUEST_TYPE_CLASS | USB_RECIPIENT_INTERFACE | USB_RECIPIENT_ENDPOINT,
tvendov 0:6435b67ad23c 255 CLEAR_FEATURE,
tvendov 0:6435b67ad23c 256 feature,
tvendov 0:6435b67ad23c 257 port,
tvendov 0:6435b67ad23c 258 NULL,
tvendov 0:6435b67ad23c 259 0);
tvendov 0:6435b67ad23c 260 }
tvendov 0:6435b67ad23c 261
tvendov 0:6435b67ad23c 262 uint32_t USBHostHub::getPortStatus(uint8_t port) {
tvendov 0:6435b67ad23c 263 uint32_t st;
tvendov 0:6435b67ad23c 264 host->controlRead( dev,
tvendov 0:6435b67ad23c 265 USB_DEVICE_TO_HOST | USB_REQUEST_TYPE_CLASS | USB_RECIPIENT_INTERFACE | USB_RECIPIENT_ENDPOINT,
tvendov 0:6435b67ad23c 266 GET_STATUS,
tvendov 0:6435b67ad23c 267 0,
tvendov 0:6435b67ad23c 268 port,
tvendov 0:6435b67ad23c 269 (uint8_t *)&st,
tvendov 0:6435b67ad23c 270 4);
tvendov 0:6435b67ad23c 271 return st;
tvendov 0:6435b67ad23c 272 }
tvendov 0:6435b67ad23c 273
tvendov 0:6435b67ad23c 274 #endif