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/api/I2C.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 | /* mbed Microcontroller Library |
tvendov | 0:6435b67ad23c | 2 | * Copyright (c) 2006-2015 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 | #ifndef MBED_I2C_H |
tvendov | 0:6435b67ad23c | 17 | #define MBED_I2C_H |
tvendov | 0:6435b67ad23c | 18 | |
tvendov | 0:6435b67ad23c | 19 | #include "platform.h" |
tvendov | 0:6435b67ad23c | 20 | |
tvendov | 0:6435b67ad23c | 21 | #if DEVICE_I2C |
tvendov | 0:6435b67ad23c | 22 | |
tvendov | 0:6435b67ad23c | 23 | #include "i2c_api.h" |
tvendov | 0:6435b67ad23c | 24 | #include "SingletonPtr.h" |
tvendov | 0:6435b67ad23c | 25 | #include "PlatformMutex.h" |
tvendov | 0:6435b67ad23c | 26 | |
tvendov | 0:6435b67ad23c | 27 | #if DEVICE_I2C_ASYNCH |
tvendov | 0:6435b67ad23c | 28 | #include "CThunk.h" |
tvendov | 0:6435b67ad23c | 29 | #include "dma_api.h" |
tvendov | 0:6435b67ad23c | 30 | #include "FunctionPointer.h" |
tvendov | 0:6435b67ad23c | 31 | #endif |
tvendov | 0:6435b67ad23c | 32 | |
tvendov | 0:6435b67ad23c | 33 | namespace mbed { |
tvendov | 0:6435b67ad23c | 34 | |
tvendov | 0:6435b67ad23c | 35 | /** An I2C Master, used for communicating with I2C slave devices |
tvendov | 0:6435b67ad23c | 36 | * |
tvendov | 0:6435b67ad23c | 37 | * @Note Synchronization level: Thread safe |
tvendov | 0:6435b67ad23c | 38 | * |
tvendov | 0:6435b67ad23c | 39 | * Example: |
tvendov | 0:6435b67ad23c | 40 | * @code |
tvendov | 0:6435b67ad23c | 41 | * // Read from I2C slave at address 0x62 |
tvendov | 0:6435b67ad23c | 42 | * |
tvendov | 0:6435b67ad23c | 43 | * #include "mbed.h" |
tvendov | 0:6435b67ad23c | 44 | * |
tvendov | 0:6435b67ad23c | 45 | * I2C i2c(p28, p27); |
tvendov | 0:6435b67ad23c | 46 | * |
tvendov | 0:6435b67ad23c | 47 | * int main() { |
tvendov | 0:6435b67ad23c | 48 | * int address = 0x62; |
tvendov | 0:6435b67ad23c | 49 | * char data[2]; |
tvendov | 0:6435b67ad23c | 50 | * i2c.read(address, data, 2); |
tvendov | 0:6435b67ad23c | 51 | * } |
tvendov | 0:6435b67ad23c | 52 | * @endcode |
tvendov | 0:6435b67ad23c | 53 | */ |
tvendov | 0:6435b67ad23c | 54 | class I2C { |
tvendov | 0:6435b67ad23c | 55 | |
tvendov | 0:6435b67ad23c | 56 | public: |
tvendov | 0:6435b67ad23c | 57 | enum RxStatus { |
tvendov | 0:6435b67ad23c | 58 | NoData, |
tvendov | 0:6435b67ad23c | 59 | MasterGeneralCall, |
tvendov | 0:6435b67ad23c | 60 | MasterWrite, |
tvendov | 0:6435b67ad23c | 61 | MasterRead |
tvendov | 0:6435b67ad23c | 62 | }; |
tvendov | 0:6435b67ad23c | 63 | |
tvendov | 0:6435b67ad23c | 64 | enum Acknowledge { |
tvendov | 0:6435b67ad23c | 65 | NoACK = 0, |
tvendov | 0:6435b67ad23c | 66 | ACK = 1 |
tvendov | 0:6435b67ad23c | 67 | }; |
tvendov | 0:6435b67ad23c | 68 | |
tvendov | 0:6435b67ad23c | 69 | /** Create an I2C Master interface, connected to the specified pins |
tvendov | 0:6435b67ad23c | 70 | * |
tvendov | 0:6435b67ad23c | 71 | * @param sda I2C data line pin |
tvendov | 0:6435b67ad23c | 72 | * @param scl I2C clock line pin |
tvendov | 0:6435b67ad23c | 73 | */ |
tvendov | 0:6435b67ad23c | 74 | I2C(PinName sda, PinName scl); |
tvendov | 0:6435b67ad23c | 75 | |
tvendov | 0:6435b67ad23c | 76 | /** Set the frequency of the I2C interface |
tvendov | 0:6435b67ad23c | 77 | * |
tvendov | 0:6435b67ad23c | 78 | * @param hz The bus frequency in hertz |
tvendov | 0:6435b67ad23c | 79 | */ |
tvendov | 0:6435b67ad23c | 80 | void frequency(int hz); |
tvendov | 0:6435b67ad23c | 81 | |
tvendov | 0:6435b67ad23c | 82 | /** Read from an I2C slave |
tvendov | 0:6435b67ad23c | 83 | * |
tvendov | 0:6435b67ad23c | 84 | * Performs a complete read transaction. The bottom bit of |
tvendov | 0:6435b67ad23c | 85 | * the address is forced to 1 to indicate a read. |
tvendov | 0:6435b67ad23c | 86 | * |
tvendov | 0:6435b67ad23c | 87 | * @param address 8-bit I2C slave address [ addr | 1 ] |
tvendov | 0:6435b67ad23c | 88 | * @param data Pointer to the byte-array to read data in to |
tvendov | 0:6435b67ad23c | 89 | * @param length Number of bytes to read |
tvendov | 0:6435b67ad23c | 90 | * @param repeated Repeated start, true - don't send stop at end |
tvendov | 0:6435b67ad23c | 91 | * |
tvendov | 0:6435b67ad23c | 92 | * @returns |
tvendov | 0:6435b67ad23c | 93 | * 0 on success (ack), |
tvendov | 0:6435b67ad23c | 94 | * non-0 on failure (nack) |
tvendov | 0:6435b67ad23c | 95 | */ |
tvendov | 0:6435b67ad23c | 96 | int read(int address, char *data, int length, bool repeated = false); |
tvendov | 0:6435b67ad23c | 97 | |
tvendov | 0:6435b67ad23c | 98 | /** Read a single byte from the I2C bus |
tvendov | 0:6435b67ad23c | 99 | * |
tvendov | 0:6435b67ad23c | 100 | * @param ack indicates if the byte is to be acknowledged (1 = acknowledge) |
tvendov | 0:6435b67ad23c | 101 | * |
tvendov | 0:6435b67ad23c | 102 | * @returns |
tvendov | 0:6435b67ad23c | 103 | * the byte read |
tvendov | 0:6435b67ad23c | 104 | */ |
tvendov | 0:6435b67ad23c | 105 | int read(int ack); |
tvendov | 0:6435b67ad23c | 106 | |
tvendov | 0:6435b67ad23c | 107 | /** Write to an I2C slave |
tvendov | 0:6435b67ad23c | 108 | * |
tvendov | 0:6435b67ad23c | 109 | * Performs a complete write transaction. The bottom bit of |
tvendov | 0:6435b67ad23c | 110 | * the address is forced to 0 to indicate a write. |
tvendov | 0:6435b67ad23c | 111 | * |
tvendov | 0:6435b67ad23c | 112 | * @param address 8-bit I2C slave address [ addr | 0 ] |
tvendov | 0:6435b67ad23c | 113 | * @param data Pointer to the byte-array data to send |
tvendov | 0:6435b67ad23c | 114 | * @param length Number of bytes to send |
tvendov | 0:6435b67ad23c | 115 | * @param repeated Repeated start, true - do not send stop at end |
tvendov | 0:6435b67ad23c | 116 | * |
tvendov | 0:6435b67ad23c | 117 | * @returns |
tvendov | 0:6435b67ad23c | 118 | * 0 on success (ack), |
tvendov | 0:6435b67ad23c | 119 | * non-0 on failure (nack) |
tvendov | 0:6435b67ad23c | 120 | */ |
tvendov | 0:6435b67ad23c | 121 | int write(int address, const char *data, int length, bool repeated = false); |
tvendov | 0:6435b67ad23c | 122 | |
tvendov | 0:6435b67ad23c | 123 | /** Write single byte out on the I2C bus |
tvendov | 0:6435b67ad23c | 124 | * |
tvendov | 0:6435b67ad23c | 125 | * @param data data to write out on bus |
tvendov | 0:6435b67ad23c | 126 | * |
tvendov | 0:6435b67ad23c | 127 | * @returns |
tvendov | 0:6435b67ad23c | 128 | * '1' if an ACK was received, |
tvendov | 0:6435b67ad23c | 129 | * '0' otherwise |
tvendov | 0:6435b67ad23c | 130 | */ |
tvendov | 0:6435b67ad23c | 131 | int write(int data); |
tvendov | 0:6435b67ad23c | 132 | |
tvendov | 0:6435b67ad23c | 133 | /** Creates a start condition on the I2C bus |
tvendov | 0:6435b67ad23c | 134 | */ |
tvendov | 0:6435b67ad23c | 135 | |
tvendov | 0:6435b67ad23c | 136 | void start(void); |
tvendov | 0:6435b67ad23c | 137 | |
tvendov | 0:6435b67ad23c | 138 | /** Creates a stop condition on the I2C bus |
tvendov | 0:6435b67ad23c | 139 | */ |
tvendov | 0:6435b67ad23c | 140 | void stop(void); |
tvendov | 0:6435b67ad23c | 141 | |
tvendov | 0:6435b67ad23c | 142 | /** Acquire exclusive access to this I2C bus |
tvendov | 0:6435b67ad23c | 143 | */ |
tvendov | 0:6435b67ad23c | 144 | virtual void lock(void); |
tvendov | 0:6435b67ad23c | 145 | |
tvendov | 0:6435b67ad23c | 146 | /** Release exclusive access to this I2C bus |
tvendov | 0:6435b67ad23c | 147 | */ |
tvendov | 0:6435b67ad23c | 148 | virtual void unlock(void); |
tvendov | 0:6435b67ad23c | 149 | |
tvendov | 0:6435b67ad23c | 150 | virtual ~I2C() { |
tvendov | 0:6435b67ad23c | 151 | // Do nothing |
tvendov | 0:6435b67ad23c | 152 | } |
tvendov | 0:6435b67ad23c | 153 | |
tvendov | 0:6435b67ad23c | 154 | #if DEVICE_I2C_ASYNCH |
tvendov | 0:6435b67ad23c | 155 | |
tvendov | 0:6435b67ad23c | 156 | /** Start non-blocking I2C transfer. |
tvendov | 0:6435b67ad23c | 157 | * |
tvendov | 0:6435b67ad23c | 158 | * @param address 8/10 bit I2c slave address |
tvendov | 0:6435b67ad23c | 159 | * @param tx_buffer The TX buffer with data to be transfered |
tvendov | 0:6435b67ad23c | 160 | * @param tx_length The length of TX buffer in bytes |
tvendov | 0:6435b67ad23c | 161 | * @param rx_buffer The RX buffer which is used for received data |
tvendov | 0:6435b67ad23c | 162 | * @param rx_length The length of RX buffer in bytes |
tvendov | 0:6435b67ad23c | 163 | * @param event The logical OR of events to modify |
tvendov | 0:6435b67ad23c | 164 | * @param callback The event callback function |
tvendov | 0:6435b67ad23c | 165 | * @param repeated Repeated start, true - do not send stop at end |
tvendov | 0:6435b67ad23c | 166 | * @return Zero if the transfer has started, or -1 if I2C peripheral is busy |
tvendov | 0:6435b67ad23c | 167 | */ |
tvendov | 0:6435b67ad23c | 168 | int transfer(int address, const char *tx_buffer, int tx_length, char *rx_buffer, int rx_length, const event_callback_t& callback, int event = I2C_EVENT_TRANSFER_COMPLETE, bool repeated = false); |
tvendov | 0:6435b67ad23c | 169 | |
tvendov | 0:6435b67ad23c | 170 | /** Abort the on-going I2C transfer |
tvendov | 0:6435b67ad23c | 171 | */ |
tvendov | 0:6435b67ad23c | 172 | void abort_transfer(); |
tvendov | 0:6435b67ad23c | 173 | protected: |
tvendov | 0:6435b67ad23c | 174 | void irq_handler_asynch(void); |
tvendov | 0:6435b67ad23c | 175 | event_callback_t _callback; |
tvendov | 0:6435b67ad23c | 176 | CThunk<I2C> _irq; |
tvendov | 0:6435b67ad23c | 177 | DMAUsage _usage; |
tvendov | 0:6435b67ad23c | 178 | #endif |
tvendov | 0:6435b67ad23c | 179 | |
tvendov | 0:6435b67ad23c | 180 | protected: |
tvendov | 0:6435b67ad23c | 181 | void aquire(); |
tvendov | 0:6435b67ad23c | 182 | |
tvendov | 0:6435b67ad23c | 183 | i2c_t _i2c; |
tvendov | 0:6435b67ad23c | 184 | static I2C *_owner; |
tvendov | 0:6435b67ad23c | 185 | int _hz; |
tvendov | 0:6435b67ad23c | 186 | static SingletonPtr<PlatformMutex> _mutex; |
tvendov | 0:6435b67ad23c | 187 | }; |
tvendov | 0:6435b67ad23c | 188 | |
tvendov | 0:6435b67ad23c | 189 | } // namespace mbed |
tvendov | 0:6435b67ad23c | 190 | |
tvendov | 0:6435b67ad23c | 191 | #endif |
tvendov | 0:6435b67ad23c | 192 | |
tvendov | 0:6435b67ad23c | 193 | #endif |
tvendov | 0:6435b67ad23c | 194 |