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/LocalFileSystem.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 | /* mbed Microcontroller 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 | #include "LocalFileSystem.h" |
tvendov | 0:6435b67ad23c | 17 | |
tvendov | 0:6435b67ad23c | 18 | #if DEVICE_LOCALFILESYSTEM |
tvendov | 0:6435b67ad23c | 19 | |
tvendov | 0:6435b67ad23c | 20 | #include "semihost_api.h" |
tvendov | 0:6435b67ad23c | 21 | #include <string.h> |
tvendov | 0:6435b67ad23c | 22 | #include <stdio.h> |
tvendov | 0:6435b67ad23c | 23 | |
tvendov | 0:6435b67ad23c | 24 | namespace mbed { |
tvendov | 0:6435b67ad23c | 25 | |
tvendov | 0:6435b67ad23c | 26 | /* Extension to FINFO type defined in RTL.h (in Keil RL) - adds 'create time'. */ |
tvendov | 0:6435b67ad23c | 27 | typedef struct { |
tvendov | 0:6435b67ad23c | 28 | unsigned char hr; /* Hours [0..23] */ |
tvendov | 0:6435b67ad23c | 29 | unsigned char min; /* Minutes [0..59] */ |
tvendov | 0:6435b67ad23c | 30 | unsigned char sec; /* Seconds [0..59] */ |
tvendov | 0:6435b67ad23c | 31 | unsigned char day; /* Day [1..31] */ |
tvendov | 0:6435b67ad23c | 32 | unsigned char mon; /* Month [1..12] */ |
tvendov | 0:6435b67ad23c | 33 | unsigned short year; /* Year [1980..2107] */ |
tvendov | 0:6435b67ad23c | 34 | } FTIME; |
tvendov | 0:6435b67ad23c | 35 | |
tvendov | 0:6435b67ad23c | 36 | typedef struct { /* File Search info record */ |
tvendov | 0:6435b67ad23c | 37 | char name[32]; /* File name */ |
tvendov | 0:6435b67ad23c | 38 | long size; /* File size in bytes */ |
tvendov | 0:6435b67ad23c | 39 | int fileID; /* System File Identification */ |
tvendov | 0:6435b67ad23c | 40 | FTIME create_time; /* Date & time file was created */ |
tvendov | 0:6435b67ad23c | 41 | FTIME write_time; /* Date & time of last write */ |
tvendov | 0:6435b67ad23c | 42 | } XFINFO; |
tvendov | 0:6435b67ad23c | 43 | |
tvendov | 0:6435b67ad23c | 44 | #define RESERVED_FOR_USER_APPLICATIONS (0x100) /* 0x100 - 0x1ff */ |
tvendov | 0:6435b67ad23c | 45 | #define USR_XFFIND (RESERVED_FOR_USER_APPLICATIONS + 0) |
tvendov | 0:6435b67ad23c | 46 | |
tvendov | 0:6435b67ad23c | 47 | static int xffind (const char *pattern, XFINFO *info) { |
tvendov | 0:6435b67ad23c | 48 | unsigned param[4]; |
tvendov | 0:6435b67ad23c | 49 | |
tvendov | 0:6435b67ad23c | 50 | param[0] = (unsigned long)pattern; |
tvendov | 0:6435b67ad23c | 51 | param[1] = (unsigned long)strlen(pattern); |
tvendov | 0:6435b67ad23c | 52 | param[2] = (unsigned long)info; |
tvendov | 0:6435b67ad23c | 53 | param[3] = (unsigned long)sizeof(XFINFO); |
tvendov | 0:6435b67ad23c | 54 | |
tvendov | 0:6435b67ad23c | 55 | return __semihost(USR_XFFIND, param); |
tvendov | 0:6435b67ad23c | 56 | } |
tvendov | 0:6435b67ad23c | 57 | |
tvendov | 0:6435b67ad23c | 58 | #define OPEN_R 0 |
tvendov | 0:6435b67ad23c | 59 | #define OPEN_B 1 |
tvendov | 0:6435b67ad23c | 60 | #define OPEN_PLUS 2 |
tvendov | 0:6435b67ad23c | 61 | #define OPEN_W 4 |
tvendov | 0:6435b67ad23c | 62 | #define OPEN_A 8 |
tvendov | 0:6435b67ad23c | 63 | #define OPEN_INVALID -1 |
tvendov | 0:6435b67ad23c | 64 | |
tvendov | 0:6435b67ad23c | 65 | int posix_to_semihost_open_flags(int flags) { |
tvendov | 0:6435b67ad23c | 66 | /* POSIX flags -> semihosting open mode */ |
tvendov | 0:6435b67ad23c | 67 | int openmode; |
tvendov | 0:6435b67ad23c | 68 | if (flags & O_RDWR) { |
tvendov | 0:6435b67ad23c | 69 | /* a plus mode */ |
tvendov | 0:6435b67ad23c | 70 | openmode = OPEN_PLUS; |
tvendov | 0:6435b67ad23c | 71 | if (flags & O_APPEND) { |
tvendov | 0:6435b67ad23c | 72 | openmode |= OPEN_A; |
tvendov | 0:6435b67ad23c | 73 | } else if (flags & O_TRUNC) { |
tvendov | 0:6435b67ad23c | 74 | openmode |= OPEN_W; |
tvendov | 0:6435b67ad23c | 75 | } else { |
tvendov | 0:6435b67ad23c | 76 | openmode |= OPEN_R; |
tvendov | 0:6435b67ad23c | 77 | } |
tvendov | 0:6435b67ad23c | 78 | } else if (flags & O_WRONLY) { |
tvendov | 0:6435b67ad23c | 79 | /* write or append */ |
tvendov | 0:6435b67ad23c | 80 | if (flags & O_APPEND) { |
tvendov | 0:6435b67ad23c | 81 | openmode = OPEN_A; |
tvendov | 0:6435b67ad23c | 82 | } else { |
tvendov | 0:6435b67ad23c | 83 | openmode = OPEN_W; |
tvendov | 0:6435b67ad23c | 84 | } |
tvendov | 0:6435b67ad23c | 85 | } else if (flags == O_RDONLY) { |
tvendov | 0:6435b67ad23c | 86 | /* read mode */ |
tvendov | 0:6435b67ad23c | 87 | openmode = OPEN_R; |
tvendov | 0:6435b67ad23c | 88 | } else { |
tvendov | 0:6435b67ad23c | 89 | /* invalid flags */ |
tvendov | 0:6435b67ad23c | 90 | openmode = OPEN_INVALID; |
tvendov | 0:6435b67ad23c | 91 | } |
tvendov | 0:6435b67ad23c | 92 | |
tvendov | 0:6435b67ad23c | 93 | return openmode; |
tvendov | 0:6435b67ad23c | 94 | } |
tvendov | 0:6435b67ad23c | 95 | |
tvendov | 0:6435b67ad23c | 96 | FILEHANDLE local_file_open(const char* name, int flags) { |
tvendov | 0:6435b67ad23c | 97 | int openmode = posix_to_semihost_open_flags(flags); |
tvendov | 0:6435b67ad23c | 98 | if (openmode == OPEN_INVALID) { |
tvendov | 0:6435b67ad23c | 99 | return (FILEHANDLE)NULL; |
tvendov | 0:6435b67ad23c | 100 | } |
tvendov | 0:6435b67ad23c | 101 | |
tvendov | 0:6435b67ad23c | 102 | FILEHANDLE fh = semihost_open(name, openmode); |
tvendov | 0:6435b67ad23c | 103 | if (fh == -1) { |
tvendov | 0:6435b67ad23c | 104 | return (FILEHANDLE)NULL; |
tvendov | 0:6435b67ad23c | 105 | } |
tvendov | 0:6435b67ad23c | 106 | |
tvendov | 0:6435b67ad23c | 107 | return fh; |
tvendov | 0:6435b67ad23c | 108 | } |
tvendov | 0:6435b67ad23c | 109 | |
tvendov | 0:6435b67ad23c | 110 | LocalFileHandle::LocalFileHandle(FILEHANDLE fh) : _fh(fh), pos(0) { |
tvendov | 0:6435b67ad23c | 111 | // No lock needed in constructor |
tvendov | 0:6435b67ad23c | 112 | } |
tvendov | 0:6435b67ad23c | 113 | |
tvendov | 0:6435b67ad23c | 114 | int LocalFileHandle::close() { |
tvendov | 0:6435b67ad23c | 115 | int retval = semihost_close(_fh); |
tvendov | 0:6435b67ad23c | 116 | delete this; |
tvendov | 0:6435b67ad23c | 117 | return retval; |
tvendov | 0:6435b67ad23c | 118 | } |
tvendov | 0:6435b67ad23c | 119 | |
tvendov | 0:6435b67ad23c | 120 | ssize_t LocalFileHandle::write(const void *buffer, size_t length) { |
tvendov | 0:6435b67ad23c | 121 | lock(); |
tvendov | 0:6435b67ad23c | 122 | ssize_t n = semihost_write(_fh, (const unsigned char*)buffer, length, 0); // number of characters not written |
tvendov | 0:6435b67ad23c | 123 | n = length - n; // number of characters written |
tvendov | 0:6435b67ad23c | 124 | pos += n; |
tvendov | 0:6435b67ad23c | 125 | unlock(); |
tvendov | 0:6435b67ad23c | 126 | return n; |
tvendov | 0:6435b67ad23c | 127 | } |
tvendov | 0:6435b67ad23c | 128 | |
tvendov | 0:6435b67ad23c | 129 | ssize_t LocalFileHandle::read(void *buffer, size_t length) { |
tvendov | 0:6435b67ad23c | 130 | lock(); |
tvendov | 0:6435b67ad23c | 131 | ssize_t n = semihost_read(_fh, (unsigned char*)buffer, length, 0); // number of characters not read |
tvendov | 0:6435b67ad23c | 132 | n = length - n; // number of characters read |
tvendov | 0:6435b67ad23c | 133 | pos += n; |
tvendov | 0:6435b67ad23c | 134 | unlock(); |
tvendov | 0:6435b67ad23c | 135 | return n; |
tvendov | 0:6435b67ad23c | 136 | } |
tvendov | 0:6435b67ad23c | 137 | |
tvendov | 0:6435b67ad23c | 138 | int LocalFileHandle::isatty() { |
tvendov | 0:6435b67ad23c | 139 | lock(); |
tvendov | 0:6435b67ad23c | 140 | int ret = semihost_istty(_fh); |
tvendov | 0:6435b67ad23c | 141 | unlock(); |
tvendov | 0:6435b67ad23c | 142 | return ret; |
tvendov | 0:6435b67ad23c | 143 | } |
tvendov | 0:6435b67ad23c | 144 | |
tvendov | 0:6435b67ad23c | 145 | off_t LocalFileHandle::lseek(off_t position, int whence) { |
tvendov | 0:6435b67ad23c | 146 | lock(); |
tvendov | 0:6435b67ad23c | 147 | if (whence == SEEK_CUR) { |
tvendov | 0:6435b67ad23c | 148 | position += pos; |
tvendov | 0:6435b67ad23c | 149 | } else if (whence == SEEK_END) { |
tvendov | 0:6435b67ad23c | 150 | position += semihost_flen(_fh); |
tvendov | 0:6435b67ad23c | 151 | } /* otherwise SEEK_SET, so position is fine */ |
tvendov | 0:6435b67ad23c | 152 | |
tvendov | 0:6435b67ad23c | 153 | /* Always seems to return -1, so just ignore for now. */ |
tvendov | 0:6435b67ad23c | 154 | semihost_seek(_fh, position); |
tvendov | 0:6435b67ad23c | 155 | pos = position; |
tvendov | 0:6435b67ad23c | 156 | unlock(); |
tvendov | 0:6435b67ad23c | 157 | return position; |
tvendov | 0:6435b67ad23c | 158 | } |
tvendov | 0:6435b67ad23c | 159 | |
tvendov | 0:6435b67ad23c | 160 | int LocalFileHandle::fsync() { |
tvendov | 0:6435b67ad23c | 161 | lock(); |
tvendov | 0:6435b67ad23c | 162 | int ret = semihost_ensure(_fh); |
tvendov | 0:6435b67ad23c | 163 | unlock(); |
tvendov | 0:6435b67ad23c | 164 | return ret; |
tvendov | 0:6435b67ad23c | 165 | } |
tvendov | 0:6435b67ad23c | 166 | |
tvendov | 0:6435b67ad23c | 167 | off_t LocalFileHandle::flen() { |
tvendov | 0:6435b67ad23c | 168 | lock(); |
tvendov | 0:6435b67ad23c | 169 | off_t off = semihost_flen(_fh); |
tvendov | 0:6435b67ad23c | 170 | unlock(); |
tvendov | 0:6435b67ad23c | 171 | return off; |
tvendov | 0:6435b67ad23c | 172 | } |
tvendov | 0:6435b67ad23c | 173 | |
tvendov | 0:6435b67ad23c | 174 | void LocalFileHandle::lock() { |
tvendov | 0:6435b67ad23c | 175 | _mutex.lock(); |
tvendov | 0:6435b67ad23c | 176 | } |
tvendov | 0:6435b67ad23c | 177 | |
tvendov | 0:6435b67ad23c | 178 | void LocalFileHandle::unlock() { |
tvendov | 0:6435b67ad23c | 179 | _mutex.unlock(); |
tvendov | 0:6435b67ad23c | 180 | } |
tvendov | 0:6435b67ad23c | 181 | |
tvendov | 0:6435b67ad23c | 182 | class LocalDirHandle : public DirHandle { |
tvendov | 0:6435b67ad23c | 183 | |
tvendov | 0:6435b67ad23c | 184 | public: |
tvendov | 0:6435b67ad23c | 185 | struct dirent cur_entry; |
tvendov | 0:6435b67ad23c | 186 | XFINFO info; |
tvendov | 0:6435b67ad23c | 187 | |
tvendov | 0:6435b67ad23c | 188 | LocalDirHandle() : cur_entry(), info() { |
tvendov | 0:6435b67ad23c | 189 | } |
tvendov | 0:6435b67ad23c | 190 | |
tvendov | 0:6435b67ad23c | 191 | virtual int closedir() { |
tvendov | 0:6435b67ad23c | 192 | // No lock can be used in destructor |
tvendov | 0:6435b67ad23c | 193 | delete this; |
tvendov | 0:6435b67ad23c | 194 | return 0; |
tvendov | 0:6435b67ad23c | 195 | } |
tvendov | 0:6435b67ad23c | 196 | |
tvendov | 0:6435b67ad23c | 197 | virtual struct dirent *readdir() { |
tvendov | 0:6435b67ad23c | 198 | lock(); |
tvendov | 0:6435b67ad23c | 199 | if (xffind("*", &info)!=0) { |
tvendov | 0:6435b67ad23c | 200 | unlock(); |
tvendov | 0:6435b67ad23c | 201 | return NULL; |
tvendov | 0:6435b67ad23c | 202 | } |
tvendov | 0:6435b67ad23c | 203 | memcpy(cur_entry.d_name, info.name, sizeof(info.name)); |
tvendov | 0:6435b67ad23c | 204 | unlock(); |
tvendov | 0:6435b67ad23c | 205 | return &cur_entry; |
tvendov | 0:6435b67ad23c | 206 | } |
tvendov | 0:6435b67ad23c | 207 | |
tvendov | 0:6435b67ad23c | 208 | virtual void rewinddir() { |
tvendov | 0:6435b67ad23c | 209 | lock(); |
tvendov | 0:6435b67ad23c | 210 | info.fileID = 0; |
tvendov | 0:6435b67ad23c | 211 | unlock(); |
tvendov | 0:6435b67ad23c | 212 | } |
tvendov | 0:6435b67ad23c | 213 | |
tvendov | 0:6435b67ad23c | 214 | virtual off_t telldir() { |
tvendov | 0:6435b67ad23c | 215 | lock(); |
tvendov | 0:6435b67ad23c | 216 | int fileId = info.fileID; |
tvendov | 0:6435b67ad23c | 217 | unlock(); |
tvendov | 0:6435b67ad23c | 218 | return fileId; |
tvendov | 0:6435b67ad23c | 219 | } |
tvendov | 0:6435b67ad23c | 220 | |
tvendov | 0:6435b67ad23c | 221 | virtual void seekdir(off_t offset) { |
tvendov | 0:6435b67ad23c | 222 | lock(); |
tvendov | 0:6435b67ad23c | 223 | info.fileID = offset; |
tvendov | 0:6435b67ad23c | 224 | unlock(); |
tvendov | 0:6435b67ad23c | 225 | } |
tvendov | 0:6435b67ad23c | 226 | |
tvendov | 0:6435b67ad23c | 227 | protected: |
tvendov | 0:6435b67ad23c | 228 | PlatformMutex _mutex; |
tvendov | 0:6435b67ad23c | 229 | |
tvendov | 0:6435b67ad23c | 230 | virtual void lock() { |
tvendov | 0:6435b67ad23c | 231 | _mutex.lock(); |
tvendov | 0:6435b67ad23c | 232 | } |
tvendov | 0:6435b67ad23c | 233 | |
tvendov | 0:6435b67ad23c | 234 | virtual void unlock() { |
tvendov | 0:6435b67ad23c | 235 | _mutex.unlock(); |
tvendov | 0:6435b67ad23c | 236 | } |
tvendov | 0:6435b67ad23c | 237 | }; |
tvendov | 0:6435b67ad23c | 238 | |
tvendov | 0:6435b67ad23c | 239 | FileHandle *LocalFileSystem::open(const char* name, int flags) { |
tvendov | 0:6435b67ad23c | 240 | // No global state modified so function is thread safe |
tvendov | 0:6435b67ad23c | 241 | |
tvendov | 0:6435b67ad23c | 242 | /* reject filenames with / in them */ |
tvendov | 0:6435b67ad23c | 243 | for (const char *tmp = name; *tmp; tmp++) { |
tvendov | 0:6435b67ad23c | 244 | if (*tmp == '/') { |
tvendov | 0:6435b67ad23c | 245 | return NULL; |
tvendov | 0:6435b67ad23c | 246 | } |
tvendov | 0:6435b67ad23c | 247 | } |
tvendov | 0:6435b67ad23c | 248 | |
tvendov | 0:6435b67ad23c | 249 | int openmode = posix_to_semihost_open_flags(flags); |
tvendov | 0:6435b67ad23c | 250 | if (openmode == OPEN_INVALID) { |
tvendov | 0:6435b67ad23c | 251 | return NULL; |
tvendov | 0:6435b67ad23c | 252 | } |
tvendov | 0:6435b67ad23c | 253 | |
tvendov | 0:6435b67ad23c | 254 | FILEHANDLE fh = semihost_open(name, openmode); |
tvendov | 0:6435b67ad23c | 255 | if (fh == -1) { |
tvendov | 0:6435b67ad23c | 256 | return NULL; |
tvendov | 0:6435b67ad23c | 257 | } |
tvendov | 0:6435b67ad23c | 258 | return new LocalFileHandle(fh); |
tvendov | 0:6435b67ad23c | 259 | } |
tvendov | 0:6435b67ad23c | 260 | |
tvendov | 0:6435b67ad23c | 261 | int LocalFileSystem::remove(const char *filename) { |
tvendov | 0:6435b67ad23c | 262 | // No global state modified so function is thread safe |
tvendov | 0:6435b67ad23c | 263 | |
tvendov | 0:6435b67ad23c | 264 | return semihost_remove(filename); |
tvendov | 0:6435b67ad23c | 265 | } |
tvendov | 0:6435b67ad23c | 266 | |
tvendov | 0:6435b67ad23c | 267 | DirHandle *LocalFileSystem::opendir(const char *name) { |
tvendov | 0:6435b67ad23c | 268 | // No global state modified so function is thread safe |
tvendov | 0:6435b67ad23c | 269 | |
tvendov | 0:6435b67ad23c | 270 | return new LocalDirHandle(); |
tvendov | 0:6435b67ad23c | 271 | } |
tvendov | 0:6435b67ad23c | 272 | |
tvendov | 0:6435b67ad23c | 273 | } // namespace mbed |
tvendov | 0:6435b67ad23c | 274 | |
tvendov | 0:6435b67ad23c | 275 | #endif |
tvendov | 0:6435b67ad23c | 276 |