Andrew Reed / Mbed OS CITY1082-i2c_master_wifi_mqtt
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers LCD_X_6800.c Source File

LCD_X_6800.c

00001 /*********************************************************************
00002 *                SEGGER Microcontroller GmbH                         *
00003 *        Solutions for real time microcontroller applications        *
00004 **********************************************************************
00005 *                                                                    *
00006 *        (c) 1996 - 2018  SEGGER Microcontroller GmbH                *
00007 *                                                                    *
00008 *        Internet: www.segger.com    Support:  support@segger.com    *
00009 *                                                                    *
00010 **********************************************************************
00011 
00012 ** emWin V5.48 - Graphical user interface for embedded applications **
00013 All  Intellectual Property rights  in the Software belongs to  SEGGER.
00014 emWin is protected by  international copyright laws.  Knowledge of the
00015 source code may not be used to write a similar product.  This file may
00016 only be used in accordance with the following terms:
00017 
00018 The software  has been licensed to  Cypress Semiconductor Corporation,
00019 whose registered  office is situated  at 198 Champion Ct. San Jose, CA 
00020 95134 USA  solely for the  purposes of creating  libraries for Cypress
00021 PSoC3 and  PSoC5 processor-based devices,  sublicensed and distributed
00022 under  the  terms  and  conditions  of  the  Cypress  End User License
00023 Agreement.
00024 Full source code is available at: www.segger.com
00025 
00026 We appreciate your understanding and fairness.
00027 ----------------------------------------------------------------------
00028 Licensing information
00029 Licensor:                 SEGGER Microcontroller Systems LLC
00030 Licensed to:              Cypress Semiconductor Corp, 198 Champion Ct., San Jose, CA 95134, USA
00031 Licensed SEGGER software: emWin
00032 License number:           GUI-00319
00033 License model:            Services and License Agreement, signed June 10th, 2009
00034 Licensed platform:        Any Cypress platform (Initial targets are: PSoC3, PSoC5)
00035 ----------------------------------------------------------------------
00036 Support and Update Agreement (SUA)
00037 SUA period:               2009-06-12 - 2022-07-27
00038 Contact to extend SUA:    sales@segger.com
00039 ----------------------------------------------------------------------
00040 File        : LCD_X_6800.c
00041 Purpose     : Port routines
00042 ----------------------------------------------------------------------
00043 */
00044 
00045 /*********************************************************************
00046 *
00047 *           Hardware configuration
00048 *
00049 **********************************************************************
00050   Needs to be adapted to your target hardware.
00051 */
00052 
00053 /* Configuration example:
00054 
00055 #include <IOM16C.H>      // Include port definitions
00056 
00057 #define LCD_CLR_A0()      P8 &= ~(1<<0)
00058 #define LCD_SET_A0()      P8 |=  (1<<0) 
00059 #define LCD_CLR_RW()      P8 &= ~(1<<1)
00060 #define LCD_SET_RW()      P8 |=  (1<<1) 
00061 #define LCD_CLR_E()       P8 &= ~(1<<2)
00062 #define LCD_SET_E()       P8 |=  (1<<2) 
00063 #define LCD_CLR_CS0()     P8 &= ~(1<<3)
00064 #define LCD_SET_CS0()     P8 |=  (1<<3)
00065 #define LCD_CLR_CS1()     P8 &= ~(1<<4)
00066 #define LCD_SET_CS1()     P8 |=  (1<<4)
00067 #define LCD_DATA_IN       P7
00068 #define LCD_DATA_OUT      P7
00069 #define LCD_SET_DIR_IN()  P7D = 0
00070 #define LCD_SET_DIR_OUT() P7D = 0xff
00071 #define LCD_DELAY(ms)     GUI_Delay(ms)
00072 */
00073 
00074 /*********************************************************************
00075 *
00076 *           Defaults
00077 *
00078 **********************************************************************
00079 */
00080 
00081 #ifndef LCD_CLR_RW
00082   #define LCD_CLR_RW()
00083 #endif
00084 #ifndef LCD_SET_RW
00085   #define LCD_SET_RW()
00086 #endif
00087 #ifndef LCD_SET_CS0
00088   #define LCD_SET_CS0()
00089 #endif
00090 #ifndef LCD_SET_CS1
00091   #define LCD_SET_CS1()
00092 #endif
00093 #ifndef LCD_SET_CS2
00094   #define LCD_SET_CS2()
00095 #endif
00096 
00097 #ifndef LCD_SET_DIR_IN
00098   #define LCD_SET_DIR_IN()
00099 #endif
00100 #ifndef LCD_SET_DIR_OUT
00101   #define LCD_SET_DIR_OUT()
00102 #endif
00103 
00104 /*********************************************************************
00105 *
00106 *           High level LCD access macros
00107 *
00108 **********************************************************************
00109   Usually, there is no need to modify these macros.
00110   It should be sufficient ot modify the low-level macros
00111   above.
00112 */
00113 
00114 #if 1 /* Works faster for writing data */
00115 
00116 #define LCD_X_READ()      \
00117   LCD_SET_DIR_IN();       \
00118   LCD_SET_RW();           \
00119   LCD_SET_E();            \
00120   c = LCD_DATA_IN;        \
00121   LCD_CLR_E();            \
00122   LCD_CLR_RW();           \
00123   LCD_SET_DIR_OUT()
00124 
00125 #define LCD_X_WRITE(Data) \
00126   LCD_DATA_OUT = Data;    \
00127   LCD_SET_E();            \
00128   LCD_CLR_E();            \
00129   LCD_SET_RW()
00130 
00131 #else /* Works faster for reading data */
00132 
00133 #define LCD_X_READ()      \
00134   LCD_SET_RW();           \
00135   LCD_SET_E();            \
00136   c = LCD_DATA_IN;        \
00137   LCD_CLR_E()
00138 
00139 #define LCD_X_WRITE(Data) \
00140   LCD_CLR_RW();           \
00141   LCD_SET_DIR_OUT();      \
00142   LCD_DATA_OUT = Data;    \
00143   LCD_SET_E();            \
00144   LCD_CLR_E();            \
00145   LCD_SET_DIR_IN();       \
00146   LCD_SET_RW()
00147 
00148 #endif
00149 
00150 
00151 /*********************************************************************
00152 *
00153 *           Initialisation
00154 *
00155 **********************************************************************
00156   This routine should be called from your application program
00157   to set port pins to their initial values
00158 */
00159 
00160 void LCD_X_Init(void) {
00161   LCD_CLR_RESET();
00162   LCD_SET_DIR_OUT();
00163   LCD_SET_E();
00164   LCD_CLR_RW();
00165   LCD_SET_A0();
00166   LCD_SET_CS0();
00167   LCD_SET_CS1();
00168   LCD_SET_CS2();
00169   LCD_SET_RESET();
00170 }
00171 
00172 /*********************************************************************
00173 *
00174 *           Access routines, controller 0
00175 *
00176 **********************************************************************
00177   Usually, there is no need to modify these routines.
00178   It should be sufficient ot modify the low-level macros
00179   above.
00180 */
00181 
00182 /* Read from controller 0, with A0 = 0, CS0 = 0, CS1 = 1 */
00183 unsigned char LCD_X_Read00(void) {
00184   unsigned char c;
00185   LCD_CLR_CS0();
00186   LCD_CLR_A0();
00187   LCD_X_READ();
00188   LCD_SET_CS0();
00189   return c;
00190 }
00191 
00192 /* Read from controller 0, with A0 = 1, CS0 = 0, CS1 = 1 */
00193 unsigned char LCD_X_Read01(void) {
00194   unsigned char c;
00195   LCD_CLR_CS0();
00196   LCD_SET_A0();
00197   LCD_X_READ();
00198   LCD_SET_CS0();
00199   return c;
00200 }
00201 
00202 /* Write to controller 0, with A0 = 0, CS0 = 0, CS1 = 1 */
00203 void LCD_X_Write00(unsigned char c) {
00204   LCD_CLR_A0();
00205   LCD_CLR_CS0();
00206   LCD_X_WRITE(c);
00207   LCD_SET_CS0();
00208 }
00209 
00210 /* Write to controller 0, with A0 = 1, CS0 = 0, CS1 = 1 */
00211 void LCD_X_Write01(unsigned char c) {
00212   LCD_SET_A0();
00213   LCD_CLR_CS0();
00214   LCD_X_WRITE(c);
00215   LCD_SET_CS0();
00216 }
00217 
00218 /* Write multiple bytes to controller 0, with A0 = 1, CS0 = 0, CS1 = 1 */
00219 void LCD_X_WriteM01(unsigned char * pData, int NumBytes) {
00220   LCD_SET_A0();
00221   LCD_CLR_CS0();
00222   for (; NumBytes; NumBytes--) {
00223     LCD_X_WRITE(*pData++);
00224   }
00225   LCD_SET_CS0();
00226 }
00227 
00228 /*********************************************************************
00229 *
00230 *           Access routines, controller 1
00231 *
00232 **********************************************************************
00233   Usually, there is no need to modify these routines.
00234   It should be sufficient ot modify the low-level macros
00235   above.
00236 */
00237 
00238 /* Read from controller 1, with A0 = 0, CS0 = 1, CS1 = 0 */
00239 
00240 #ifdef LCD_CLR_CS1
00241 
00242 unsigned char LCD_X_Read10(void) {
00243   unsigned char c;
00244   LCD_CLR_CS1();
00245   LCD_CLR_A0();
00246   LCD_X_READ();
00247   LCD_SET_CS1();
00248   return c;
00249 }
00250 
00251 /* Read from controller 1, with A0 = 1, CS0 = 1, CS1 = 0 */
00252 unsigned char LCD_X_Read11(void) {
00253   unsigned char c;
00254   LCD_CLR_CS1();
00255   LCD_SET_A0();
00256   LCD_X_READ();
00257   LCD_SET_CS1();
00258   return c;
00259 }
00260 
00261 /* Write to controller 1, with A0 = 0, CS0 = 1, CS1 = 0 */
00262 void LCD_X_Write10(unsigned char c) {
00263   LCD_CLR_A0();
00264   LCD_CLR_CS1();
00265   LCD_X_WRITE(c);
00266   LCD_SET_CS1();
00267 }
00268 
00269 /* Write to controller 1, with A0 = 1, CS0 = 1, CS1 = 0 */
00270 void LCD_X_Write11(unsigned char c) {
00271   LCD_SET_A0();
00272   LCD_CLR_CS1();
00273   LCD_X_WRITE(c);
00274   LCD_SET_CS1();
00275 }
00276 
00277 /* Write multiple bytes to controller 1, with A0 = 1, CS0 = 0, CS1 = 1 */
00278 void LCD_X_WriteM11(unsigned char * pData, int NumBytes) {
00279   LCD_SET_A0();
00280   LCD_CLR_CS1();
00281   for (; NumBytes; NumBytes--) {
00282     LCD_X_WRITE(*pData++);
00283   }
00284   LCD_SET_CS1();
00285 }
00286 
00287 #endif /* LCD_CLR_CS1 */
00288 
00289 /*********************************************************************
00290 *
00291 *           Access routines, controller 2
00292 *
00293 **********************************************************************
00294   Usually, there is no need to modify these routines.
00295   It should be sufficient ot modify the low-level macros
00296   above.
00297 */
00298 
00299 #ifdef LCD_CLR_CS2
00300 
00301 /* Read from controller 2, with A0 = 0, CS0 = 1, CS1 = 1 */
00302 unsigned char LCD_X_Read20(void) {
00303   unsigned char c;
00304   LCD_CLR_CS2();
00305   LCD_CLR_A0();
00306   LCD_X_READ();
00307   LCD_SET_CS2();
00308   return c;
00309 }
00310 
00311 /* Read from controller 2, with A0 = 1, CS0 = 1, CS1 = 1 */
00312 unsigned char LCD_X_Read21(void) {
00313   unsigned char c;
00314   LCD_CLR_CS2();
00315   LCD_SET_A0();
00316   LCD_X_READ();
00317   LCD_SET_CS2();
00318   return c;
00319 }
00320 
00321 /* Write to controller 2, with A0 = 0, CS0 = 1, CS1 = 1 */
00322 void LCD_X_Write20(unsigned char c) {
00323   LCD_CLR_A0();
00324   LCD_CLR_CS2();
00325   LCD_X_WRITE(c);
00326   LCD_SET_CS2();
00327 }
00328 
00329 /* Write to controller 2, with A0 = 1, CS0 = 1, CS1 = 1 */
00330 void LCD_X_Write21(unsigned char c) {
00331   LCD_SET_A0();
00332   LCD_CLR_CS2();
00333   LCD_X_WRITE(c);
00334   LCD_SET_CS2();
00335 }
00336 
00337 /* Write multiple bytes to controller 2, with A0 = 1, CS0 = 0, CS1 = 1 */
00338 void LCD_X_WriteM21(unsigned char * pData, int NumBytes) {
00339   LCD_SET_A0();
00340   LCD_CLR_CS2();
00341   for (; NumBytes; NumBytes--) {
00342     LCD_X_WRITE(*pData++);
00343   }
00344   LCD_SET_CS2();
00345 }
00346 
00347 #endif /* LCD_CLR_CS2 */
00348