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
USB/USBisochronous/USBIsochronous.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 | // USBIsochronous.h |
tvendov | 0:6435b67ad23c | 2 | #pragma once |
tvendov | 0:6435b67ad23c | 3 | #if !defined (__CC_ARM) && (!defined (_POSIX_C_SOURCE) || (_POSIX_C_SOURCE < 200112L)) |
tvendov | 0:6435b67ad23c | 4 | #if defined(__ICCARM__) |
tvendov | 0:6435b67ad23c | 5 | #include <iar_dlmalloc.h> |
tvendov | 0:6435b67ad23c | 6 | #define memalign __iar_dlmemalign |
tvendov | 0:6435b67ad23c | 7 | #else |
tvendov | 0:6435b67ad23c | 8 | #include <malloc.h> |
tvendov | 0:6435b67ad23c | 9 | #endif |
tvendov | 0:6435b67ad23c | 10 | #endif |
tvendov | 0:6435b67ad23c | 11 | |
tvendov | 0:6435b67ad23c | 12 | class IsochronousEp; |
tvendov | 0:6435b67ad23c | 13 | struct HCITD { // HostController Isochronous Transfer Descriptor |
tvendov | 0:6435b67ad23c | 14 | __IO uint32_t Control; // +0 Transfer descriptor control |
tvendov | 0:6435b67ad23c | 15 | uint8_t* BufferPage0; // +4 Buffer Page 0 |
tvendov | 0:6435b67ad23c | 16 | HCITD* Next; // +8 Physical pointer to next Isochronous Transfer Descriptor |
tvendov | 0:6435b67ad23c | 17 | uint8_t* BufferEnd; // +12 buffer End |
tvendov | 0:6435b67ad23c | 18 | __IO uint16_t OffsetPSW[8]; // +16 Offset/PSW |
tvendov | 0:6435b67ad23c | 19 | IsochronousEp* ep; // +32 endpoint object |
tvendov | 0:6435b67ad23c | 20 | uint8_t* buf; // +36 buffer |
tvendov | 0:6435b67ad23c | 21 | // +40 |
tvendov | 0:6435b67ad23c | 22 | HCITD(IsochronousEp* obj, uint16_t FrameNumber, int FrameCount, uint16_t PacketSize); |
tvendov | 0:6435b67ad23c | 23 | inline void* operator new(size_t size, int buf_size) { |
tvendov | 0:6435b67ad23c | 24 | void* p; |
tvendov | 0:6435b67ad23c | 25 | struct HCITD * wk_hcitd; |
tvendov | 0:6435b67ad23c | 26 | void* q; |
tvendov | 0:6435b67ad23c | 27 | #if !defined (__CC_ARM) && (!defined (_POSIX_C_SOURCE) || (_POSIX_C_SOURCE < 200112L)) |
tvendov | 0:6435b67ad23c | 28 | p = memalign(0x20, size); |
tvendov | 0:6435b67ad23c | 29 | if (p != NULL) { |
tvendov | 0:6435b67ad23c | 30 | q = memalign(0x1000, buf_size); |
tvendov | 0:6435b67ad23c | 31 | if (q != NULL) { |
tvendov | 0:6435b67ad23c | 32 | wk_hcitd = (struct HCITD *)p; |
tvendov | 0:6435b67ad23c | 33 | wk_hcitd->buf = (uint8_t*)q; |
tvendov | 0:6435b67ad23c | 34 | } else { |
tvendov | 0:6435b67ad23c | 35 | free(p); |
tvendov | 0:6435b67ad23c | 36 | p = NULL; |
tvendov | 0:6435b67ad23c | 37 | } |
tvendov | 0:6435b67ad23c | 38 | } |
tvendov | 0:6435b67ad23c | 39 | return p; |
tvendov | 0:6435b67ad23c | 40 | #else |
tvendov | 0:6435b67ad23c | 41 | if (posix_memalign(&p, 0x20, size) == 0) { |
tvendov | 0:6435b67ad23c | 42 | if (posix_memalign(&q, 0x1000, buf_size) == 0) { |
tvendov | 0:6435b67ad23c | 43 | wk_hcitd = (struct HCITD *)p; |
tvendov | 0:6435b67ad23c | 44 | wk_hcitd->buf = (uint8_t*)q; |
tvendov | 0:6435b67ad23c | 45 | } else { |
tvendov | 0:6435b67ad23c | 46 | free(p); |
tvendov | 0:6435b67ad23c | 47 | p = NULL; |
tvendov | 0:6435b67ad23c | 48 | } |
tvendov | 0:6435b67ad23c | 49 | return p; |
tvendov | 0:6435b67ad23c | 50 | } |
tvendov | 0:6435b67ad23c | 51 | return NULL; |
tvendov | 0:6435b67ad23c | 52 | #endif |
tvendov | 0:6435b67ad23c | 53 | } |
tvendov | 0:6435b67ad23c | 54 | |
tvendov | 0:6435b67ad23c | 55 | inline void operator delete(void* p) { |
tvendov | 0:6435b67ad23c | 56 | struct HCITD * wk_hcitd = (struct HCITD *)p; |
tvendov | 0:6435b67ad23c | 57 | free((void *)wk_hcitd->buf); |
tvendov | 0:6435b67ad23c | 58 | free(p); |
tvendov | 0:6435b67ad23c | 59 | } |
tvendov | 0:6435b67ad23c | 60 | |
tvendov | 0:6435b67ad23c | 61 | inline uint16_t StartingFrame() { |
tvendov | 0:6435b67ad23c | 62 | return Control & 0xffff; |
tvendov | 0:6435b67ad23c | 63 | } |
tvendov | 0:6435b67ad23c | 64 | |
tvendov | 0:6435b67ad23c | 65 | inline void SetStartingFrame(uint16_t FrameNumber) { |
tvendov | 0:6435b67ad23c | 66 | Control = (Control & 0xffff0000) | FrameNumber; |
tvendov | 0:6435b67ad23c | 67 | } |
tvendov | 0:6435b67ad23c | 68 | |
tvendov | 0:6435b67ad23c | 69 | inline uint8_t FrameCount() { |
tvendov | 0:6435b67ad23c | 70 | return ((Control>>24)&7)+1; |
tvendov | 0:6435b67ad23c | 71 | } |
tvendov | 0:6435b67ad23c | 72 | |
tvendov | 0:6435b67ad23c | 73 | inline uint8_t ConditionCode() { |
tvendov | 0:6435b67ad23c | 74 | return Control>>28; |
tvendov | 0:6435b67ad23c | 75 | } |
tvendov | 0:6435b67ad23c | 76 | }; |
tvendov | 0:6435b67ad23c | 77 | |
tvendov | 0:6435b67ad23c | 78 | struct _HCED { // HostController EndPoint Descriptor |
tvendov | 0:6435b67ad23c | 79 | __IO uint32_t Control; // +0 Endpoint descriptor control |
tvendov | 0:6435b67ad23c | 80 | HCTD* TailTd; // +4 Physical address of tail in Transfer descriptor list |
tvendov | 0:6435b67ad23c | 81 | __IO HCTD* HeadTd; // +8 Physcial address of head in Transfer descriptor list |
tvendov | 0:6435b67ad23c | 82 | _HCED* Next; // +12 Physical address of next Endpoint descriptor |
tvendov | 0:6435b67ad23c | 83 | // +16 |
tvendov | 0:6435b67ad23c | 84 | _HCED(int addr, uint8_t ep, uint16_t size, int lowSpeed = 0) { |
tvendov | 0:6435b67ad23c | 85 | Control = addr | /* USB address */ |
tvendov | 0:6435b67ad23c | 86 | ((ep & 0x7F) << 7) | /* Endpoint address */ |
tvendov | 0:6435b67ad23c | 87 | (ep!=0?(((ep&0x80)?2:1) << 11):0)| /* direction : Out = 1, 2 = In */ |
tvendov | 0:6435b67ad23c | 88 | ((lowSpeed?1:0) << 13) | /* speed full=0 low=1 */ |
tvendov | 0:6435b67ad23c | 89 | (size << 16); /* MaxPkt Size */ |
tvendov | 0:6435b67ad23c | 90 | Next = NULL; |
tvendov | 0:6435b67ad23c | 91 | } |
tvendov | 0:6435b67ad23c | 92 | |
tvendov | 0:6435b67ad23c | 93 | inline void* operator new(size_t size) { |
tvendov | 0:6435b67ad23c | 94 | void* p; |
tvendov | 0:6435b67ad23c | 95 | #if !defined (__CC_ARM) && (!defined (_POSIX_C_SOURCE) || (_POSIX_C_SOURCE < 200112L)) |
tvendov | 0:6435b67ad23c | 96 | p = memalign(16, size); |
tvendov | 0:6435b67ad23c | 97 | return p; |
tvendov | 0:6435b67ad23c | 98 | #else |
tvendov | 0:6435b67ad23c | 99 | if (posix_memalign(&p, 16, size) == 0) { |
tvendov | 0:6435b67ad23c | 100 | return p; |
tvendov | 0:6435b67ad23c | 101 | } |
tvendov | 0:6435b67ad23c | 102 | return NULL; |
tvendov | 0:6435b67ad23c | 103 | #endif |
tvendov | 0:6435b67ad23c | 104 | } |
tvendov | 0:6435b67ad23c | 105 | |
tvendov | 0:6435b67ad23c | 106 | inline void operator delete(void* p) { |
tvendov | 0:6435b67ad23c | 107 | free(p); |
tvendov | 0:6435b67ad23c | 108 | } |
tvendov | 0:6435b67ad23c | 109 | |
tvendov | 0:6435b67ad23c | 110 | inline uint8_t FunctionAddress() { |
tvendov | 0:6435b67ad23c | 111 | return Control & 0x7f; |
tvendov | 0:6435b67ad23c | 112 | } |
tvendov | 0:6435b67ad23c | 113 | |
tvendov | 0:6435b67ad23c | 114 | inline int Speed() { |
tvendov | 0:6435b67ad23c | 115 | return (Control>>13)&1; |
tvendov | 0:6435b67ad23c | 116 | } |
tvendov | 0:6435b67ad23c | 117 | |
tvendov | 0:6435b67ad23c | 118 | inline void setFunctionAddress(int addr) { |
tvendov | 0:6435b67ad23c | 119 | Control &= ~0x7f; |
tvendov | 0:6435b67ad23c | 120 | Control |= addr; |
tvendov | 0:6435b67ad23c | 121 | } |
tvendov | 0:6435b67ad23c | 122 | |
tvendov | 0:6435b67ad23c | 123 | inline void setMaxPacketSize(uint16_t size) { |
tvendov | 0:6435b67ad23c | 124 | Control &= ~0xffff0000; |
tvendov | 0:6435b67ad23c | 125 | Control |= size<<16; |
tvendov | 0:6435b67ad23c | 126 | } |
tvendov | 0:6435b67ad23c | 127 | |
tvendov | 0:6435b67ad23c | 128 | int Skip() { |
tvendov | 0:6435b67ad23c | 129 | return (Control>>14) & 1; |
tvendov | 0:6435b67ad23c | 130 | } |
tvendov | 0:6435b67ad23c | 131 | |
tvendov | 0:6435b67ad23c | 132 | void setSkip() { |
tvendov | 0:6435b67ad23c | 133 | Control |= (1<<14); |
tvendov | 0:6435b67ad23c | 134 | } |
tvendov | 0:6435b67ad23c | 135 | |
tvendov | 0:6435b67ad23c | 136 | void setFormat() { |
tvendov | 0:6435b67ad23c | 137 | Control |= (1<<15); |
tvendov | 0:6435b67ad23c | 138 | } |
tvendov | 0:6435b67ad23c | 139 | |
tvendov | 0:6435b67ad23c | 140 | template<typename T> |
tvendov | 0:6435b67ad23c | 141 | inline bool enqueue(T* td) { |
tvendov | 0:6435b67ad23c | 142 | if (td) { |
tvendov | 0:6435b67ad23c | 143 | T* tail = reinterpret_cast<T*>(TailTd); |
tvendov | 0:6435b67ad23c | 144 | if (tail) { |
tvendov | 0:6435b67ad23c | 145 | tail->Next = td; |
tvendov | 0:6435b67ad23c | 146 | TailTd = reinterpret_cast<HCTD*>(td); |
tvendov | 0:6435b67ad23c | 147 | return true; |
tvendov | 0:6435b67ad23c | 148 | } |
tvendov | 0:6435b67ad23c | 149 | } |
tvendov | 0:6435b67ad23c | 150 | return false; |
tvendov | 0:6435b67ad23c | 151 | } |
tvendov | 0:6435b67ad23c | 152 | |
tvendov | 0:6435b67ad23c | 153 | template<typename T> |
tvendov | 0:6435b67ad23c | 154 | inline T* dequeue() { |
tvendov | 0:6435b67ad23c | 155 | T* head = reinterpret_cast<T*>(reinterpret_cast<uint32_t>(HeadTd)&~3); // delete Halted and Toggle Carry bit |
tvendov | 0:6435b67ad23c | 156 | T* tail = reinterpret_cast<T*>(TailTd); |
tvendov | 0:6435b67ad23c | 157 | if (head == NULL || tail == NULL || head == tail) { |
tvendov | 0:6435b67ad23c | 158 | return NULL; |
tvendov | 0:6435b67ad23c | 159 | } |
tvendov | 0:6435b67ad23c | 160 | HeadTd = reinterpret_cast<HCTD*>(head->Next); |
tvendov | 0:6435b67ad23c | 161 | return head; |
tvendov | 0:6435b67ad23c | 162 | } |
tvendov | 0:6435b67ad23c | 163 | template<typename T> |
tvendov | 0:6435b67ad23c | 164 | void init_queue(T* td) { |
tvendov | 0:6435b67ad23c | 165 | TailTd = reinterpret_cast<HCTD*>(td); |
tvendov | 0:6435b67ad23c | 166 | HeadTd = reinterpret_cast<HCTD*>(td); |
tvendov | 0:6435b67ad23c | 167 | } |
tvendov | 0:6435b67ad23c | 168 | }; |
tvendov | 0:6435b67ad23c | 169 | |
tvendov | 0:6435b67ad23c | 170 | struct _HCCA { // Host Controller Communication Area |
tvendov | 0:6435b67ad23c | 171 | _HCED* InterruptTable[32]; // +0 Interrupt Table |
tvendov | 0:6435b67ad23c | 172 | __IO uint16_t FrameNumber;// +128 Frame Number |
tvendov | 0:6435b67ad23c | 173 | __IO uint16_t Pad1; // +130 |
tvendov | 0:6435b67ad23c | 174 | __IO HCTD* DoneHead; // +132 Done Head |
tvendov | 0:6435b67ad23c | 175 | uint8_t Reserved[116]; // +136 Reserved for future use |
tvendov | 0:6435b67ad23c | 176 | uint8_t Unknown[4]; // +252 Unused |
tvendov | 0:6435b67ad23c | 177 | // +256 |
tvendov | 0:6435b67ad23c | 178 | inline void* operator new(size_t size) { |
tvendov | 0:6435b67ad23c | 179 | void* p; |
tvendov | 0:6435b67ad23c | 180 | #if !defined (__CC_ARM) && (!defined (_POSIX_C_SOURCE) || (_POSIX_C_SOURCE < 200112L)) |
tvendov | 0:6435b67ad23c | 181 | p = memalign(256, size); |
tvendov | 0:6435b67ad23c | 182 | return p; |
tvendov | 0:6435b67ad23c | 183 | #else |
tvendov | 0:6435b67ad23c | 184 | if (posix_memalign(&p, 256, size) == 0) { |
tvendov | 0:6435b67ad23c | 185 | return p; |
tvendov | 0:6435b67ad23c | 186 | } |
tvendov | 0:6435b67ad23c | 187 | return NULL; |
tvendov | 0:6435b67ad23c | 188 | #endif |
tvendov | 0:6435b67ad23c | 189 | } |
tvendov | 0:6435b67ad23c | 190 | |
tvendov | 0:6435b67ad23c | 191 | inline void operator delete(void* p) { |
tvendov | 0:6435b67ad23c | 192 | free(p); |
tvendov | 0:6435b67ad23c | 193 | } |
tvendov | 0:6435b67ad23c | 194 | |
tvendov | 0:6435b67ad23c | 195 | inline void enqueue(_HCED* ed) { |
tvendov | 0:6435b67ad23c | 196 | for(int i = 0; i < 32; i++) { |
tvendov | 0:6435b67ad23c | 197 | if (InterruptTable[i] == NULL) { |
tvendov | 0:6435b67ad23c | 198 | InterruptTable[i] = ed; |
tvendov | 0:6435b67ad23c | 199 | } else { |
tvendov | 0:6435b67ad23c | 200 | _HCED* nextEd = InterruptTable[i]; |
tvendov | 0:6435b67ad23c | 201 | while(nextEd->Next && nextEd->Next != ed) { |
tvendov | 0:6435b67ad23c | 202 | nextEd = nextEd->Next; |
tvendov | 0:6435b67ad23c | 203 | } |
tvendov | 0:6435b67ad23c | 204 | nextEd->Next = ed; |
tvendov | 0:6435b67ad23c | 205 | } |
tvendov | 0:6435b67ad23c | 206 | } |
tvendov | 0:6435b67ad23c | 207 | } |
tvendov | 0:6435b67ad23c | 208 | |
tvendov | 0:6435b67ad23c | 209 | inline void dequeue(_HCED* ed) { |
tvendov | 0:6435b67ad23c | 210 | for(int i = 0; i < 32; i++) { |
tvendov | 0:6435b67ad23c | 211 | if (InterruptTable[i] == ed) { |
tvendov | 0:6435b67ad23c | 212 | InterruptTable[i] = ed->Next; |
tvendov | 0:6435b67ad23c | 213 | } else if (InterruptTable[i]) { |
tvendov | 0:6435b67ad23c | 214 | _HCED* nextEd = InterruptTable[i]; |
tvendov | 0:6435b67ad23c | 215 | while(nextEd) { |
tvendov | 0:6435b67ad23c | 216 | if (nextEd->Next == ed) { |
tvendov | 0:6435b67ad23c | 217 | nextEd->Next = ed->Next; |
tvendov | 0:6435b67ad23c | 218 | break; |
tvendov | 0:6435b67ad23c | 219 | } |
tvendov | 0:6435b67ad23c | 220 | nextEd = nextEd->Next; |
tvendov | 0:6435b67ad23c | 221 | } |
tvendov | 0:6435b67ad23c | 222 | } |
tvendov | 0:6435b67ad23c | 223 | } |
tvendov | 0:6435b67ad23c | 224 | } |
tvendov | 0:6435b67ad23c | 225 | }; |
tvendov | 0:6435b67ad23c | 226 | |
tvendov | 0:6435b67ad23c | 227 | #define HCITD_QUEUE_SIZE 24 |
tvendov | 0:6435b67ad23c | 228 | |
tvendov | 0:6435b67ad23c | 229 | class IsochronousEp { |
tvendov | 0:6435b67ad23c | 230 | public: |
tvendov | 0:6435b67ad23c | 231 | void init(int addr, uint8_t ep, uint16_t size, uint8_t frameCount = 4, uint8_t queueLimit = 3); |
tvendov | 0:6435b67ad23c | 232 | void reset(int delay_ms = 100); |
tvendov | 0:6435b67ad23c | 233 | HCITD* isochronousReceive(int timeout_ms); |
tvendov | 0:6435b67ad23c | 234 | int isochronousSend(uint8_t* buf, int len, int timeout_ms); |
tvendov | 0:6435b67ad23c | 235 | HCITD* get_queue_HCITD(int timeout_ms); |
tvendov | 0:6435b67ad23c | 236 | uint16_t m_PacketSize; |
tvendov | 0:6435b67ad23c | 237 | void disconnect(); |
tvendov | 0:6435b67ad23c | 238 | void irqWdhHandler(HCITD* itd) {m_queue.put(itd);} // WDH |
tvendov | 0:6435b67ad23c | 239 | int getQueueNum() {return m_itd_queue_count;} |
tvendov | 0:6435b67ad23c | 240 | private: |
tvendov | 0:6435b67ad23c | 241 | HCITD* new_HCITD(IsochronousEp* obj); |
tvendov | 0:6435b67ad23c | 242 | Queue<HCITD, HCITD_QUEUE_SIZE> m_queue; // ITD done queue |
tvendov | 0:6435b67ad23c | 243 | int m_itd_queue_count; |
tvendov | 0:6435b67ad23c | 244 | int m_itd_queue_limit; |
tvendov | 0:6435b67ad23c | 245 | uint16_t m_FrameNumber; |
tvendov | 0:6435b67ad23c | 246 | int m_FrameCount; // 1-8 |
tvendov | 0:6435b67ad23c | 247 | void enable(); |
tvendov | 0:6435b67ad23c | 248 | _HCED* m_pED; |
tvendov | 0:6435b67ad23c | 249 | }; |