Andrew Reed
/
CITY1082-TFT-basic
Basic TFT display program for CITY082
Revision 1:402b32a1025f, committed 2019-11-19
- Comitter:
- reedas
- Date:
- Tue Nov 19 10:04:48 2019 +0000
- Parent:
- 0:6beb6f498640
- Commit message:
- Basic Hello World tft display library program
Changed in this revision
--- a/TextLCD.cpp Mon Aug 09 14:17:02 2010 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,193 +0,0 @@ -/* mbed I2CTextLCD Library, for a 4-bit LCD driven by I2C and a PCF8574 - * Copyright (c) 2007-2010, sford, rcocking - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -/* This is a hack of Simon Ford's direct-driven TextLCD code. -* It should be refactored to extract a common superclass -* but my C++ isn't yet good enough :) -* -* The code assumes the following connections between the PCF8574 -* and the LCD -* -* nc - D0 -* nc - D1 -* nc - D2 -* nc - D3 -* P0 - D4 -* P1 - D5 -* P2 - D6 -* P3 - D7 -* P4 - E -* P5 - nc -* P6 - nc -* P7 - RS -* gnd - R/W -* -* D0-3 of the LCD are not connected because we work in 4-bit mode -* R/W is hardwired to gound, as we only ever write to the LCD -* A0-2 on the PCF8574 can be set in any combination; you will need to modify -* the I2C address in the I2CTextLCD constructor. -* Remember that the mbed uses 8-bit addresses, which should be -* in the range 0x40-0x4E for the PCF8574 -*/ -#include "TextLCD.h" -#include "mbed.h" - -TextLCD::TextLCD(PinName sda, PinName scl, int i2cAddress, LCDType type) : _i2c(sda, scl), - _type(type) { - _i2cAddress = i2cAddress; - wait(0.015); // Wait 15ms to ensure powered up - - // send "Display Settings" 3 times (Only top nibble of 0x30 as we've got 4-bit bus) - for (int i=0; i<3; i++) { - writeByte(0x3, false); - wait(0.00164); // this command takes 1.64ms, so wait for it - } - writeByte(0x2, false); // 4-bit mode - wait(0.000040f); // most instructions take 40us - - writeCommand(0x28); // Function set 001 BW N F - - - writeCommand(0x0C); - writeCommand(0x6); // Cursor Direction and Display Shift : 0000 01 CD S (CD 0-left, 1-right S(hift) 0-no, 1-yes - cls(); -} - -void TextLCD::character(int column, int row, int c) { - int a = address(column, row); - writeCommand(a); - writeData(c); -} - -void TextLCD::cls() { - writeCommand(0x01); // cls, and set cursor to 0 - wait(0.00164f); // This command takes 1.64 ms - locate(0, 0); -} - -void TextLCD::locate(int column, int row) { - _column = column; - _row = row; -} - -int TextLCD::_putc(int value) { - if (value == '\n') { - _column = 0; - _row++; - if (_row >= rows()) { - _row = 0; - } - } else { - character(_column, _row, value); - _column++; - if (_column >= columns()) { - _column = 0; - _row++; - if (_row >= rows()) { - _row = 0; - } - } - } - return value; -} - -int TextLCD::_getc() { - return -1; -} - -void TextLCD::writeI2CByte(int data) { - // equivalent to writeI2CByte - char * cmd = new char[1]; - cmd[0] = data; - _i2c.write(_i2cAddress, cmd, 1); -} - -void TextLCD::writeNibble(int data, bool rs) { - if (rs) { - data = data | RS_ON; // set rs bit - } - data |= E_ON; // E on - writeI2CByte(data); - data ^= E_ON; // E off - wait_us(1); - writeI2CByte(data); - wait_us(1000); -} - -void TextLCD::writeByte(int data, bool rs) { - writeNibble(data >> 4, rs); - writeNibble(data & 0x0F, rs); -} - -void TextLCD::writeCommand(int command) { - // equivalent to ard commandWrite - writeByte(command, false); -} - -void TextLCD::writeData(int data) { - - writeByte(data, true); -} - -int TextLCD::address(int column, int row) { - switch (_type) { - case LCD20x4: - switch (row) { - case 0: - return 0x80 + column; - case 1: - return 0xc0 + column; - case 2: - return 0x94 + column; - case 3: - return 0xd4 + column; - } - case LCD16x2B: - return 0x80 + (row * 40) + column; - case LCD16x2: - case LCD20x2: - default: - return 0x80 + (row * 0x40) + column; - } -} - -int TextLCD::columns() { - switch (_type) { - case LCD20x4: - case LCD20x2: - return 20; - case LCD16x2: - case LCD16x2B: - default: - return 16; - } -} - -int TextLCD::rows() { - switch (_type) { - case LCD20x4: - return 4; - case LCD16x2: - case LCD16x2B: - case LCD20x2: - default: - return 2; - } -}
--- a/TextLCD.h Mon Aug 09 14:17:02 2010 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,117 +0,0 @@ -/* mbed TextLCD Library, for a 4-bit LCD based on HD44780 - * Copyright (c) 2007-2010, sford - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#ifndef MBED_TEXTLCD_H -#define MBED_TEXTLCD_H - -#include "mbed.h" - -#define E_ON 0x10 -#define RS_ON 0x80 - -/** A TextLCD interface for driving 4-bit HD44780-based LCDs - * - * Currently supports 16x2, 20x2 and 20x4 panels - * - * @code - * #include "mbed.h" - * #include "TextLCD.h" - * - * TextLCD lcd(p10, p12, p15, p16, p29, p30); // rs, e, d0-d3 - * - * int main() { - * lcd.printf("Hello World!\n"); - * } - * @endcode - */ -class TextLCD : public Stream { -public: - - /** LCD panel format */ - enum LCDType { - LCD16x2 /**< 16x2 LCD panel (default) */ - , LCD16x2B /**< 16x2 LCD panel alternate addressing */ - , LCD20x2 /**< 20x2 LCD panel */ - , LCD20x4 /**< 20x4 LCD panel */ - }; - - /** Create a TextLCD interface - * - * @param rs Instruction/data control line - * @param e Enable line (clock) - * @param d0-d3 Data lines - * @param type Sets the panel size/addressing mode (default = LCD16x2) - */ - TextLCD(PinName sda, PinName scl, int i2cAddress = 0x40, LCDType type = LCD16x2); - -#if DOXYGEN_ONLY - /** Write a character to the LCD - * - * @param c The character to write to the display - */ - int putc(int c); - - /** Write a formated string to the LCD - * - * @param format A printf-style format string, followed by the - * variables to use in formating the string. - */ - int printf(const char* format, ...); -#endif - - /** Locate to a screen column and row - * - * @param column The horizontal position from the left, indexed from 0 - * @param row The vertical position from the top, indexed from 0 - */ - void locate(int column, int row); - - /** Clear the screen and locate to 0,0 */ - void cls(); - - int rows(); - int columns(); - -protected: - - // Stream implementation functions - virtual int _putc(int value); - virtual int _getc(); - - int address(int column, int row); - void character(int column, int row, int c); - void writeByte(int value, bool rs); - void writeCommand(int command); - void writeData(int data); - void writeNibble(int value, bool rs); - void writeI2CByte(int data); - - LCDType _type; - int _rs; - I2C _i2c; - int _i2cAddress; - - int _column; - int _row; -}; - -#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emwin_config/GUIConf.cpp Tue Nov 19 10:04:48 2019 +0000 @@ -0,0 +1,88 @@ +/********************************************************************* +* SEGGER Microcontroller GmbH & Co. KG * +* Solutions for real time microcontroller applications * +********************************************************************** +* * +* (c) 1996 - 2017 SEGGER Microcontroller GmbH & Co. KG * +* * +* Internet: www.segger.com Support: support@segger.com * +* * +********************************************************************** + +** emWin V5.46 - Graphical user interface for embedded applications ** +All Intellectual Property rights in the Software belongs to SEGGER. +emWin is protected by international copyright laws. Knowledge of the +source code may not be used to write a similar product. This file may +only be used in accordance with the following terms: + +The software has been licensed to Cypress Semiconductor Corporation, +whose registered office is situated at 198 Champion Ct. San Jose, CA +95134 USA solely for the purposes of creating libraries for Cypress +PSoC3 and PSoC5 processor-based devices, sublicensed and distributed +under the terms and conditions of the Cypress End User License +Agreement. +Full source code is available at: www.segger.com + +We appreciate your understanding and fairness. +---------------------------------------------------------------------- +Licensing information +Licensor: SEGGER Microcontroller Systems LLC +Licensed to: Cypress Semiconductor Corp, 198 Champion Ct., San Jose, CA 95134, USA +Licensed SEGGER software: emWin +License number: GUI-00319 +License model: Services and License Agreement, signed June 10th, 2009 +Licensed platform: Any Cypress platform (Initial targets are: PSoC3, PSoC5) +---------------------------------------------------------------------- +Support and Update Agreement (SUA) +SUA period: 2009-06-12 - 2022-07-27 +Contact to extend SUA: sales@segger.com +---------------------------------------------------------------------- +File : GUIConf.c +Purpose : Display controller initialization +---------------------------END-OF-HEADER------------------------------ +*/ + +#include "GUI.h" + +/********************************************************************* +* +* Defines +* +********************************************************************** +*/ +// +// Define the available number of bytes available for the GUI +// +#define GUI_NUMBYTES 0x8000 + +/********************************************************************* +* +* Public code +* +********************************************************************** +*/ +/********************************************************************* +* +* GUI_X_Config +* +* Purpose: +* Called during the initialization process in order to set up the +* available memory for the GUI. +*/ +void GUI_X_Config(void) { + // + // 32 bit aligned memory area + // + static U32 aMemory[GUI_NUMBYTES / 4]; + // + // Assign memory to emWin + // + GUI_ALLOC_AssignMemory(aMemory, GUI_NUMBYTES); + // + // Set default font + // + GUI_SetDefaultFont(GUI_FONT_6X8); +} + +/*************************** End of file ****************************/ +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emwin_config/GUI_X_Mbed.cpp Tue Nov 19 10:04:48 2019 +0000 @@ -0,0 +1,158 @@ +/********************************************************************* +* SEGGER Microcontroller GmbH * +* Solutions for real time microcontroller applications * +********************************************************************** +* * +* (c) 1996 - 2018 SEGGER Microcontroller GmbH * +* * +* Internet: www.segger.com Support: support@segger.com * +* * +********************************************************************** + +** emWin V5.48 - Graphical user interface for embedded applications ** +All Intellectual Property rights in the Software belongs to SEGGER. +emWin is protected by international copyright laws. Knowledge of the +source code may not be used to write a similar product. This file may +only be used in accordance with the following terms: + +The software has been licensed to Cypress Semiconductor Corporation, +whose registered office is situated at 198 Champion Ct. San Jose, CA +95134 USA solely for the purposes of creating libraries for Cypress +PSoC3 and PSoC5 processor-based devices, sublicensed and distributed +under the terms and conditions of the Cypress End User License +Agreement. +Full source code is available at: www.segger.com + +We appreciate your understanding and fairness. +---------------------------------------------------------------------- +Licensing information +Licensor: SEGGER Microcontroller Systems LLC +Licensed to: Cypress Semiconductor Corp, 198 Champion Ct., San Jose, CA 95134, USA +Licensed SEGGER software: emWin +License number: GUI-00319 +License model: Services and License Agreement, signed June 10th, 2009 +Licensed platform: Any Cypress platform (Initial targets are: PSoC3, PSoC5) +---------------------------------------------------------------------- +Support and Update Agreement (SUA) +SUA period: 2009-06-12 - 2022-07-27 +Contact to extend SUA: sales@segger.com +---------------------------------------------------------------------- +File : GUI_X_Mbed.c +Purpose : Config / System dependent externals for GUI +---------------------------END-OF-HEADER------------------------------ +*/ + +#include <stdio.h> +#include "mbed.h" + +extern "C" { + #include "GUI.h" +} + +/********************************************************************* +* +* Global data +*/ + +Ticker emwin_ticker; +Mutex emwin_mutex; +volatile GUI_TIMER_TIME timeMS = 0; + +/********************************************************************* +* +* Public code +* +********************************************************************** +*/ +/********************************************************************* +* +* Timing: +* GUI_X_GetTime() +* GUI_X_Delay(int) + + Some timing dependent routines require a GetTime + and delay function. Default time unit (tick), normally is + 1 ms. +*/ + +GUI_TIMER_TIME GUI_X_GetTime(void) +{ + return timeMS; +} + +void GUI_X_Delay(int ms) +{ + wait_ms(ms); +} + +/********************************************************************* +* +* GUI_X_ExecIdle() +* +*/ +void GUI_X_ExecIdle(void) +{ + wait_ms(1); +} + +/********************************************************************* +* +* Multitasking: +* +* GUI_X_InitOS() +* GUI_X_GetTaskId() +* GUI_X_Lock() +* GUI_X_Unlock() +* +* Note: +* The following routines are required only if emWin is used in a +* true multi task environment, which means you have more than one +* thread using the emWin API. +* In this case the +* #define GUI_OS 1 +* needs to be in GUIConf.h +*/ +void GUI_X_InitOS(void) {} +void GUI_X_Unlock(void) { emwin_mutex.unlock(); } +void GUI_X_Lock(void) { emwin_mutex.lock(); } +U32 GUI_X_GetTaskId(void) { return 0; } + +/********************************************************************* +* +* Logging: OS dependent + +Note: + Logging is used in higher debug levels only. The typical target + build does not use logging and does therefor not require any of + the logging routines below. For a release build without logging + the routines below may be eliminated to save some space. + (If the linker is not function aware and eliminates unreferenced + functions automatically) + +*/ + +void GUI_X_Log (const char *s) { GUI_USE_PARA(s); } +void GUI_X_Warn (const char *s) { GUI_USE_PARA(s); } +void GUI_X_ErrorOut(const char *s) { GUI_USE_PARA(s); } + +void ticker_handler(void) +{ + timeMS++; +} + +/********************************************************************* +* +* GUI_X_Init() +* +* Note: +* This routine is called from GUI_Init() in any case whether there +* is an RTOS or not. You can use it for additional initializations +* needed. +*/ + +void GUI_X_Init(void) +{ + emwin_ticker.attach(&ticker_handler, 0.001); +} + +/*************************** End of file ****************************/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emwin_config/LCDConf.cpp Tue Nov 19 10:04:48 2019 +0000 @@ -0,0 +1,299 @@ +/********************************************************************* +* SEGGER Microcontroller GmbH & Co. KG * +* Solutions for real time microcontroller applications * +********************************************************************** +* * +* (c) 1996 - 2017 SEGGER Microcontroller GmbH & Co. KG * +* * +* Internet: www.segger.com Support: support@segger.com * +* * +********************************************************************** + +** emWin V5.46 - Graphical user interface for embedded applications ** +All Intellectual Property rights in the Software belongs to SEGGER. +emWin is protected by international copyright laws. Knowledge of the +source code may not be used to write a similar product. This file may +only be used in accordance with the following terms: + +The software has been licensed to Cypress Semiconductor Corporation, +whose registered office is situated at 198 Champion Ct. San Jose, CA +95134 USA solely for the purposes of creating libraries for Cypress +PSoC3 and PSoC5 processor-based devices, sublicensed and distributed +under the terms and conditions of the Cypress End User License +Agreement. +Full source code is available at: www.segger.com + +We appreciate your understanding and fairness. +---------------------------------------------------------------------- +Licensing information +Licensor: SEGGER Microcontroller Systems LLC +Licensed to: Cypress Semiconductor Corp, 198 Champion Ct., San Jose, CA 95134, USA +Licensed SEGGER software: emWin +License number: GUI-00319 +License model: Services and License Agreement, signed June 10th, 2009 +Licensed platform: Any Cypress platform (Initial targets are: PSoC3, PSoC5) +---------------------------------------------------------------------- +Support and Update Agreement (SUA) +SUA period: 2009-06-12 - 2022-07-27 +Contact to extend SUA: sales@segger.com +---------------------------------------------------------------------- +File : LCDConf.c +Purpose : Display controller configuration (single layer) +---------------------------END-OF-HEADER------------------------------ +*/ + +#include "GUI.h" +#include "GUIDRV_FlexColor.h" + +#include "cy8ckit_028_tft.h" + + +/********************************************************************* +* +* Layer configuration (to be modified) +* +********************************************************************** +*/ +// +// Physical display size +// The display size should be adapted in order to match the size of +// the target display. +// +#define XSIZE_PHYS 240 +#define YSIZE_PHYS 320 + +// +// Color conversion +// The color conversion functions should be selected according to +// the color mode of the target display. Details can be found in +// the chapter "Colors" in the emWin user manual. +// +#define COLOR_CONVERSION GUICC_M565 + +// +// Display driver +// +#define DISPLAY_DRIVER GUIDRV_FLEXCOLOR + +/********************************************************************* +* +* Configuration checking +* +********************************************************************** +*/ +#ifndef VXSIZE_PHYS + #define VXSIZE_PHYS XSIZE_PHYS +#endif +#ifndef VYSIZE_PHYS + #define VYSIZE_PHYS YSIZE_PHYS +#endif +#ifndef XSIZE_PHYS + #error Physical X size of display is not defined! +#endif +#ifndef YSIZE_PHYS + #error Physical Y size of display is not defined! +#endif +#ifndef COLOR_CONVERSION + #error Color conversion not defined! +#endif +#ifndef DISPLAY_DRIVER + #error No display driver defined! +#endif + +/******************************************************************** +* +* CY8CKIT_028_TFT_InitController +* +* Purpose: +* Initializes the LCD controller +* +*/ +static void CY8CKIT_028_TFT_InitController(void) { + /* Set up the display controller and put it into operation. If the + * display controller is not initialized by any external routine + * this needs to be adapted by the customer. + */ + DisplayIntf_Init(); + +/* + Cy_GPIO_Set(LCD_RESET_PORT, LCD_RESET_NUM); + GUI_Delay(20); + Cy_GPIO_Clr(LCD_RESET_PORT, LCD_RESET_NUM); + GUI_Delay(100); + Cy_GPIO_Set(LCD_RESET_PORT, LCD_RESET_NUM); + GUI_Delay(100); + */ + LCD_RESET = 1u; + GUI_Delay(20); + LCD_RESET = 0u; + GUI_Delay(100); + + LCD_RESET = 1u; + GUI_Delay(100); + + DisplayIntf_Write8_A0(0x28); + DisplayIntf_Write8_A0(0x11); /* Exit Sleep mode */ + GUI_Delay(100); + DisplayIntf_Write8_A0(0x36); + DisplayIntf_Write8_A1(0xA0); /* MADCTL: memory data access control */ + DisplayIntf_Write8_A0(0x3A); + DisplayIntf_Write8_A1(0x65); /* COLMOD: Interface Pixel format */ + DisplayIntf_Write8_A0(0xB2); + DisplayIntf_Write8_A1(0x0C); + DisplayIntf_Write8_A1(0x0C); + DisplayIntf_Write8_A1(0x00); + DisplayIntf_Write8_A1(0x33); + DisplayIntf_Write8_A1(0x33); /* PORCTRK: Porch setting */ + DisplayIntf_Write8_A0(0xB7); + DisplayIntf_Write8_A1(0x35); /* GCTRL: Gate Control */ + DisplayIntf_Write8_A0(0xBB); + DisplayIntf_Write8_A1(0x2B); /* VCOMS: VCOM setting */ + DisplayIntf_Write8_A0(0xC0); + DisplayIntf_Write8_A1(0x2C); /* LCMCTRL: LCM Control */ + DisplayIntf_Write8_A0(0xC2); + DisplayIntf_Write8_A1(0x01); + DisplayIntf_Write8_A1(0xFF); /* VDVVRHEN: VDV and VRH Command Enable */ + DisplayIntf_Write8_A0(0xC3); + DisplayIntf_Write8_A1(0x11); /* VRHS: VRH Set */ + DisplayIntf_Write8_A0(0xC4); + DisplayIntf_Write8_A1(0x20); /* VDVS: VDV Set */ + DisplayIntf_Write8_A0(0xC6); + DisplayIntf_Write8_A1(0x0F); /* FRCTRL2: Frame Rate control in normal mode */ + DisplayIntf_Write8_A0(0xD0); + DisplayIntf_Write8_A1(0xA4); + DisplayIntf_Write8_A1(0xA1); /* PWCTRL1: Power Control 1 */ + DisplayIntf_Write8_A0(0xE0); + DisplayIntf_Write8_A1(0xD0); + DisplayIntf_Write8_A1(0x00); + DisplayIntf_Write8_A1(0x05); + DisplayIntf_Write8_A1(0x0E); + DisplayIntf_Write8_A1(0x15); + DisplayIntf_Write8_A1(0x0D); + DisplayIntf_Write8_A1(0x37); + DisplayIntf_Write8_A1(0x43); + DisplayIntf_Write8_A1(0x47); + DisplayIntf_Write8_A1(0x09); + DisplayIntf_Write8_A1(0x15); + DisplayIntf_Write8_A1(0x12); + DisplayIntf_Write8_A1(0x16); + DisplayIntf_Write8_A1(0x19); /* PVGAMCTRL: Positive Voltage Gamma control */ + DisplayIntf_Write8_A0(0xE1); + DisplayIntf_Write8_A1(0xD0); + DisplayIntf_Write8_A1(0x00); + DisplayIntf_Write8_A1(0x05); + DisplayIntf_Write8_A1(0x0D); + DisplayIntf_Write8_A1(0x0C); + DisplayIntf_Write8_A1(0x06); + DisplayIntf_Write8_A1(0x2D); + DisplayIntf_Write8_A1(0x44); + DisplayIntf_Write8_A1(0x40); + DisplayIntf_Write8_A1(0x0E); + DisplayIntf_Write8_A1(0x1C); + DisplayIntf_Write8_A1(0x18); + DisplayIntf_Write8_A1(0x16); + DisplayIntf_Write8_A1(0x19); /* NVGAMCTRL: Negative Voltage Gamma control */ + DisplayIntf_Write8_A0(0x2B); + DisplayIntf_Write8_A1(0x00); + DisplayIntf_Write8_A1(0x00); + DisplayIntf_Write8_A1(0x00); + DisplayIntf_Write8_A1(0xEF); /* Y address set */ + DisplayIntf_Write8_A0(0x2A); + DisplayIntf_Write8_A1(0x00); + DisplayIntf_Write8_A1(0x00); + DisplayIntf_Write8_A1(0x01); + DisplayIntf_Write8_A1(0x3F); /* X address set */ + GUI_Delay(10); + DisplayIntf_Write8_A0(0x29); +} + +/********************************************************************* +* +* Public code +* +********************************************************************** +*/ +/********************************************************************* +* +* LCD_X_Config +* +* Function description +* Called during the initialization process in order to set up the +* display driver configuration. +*/ +void LCD_X_Config(void) { + GUI_DEVICE * pDevice; + CONFIG_FLEXCOLOR Config = {0}; + GUI_PORT_API PortAPI = {0}; + // + // Set the display driver and color conversion + // + pDevice = GUI_DEVICE_CreateAndLink(DISPLAY_DRIVER, COLOR_CONVERSION, 0, 0); + // + // Display driver configuration + // + LCD_SetSizeEx (0, XSIZE_PHYS, YSIZE_PHYS); + LCD_SetVSizeEx (0, VXSIZE_PHYS, VYSIZE_PHYS); + // + // Orientation + // + Config.Orientation = GUI_MIRROR_Y | GUI_SWAP_XY; + GUIDRV_FlexColor_Config(pDevice, &Config); + // + // Set controller and operation mode + // + PortAPI.pfWrite8_A0 = DisplayIntf_Write8_A0; + PortAPI.pfWrite8_A1 = DisplayIntf_Write8_A1; + PortAPI.pfWriteM8_A1 = DisplayIntf_WriteM8_A1; + PortAPI.pfRead8_A1 = DisplayIntf_Read8_A1; + PortAPI.pfReadM8_A1 = DisplayIntf_ReadM8_A1; + + GUIDRV_FlexColor_SetFunc(pDevice, &PortAPI, GUIDRV_FLEXCOLOR_F66709, GUIDRV_FLEXCOLOR_M16C0B8); +} + +/********************************************************************* +* +* LCD_X_DisplayDriver +* +* Purpose: +* This function is called by the display driver for several purposes. +* To support the according task, the routine needs to be adapted to +* the display controller. Note that the commands marked +* "optional" are not cogently required and should only be adapted if +* the display controller supports these features. +* +* Parameter: +* LayerIndex - Zero based layer index +* Cmd - Command to be executed +* pData - Pointer to a data structure. +* +* Return Value: +* < -1 - Error +* -1 - The command is not handled. +* 0 - OK. +*/ +int LCD_X_DisplayDriver(unsigned LayerIndex, unsigned Cmd, void * pData) { + int r; + + GUI_USE_PARA(LayerIndex); + GUI_USE_PARA(pData); + + switch (Cmd) { + case LCD_X_INITCONTROLLER: { + // + // Called during the initialization process in order to set up the + // display controller and put it into operation. If the display + // controller is not initialized by any external routine, this needs + // to be adapted by the customer... + // + // ... + CY8CKIT_028_TFT_InitController(); + return 0; + } + default: + r = -1; + } + return r; +} + +/*************************** End of file ****************************/ +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emwin_config/LCDConf.h Tue Nov 19 10:04:48 2019 +0000 @@ -0,0 +1,51 @@ +/********************************************************************* +* SEGGER Microcontroller GmbH & Co. KG * +* Solutions for real time microcontroller applications * +********************************************************************** +* * +* (c) 1996 - 2017 SEGGER Microcontroller GmbH & Co. KG * +* * +* Internet: www.segger.com Support: support@segger.com * +* * +********************************************************************** + +** emWin V5.46 - Graphical user interface for embedded applications ** +All Intellectual Property rights in the Software belongs to SEGGER. +emWin is protected by international copyright laws. Knowledge of the +source code may not be used to write a similar product. This file may +only be used in accordance with the following terms: + +The software has been licensed to Cypress Semiconductor Corporation, +whose registered office is situated at 198 Champion Ct. San Jose, CA +95134 USA solely for the purposes of creating libraries for Cypress +PSoC3 and PSoC5 processor-based devices, sublicensed and distributed +under the terms and conditions of the Cypress End User License +Agreement. +Full source code is available at: www.segger.com + +We appreciate your understanding and fairness. +---------------------------------------------------------------------- +Licensing information +Licensor: SEGGER Microcontroller Systems LLC +Licensed to: Cypress Semiconductor Corp, 198 Champion Ct., San Jose, CA 95134, USA +Licensed SEGGER software: emWin +License number: GUI-00319 +License model: Services and License Agreement, signed June 10th, 2009 +Licensed platform: Any Cypress platform (Initial targets are: PSoC3, PSoC5) +---------------------------------------------------------------------- +Support and Update Agreement (SUA) +SUA period: 2009-06-12 - 2022-07-27 +Contact to extend SUA: sales@segger.com +---------------------------------------------------------------------- +File : LCDConf.h +Purpose : Display driver configuration file +---------------------------------------------------------------------- +*/ + +#ifndef LCDCONF_H +#define LCDCONF_H + +#endif /* LCDCONF_H */ + +/*************************** End of file ****************************/ +
--- a/main.cpp Mon Aug 09 14:17:02 2010 +0000 +++ b/main.cpp Tue Nov 19 10:04:48 2019 +0000 @@ -1,8 +1,37 @@ +/* Hello World! for the TextLCD Enhanced Library*/ + #include "mbed.h" -#include "TextLCD.h" +#include "GUI.h" +#include "cy8ckit_028_tft.h" + +void Display_Init(void) +{ + + /* Set font size, foreground and background Colours */ + GUI_SetFont(GUI_FONT_16B_1); + GUI_SetColor(GUI_WHITE); + GUI_SetBkColor(GUI_BLACK); -TextLCD lcd(p9, p10); + /* Clear screen and print splash screen */ + GUI_Clear(); + GUI_SetTextAlign(GUI_TA_HCENTER); + GUI_DispStringAt("TFT Demo", 160, 20); +} + +int main() +{ + /* Initialise EmWin driver*/ + GUI_Init(); -int main() { - lcd.printf("Hi mbed World!\n"); + /* Initialise display */ + Display_Init(); + + + GUI_SetFont(GUI_FONT_8X16X2X2); + GUI_SetTextAlign(GUI_TA_HCENTER); + GUI_DispStringAt("Hello World!", 160, 200); + } + + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os.lib Tue Nov 19 10:04:48 2019 +0000 @@ -0,0 +1,1 @@ +https://github.com/ARMmbed/mbed-os/#679d24833acf0a0b5b0d528576bb37c70863bc4e
--- a/mbed.bld Mon Aug 09 14:17:02 2010 +0000 +++ b/mbed.bld Tue Nov 19 10:04:48 2019 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/9114680c05da +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed_app.json Tue Nov 19 10:04:48 2019 +0000 @@ -0,0 +1,16 @@ +{ + "config": { + "SDA":"P6_1", + "SCL":"P6_0" + },"target_overrides": { + "*": { + "SDA" : "SDA", + "SCL" : "SCL", + "target.components_add": ["EMWIN_NOSNTS"], + "platform.stdio-convert-newlines": true, + "platform.stdio-baud-rate": 115200, + "platform.default-serial-baud-rate": 115200 + + } + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/middleware-emwin.lib Tue Nov 19 10:04:48 2019 +0000 @@ -0,0 +1,1 @@ +https://github.com/cypresssemiconductorco/middleware-emwin/#4f7b679659cb7696659d1a5bc084b1a5b3be6c70
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/stats_report.h Tue Nov 19 10:04:48 2019 +0000 @@ -0,0 +1,132 @@ +/* mbed Microcontroller Library + * Copyright (c) 2018 ARM Limited + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef STATS_REPORT_H +#define STATS_REPORT + +#include "mbed.h" + +/** + * System Reporting library. Provides runtime information on device: + * - CPU sleep, idle, and wake times + * - Heap and stack usage + * - Thread information + * - Static system information + */ +class SystemReport { + mbed_stats_heap_t heap_stats; + mbed_stats_cpu_t cpu_stats; + mbed_stats_sys_t sys_stats; + + mbed_stats_thread_t *thread_stats; + uint8_t thread_count; + uint8_t max_thread_count; + uint32_t sample_time_ms; + +public: + /** + * SystemReport - Sample rate in ms is required to handle the CPU percent awake logic + */ + SystemReport(uint32_t sample_rate) : max_thread_count(8), sample_time_ms(sample_rate) + { + thread_stats = new mbed_stats_thread_t[max_thread_count]; + + // Collect the static system information + mbed_stats_sys_get(&sys_stats); + + printf("=============================== SYSTEM INFO ================================\r\n"); + printf("Mbed OS Version: %ld \r\n", sys_stats.os_version); + printf("CPU ID: 0x%lx \r\n", sys_stats.cpu_id); + printf("Compiler ID: %d \r\n", sys_stats.compiler_id); + printf("Compiler Version: %ld \r\n", sys_stats.compiler_version); + + for (int i = 0; i < MBED_MAX_MEM_REGIONS; i++) { + if (sys_stats.ram_size[i] != 0) { + printf("RAM%d: Start 0x%lx Size: 0x%lx \r\n", i, sys_stats.ram_start[i], sys_stats.ram_size[i]); + } + } + for (int i = 0; i < MBED_MAX_MEM_REGIONS; i++) { + if (sys_stats.rom_size[i] != 0) { + printf("ROM%d: Start 0x%lx Size: 0x%lx \r\n", i, sys_stats.rom_start[i], sys_stats.rom_size[i]); + } + } + } + + ~SystemReport(void) + { + free(thread_stats); + } + + /** + * Report on each Mbed OS Platform stats API + */ + void report_state(void) + { + report_cpu_stats(); + report_heap_stats(); + report_thread_stats(); + + // Clear next line to separate subsequent report logs + printf("\r\n"); + } + + /** + * Report CPU idle and awake time in terms of percentage + */ + void report_cpu_stats(void) + { + static uint64_t prev_idle_time = 0; + + printf("================= CPU STATS =================\r\n"); + + // Collect and print cpu stats + mbed_stats_cpu_get(&cpu_stats); + + uint64_t diff = (cpu_stats.idle_time - prev_idle_time); + uint8_t idle = (diff * 100) / (sample_time_ms * 1000); // usec; + uint8_t usage = 100 - ((diff * 100) / (sample_time_ms * 1000)); // usec;; + prev_idle_time = cpu_stats.idle_time; + + printf("Idle: %d%% Usage: %d%% \r\n", idle, usage); + } + + /** + * Report current heap stats. Current heap refers to the current amount of + * allocated heap. Max heap refers to the highest amount of heap allocated + * since reset. + */ + void report_heap_stats(void) + { + printf("================ HEAP STATS =================\r\n"); + + // Collect and print heap stats + mbed_stats_heap_get(&heap_stats); + + printf("Current heap: %lu\r\n", heap_stats.current_size); + printf("Max heap size: %lu\r\n", heap_stats.max_size); + } + + /** + * Report active thread stats + */ + void report_thread_stats(void) + { + printf("================ THREAD STATS ===============\r\n"); + + // Collect and print running thread stats + int count = mbed_stats_thread_get_each(thread_stats, max_thread_count); + + for (int i = 0; i < count; i++) { + printf("ID: 0x%lx \r\n", thread_stats[i].id); + printf("Name: %s \r\n", thread_stats[i].name); + printf("State: %ld \r\n", thread_stats[i].state); + printf("Priority: %ld \r\n", thread_stats[i].priority); + printf("Stack Size: %ld \r\n", thread_stats[i].stack_size); + printf("Stack Space: %ld \r\n", thread_stats[i].stack_space); + } + } +}; + +#endif // STATS_REPORT_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tft_interface/cy8ckit_028_tft.cpp Tue Nov 19 10:04:48 2019 +0000 @@ -0,0 +1,398 @@ +/***************************************************************************//** +* \file DisplayInterface.h +* \version 1.0 +* +* \brief +* Objective: +* This is display software i8080 interface source file +* +******************************************************************************** +* \copyright +* Copyright 2018-2019 Cypress Semiconductor Corporation +* SPDX-License-Identifier: Apache-2.0 +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*******************************************************************************/ + + +#include "cy8ckit_028_tft.h" +#include <mbed_wait_api.h> +#include "mbed.h" +#include "PortInOut.h" + + +DigitalInOut LCD_REG0(P9_0); +DigitalInOut LCD_REG1(P9_1); +DigitalInOut LCD_REG2(P9_2); +DigitalInOut LCD_REG3(P9_4); +DigitalInOut LCD_REG4(P9_5); +DigitalInOut LCD_REG5(P0_2); +DigitalInOut LCD_REG6(P13_0); +DigitalInOut LCD_REG7(P13_1); +PortInOut P0(Port0, 0x04); +PortInOut P9(Port9, 0x37); +PortInOut P13(Port13, 0x03); + +DigitalOut LCD_NWR(P12_0); +DigitalOut LCD_DC(P12_1); +DigitalOut LCD_RESET(P12_2); +DigitalOut LCD_NRD(P12_3); + +/******************************************************************************* +* Function Name: DataWrite +****************************************************************************/ +/** +* +* \brief +* Writes one byte of data to the software i8080 interface. +* +* \details +* This function: +* - Writes data to the data bus +* - Sends low pulse to the LCD_NWR line to write data +* +* Changed from individual bit banging to port masked writes to +* P9[5,4,2,1,0], P13[1,0], P0[2] to optimise slightly +* +* \todo +* All this should be replaced with a udb register to save all the shifting +* and individual bit writing. +* +*******************************************************************************/ +void DataWrite(U8 data) +{ +// LCD_REG0 = (data & 0x01); +// LCD_REG1 = ((data>>1) & 0x01); +// LCD_REG2 = ((data>>2) & 0x01); +// LCD_REG3 = ((data>>3) & 0x01); +// LCD_REG4 = ((data>>4) & 0x01); + +/* read the appropriate port and only change the bits we need to then write the + * affected bits back to the port retaining any unaffected bit values + */ + int pbyte = P9.read(); + int bit012 = (data & 0x07); + int bit34 = (data & 0x18) << 1; + pbyte = (pbyte & 0xc8) | bit34 | bit012; + P9.write(pbyte); +// LCD_REG5 = ((data>>5) & 0x01); + pbyte = P0.read(); + int bit5 = (data & 0x20) >> 3 ; + pbyte = (pbyte & 0xfb) | bit5 ; + P0.write(pbyte); + +// LCD_REG6 = ((data>>6) & 0x01); +// LCD_REG7 = ((data>>7) & 0x01); + pbyte = P13.read(); + int bit67 = (data & 0xc0) >> 6 ; + pbyte = (pbyte & 0xfc) | bit67 ; + P13.write(pbyte); + LCD_NWR = 0u; + LCD_NWR = 1u; + +} + + +/******************************************************************************* +* Function Name: DataRead +****************************************************************************//** +* +* \brief +* Reads one byte of data from the software i8080 interface. +* +* \details +* This function: +* - Changes data bus GPIO pins drive mode to digital Hi-Z with enabled input +* buffer +* - Sends low pulse to LCD_NRD line to read data +* - Reads data from the data bus +* - Sends low pulse to the LCD_NWR line to write data +* - Changes data bus GPIO pins drive mode back to to Strong Drive mode +* +* \todo +* All this should be replaced with a udb register to save all the shifting +* and individual bit reading. +* +*******************************************************************************/ +U8 DataRead(void) +{ + U8 data = 0u; + + /* enable input */ + LCD_REG0.input(); + LCD_REG1.input(); + LCD_REG2.input(); + LCD_REG3.input(); + LCD_REG4.input(); + LCD_REG5.input(); + LCD_REG6.input(); + LCD_REG7.input(); + + LCD_NRD = 0u; // Pulse read line low then read the data port + + data = (U8)LCD_REG0.read(); + data |= (U8)LCD_REG1.read()<<1; + data |= (U8)LCD_REG2.read()<<2; + data |= (U8)LCD_REG3.read()<<3; + data |= (U8)LCD_REG4.read()<<4; + data |= (U8)LCD_REG5.read()<<5; + data |= (U8)LCD_REG6.read()<<6; + data |= (U8)LCD_REG7.read()<<7; + + LCD_NRD = 1u; // Raise the read line and then go back to output port + + LCD_REG0.output(); + LCD_REG1.output(); + LCD_REG2.output(); + LCD_REG3.output(); + LCD_REG4.output(); + LCD_REG5.output(); + LCD_REG6.output(); + LCD_REG7.output(); + + return data; +} + + +/******************************************************************************* +* Function Name: DisplayIntf_Init +****************************************************************************//** +* +* \brief +* Initializes software i8080 interface. +* +* \details +* This function: +* - Initializes interface GPIO pins +* +*******************************************************************************/ +void DisplayIntf_Init(void) +{ + /* All pins are initialized by the Device Configurator. */ + LCD_RESET = 1u; + LCD_NRD = 1u; + LCD_NWR = 1u; + LCD_DC = 0u; + LCD_REG0.output(); + LCD_REG1.output(); + LCD_REG2.output(); + LCD_REG3.output(); + LCD_REG4.output(); + LCD_REG5.output(); + LCD_REG6.output(); + LCD_REG7.output(); + wait_ms(20); + LCD_RESET = 0u; + wait_ms(100); + + LCD_RESET = 1u; + wait_ms(100); + + DisplayIntf_Write8_A0(0x28); + DisplayIntf_Write8_A0(0x11); /* Exit Sleep mode */ + wait_ms(100); + DisplayIntf_Write8_A0(0x36); + DisplayIntf_Write8_A1(0xA0); /* MADCTL: memory data access control */ + DisplayIntf_Write8_A0(0x3A); + DisplayIntf_Write8_A1(0x65); /* COLMOD: Interface Pixel format */ + DisplayIntf_Write8_A0(0xB2); + DisplayIntf_Write8_A1(0x0C); + DisplayIntf_Write8_A1(0x0C); + DisplayIntf_Write8_A1(0x00); + DisplayIntf_Write8_A1(0x33); + DisplayIntf_Write8_A1(0x33); /* PORCTRK: Porch setting */ + DisplayIntf_Write8_A0(0xB7); + DisplayIntf_Write8_A1(0x35); /* GCTRL: Gate Control */ + DisplayIntf_Write8_A0(0xBB); + DisplayIntf_Write8_A1(0x2B); /* VCOMS: VCOM setting */ + DisplayIntf_Write8_A0(0xC0); + DisplayIntf_Write8_A1(0x2C); /* LCMCTRL: LCM Control */ + DisplayIntf_Write8_A0(0xC2); + DisplayIntf_Write8_A1(0x01); + DisplayIntf_Write8_A1(0xFF); /* VDVVRHEN: VDV and VRH Command Enable */ + DisplayIntf_Write8_A0(0xC3); + DisplayIntf_Write8_A1(0x11); /* VRHS: VRH Set */ + DisplayIntf_Write8_A0(0xC4); + DisplayIntf_Write8_A1(0x20); /* VDVS: VDV Set */ + DisplayIntf_Write8_A0(0xC6); + DisplayIntf_Write8_A1(0x0F); /* FRCTRL2: Frame Rate control in normal mode */ + DisplayIntf_Write8_A0(0xD0); + DisplayIntf_Write8_A1(0xA4); + DisplayIntf_Write8_A1(0xA1); /* PWCTRL1: Power Control 1 */ + DisplayIntf_Write8_A0(0xE0); + DisplayIntf_Write8_A1(0xD0); + DisplayIntf_Write8_A1(0x00); + DisplayIntf_Write8_A1(0x05); + DisplayIntf_Write8_A1(0x0E); + DisplayIntf_Write8_A1(0x15); + DisplayIntf_Write8_A1(0x0D); + DisplayIntf_Write8_A1(0x37); + DisplayIntf_Write8_A1(0x43); + DisplayIntf_Write8_A1(0x47); + DisplayIntf_Write8_A1(0x09); + DisplayIntf_Write8_A1(0x15); + DisplayIntf_Write8_A1(0x12); + DisplayIntf_Write8_A1(0x16); + DisplayIntf_Write8_A1(0x19); /* PVGAMCTRL: Positive Voltage Gamma control */ + DisplayIntf_Write8_A0(0xE1); + DisplayIntf_Write8_A1(0xD0); + DisplayIntf_Write8_A1(0x00); + DisplayIntf_Write8_A1(0x05); + DisplayIntf_Write8_A1(0x0D); + DisplayIntf_Write8_A1(0x0C); + DisplayIntf_Write8_A1(0x06); + DisplayIntf_Write8_A1(0x2D); + DisplayIntf_Write8_A1(0x44); + DisplayIntf_Write8_A1(0x40); + DisplayIntf_Write8_A1(0x0E); + DisplayIntf_Write8_A1(0x1C); + DisplayIntf_Write8_A1(0x18); + DisplayIntf_Write8_A1(0x16); + DisplayIntf_Write8_A1(0x19); /* NVGAMCTRL: Negative Voltage Gamma control */ + DisplayIntf_Write8_A0(0x2B); + DisplayIntf_Write8_A1(0x00); + DisplayIntf_Write8_A1(0x00); + DisplayIntf_Write8_A1(0x00); + DisplayIntf_Write8_A1(0xEF); /* Y address set */ + DisplayIntf_Write8_A0(0x2A); + DisplayIntf_Write8_A1(0x00); + DisplayIntf_Write8_A1(0x00); + DisplayIntf_Write8_A1(0x01); + DisplayIntf_Write8_A1(0x3F); /* X address set */ + wait_ms(10); + DisplayIntf_Write8_A0(0x29); + + +} + + +/******************************************************************************* +* Function Name: DisplayIntf_Write8_A0 +****************************************************************************//** +* +* \brief +* Writes one byte of data to the software i8080 interface with the LCD_DC pin +* set to 0 +* +* \details +* This function: +* - Sets LCD_DC pin to 0 +* - Writes one data byte +* +*******************************************************************************/ +void DisplayIntf_Write8_A0(U8 data) +{ + LCD_DC = 0u; + DataWrite(data); +} + + +/******************************************************************************* +* Function Name: DisplayIntf_Write8_A1 +****************************************************************************//** +* +* \brief +* Writes one byte of data to the software i8080 interface with the LCD_DC pin +* set to 1 +* +* \details +* This function: +* - Sets LCD_DC pin to 1 +* - Writes one data byte +* +*******************************************************************************/ +void DisplayIntf_Write8_A1(U8 data) +{ + LCD_DC = 1u; + DataWrite(data); +} + + +/******************************************************************************* +* Function Name: DisplayIntf_WriteM8_A1 +****************************************************************************//** +* +* \brief +* Writes multiple bytes of data to the software i8080 interface with the LCD_DC +* pin set to 1 +* +* \details +* This function: +* - Sets LCD_DC pin to 1 +* - Writes data bytes +* +*******************************************************************************/ +void DisplayIntf_WriteM8_A1(U8 data[], int num) +{ + int i = 0; + + LCD_DC = 1u; + + for(i = 0; i < num; i++) + { + DataWrite(data[i]); + } +} + + +/******************************************************************************* +* Function Name: DisplayIntf_Read8_A1 +****************************************************************************//** +* +* \brief +* Reads one byte of data from the software i8080 interface with the LCD_DC pin +* set to 1 +* +* \details +* This function: +* - Sets LCD_DC pin to 1 +* - Reads one data byte +* +*******************************************************************************/ +U8 DisplayIntf_Read8_A1(void) +{ + LCD_DC = 1u; + return DataRead(); +} + + +/******************************************************************************* +* Function Name: DisplayIntf_ReadM8_A1 +****************************************************************************//** +* +* \brief +* Reads multiple bytes of data from the software i8080 interface with the LCD_DC +* pin set to 1 +* +* \details +* This function: +* - Sets LCD_DC pin to 1 +* - Reads data bytes +* +*******************************************************************************/ +void DisplayIntf_ReadM8_A1(U8 data[], int num) +{ + int i = 0; + + LCD_DC = 1u; + + for(i = 0; i < num; i++) + { + data[i] = DataRead(); + } +} + + +/* [] END OF FILE */ + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tft_interface/cy8ckit_028_tft.h Tue Nov 19 10:04:48 2019 +0000 @@ -0,0 +1,93 @@ +/***************************************************************************//** +* \file DisplayInterface.h +* \version 1.0 +* +* \brief +* Objective: +* This is display software i8080 interface header file. +* +******************************************************************************** +* \copyright +* Copyright 2018-2019 Cypress Semiconductor Corporation +* SPDX-License-Identifier: Apache-2.0 +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*******************************************************************************/ +/*#include "mbed.h" +#ifndef LCD_REG0 +DigitalInOut LCD_REG0(P9_0); +DigitalInOut LCD_REG1(P9_1); +DigitalInOut LCD_REG2(P9_2); +DigitalInOut LCD_REG3(P9_4); +DigitalInOut LCD_REG4(P9_5); +DigitalInOut LCD_REG5(P0_2); +DigitalInOut LCD_REG6(P13_0); +DigitalInOut LCD_REG7(P13_1); + +DigitalOut LCD_NWR(P12_0); +DigitalOut LCD_DC(P12_1); +DigitalOut LCD_RESET(P12_2); +DigitalOut LCD_NRD(P12_3); +#endif +*/ +#include <DigitalInOut.h> +#include <DigitalOut.h> + +extern mbed::DigitalInOut LCD_REG0; +extern mbed::DigitalInOut LCD_REG1; +extern mbed::DigitalInOut LCD_REG2; +extern mbed::DigitalInOut LCD_REG3; +extern mbed::DigitalInOut LCD_REG4; +extern mbed::DigitalInOut LCD_REG5; +extern mbed::DigitalInOut LCD_REG6; +extern mbed::DigitalInOut LCD_REG7; + + +extern mbed::DigitalOut LCD_NWR; +extern mbed::DigitalOut LCD_DC; +extern mbed::DigitalOut LCD_RESET; +extern mbed::DigitalOut LCD_NRD; + +#ifndef DISPLAYINTERFACE_H +#define DISPLAYINTERFACE_H + + +#include "GUI_Type.h" +//#include "cycfg_pins.h" + /* "LCD_DATA_0": "P9_0", + "LCD_DATA_1": "P9_1", + "LCD_DATA_2": "P9_2", + "LCD_DATA_3": "P9_4", + "LCD_DATA_4": "P9_5", + "LCD_DATA_5": "P0_2", + "LCD_DATA_6": "P13_0", + "LCD_DATA_7": "P13_1", + "LCD_NWR": "P12_0", + "LCD_DC": "P12_1", + "LCD_RESET": "P12_2", + "LDC_NRD": "P12_3", + */ + + +void DisplayIntf_Init(void); +void DisplayIntf_Write8_A0(U8 data); +void DisplayIntf_Write8_A1(U8 data); +void DisplayIntf_WriteM8_A1(U8 data[], int num); +U8 DisplayIntf_Read8_A1(void); +void DisplayIntf_ReadM8_A1(U8 data[], int num); + +#endif + +/* [] END OF FILE */ + +