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 // USBHostCam.cpp
tvendov 0:6435b67ad23c 2 #include "USBHostCam.h"
tvendov 0:6435b67ad23c 3 #include "dbg.h"
tvendov 0:6435b67ad23c 4
tvendov 0:6435b67ad23c 5 //#define CAM_DEBUG 1
tvendov 0:6435b67ad23c 6 #ifdef CAM_DEBUG
tvendov 0:6435b67ad23c 7 #define CAM_DBG(x, ...) std::printf("[%s:%d]"x"\r\n", __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
tvendov 0:6435b67ad23c 8 #else
tvendov 0:6435b67ad23c 9 #define CAM_DBG(...) while(0);
tvendov 0:6435b67ad23c 10 #endif
tvendov 0:6435b67ad23c 11
tvendov 0:6435b67ad23c 12 // ------------------ HcControl Register ---------------------
tvendov 0:6435b67ad23c 13 #define OR_CONTROL_IE 0x00000008
tvendov 0:6435b67ad23c 14
tvendov 0:6435b67ad23c 15 CamInfo* getCamInfoList(); // CamInfo.cpp
tvendov 0:6435b67ad23c 16
tvendov 0:6435b67ad23c 17 USBHostCam::USBHostCam(uint8_t size, uint8_t option, CamInfo* user_caminfo)
tvendov 0:6435b67ad23c 18 {
tvendov 0:6435b67ad23c 19 CAM_DBG("size: %d, option: %d", size, option);
tvendov 0:6435b67ad23c 20 _caminfo_size = size;
tvendov 0:6435b67ad23c 21 _caminfo_option = option;
tvendov 0:6435b67ad23c 22 if (user_caminfo) {
tvendov 0:6435b67ad23c 23 CamInfoList = user_caminfo;
tvendov 0:6435b67ad23c 24 } else {
tvendov 0:6435b67ad23c 25 CamInfoList = getCamInfoList();
tvendov 0:6435b67ad23c 26 }
tvendov 0:6435b67ad23c 27 clearOnResult();
tvendov 0:6435b67ad23c 28 host = USBHost::getHostInst();
tvendov 0:6435b67ad23c 29 m_isoEp = new IsochronousEp;
tvendov 0:6435b67ad23c 30 init();
tvendov 0:6435b67ad23c 31 }
tvendov 0:6435b67ad23c 32
tvendov 0:6435b67ad23c 33 void USBHostCam::init()
tvendov 0:6435b67ad23c 34 {
tvendov 0:6435b67ad23c 35 CAM_DBG("");
tvendov 0:6435b67ad23c 36 dev_connected = false;
tvendov 0:6435b67ad23c 37 dev = NULL;
tvendov 0:6435b67ad23c 38 cam_intf = -1;
tvendov 0:6435b67ad23c 39 device_found = false;
tvendov 0:6435b67ad23c 40 caminfo_found = false;
tvendov 0:6435b67ad23c 41 }
tvendov 0:6435b67ad23c 42
tvendov 0:6435b67ad23c 43 bool USBHostCam::connected()
tvendov 0:6435b67ad23c 44 {
tvendov 0:6435b67ad23c 45 return dev_connected;
tvendov 0:6435b67ad23c 46 }
tvendov 0:6435b67ad23c 47
tvendov 0:6435b67ad23c 48 bool USBHostCam::plugged()
tvendov 0:6435b67ad23c 49 {
tvendov 0:6435b67ad23c 50 return host->plug_status;
tvendov 0:6435b67ad23c 51 }
tvendov 0:6435b67ad23c 52
tvendov 0:6435b67ad23c 53 bool USBHostCam::connect()
tvendov 0:6435b67ad23c 54 {
tvendov 0:6435b67ad23c 55 if (dev_connected) {
tvendov 0:6435b67ad23c 56 return true;
tvendov 0:6435b67ad23c 57 }
tvendov 0:6435b67ad23c 58
tvendov 0:6435b67ad23c 59 for (uint8_t i = 0; i < MAX_DEVICE_CONNECTED; i++) {
tvendov 0:6435b67ad23c 60 if ((dev = host->getDevice(i)) != NULL) {
tvendov 0:6435b67ad23c 61
tvendov 0:6435b67ad23c 62 CAM_DBG("Trying to connect Cam device\r\n");
tvendov 0:6435b67ad23c 63
tvendov 0:6435b67ad23c 64 if(host->enumerate(dev, this)) {
tvendov 0:6435b67ad23c 65 break;
tvendov 0:6435b67ad23c 66 }
tvendov 0:6435b67ad23c 67 if (device_found) {
tvendov 0:6435b67ad23c 68 USB_INFO("New Cam: %s device: VID:%04x PID:%04x [dev: %p - intf: %d]", caminfo->name, dev->getVid(), dev->getPid(), dev, cam_intf);
tvendov 0:6435b67ad23c 69 dev->setName(caminfo->name, cam_intf);
tvendov 0:6435b67ad23c 70 host->registerDriver(dev, cam_intf, this, &USBHostCam::onDisconnect);
tvendov 0:6435b67ad23c 71 int addr = dev->getAddress();
tvendov 0:6435b67ad23c 72 m_isoEp->init(addr, caminfo->en, caminfo->mps, caminfo->frameCount, caminfo->queueLimit);
tvendov 0:6435b67ad23c 73 uint8_t buf[26];
tvendov 0:6435b67ad23c 74 memset(buf, 0, sizeof(buf));
tvendov 0:6435b67ad23c 75 buf[2] = caminfo->formatIndex;
tvendov 0:6435b67ad23c 76 buf[3] = caminfo->frameIndex;
tvendov 0:6435b67ad23c 77 *reinterpret_cast<uint32_t*>(buf+4) = caminfo->interval;
tvendov 0:6435b67ad23c 78 USB_TYPE res = Control(SET_CUR, VS_COMMIT_CONTROL, 1, buf, sizeof(buf));
tvendov 0:6435b67ad23c 79 if (res != USB_TYPE_OK) {
tvendov 0:6435b67ad23c 80 CAM_DBG("SET_CUR VS_COMMIT_CONTROL FAILED");
tvendov 0:6435b67ad23c 81 }
tvendov 0:6435b67ad23c 82 res = setInterfaceAlternate(1, caminfo->if_alt);
tvendov 0:6435b67ad23c 83 if (res != USB_TYPE_OK) {
tvendov 0:6435b67ad23c 84 CAM_DBG("SET_INTERFACE FAILED");
tvendov 0:6435b67ad23c 85 }
tvendov 0:6435b67ad23c 86 for(int i = 0; i < 16; i++) {
tvendov 0:6435b67ad23c 87 report_cc_count[i] = 0;
tvendov 0:6435b67ad23c 88 report_ps_cc_count[i] = 0;
tvendov 0:6435b67ad23c 89 }
tvendov 0:6435b67ad23c 90
tvendov 0:6435b67ad23c 91 dev_connected = true;
tvendov 0:6435b67ad23c 92 return true;
tvendov 0:6435b67ad23c 93 }
tvendov 0:6435b67ad23c 94 }
tvendov 0:6435b67ad23c 95 }
tvendov 0:6435b67ad23c 96 init();
tvendov 0:6435b67ad23c 97 return false;
tvendov 0:6435b67ad23c 98 }
tvendov 0:6435b67ad23c 99
tvendov 0:6435b67ad23c 100 void USBHostCam::onDisconnect()
tvendov 0:6435b67ad23c 101 {
tvendov 0:6435b67ad23c 102 CAM_DBG("dev_connected: %d", dev_connected);
tvendov 0:6435b67ad23c 103 if (dev_connected) {
tvendov 0:6435b67ad23c 104 m_isoEp->disconnect();
tvendov 0:6435b67ad23c 105 init();
tvendov 0:6435b67ad23c 106 }
tvendov 0:6435b67ad23c 107 }
tvendov 0:6435b67ad23c 108
tvendov 0:6435b67ad23c 109 /*virtual*/ void USBHostCam::setVidPid(uint16_t vid, uint16_t pid)
tvendov 0:6435b67ad23c 110 {
tvendov 0:6435b67ad23c 111 CAM_DBG("vid:%04x,pid:%04x", vid, pid);
tvendov 0:6435b67ad23c 112 caminfo = CamInfoList;
tvendov 0:6435b67ad23c 113 while(caminfo->vid != 0) {
tvendov 0:6435b67ad23c 114 if (caminfo->vid == vid && caminfo->pid == pid &&
tvendov 0:6435b67ad23c 115 caminfo->size == _caminfo_size && caminfo->option == _caminfo_option) {
tvendov 0:6435b67ad23c 116 caminfo_found = true;
tvendov 0:6435b67ad23c 117 break;
tvendov 0:6435b67ad23c 118 }
tvendov 0:6435b67ad23c 119 caminfo++;
tvendov 0:6435b67ad23c 120 }
tvendov 0:6435b67ad23c 121 }
tvendov 0:6435b67ad23c 122
tvendov 0:6435b67ad23c 123 /*virtual*/ bool USBHostCam::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 124 {
tvendov 0:6435b67ad23c 125 CAM_DBG("intf_nb=%d,intf_class=%02X,intf_subclass=%d,intf_protocol=%d", intf_nb, intf_class, intf_subclass, intf_protocol);
tvendov 0:6435b67ad23c 126 if ((cam_intf == -1) && caminfo_found) {
tvendov 0:6435b67ad23c 127 cam_intf = intf_nb;
tvendov 0:6435b67ad23c 128 device_found = true;
tvendov 0:6435b67ad23c 129 return true;
tvendov 0:6435b67ad23c 130 }
tvendov 0:6435b67ad23c 131 return false;
tvendov 0:6435b67ad23c 132 }
tvendov 0:6435b67ad23c 133
tvendov 0:6435b67ad23c 134 /*virtual*/ bool USBHostCam::useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir) //Must return true if the endpoint will be used
tvendov 0:6435b67ad23c 135 {
tvendov 0:6435b67ad23c 136 CAM_DBG("intf_nb:%d,type:%d,dir:%d",intf_nb, type, dir);
tvendov 0:6435b67ad23c 137 return false;
tvendov 0:6435b67ad23c 138 }
tvendov 0:6435b67ad23c 139
tvendov 0:6435b67ad23c 140 #define SEQ_READ_IDOL 0
tvendov 0:6435b67ad23c 141 #define SEQ_READ_EXEC 1
tvendov 0:6435b67ad23c 142 #define SEQ_READ_DONE 2
tvendov 0:6435b67ad23c 143
tvendov 0:6435b67ad23c 144 int USBHostCam::readJPEG(uint8_t* buf, int size, int timeout_ms) {
tvendov 0:6435b67ad23c 145 _buf = buf;
tvendov 0:6435b67ad23c 146 _pos = 0;
tvendov 0:6435b67ad23c 147 _size = size;
tvendov 0:6435b67ad23c 148 _seq = SEQ_READ_IDOL;
tvendov 0:6435b67ad23c 149 setOnResult(this, &USBHostCam::callback_motion_jpeg);
tvendov 0:6435b67ad23c 150 Timer timeout_t;
tvendov 0:6435b67ad23c 151 timeout_t.reset();
tvendov 0:6435b67ad23c 152 timeout_t.start();
tvendov 0:6435b67ad23c 153 while(timeout_t.read_ms() < timeout_ms && _seq != SEQ_READ_DONE && connected()) {
tvendov 0:6435b67ad23c 154 poll();
tvendov 0:6435b67ad23c 155 Thread::wait(1);
tvendov 0:6435b67ad23c 156 }
tvendov 0:6435b67ad23c 157 return _pos;
tvendov 0:6435b67ad23c 158 }
tvendov 0:6435b67ad23c 159
tvendov 0:6435b67ad23c 160 /* virtual */ void USBHostCam::outputJPEG(uint8_t c, int status) { // from decodeMJPEG
tvendov 0:6435b67ad23c 161 if (_seq == SEQ_READ_IDOL) {
tvendov 0:6435b67ad23c 162 if (status == JPEG_START) {
tvendov 0:6435b67ad23c 163 _pos = 0;
tvendov 0:6435b67ad23c 164 _seq = SEQ_READ_EXEC;
tvendov 0:6435b67ad23c 165 }
tvendov 0:6435b67ad23c 166 }
tvendov 0:6435b67ad23c 167 if (_seq == SEQ_READ_EXEC) {
tvendov 0:6435b67ad23c 168 if (_pos < _size) {
tvendov 0:6435b67ad23c 169 _buf[_pos++] = c;
tvendov 0:6435b67ad23c 170 }
tvendov 0:6435b67ad23c 171 if (status == JPEG_END) {
tvendov 0:6435b67ad23c 172 _seq = SEQ_READ_DONE;
tvendov 0:6435b67ad23c 173 }
tvendov 0:6435b67ad23c 174 }
tvendov 0:6435b67ad23c 175 }
tvendov 0:6435b67ad23c 176
tvendov 0:6435b67ad23c 177 void USBHostCam::callback_motion_jpeg(uint16_t frame, uint8_t* buf, int len) {
tvendov 0:6435b67ad23c 178 inputPacket(buf, len);
tvendov 0:6435b67ad23c 179 }