Brought over the files from the Freescale site and modified for mbed.

This code is only partially working for me. Not every download seems to be successful on Mac OS X. I just took the example files and hacked them around to get it working with mbed. If you want working code I think Erik Olieman's SLCD project is probably a better source.

main.cpp

//KL46Z try out
#include "mbed.h"
#include "TSISensor.h"
#include "MMA8451Q.h"
#include "MAG3110.h"
#include "vfnLCD.h"
#include <cstdlib>
#include <iostream>

Serial pc(USBTX, USBRX);

TSISensor tsi;
MMA8451Q acc51(PTE25, PTE24, 0x1D<<1);
MAG3110 mag(PTE25, PTE24, 0x0E<<1);
vfnLCD lcd;

PwmOut rled(PTE29);
PwmOut gled(PTD5);
AnalogIn lightSensor(PTE22);
//DigitalIn SW1(PTC3);
//DigitalIn SW3(PTC12);
//AnalogOut lcd03(PTB23);
//PwmOut lcd07(PTB7);

char chBufDisp[10];

int main()
{
    using namespace std;

    float onTime = 1.0;
    float offTime = 0.0;
    float holdTime = 1.0;
    bool on = true;
    bool off = false;
    int magX = 0, magY = 0, magZ = 0;
    int count=100;
 
    uint8_t message[]="1234";
    lcd.vfnLCD_All_Segments_ON();     

    while(true) {  
        cout << "I'm alive and running\n\r";              
        rled = onTime - abs(acc51.getAccX());
        gled = onTime - abs(acc51.getAccY());
        mag.getValues(&magX, &magY, &magZ);
        
        cout << "MMA8451: " << acc51.getAccX() << "\t" << acc51.getAccY() << "\t" << acc51.getAccZ() << "\n\r" << endl;
        cout << "MAG3110: " << magX << "\t" << magY << "\t" << magZ << "\n\r" << endl;
        cout << "MAG3110: " << mag.getHeading() << "\n\r" << endl;
        wait(holdTime);
        
        rled = tsi.readPercentage();
        gled = tsi.readPercentage();
        
        cout << "Touch: " << tsi.readPercentage() << "\n\r" << endl;
        cout << "SW1: " << SW1 << "\n\r" << endl;
        cout << "SW3: " << SW3 << "\n\r" << endl;
        cout << "Light Sensor: " << lightSensor << "\n\r" << endl;
        sprintf(chBufDisp,"%04i",count);
        lcd.vfnLCD_Write_Msg((uint8_t *)chBufDisp);
        count++;
        if (count>9999) count=0;
        wait(holdTime);
    }
    return 0;
}

Files at this revision

API Documentation at this revision

Comitter:
highroads
Date:
Mon Jan 13 22:32:43 2014 +0000
Commit message:
Partially working version.

Changed in this revision

FRDM-s401.h Show annotated file Show diff for this revision Revisions of this file
LCDConfig.h Show annotated file Show diff for this revision Revisions of this file
LCDHDW.h Show annotated file Show diff for this revision Revisions of this file
s401.cpp Show annotated file Show diff for this revision Revisions of this file
vfnLCD.cpp Show annotated file Show diff for this revision Revisions of this file
vfnLCD.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FRDM-s401.h	Mon Jan 13 22:32:43 2014 +0000
@@ -0,0 +1,130 @@
+#ifndef __FRDM_S401_H_
+#define __FRDM_S401_H_
+/*^^^^^^^^^^^^^^^^      LCD HARDWARE CONECTION ^^^^^^^^^^^^^^^^^^^^^^^^*/
+#define  _LCDFRONTPLANES   (8)                             // # of frontPlanes
+#define  _LCDBACKPLANES    (4)                              // # of backplanes
+
+/*
+   LCD logical organization definition
+    This section indicate how the LCD is distributed  how many characteres of (7-seg, 14,seg, 16 seg, or colums in case of Dot Matrix) does it contain
+   First character is forced only one can be written
+
+*/
+// HARDWARE_CONFIG Changing LCD pins Allows to verify all LCD pins easily
+// if HARDWARE_CONFIG  == 0 FRDM-KL46 RevB 
+// if HARDWARE_CONFIG  == 1 FRDM-KL46 RevA
+#include "mbed.h"
+
+#ifdef FRDM_REVA
+#define HARDWARE_CONFIG 1
+#else
+#define HARDWARE_CONFIG 0
+#endif
+
+#define _CHARNUM     (4)  //number of chars that can be written
+#define _CHAR_SIZE   (2)  // Used only when Dot Matrix is used
+#define _LCDTYPE     (2)  //indicate how many LCD_WF are required to write a single Character / or Column in case of DOT matrix LCD
+
+/*
+  Following definitions indicate how characters are associated to waveform
+*/
+/* Hardware configuration  */
+#if HARDWARE_CONFIG == 0
+#undef DOT_MATRIX
+
+// LCD PIN1 to LCDWF0  Rev B
+#define   CHAR1a    37 // LCD Pin 5
+#define   CHAR1b    17 // LCD Pin 6
+#define   CHAR2a    7 // LCD Pin 7
+#define   CHAR2b    8 // LCD Pin 8
+#define   CHAR3a    53 // LCD Pin 9
+#define   CHAR3b    38 // LCD Pin 10
+#define   CHAR4a    10 // LCD Pin 11
+#define   CHAR4b    11 // LCD Pin 12
+#define   CHARCOM0    40 // LCD Pin 1
+#define   CHARCOM1    52 // LCD Pin 2
+#define   CHARCOM2    19 // LCD Pin 3
+#define   CHARCOM3    18 // LCD Pin 4
+
+/*Special Symbols */
+#define SPECIAL_SYMBOL_COUNT   4
+
+#define   _LCD_DP1_ON()      SymbolON(17,0)
+#define   _LCD_DP2_ON()      SymbolON(8,0)
+#define   _LCD_DP3_ON()      SymbolON(38,0)
+#define   _LCD_COL_ON()      SymbolON(11,0)
+
+#define   _LCD_DP1_OFF()      SymbolOFF(17,0)
+#define   _LCD_DP2_OFF()      SymbolOFF(8,0)
+#define   _LCD_DP3_OFF()      SymbolOFF(38,0)
+#define   _LCD_COL_OFF()      SymbolOFF(11,0)
+
+// LCD PIN1 to LCDWF2   for FRDM-KL46Z
+#elif HARDWARE_CONFIG == 1
+#define   CHAR1a    37 // LCD Pin 5
+#define   CHAR1b    17 // LCD Pin 6
+#define   CHAR2a    7 // LCD Pin 7
+#define   CHAR2b    8 // LCD Pin 8
+#define   CHAR3a    12 // LCD Pin 9
+#define   CHAR3b    26 // LCD Pin 10
+#define   CHAR4a    10 // LCD Pin 11
+#define   CHAR4b    11 // LCD Pin 12
+#define   CHARCOM0    51 // LCD Pin 1
+#define   CHARCOM1    52 // LCD Pin 2
+#define   CHARCOM2    19 // LCD Pin 3
+#define   CHARCOM3    16 // LCD Pin 4
+
+#define SPECIAL_SYMBOL_COUNT   4
+
+
+#define   _LCD_DP1_ON()      SymbolON(17,0)
+#define   _LCD_DP2_ON()      SymbolON(8,0)
+#define   _LCD_DP3_ON()      SymbolON(26,0)
+#define   _LCD_COL_ON()      SymbolON(11,0)
+
+#define   _LCD_DP1_OFF()      SymbolOFF(17,0)
+#define   _LCD_DP2_OFF()      SymbolOFF(8,0)
+#define   _LCD_DP3_OFF()      SymbolOFF(26,0)
+#define   _LCD_COL_OFF()      SymbolOFF(11,0)
+
+
+
+#endif
+
+
+/*Ascii Codification table information */
+#define ASCCI_TABLE_START '0'   // indicates which is the first Ascii character in the table
+#define ASCCI_TABLE_END   'Z'   // indicates which is the first Ascii character in the table
+#define BLANK_CHARACTER   '>'  // Indicate which ASCII character is a blank character (depends on ASCII table)
+
+#define _ALLON 0xFF     // Used for ALL_on function 
+
+#define SEGDP 0x01
+#define SEGC  0x02
+#define SEGB  0x04
+#define SEGA  0x08
+
+#define SEGD  0x01
+#define SEGE  0x02
+#define SEGG  0x04
+#define SEGF  0x08
+
+
+/* Fault detect initial limits */
+
+/* Fault detect initial parameters and limits */
+#define FAULTD_FP_FDPRS  FDPRS_32
+#define FAULTD_FP_FDSWW  FDSWW_128
+#define FAULTD_BP_FDPRS  FDPRS_64
+#define FAULTD_BP_FDSWW  FDSWW_128
+
+#define FAULTD_FP_HI  127
+#define FAULTD_FP_LO  110
+#define FAULTD_BP_HI  127
+#define FAULTD_BP_LO  110
+#define FAULTD_TIME   6
+
+extern const uint8_t  WF_ORDERING_TABLE[];              //   Logical Front plane N to LCD_WFx
+extern const char  ASCII_TO_WF_CODIFICATION_TABLE[]; //   ASCII to 7x5 Dot Matrix
+
+#endif /* __FRDM_S401_H_ */
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LCDConfig.h	Mon Jan 13 22:32:43 2014 +0000
@@ -0,0 +1,188 @@
+#ifndef __LCDConfig_H_
+#define __LCDConfig_H_
+
+#include "FRDM-s401.h"  //  4x7 segdisplay
+
+
+#if 1  // VREF to VLL1
+/* Following configuration is used for LCD default initialization  */
+#define _LCDRVEN          (1)  //
+#define _LCDRVTRIM        (8)           // CPSEL = 1     0 -- 8000 pf 1 -- 6000 pf  2 -- 4000 pf  3 -- 2000 pf
+#define _LCDCPSEL         (1)          //  charge pump select 0 or 1 
+#define _LCDLOADADJUST    (3)           // CPSEL = 1     0 -- 8000 pf 1 -- 6000 pf  2 -- 4000 pf  3 -- 2000 pf
+#define _LCDALTDIV        (0)           // CPSEL = 1     0 -- 8000 pf 1 -- 6000 pf  2 -- 4000 pf  3 -- 2000 pf
+#define _LCDALRCLKSOURCE  (0)         // 0 -- External clock       1 --  Alternate clock
+
+#define _LCDCLKPSL        (0)         //  Clock divider to generate the LCD Waveforms 
+#define _LCDSUPPLY        (1) 
+#define _LCDHREF          (0)          // 0 or 1 
+#define _LCDCLKSOURCE     (1)         // 0 -- External clock       1 --  Alternate clock
+#define _LCDLCK           (1)         //Any number between 0 and 7 
+#define _LCDBLINKRATE     (3)         //Any number between 0 and 7 
+
+
+#else    //VLL3 to VDD internally
+/* Following configuration is used for LCD default initialization  */
+#define _LCDCLKSOURCE     (1)         // 0 -- External clock       1 --  Alternate clock
+#define _LCDALRCLKSOURCE  (0)         // 0 -- External clock       1 --  Alternate clock
+#define _LCDCLKPSL        (0)         //  Clock divider to generate the LCD Waveforms 
+#define _LCDSUPPLY        (0) 
+#define _LCDLOADADJUST    (3)           // CPSEL = 1     0 -- 8000 pf 1 -- 6000 pf  2 -- 4000 pf  3 -- 2000 pf
+#define _LCDALTDIV        (0)           // CPSEL = 1     0 -- 8000 pf 1 -- 6000 pf  2 -- 4000 pf  3 -- 2000 pf
+#define _LCDRVTRIM        (0)           // CPSEL = 1     0 -- 8000 pf 1 -- 6000 pf  2 -- 4000 pf  3 -- 2000 pf
+#define _LCDHREF          (0)          // 0 or 1 
+#define _LCDCPSEL         (1)          // 0 or 1 
+#define _LCDRVEN          (0)  //
+#define _LCDBLINKRATE     (3)         //Any number between 0 and 7 
+#define _LCDLCK           (0)         //Any number between 0 and 7 
+
+#endif
+
+
+
+
+/*~|~|~|~|~|~|~|~|~|~|~|~|~|~  LCD  Control Register 0  ~|~|~|~|~|~|~|~|~|~|~|~|~*/
+/*~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|*/
+#define _LCDINTENABLE         (1)    
+
+/*~|~|~|~|~|~|~|~|~|~|~|~|~|~  LCD  Control Register 1  ~|~|~|~|~|~|~|~|~|~|~|~|~|*/
+/*~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|*/
+#define _LCDFRAMEINTERRUPT     (0)        //0 Disable Frame Frequency Interrupt
+                                                                       //1 Enable an LCD interrupt that coincides with the LCD frame frequency
+#define _LCDFULLCPLDIRIVE      (0)        // 0 GPIO shared with the LCD. Inputs levels and internal pullup reference to VDD
+                                                                      // 1 If VSUPPLY=11and RVEN=0. Inputs levels and internal pullup reference to VLL3
+#define _LCDWAITMODE           (0)       // 0 Allows the LCD driver and charge pump to continue running during wait mode
+                                                                     //  1 Disable the LCD when the MCU goes into wait mode
+#define _LCDSTOPMODE           (0)     // 0 Allows the LCD driver and charge pump to continue running during stop2 or stop3
+
+                                                                     //  1 Disable the LCD when and charge pump when the MCU goes into stop2 or stop3                                                               
+
+/*~|~|~|~|~|~|~|~|~|~|~|~|~|~  LCD  Voltage Supply Register  ~|~|~|~|~|~|~|~|~|~|~|~*/
+/*~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|*/
+#define _LCDHIGHREF             (0)      //0 Divide input VIREG=1.0v
+                                                                    //1 Do not divide the input VIREG=1.67v
+#define _LCDBBYPASS             (0)      //Determines whether the internal LCD op amp buffer is bypassed
+                                                                      //0 Buffered mode
+                                                                      //1 Unbuffered mode
+                            
+/*~|~|~|~|~|~|~|~|~|~|~|~|~|~  LCD  Regulated Voltage Control |~|~|~|~|~|~|~|~|~|~*/
+/*~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|*/
+#define _LCDCONTRAST                    (1)       //Contrast by software   0 -- Disable    1-- Enable
+#define _LVLCONTRAST                    (0)       //Any number between 0  and 15, if the number is bigger the glass get darker
+
+/*~|~|~|~|~|~|~|~|~|~|~|~|~|~  LCD  Blink Control Register ~|~|~|~|~|~|~|~|~|~|~|~*/
+/*~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|*/
+#define _LCDBLINKCONTROL         (0)   //0 Disable blink mode
+                                                                       //1 Enable blink mode
+#define _LCDALTMODE              (0)   //0 Normal display 
+                                                                      //1 Alternate display for 4 backplanes or less the LCD backplane sequencer changes to otuput an alternate display
+#define _LCDBLANKDISP           (0)  //0 Do not blank display
+                                                                      //1 Blank display if you put it in 0 the text before blank is manteined     
+#define _LCDBLINKMODE           (0)  //0 Display blank during the blink period 
+                                                                     //1 Display alternate displat during blink period (Ignored if duty is 5 or greater)
+
+
+//Calculated values
+#define _LCDUSEDPINS   (_LCDFRONTPLANES + _LCDBACKPLANES)
+#define _LCDDUTY       (_LCDBACKPLANES-1)         //Any number between 0 and 7 
+#define  LCD_WF_BASE    LCD_WF3TO0
+
+// General definitions used by the LCD library
+#define  SymbolON(LCDn,bit)     *((uint8 *)&LCD_WF_BASE + LCDn)  |=  (1<<(bit))         
+#define  SymbolOFF(LCDn,bit)    *((uint8 *)&LCD_WF_BASE + LCDn)  &= ~(1<<(bit))         
+//#define  LCD_WF(x)              *((uint8 *)&LCD_WF_BASE + x) 
+
+/*LCD Fault Detections Consts*/
+#define  FP_TYPE  0x00         // pin is a Front Plane
+#define  BP_TYPE  0x80         // pin is Back Plane
+
+// Fault Detect Preescaler Options
+#define FDPRS_1      0
+#define FDPRS_2      1
+#define FDPRS_4      2
+#define FDPRS_8      3
+#define FDPRS_16     4 
+#define FDPRS_32     5
+#define FDPRS_64     6
+#define FDPRS_128    7
+
+// Fault Detect Sample Window Width Values  
+#define FDSWW_4           0
+#define FDSWW_8           1
+#define FDSWW_16          2
+#define FDSWW_32          3
+#define FDSWW_64          4
+#define FDSWW_128         5
+#define FDSWW_256         6
+#define FDSWW_512         7
+
+/*
+  Mask Bit definitions used f
+*/
+#define     mBIT0   1
+#define     mBIT1   2
+#define     mBIT2   4
+#define     mBIT3   8
+#define     mBIT4   16
+#define     mBIT5   32
+#define     mBIT6   64
+#define     mBIT7   128
+#define     mBIT8   256
+#define     mBIT9   512
+#define     mBIT10   1024
+#define     mBIT11   2048
+#define     mBIT12   4096
+#define     mBIT13   8192
+#define     mBIT14   16384
+#define     mBIT15   32768
+#define     mBIT16   65536
+#define     mBIT17   131072
+#define     mBIT18   262144
+#define     mBIT19   524288
+#define     mBIT20   1048576
+#define     mBIT21   2097152
+#define     mBIT22   4194304
+#define     mBIT23   8388608
+#define     mBIT24   16777216
+#define     mBIT25   33554432
+#define     mBIT26   67108864
+#define     mBIT27   134217728
+#define     mBIT28   268435456
+#define     mBIT29   536870912
+#define     mBIT30   1073741824
+#define     mBIT31   2147483648
+
+#define    mBIT32      1
+#define    mBIT33      2
+#define    mBIT34      4
+#define    mBIT35      8
+#define    mBIT36      16
+#define    mBIT37      32
+#define    mBIT38      64
+#define    mBIT39      128
+#define    mBIT40      256
+#define    mBIT41      512
+#define    mBIT42      1024
+#define    mBIT43      2048
+#define    mBIT44      4096
+#define    mBIT45      8192
+#define    mBIT46      16384
+#define    mBIT47      32768
+#define    mBIT48      65536
+#define    mBIT49      131072
+#define    mBIT50      262144
+#define    mBIT51      524288
+#define    mBIT52      1048576
+#define    mBIT53      2097152
+#define    mBIT54      4194304
+#define    mBIT55      8388608
+#define    mBIT56      16777216
+#define    mBIT57      33554432
+#define    mBIT58      67108864
+#define    mBIT59      134217728
+#define    mBIT60      268435456
+#define    mBIT61      536870912
+#define    mBIT62      1073741824
+#define    mBIT63      2147483648
+
+#endif /* __LCDConfig_H_ */
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LCDHDW.h	Mon Jan 13 22:32:43 2014 +0000
@@ -0,0 +1,280 @@
+/*^^^^^^^^^^^^^^^^   LCD HARDWARE CONECTION 
+ FB-GD6363AP.h
+             Marconi Daugther Card to GD-5366AP configuration
+             8x35 Dot Matrix LCD  + 8 special characters
+             3 Volts
+
+^^^^^^^^^^^^^^^^^^^^^^^^*/
+
+
+
+#define _CHARNUM    (35)  //number of chars that can be written
+#define _CHAR_SIZE   (6)  // Used only when Dot Matrix is used
+#define _LCDTYPE     (1)  //indicate how many LCD_WF are required to write a single Character / or Colum in case of DOT matrix LCD
+
+
+#define  EnableLCDpin(RegNum,LCDn)    LCDPEN##RegNum##_PEN##LCDn = 1
+#define  EnableBackplane(RegNum, LCDn)      LCDBPEN##RegNum##_BPEN##LCDn  = 1    
+
+
+// with mask
+#define  SetBackplane(ComNum, LCDn)   LCDWF##LCDn  = (1 << (ComNum))
+                                                      
+#define  CharacterPlace(LCDn)        LCDWF##LCDn        // _LCDWF0
+                        
+#define BP_FLAG 0x80 // used to indicate if the WF is used as backplane
+                                 
+                                            
+// Enable all LCD pins to be used as LCD function  inlcuding Backplanes and Front planes
+     #define     EnablePin4    EnableLCDpin (5,40)
+     #define     EnablePin3    EnableLCDpin (5,41)
+     #define     EnablePin2    EnableLCDpin (5,42)
+     #define     EnablePin1    EnableLCDpin (5,43)
+     #define     EnablePin23    EnableLCDpin (0,0)
+     #define     EnablePin24    EnableLCDpin (0,1)
+     #define     EnablePin25    EnableLCDpin (0,2)
+     #define     EnablePin26    EnableLCDpin (0,3)
+     #define     EnablePin27    EnableLCDpin (0,4)
+     #define     EnablePin28    EnableLCDpin (0,5)
+     #define     EnablePin29    EnableLCDpin (0,6)
+     #define     EnablePin30    EnableLCDpin (0,7)
+     #define     EnablePin31    EnableLCDpin (1,8)
+     #define     EnablePin32    EnableLCDpin (1,9)
+     #define     EnablePin33    EnableLCDpin (1,10)
+     #define     EnablePin34    EnableLCDpin (1,11)
+     #define     EnablePin35    EnableLCDpin (1,12)
+     #define     EnablePin5    EnableLCDpin (4,39)
+     #define     EnablePin6    EnableLCDpin (4,38)
+     #define     EnablePin7    EnableLCDpin (4,37)
+     #define     EnablePin8    EnableLCDpin (4,36)
+     #define     EnablePin9    EnableLCDpin (4,35)
+     #define     EnablePin10    EnableLCDpin (4,34)
+     #define     EnablePin11    EnableLCDpin (4,33)
+     #define     EnablePin12    EnableLCDpin (4,32)
+     #define     EnablePin13    EnableLCDpin (3,31)
+     #define     EnablePin14    EnableLCDpin (3,30)
+     #define     EnablePin15    EnableLCDpin (3,29)
+     #define     EnablePin16    EnableLCDpin (3,28)
+     #define     EnablePin17    EnableLCDpin (3,27)
+     #define     EnablePin18    EnableLCDpin (3,26)
+     #define     EnablePin19    EnableLCDpin (3,25)
+     #define     EnablePin20    EnableLCDpin (3,24)
+     #define     EnablePin21    EnableLCDpin (2,23)
+     #define     EnablePin36    EnableLCDpin (1,13)
+     #define     EnablePin37    EnableLCDpin (1,14)
+     #define     EnablePin38    EnableLCDpin (1,15)
+     #define     EnablePin39    EnableLCDpin (2,16)
+     #define     EnablePin40    EnableLCDpin (2,17)
+     #define     EnablePin41    EnableLCDpin (2,18)
+     #define     EnablePin42    EnableLCDpin (2,19)
+     #define     EnablePin43    EnableLCDpin (2,20)
+     #define     EnablePin44    EnableLCDpin (2,21)
+     #define     EnablePin22    EnableLCDpin (2,22)
+
+
+
+/*Related with register names */
+
+
+
+// Enable the LCD pin like a Backplane functionality 
+// (registernumber,LCD pin number)
+     #define     EnablePin4    EnableLCDpin (5,40)
+     #define     EnablePin3    EnableLCDpin (5,41)
+     #define     EnablePin2    EnableLCDpin (5,42)
+     #define     EnablePin1    EnableLCDpin (5,43)
+     #define     EnablePin23    EnableLCDpin (0,0)
+     #define     EnablePin24    EnableLCDpin (0,1)
+     #define     EnablePin25    EnableLCDpin (0,2)
+     #define     EnablePin26    EnableLCDpin (0,3)
+
+
+
+// Give the mask to the Backplane  
+// (ComNumber/BitNumber/priority  segun el LCD manual ,  LCDn)
+        #define SetCom1         SetBackplane(0,0)
+        #define SetCom2         SetBackplane(1,1)
+        #define SetCom3         SetBackplane(2,2)
+        #define SetCom4         SetBackplane(3,3)
+        #define SetCom5         SetBackplane(0,0)
+        #define SetCom6         SetBackplane(1,1)
+        #define SetCom7         SetBackplane(2,2)
+        #define SetCom8         SetBackplane(3,3)
+
+
+
+
+// Indicate how Character is connected to LCDn
+
+#ifdef GD5602P
+#define   Char1        41  // LCD Pin 40
+#define   Char2        40  // LCD Pin 39
+#define   Char3        39  // LCD Pin 38
+#define   Char4        38  // LCD Pin 37
+#define   Char5        37  // LCD Pin 36
+#define   Char6        36  // LCD Pin 35
+#define   Char7        35  // LCD Pin 34
+#define   Char8        34  // LCD Pin 33
+#define   Char9        33  // LCD Pin 32
+#define   Char10        17  // LCD Pin 5
+#define   Char11        16  // LCD Pin 6
+#define   Char12        15  // LCD Pin 7
+#define   Char13        14  // LCD Pin 8
+#define   Char14        13  // LCD Pin 9
+#define   Char15        12  // LCD Pin 10
+#define   Char16        11  // LCD Pin 11
+#define   Char17        10  // LCD Pin 12
+#define   Char18        9  // LCD Pin 13
+#define   Char19        8  // LCD Pin 14
+#define   Char20        7  // LCD Pin 15
+#define   Char21        6  // LCD Pin 16
+#define   Char22        5  // LCD Pin 17
+#define   Char23        4  // LCD Pin 18
+#define   Char24        3  // LCD Pin 19
+#define   Char25        2  // LCD Pin 20
+#define   Char26        1  // LCD Pin 21
+#define   Char27        32  // LCD Pin 31
+#define   Char28        31  // LCD Pin 30
+#define   Char29        30  // LCD Pin 29
+#define   Char30        29  // LCD Pin 28
+#define   Char31        28  // LCD Pin 27
+#define   Char32        27  // LCD Pin 26
+#define   Char33        26  // LCD Pin 25
+#define   Char34        25  // LCD Pin 24
+#define   Char35        24  // LCD Pin 23
+#define   Char36        0  // LCD Pin 22
+#endif
+
+#ifdef  GD5663AP
+#define   CHAR1        0  // LCD Pin 1
+#define   CHAR2        1  // LCD Pin 2
+#define   CHAR3        2  // LCD Pin 3
+#define   CHAR4        3  // LCD Pin 4
+#define   CHAR5        4  // LCD Pin 5
+#define   CHAR6        5  // LCD Pin 6
+#define   CHAR7        6  // LCD Pin 7
+#define   CHAR8        7  // LCD Pin 8
+#define   CHAR9        8  // LCD Pin 9
+#define   CHAR10        9  // LCD Pin 10
+#define   CHAR11        10  // LCD Pin 11
+#define   CHAR12        11  // LCD Pin 12
+#define   CHAR13        12  // LCD Pin 13
+#define   CHAR14        13  // LCD Pin 14
+#define   CHAR15        14  // LCD Pin 15
+#define   CHAR16        15  // LCD Pin 16
+#define   CHAR17        16  // LCD Pin 17
+#define   CHAR18        17  // LCD Pin 18
+#define   CHAR19        18  // LCD Pin 19
+#define   CHAR20        19  // LCD Pin 20
+#define   CHAR21        20  // LCD Pin 21
+#define   CHAR22        21  // LCD Pin 22
+#define   CHAR23        32  // LCD Pin 36
+#define   CHAR24        33  // LCD Pin 35
+#define   CHAR25        34  // LCD Pin 34
+#define   CHAR26        35  // LCD Pin 33
+#define   CHAR27        36  // LCD Pin 32
+#define   CHAR28        37  // LCD Pin 31
+#define   CHAR29        38  // LCD Pin 30
+#define   CHAR30        39  // LCD Pin 29
+#define   CHAR31        40  // LCD Pin 28
+#define   CHAR32        41  // LCD Pin 27
+#define   CHAR33        42  // LCD Pin 26
+#define   CHAR34        43  // LCD Pin 25
+#define   CHAR35        44  // LCD Pin 24
+#define   CHAR_S1        45  // LCD Pin 23
+
+#define   CHARCOM0        31  // LCD Pin 37
+#define   CHARCOM1        30  // LCD Pin 38
+#define   CHARCOM2        29  // LCD Pin 39
+#define   CHARCOM3        28  // LCD Pin 40
+#define   CHARCOM4        27  // LCD Pin 41
+#define   CHARCOM5        26  // LCD Pin 42
+#define   CHARCOM6        25  // LCD Pin 43
+#define   CHARCOM7        24  // LCD Pin 44
+
+/* Define which LCDWF are used as backplane (COM0 to COM7 are set as reference but is not configured here */
+#define  BP_COM0        31
+#define  BP_COM1        30
+#define  BP_COM2        29
+#define  BP_COM3        28
+#define  BP_COM4        27
+#define  BP_COM5        26
+#define  BP_COM6        25
+#define  BP_COM7        24
+
+#endif
+
+
+
+
+
+
+
+ // *((uint8_t *)&LCD_WF3TO0 + CHAR_S1) |= 0xFF;
+ // *((uint8_t *)&LCD_WF3TO0 + CHAR_S1) |= 0x00;
+
+
+#define SymbolON(LCDn,bit)     *((uint8 *)&LCD_WF3TO0 + LCDn)  |=  (1<<(bit))         
+#define SymbolOFF(LCDn,bit)    *((uint8 *)&LCD_WF3TO0 + LCDn)  &= ~(1<<(bit))         
+#define LCD_WF(x)              *((uint8 *)&LCD_WF3TO0 + x) 
+
+
+#define   _LCD_FREESCALE_ON()    SymbolON(CHAR_S1,0)
+#define   _LCD_BATTERY_ON()    SymbolON(CHAR_S1,1)
+#define   _LCD_LEVEL4_ON()    SymbolON(CHAR_S1,2)
+#define   _LCD_LEVEL3_ON()    SymbolON(CHAR_S1,3)
+#define   _LCD_LEVEL2_ON()    SymbolON(CHAR_S1,4)
+#define   _LCD_LEVEL1_ON()    SymbolON(CHAR_S1,5)
+#define   _LCD_SNOW_ON()    SymbolON(CHAR_S1,6)
+#define   _LCD_FIRE_ON()    SymbolON(CHAR_S1,7)
+
+#define   _LCD_FREESCALE_OFF()      SymbolOFF(CHAR_S1,0)
+#define   _LCD_BATTERY_OFF()      SymbolOFF(CHAR_S1,1)
+#define   _LCD_LEVEL4_OFF()      SymbolOFF(CHAR_S1,2)
+#define   _LCD_LEVEL3_OFF()      SymbolOFF(CHAR_S1,3)
+#define   _LCD_LEVEL2_OFF()      SymbolOFF(CHAR_S1,4)
+#define   _LCD_LEVEL1_OFF()      SymbolOFF(CHAR_S1,5)
+#define   _LCD_SNOW_OFF()      SymbolOFF(CHAR_S1,6)
+#define   _LCD_FIRE_OFF()      SymbolOFF(CHAR_S1,7)
+
+
+//  (LCDn, BitNumber)
+
+
+
+#define MapSegment(SegmentName,Mask)   (1<<(##Mask##)) 
+          
+          #define  SEG1               MapSegment (0,0)
+          #define  SEG2               MapSegment (1,1)
+          #define  SEG3               MapSegment (2,2)
+          #define  SEG4               MapSegment (3,3)
+          #define  SEG5               MapSegment (4,4)
+          #define  SEG6               MapSegment (5,5)
+          #define  SEG7               MapSegment (6,6)
+          #define  SEG8               MapSegment (7,7)
+          
+          
+  
+
+/*Map segment to COM mask*/
+#define  SEGB   0x01
+#define  SEGC   0x02
+
+#define  SEGH   0x01
+#define  SEGF   0x02
+#define  SEGE   0x04
+#define  SEGN   0x08
+
+#define  SEGA   0x01
+#define  SEGJ   0x02
+#define  SEGG   0x04
+#define  SEGM   0x08
+
+#define  SEGK   0x01
+#define  SEGL   0x02
+#define  SEGD   0x04
+
+
+//Ascii table American Standar
+#define _ALLON  (SEG1  | SEG2 | SEG3 | SEG4 | SEG5  | SEG6 | SEG7 | SEG8)  
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/s401.cpp	Mon Jan 13 22:32:43 2014 +0000
@@ -0,0 +1,85 @@
+/*
+  Following table indicate how LCD_WF are logically organized to Chars(columns in the LCD)
+  Char1 (LCD physical position)   to LCD_WF (offset)
+   This table is used by  WriteChar function to write the character/column to appropriate place
+Char1  is Defined in LCDHDW.h
+
+Following Table is used 
+1) indicate how WF are organized with 
+2) LCD_Px  in this table will be enabled
+3) LCD_Px  after _LCDFRONTPLANES will be configured as backplanes and initialized as 0x01, 0x02, etc.
+*/
+
+#include "LCDConfig.h" 
+
+const uint8_t WF_ORDERING_TABLE[ ] =
+{
+   CHAR1a,   // LCD81 --- Pin:5  LCDnAddress=51
+   CHAR1b,   // LCD82 --- Pin:6  LCDnAddress=52
+   CHAR2a,   // LCD83 --- Pin:7  LCDnAddress=53
+   CHAR2b,   // LCD84 --- Pin:8  LCDnAddress=54
+   CHAR3a,   // LCD85 --- Pin:9  LCDnAddress=55
+   CHAR3b,   // LCD86 --- Pin:10  LCDnAddress=56
+   CHAR4a,   // LCD87 --- Pin:11  LCDnAddress=57
+   CHAR4b,   // LCD88 --- Pin:12  LCDnAddress=58
+   CHARCOM0,   // LCD77 --- Pin:1  LCDnAddress=4D
+   CHARCOM1,   // LCD78 --- Pin:2  LCDnAddress=4E
+   CHARCOM2,   // LCD79 --- Pin:3  LCDnAddress=4F
+   CHARCOM3,   // LCD80 --- Pin:4  LCDnAddress=50
+};
+
+/*
+   Ascii to 8x6 dot matrix decodification table
+*/
+const char ASCII_TO_WF_CODIFICATION_TABLE [ ] =
+{
+( SEGD+ SEGE+ SEGF+!SEGG) , ( SEGC+ SEGB+ SEGA) ,//Char = 0,   offset=0
+(!SEGD+!SEGE+!SEGF+!SEGG) , ( SEGC+ SEGB+!SEGA) ,//Char = 1,   offset=4
+( SEGD+ SEGE+!SEGF+ SEGG) , (!SEGC+ SEGB+ SEGA) ,//Char = 2,   offset=8
+( SEGD+!SEGE+!SEGF+ SEGG) , ( SEGC+ SEGB+ SEGA) ,//Char = 3,   offset=12
+(!SEGD+!SEGE+ SEGF+ SEGG) , ( SEGC+ SEGB+!SEGA) ,//Char = 4,   offset=16
+( SEGD+!SEGE+ SEGF+ SEGG) , ( SEGC+!SEGB+ SEGA) ,//Char = 5,   offset=20
+( SEGD+ SEGE+ SEGF+ SEGG) , ( SEGC+!SEGB+ SEGA) ,//Char = 6,   offset=24
+(!SEGD+!SEGE+!SEGF+!SEGG) , ( SEGC+ SEGB+ SEGA) ,//Char = 7,   offset=28
+( SEGD+ SEGE+ SEGF+ SEGG) , ( SEGC+ SEGB+ SEGA) ,//Char = 8,   offset=32
+( SEGD+!SEGE+ SEGF+ SEGG) , ( SEGC+ SEGB+ SEGA) ,//Char = 9,   offset=36
+(!SEGD+!SEGE+!SEGF+!SEGG) , (!SEGC+!SEGB+!SEGA) ,//Char = :,   offset=40
+(!SEGD+!SEGE+!SEGF+!SEGG) , (!SEGC+!SEGB+!SEGA) ,//Char = ;,   offset=44
+(!SEGD+!SEGE+!SEGF+!SEGG) , (!SEGC+!SEGB+!SEGA) ,//Char = <,   offset=48
+( SEGD+!SEGE+!SEGF+ SEGG) , (!SEGC+!SEGB+!SEGA) ,//Char = =,   offset=52
+(!SEGD+!SEGE+!SEGF+!SEGG) , (!SEGC+!SEGB+!SEGA) ,//Char = >,   offset=56
+(!SEGD+!SEGE+!SEGF+!SEGG) , (!SEGC+!SEGB+ SEGA) ,//Char = ?,   offset=60
+( SEGD+ SEGE+ SEGF+ SEGG) , ( SEGC+ SEGB+ SEGA) ,//Char = @,   offset=64
+(!SEGD+ SEGE+ SEGF+ SEGG) , ( SEGC+ SEGB+ SEGA) ,//Char = A,   offset=68
+( SEGD+ SEGE+ SEGF+ SEGG) , ( SEGC+!SEGB+!SEGA) ,//Char = B,   offset=72
+( SEGD+ SEGE+ SEGF+!SEGG) , (!SEGC+!SEGB+ SEGA) ,//Char = C,   offset=76
+( SEGD+ SEGE+!SEGF+ SEGG) , ( SEGC+ SEGB+ SEGA) ,//Char = D,   offset=80
+( SEGD+ SEGE+ SEGF+ SEGG) , (!SEGC+!SEGB+ SEGA) ,//Char = E,   offset=84
+(!SEGD+ SEGE+ SEGF+ SEGG) , (!SEGC+!SEGB+ SEGA) ,//Char = F,   offset=88
+( SEGD+ SEGE+ SEGF+ SEGG) , ( SEGC+!SEGB+ SEGA) ,//Char = G,   offset=92
+(!SEGD+ SEGE+ SEGF+ SEGG) , ( SEGC+ SEGB+!SEGA) ,//Char = H,   offset=96
+(!SEGD+!SEGE+!SEGF+!SEGG) , ( SEGC+!SEGB+!SEGA) ,//Char = I,   offset=100
+( SEGD+ SEGE+!SEGF+!SEGG) , ( SEGC+ SEGB+!SEGA) ,//Char = J,   offset=104
+(!SEGD+!SEGE+!SEGF+!SEGG) , (!SEGC+!SEGB+!SEGA) ,//Char = K,   offset=108
+( SEGD+ SEGE+ SEGF+!SEGG) , (!SEGC+!SEGB+!SEGA) ,//Char = L,   offset=112
+(!SEGD+ SEGE+ SEGF+!SEGG) , ( SEGC+ SEGB+!SEGA) ,//Char = M,   offset=116
+(!SEGD+ SEGE+!SEGF+ SEGG) , ( SEGC+!SEGB+!SEGA) ,//Char = N,   offset=120
+( SEGD+ SEGE+!SEGF+ SEGG) , ( SEGC+!SEGB+!SEGA) ,//Char = O,   offset=124
+(!SEGD+ SEGE+ SEGF+ SEGG) , ( SEGC+ SEGB+ SEGA) ,//Char = P,   offset=128
+( SEGD+!SEGE+ SEGF+ SEGG) , ( SEGC+ SEGB+ SEGA) ,//Char = Q,   offset=132
+(!SEGD+ SEGE+ SEGF+ SEGG) , (!SEGC+ SEGB+ SEGA) ,//Char = R,   offset=136
+( SEGD+!SEGE+ SEGF+ SEGG) , ( SEGC+!SEGB+ SEGA) ,//Char = S,   offset=140
+( SEGD+ SEGE+ SEGF+ SEGG) , (!SEGC+!SEGB+!SEGA) ,//Char = T,   offset=144
+( SEGD+ SEGE+ SEGF+!SEGG) , ( SEGC+ SEGB+!SEGA) ,//Char = U,   offset=148
+(!SEGD+!SEGE+!SEGF+!SEGG) , (!SEGC+!SEGB+!SEGA) ,//Char = V,   offset=152
+(!SEGD+ SEGE+ SEGF+!SEGG) , ( SEGC+ SEGB+!SEGA) ,//Char = W,   offset=156
+(!SEGD+!SEGE+!SEGF+!SEGG) , (!SEGC+!SEGB+!SEGA) ,//Char = X,   offset=160
+(!SEGD+!SEGE+!SEGF+!SEGG) , (!SEGC+!SEGB+!SEGA) ,//Char = Y,   offset=164
+( SEGD+!SEGE+!SEGF+!SEGG) , (!SEGC+!SEGB+ SEGA) ,//Char = Z,   offset=168
+( SEGD+!SEGE+!SEGF+!SEGG) , (!SEGC+!SEGB+ SEGA) ,//Char = [,   offset=172
+( SEGD+!SEGE+!SEGF+!SEGG) , (!SEGC+!SEGB+ SEGA) ,//Char = \,   offset=176
+( SEGD+!SEGE+!SEGF+!SEGG) , (!SEGC+!SEGB+ SEGA) ,//Char = ],   offset=180
+( SEGD+!SEGE+!SEGF+!SEGG) , (!SEGC+!SEGB+ SEGA) ,//Char = ^,   offset=184
+( SEGD+!SEGE+!SEGF+!SEGG) , (!SEGC+!SEGB+ SEGA) ,//Char = _,   offset=188
+( SEGD+!SEGE+!SEGF+!SEGG) , (!SEGC+!SEGB+ SEGA) ,//Char = `,   offset=192
+};
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/vfnLCD.cpp	Mon Jan 13 22:32:43 2014 +0000
@@ -0,0 +1,588 @@
+#include "mbed.h"
+#include "vfnLCD.h"
+#include "LCDConfig.h"
+
+/*used to indicate in which position of the LCD is the next character to write */
+static uint8_t bLCD_CharPosition;
+uint8_t lcd_alternate_mode;  //this variable must be 0 or 4 
+uint8_t bflgLCD_Scroll = 0x01;
+
+extern const uint32_t *LCD_TO_PORT[];
+extern const uint32_t MASK_BIT[32];
+
+char lcdBuffer[32]; // used for temporary storage for formating strings
+
+/*
+local functions
+
+void vfnLCD_Init(void);
+void vfnEnablePins(void);  // Pin Enable/ BPEN / COM configurations
+void vfnSetBackplanes(void); // reconfigure COM to default values
+void vfnBP_VScroll(int8_t scroll_count);
+void vfnLCD_Home (void);
+void vfnLCD_Contrast (uint8_t lbContrast);
+void vfnLCD_Write_MsgPlace (uint8_t *lbpMessage, uint8_t lbSize );
+void vfnLCD_Write_Msg (uint8_t *lbpMessage);
+void vfnLCD_All_Segments_ON (void);    
+void vfnLCD_All_Segments_Char (uint8_t val);
+void vfnLCD_All_Segments_OFF (void);
+
+void vfnLCD_Write_Char (uint8_t lbValue);  // This function is dependent on the LCD panel
+void PutPoint(uint8_t x, uint8_t y);
+void ClrPoint(uint8_t x, uint8_t y);
+void SetX(uint8_t x, uint8_t value);
+
+
+void lcd_pinmux(uint8_t  mux_val);
+
+void vfnLCD_interrupt_init(void);
+void vfnLCD_isrv(void);
+
+
+
+void print_slcd_registers(void)
+{
+ // printf("\n\r LCD_GCR ");
+    printf("\n\r LCD_GCR = %i",LCD_GCR);
+   printf("\n\r LCD_AR = %i",LCD_AR);
+   printf("\n\r LCD_FDCR = %i",LCD_FDCR);
+   printf("\n\r LCD_FDSR = %i",LCD_FDSR);
+   printf("\n\r LCD_PENL = %i",LCD_PENL);
+  
+   printf("\n\r LCD_PENH = %i",LCD_PENH);
+   printf("\n\r LCD_BPENL = %i",LCD_BPENL);
+   printf("\n\r LCD_BPENH = %i",LCD_BPENH);
+   printf("\n\r LCD_WF3TO0 = %i",LCD_WF3TO0);
+   printf("\n\r LCD_WF7TO4 = %i",LCD_WF7TO4);
+   printf("\n\r LCD_WF11TO8 = %i",LCD_WF11TO8);
+   printf("\n\r LCD_WF15TO12 = %i",LCD_WF15TO12);
+   printf("\n\r LCD_WF19TO16 = %i",LCD_WF19TO16);
+   printf("\n\r LCD_WF23TO20 = %i",LCD_WF23TO20);
+   printf("\n\r LCD_WF27TO24 = %i",LCD_WF27TO24);
+   printf("\n\r LCD_WF31TO28 = %i",LCD_WF31TO28);
+   printf("\n\r LCD_WF35TO32 = %i",LCD_WF35TO32);
+   printf("\n\r LCD_WF39TO36 = %i",LCD_WF39TO36);
+   printf("\n\r LCD_WF43TO40 = %i",LCD_WF43TO40);
+   printf("\n\r LCD_WF47TO44 = %i",LCD_WF47TO44);
+   printf("\n\r LCD_WF51TO48 = %i",LCD_WF51TO48);
+   printf("\n\r LCD_WF55TO52 = %i",LCD_WF55TO52);
+   printf("\n\r LCD_WF59TO56 = %i",LCD_WF59TO56);
+   printf("\n\r LCD_WF63TO60 = %i",LCD_WF63TO60);
+*/
+                     
+vfnLCD::vfnLCD() {
+  
+  SIM->SCGC5 |= SIM_SCGC5_SLCD_MASK | SIM_SCGC5_PORTB_MASK | SIM_SCGC5_PORTC_MASK | SIM_SCGC5_PORTD_MASK | SIM_SCGC5_PORTE_MASK;
+     
+     //* configure pins for LCD operation    
+  PORTC->PCR[20] = 0x00000000;     //VLL2
+  PORTC->PCR[21] = 0x00000000;     //VLL1
+  PORTC->PCR[22] = 0x00000000;     //VCAP2
+  PORTC->PCR[23] = 0x00000000;     //VCAP1
+
+     
+     
+     // Enable IRCLK 
+     MCG->C1  = MCG_C1_IRCLKEN_MASK | MCG_C1_IREFSTEN_MASK;
+     MCG->C2 &= ~MCG_C2_IRCS_MASK ;  //0 32KHZ internal reference clock; 1= 4MHz irc
+
+
+     vfnLCD_interrupt_init();       
+     
+     LCD->GCR = 0x0;
+     LCD->AR  = 0x0;
+
+ //    lcd_pinmux(0); 
+     
+/* LCD configurartion according to */     
+      LCD->GCR =  (   LCD_GCR_RVEN_MASK*_LCDRVEN  
+                   | LCD_GCR_RVTRIM(_LCDRVTRIM)    //0-15
+                   | LCD_GCR_CPSEL_MASK*_LCDCPSEL 
+                   | LCD_GCR_LADJ(_LCDLOADADJUST)     //0-3*/
+                   | LCD_GCR_VSUPPLY_MASK*_LCDSUPPLY  //0-1*/
+                   |!LCD_GCR_FDCIEN_MASK
+                   | LCD_GCR_ALTDIV(_LCDALTDIV)  //0-3
+                   |!LCD_GCR_LCDDOZE_MASK  
+                   |!LCD_GCR_LCDSTP_MASK
+                   |!LCD_GCR_LCDEN_MASK    //WILL BE ENABLE ON SUBSEQUENT STEP
+                   | LCD_GCR_SOURCE_MASK*_LCDCLKSOURCE
+                   | LCD_GCR_ALTSOURCE_MASK*_LCDALRCLKSOURCE  
+                   | LCD_GCR_LCLK(_LCDLCK)   //0-7
+                   | LCD_GCR_DUTY(_LCDDUTY)   //0-7
+                 );    
+     
+      lcd_alternate_mode = LCD_NORMAL_MODE;          //Message will be written to default backplanes  if = 4
+     
+      vfnEnablePins();         // Enable LCD pins and Configure BackPlanes
+ 
+      
+      LCD->GCR |= LCD_GCR_LCDEN_MASK;
+   /*   LCD_GCR |= LCD_GCR_LCDIEN_MASK;    // Enable interrupts */
+      
+      
+   /* Configure LCD Auxiliar Register*/   
+      LCD->AR  = LCD_AR_BRATE(_LCDBLINKRATE); // all other flags set as zero
+     // print_slcd_registers();
+}
+  
+
+/* Enable pins according  WF_ORDERING_TABLE, BP_ORDERING_TABLE
+ //Enable the LCD module frontplane waveform output (FP[39:0])
+  LCD_PENH = 0xFFFFFFFF;
+  LCD_PENL = 0xFFFFFFFF;
+
+*/
+
+  void vfnLCD::vfnEnablePins (void)
+  {
+   uint8_t i;
+   uint32_t *p_pen;
+   uint8_t pen_offset;   // 0 or 1   
+   uint8_t pen_bit;      //0 to 31
+
+   LCD->PEN[0]= 0x00;
+   LCD->PEN[1] = 0x0;
+   LCD->BPEN[0] = 0x00;
+   LCD->BPEN[1] = 0x00;
+   
+   p_pen = (uint32_t *)LCD->PEN;
+
+    for (i=0;i<_LCDUSEDPINS;i++) 
+    {
+      pen_offset = WF_ORDERING_TABLE[i]/32;
+      pen_bit    = WF_ORDERING_TABLE[i]%32;
+      p_pen[pen_offset] |= MASK_BIT[pen_bit];
+      if (i>= _LCDFRONTPLANES)    // Pin is a backplane
+      {
+        p_pen[pen_offset+2] |= MASK_BIT[pen_bit];  // Enable  BPEN 
+        LCD->WF8B[WF_ORDERING_TABLE[i]] = MASK_BIT[i - _LCDFRONTPLANES];   // fill with 0x01, 0x02, etc 
+      } 
+    }
+  }
+  
+/*
+  Fill Backplanes with normal mask for  0x01, 0x02,  according to BP_ORDERING_TABLE;
+*/
+void vfnLCD::vfnSetBackplanes(void)
+ {
+   uint8_t i;
+   for (i=0;i<_LCDBACKPLANES;i++)
+   {
+       LCD->WF8B[WF_ORDERING_TABLE[i+_LCDFRONTPLANES]]=0x01<<i;
+   }  
+  };
+
+ 
+ /*
+ 
+ rotate Backplanes  scroll_y units
+   if scroll_y>0  rotate to the right
+   if scroll_y<0  rotate to the left
+   if scroll_y=0  set normal configuration
+
+*/
+void vfnLCD::vfnBP_VScroll(int8_t scroll_count)
+ {
+   uint8_t bp_count;
+   if (scroll_count != 0)
+   {  
+    for (bp_count=0;bp_count< _LCDBACKPLANES; bp_count++)
+    {
+       if (scroll_count>0)
+         LCD->WF8B[0]=((uint8_t)WF_ORDERING_TABLE[_LCDFRONTPLANES +bp_count]);
+      else   //(scroll_count<0)
+        { 
+           LCD->WF8B[0]=((uint8_t)WF_ORDERING_TABLE[_LCDFRONTPLANES +bp_count]);       
+        }
+    }  
+   }
+    else vfnSetBackplanes(); 
+  }
+
+
+
+void vfnLCD::vfnLCD_Home (void)
+ {
+      bLCD_CharPosition =  0;
+ }
+
+void vfnLCD::vfnLCD_Contrast (uint8_t lbContrast)
+{
+       lbContrast &= 0x0F;                                               //Forced to the only values accepted 
+       LCD->GCR |= LCD_GCR_RVTRIM(lbContrast);
+}
+ 
+void vfnLCD::vfnLCD_Write_MsgPlace (uint8_t *lbpMessage, uint8_t lbSize )
+ {
+          
+          if (lbSize > _CHARNUM)
+          {
+               vfnLCD_Scroll(lbpMessage, lbSize);
+          }
+          else
+          {
+            do
+            {
+                    vfnLCD_Write_Char (*lbpMessage);
+                    lbpMessage ++;     
+             }while (--lbSize);
+          }
+
+ }
+ 
+ 
+ 
+ /*
+ vfnLCD_Write_Msg.  Display a Message starting at the first character of display
+   until _CHARNUM  or End of string.
+ */
+ 
+void  vfnLCD::vfnLCD_Write_Msg (uint8_t *lbpMessage) {
+  uint8_t lbSize      = 0;          
+  bLCD_CharPosition = 0;  //Home display
+  while (lbSize<_CHARNUM && *lbpMessage!='\0') {
+    vfnLCD_Write_Char(*lbpMessage++);
+    lbSize++;     
+  }
+  if (lbSize<_CHARNUM) {
+    while (lbSize++< _CHARNUM) {
+      vfnLCD_Write_Char(BLANK_CHARACTER);  // complete data with blanks
+    }
+  }
+}
+
+void vfnLCD::vfnLCD_All_Segments_ON (void)
+{
+ uint8_t lbTotalBytes = _CHARNUM * _LCDTYPE;              
+ uint8_t lbCounter=0;
+ uint8_t *lbpLCDWF;
+ 
+    lbpLCDWF = (uint8_t *)&LCD->WF;
+      
+        while (lbCounter < lbTotalBytes)
+          {
+              lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[lbCounter++]]=_ALLON;
+          }
+         
+}
+
+
+void vfnLCD::vfnLCD_All_Segments_Char (uint8_t val)
+{
+ uint8_t lbTotalBytes = _CHARNUM * _LCDTYPE;              
+ uint8_t lbCounter=0;
+ uint8_t *lbpLCDWF;
+    lbpLCDWF = (uint8_t *)&LCD->WF;
+        while (lbCounter < lbTotalBytes)
+          {
+              lbpLCDWF[WF_ORDERING_TABLE[lbCounter++]]=val;
+          }
+         
+}
+
+
+void vfnLCD::vfnLCD_All_Segments_OFF (void)
+{              
+ uint8_t lbTotalBytes = _CHARNUM * _LCDTYPE;              
+ uint8_t lbCounter=0;
+ uint8_t *lbpLCDWF;
+ 
+    lbpLCDWF = (uint8_t *)&LCD->WF;
+        while (lbCounter < lbTotalBytes)
+          {
+              lbpLCDWF[WF_ORDERING_TABLE[lbCounter++]]=0;
+          }
+}
+
+
+         
+/*
+
+ Write a Char at position bLCD_CharPosition;
+ After write is complete  bLCD_CharPosition point to next position 
+ 
+ Verify Char is a Valid character  between '0'  and 'z'
+ in this case char is between 'a' to 'z' are taken as upper case
+ 
+ If the char is a invalid char it is taken as ':'  code, in this case as SPACE
+
+Aug-16   LP  arrayOffset was added due that array size with matrix symbols is greater than uint8
+
+*/
+#ifdef DOT_MATRIX
+
+void vfnLCD::vfnLCD_Write_Char (uint8_t lbValue)
+{
+          uint8_t char_val, temp;   //for test only
+          uint8_t *lbpLCDWF;
+          uint8_t lbCounter;
+          
+          uint16_t arrayOffset;
+          uint8_t position;
+
+          
+          lbpLCDWF = (uint8_t *)&LCD_WF3TO0;
+          
+          
+/*only ascci character if value not writeable write as @*/
+
+          if (lbValue>='a' && lbValue<='z') lbValue -= 32; // UpperCase
+          if (lbValue<ASCCI_TABLE_START || lbValue >ASCCI_TABLE_END) lbValue = BLANK_CHARACTER;  // default value as space
+
+          lbValue -=ASCCI_TABLE_START;        // Remove the offset to search in the ascci table
+          
+          arrayOffset = (lbValue * _CHAR_SIZE); // Compensate matrix offset
+          
+          
+          
+// ensure bLCD position is in valid limit
+          
+          lbCounter =0;  //number of writings to complete one char
+          while (lbCounter<_CHAR_SIZE  && bLCD_CharPosition < _CHARNUM )
+          {
+              //    position = (bLCD_CharPosition) *_CHAR_SIZE + lbCounter; //-1 to compensate first incomplete character
+              //     position = (bLCD_CharPosition) *_LCDTYPE + lbCounter; //-1 to compensate first incomplete character
+                     position = bLCD_CharPosition; // for DOt matrix 
+            
+                    
+                    char_val = ASCII_TO_WF_CODIFICATION_TABLE[arrayOffset + lbCounter]; 
+                    if (bLCD_CharPosition==0) //write complete character
+                    {
+                     lbpLCDWF[WF_ORDERING_TABLE[position]] = char_val;  //all 4 bits correspond to 7 digit character
+                    }
+                    else  //bit0 of second character is a symbol (DP o COL on the LCD) and must not be written
+                    {
+                    
+                      temp = lbpLCDWF[WF_ORDERING_TABLE[position]] & 0x01;  //bit 0 correspond to a Symbol
+                      lbpLCDWF[WF_ORDERING_TABLE[position]] = char_val | temp;  //only bit 1,2,3 correspond to 7 digit character
+                    }  
+                    
+                    if (char_val==0) lbCounter = _CHAR_SIZE; //end of this character
+                    lbCounter++;
+                    bLCD_CharPosition++;
+          }
+
+}
+
+#else
+
+// For 7 Segment LCD
+void vfnLCD::vfnLCD_Write_Char (uint8_t lbValue) {
+  uint8_t char_val;
+  uint8_t temp;
+  uint8_t *lbpLCDWF;
+  uint8_t lbCounter;
+  uint16_t arrayOffset;
+  uint8_t position;
+  
+  lbpLCDWF = (uint8_t *)LCD->WF;
+  /* only ascii character if value not writeable write as @ */
+  if (lbValue>='a' && lbValue<='z') {
+    lbValue -= 32; // UpperCase
+  }
+  if (lbValue<ASCCI_TABLE_START || lbValue >ASCCI_TABLE_END) {
+    lbValue = BLANK_CHARACTER;  // default value as space
+  }
+  lbValue -=ASCCI_TABLE_START;        // Remove the offset to search in the ascci table
+  arrayOffset = (lbValue * _CHAR_SIZE); // Compensate matrix offset
+  // ensure bLCD position is in valid limit
+  lbCounter = 0;  //number of writings to complete one char
+  while (lbCounter<_CHAR_SIZE  && bLCD_CharPosition < _CHARNUM) {
+    position = (bLCD_CharPosition) *_LCDTYPE + lbCounter; 
+    temp=0;
+    if (lbCounter==1) {
+      temp = lbpLCDWF[WF_ORDERING_TABLE[position]] & 0x01;//bit 0 has the special symbol information
+    } 
+    char_val = ASCII_TO_WF_CODIFICATION_TABLE[arrayOffset + lbCounter];
+    lbpLCDWF[WF_ORDERING_TABLE[position]] = char_val | temp;
+    //  if (char_val==0) lbCounter = _CHAR_SIZE; //end of this character
+    lbCounter++;
+  }
+  bLCD_CharPosition++;
+}
+
+#endif
+
+void vfnLCD::vfnLCD_Scroll(uint8_t *lbpMessage, uint8_t lbSize)
+ {
+ }
+
+void vfnLCD::PutPoint(uint8_t x, uint8_t y)
+ {
+   uint8_t *lbpLCDWF;
+   lbpLCDWF = (uint8_t *)LCD->WF;
+   
+   if (x>= _CHARNUM  || y>7) return;
+   lbpLCDWF[WF_ORDERING_TABLE[x]] |= (1<<y); 
+       
+ }
+ 
+
+void vfnLCD::ClrPoint(uint8_t x, uint8_t y)
+ {
+   uint8_t *lbpLCDWF;
+              lbpLCDWF = (uint8_t *)LCD->WF;
+              if (x>= _CHARNUM  || y>7) return;
+              lbpLCDWF[WF_ORDERING_TABLE[x]] &= ~(1<<y); 
+ 
+ }
+ 
+ 
+
+void vfnLCD::SetX(uint8_t x, uint8_t value)
+ {
+   uint8_t *lbpLCDWF;
+   lbpLCDWF = (uint8_t *)LCD->WF;
+ 
+              if (x>= _CHARNUM) return;
+              lbpLCDWF[WF_ORDERING_TABLE[x]] = value;  
+      
+ }
+ 
+
+
+/*
+ Configure LCD used pins as MUX=0  for LCD normal operation (analog operation)
+ Configure LCD used pins as MUX=7  for LCD Fault detectionoperation (pull resistor  control enabled)
+ only 0 or 7 is allowed for LCD operation
+*/ 
+
+void vfnLCD::lcd_pinmux(uint8_t  mux_val)
+{
+   uint8_t i;
+  
+   for (i=0;i< _LCDUSEDPINS; i++)
+   {
+      *(uint32_t *)LCD_TO_PORT[WF_ORDERING_TABLE[i]] &= ~PORT_PCR_MUX_MASK; //Clear previos value
+      *(uint32_t *)LCD_TO_PORT[WF_ORDERING_TABLE[i]] |= PORT_PCR_MUX(mux_val); // Set new value
+   }
+}
+ 
+/*
+  vfnLCD_interrupt_init
+ for kinetis NVIC must be initialized in order to 
+
+*/
+void vfnLCD::vfnLCD_interrupt_init(void)
+{
+
+}
+
+/*
+
+
+*/
+void vfnLCD::vfnLCD_isrv(void) 
+ {
+//   LcdInterruptCallBack(); // User defined function
+ }
+
+
+/*
+   This table relates LCD_Px to PORT Control Pin
+   in used for pinmux function
+*/
+
+
+const uint32_t *LCD_TO_PORT[60] =
+ {
+    (uint32_t *) PORTB->PCR[0],  //LCD_P00
+    (uint32_t *) PORTB->PCR[1],  //LCD_P01
+    (uint32_t *) PORTB->PCR[2],  //LCD_P02
+    (uint32_t *) PORTB->PCR[3],  //LCD_P03
+    (uint32_t *) PORTC->PCR[20],  //LCD_P04
+    (uint32_t *) PORTC->PCR[21],  //LCD_P05
+    //(uint32 *) PORTC->PCR[22],  //LCD_P06
+    (uint32_t *) PORTB->PCR[0],  //LCD_P00  test
+    
+    (uint32_t *) PORTB->PCR[7],  //LCD_P07
+    (uint32_t *) PORTB->PCR[8],  //LCD_P08
+    (uint32_t *) PORTB->PCR[9],  //LCD_P09
+    (uint32_t *) PORTB->PCR[10],  //LCD_P10
+    (uint32_t *) PORTB->PCR[11],  //LCD_P11
+    (uint32_t *) PORTB->PCR[16],  //LCD_P12
+    (uint32_t *) PORTB->PCR[17],  //LCD_P13
+    (uint32_t *) PORTB->PCR[18],  //LCD_P14
+    (uint32_t *) PORTB->PCR[19],  //LCD_P15
+    (uint32_t *) PORTB->PCR[20],  //LCD_P16
+    (uint32_t *) PORTB->PCR[21],  //LCD_P17
+    (uint32_t *) PORTB->PCR[22],  //LCD_P18
+    (uint32_t *) PORTB->PCR[23],  //LCD_P19
+    (uint32_t *) PORTC->PCR[0],  //LCD_P20
+    (uint32_t *) PORTC->PCR[1],  //LCD_P21
+    (uint32_t *) PORTC->PCR[2],  //LCD_P22
+    (uint32_t *) PORTC->PCR[3],  //LCD_P23
+    (uint32_t *) PORTC->PCR[4],  //LCD_P24
+    (uint32_t *) PORTC->PCR[5],  //LCD_P25
+    (uint32_t *) PORTC->PCR[6],  //LCD_P26
+    (uint32_t *) PORTC->PCR[7],  //LCD_P27
+    (uint32_t *) PORTC->PCR[8],  //LCD_P28
+    (uint32_t *) PORTC->PCR[9],  //LCD_P29
+    (uint32_t *) PORTC->PCR[10],  //LCD_P30
+    (uint32_t *) PORTC->PCR[11],  //LCD_P31
+    (uint32_t *) PORTC->PCR[12],  //LCD_P32
+    (uint32_t *) PORTC->PCR[13],  //LCD_P33
+    (uint32_t *) PORTC->PCR[16],  //LCD_P36
+    (uint32_t *) PORTC->PCR[17],  //LCD_P37
+    (uint32_t *) PORTC->PCR[18],  //LCD_P38
+    (uint32_t *) PORTC->PCR[23],  //LCD_P39
+    (uint32_t *) PORTD->PCR[0],  //LCD_P40
+    (uint32_t *) PORTD->PCR[1],  //LCD_P41
+    (uint32_t *) PORTD->PCR[2],  //LCD_P42
+    (uint32_t *) PORTD->PCR[3],  //LCD_P43
+    (uint32_t *) PORTD->PCR[4],  //LCD_P44
+    (uint32_t *) PORTD->PCR[5],  //LCD_P45
+    (uint32_t *) PORTD->PCR[6],  //LCD_P46
+    (uint32_t *) PORTD->PCR[7],  //LCD_P47
+    (uint32_t *) PORTE->PCR[0],  //LCD_P48
+    (uint32_t *) PORTE->PCR[1],  //LCD_P49
+    (uint32_t *) PORTE->PCR[2],  //LCD_P50
+    (uint32_t *) PORTE->PCR[3],  //LCD_P51
+    (uint32_t *) PORTE->PCR[4],  //LCD_P52
+    (uint32_t *) PORTE->PCR[5],  //LCD_P53
+    (uint32_t *) PORTE->PCR[6],  //LCD_P54
+    (uint32_t *) PORTE->PCR[16],  //LCD_P55
+    (uint32_t *) PORTE->PCR[17],  //LCD_P56
+    (uint32_t *) PORTE->PCR[18],  //LCD_P57
+    (uint32_t *) PORTE->PCR[19],  //LCD_P58
+    (uint32_t *) PORTE->PCR[20],  //LCD_P59
+    (uint32_t *) PORTE->PCR[21],  //LCD_P60
+
+
+    };
+
+const uint32_t MASK_BIT[32] = 
+{
+       0x00000001 ,
+       0x00000002 ,
+       0x00000004 ,
+       0x00000008 ,
+       0x00000010 ,
+       0x00000020 ,
+       0x00000040 ,
+       0x00000080 ,
+       0x00000100 ,
+       0x00000200 ,
+       0x00000400 ,
+       0x00000800 ,
+       0x00001000 ,
+       0x00002000 ,
+       0x00004000 ,
+       0x00008000 ,
+       0x00010000 ,
+       0x00020000 ,
+       0x00040000 ,
+       0x00080000 ,
+       0x00100000 ,
+       0x00200000 ,
+       0x00400000 ,
+       0x00800000 ,
+       0x01000000 ,
+       0x02000000 ,
+       0x04000000 ,
+       0x08000000 ,
+       0x10000000 ,
+       0x20000000 ,
+       0x40000000 ,
+       0x80000000 ,
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/vfnLCD.h	Mon Jan 13 22:32:43 2014 +0000
@@ -0,0 +1,146 @@
+//#include "common.h"
+#include "mbed.h"
+#include "LCDConfig.h"   // indicates how LCD module is configured and what type of LCD is going to be used 7seg, 14-seg, 16 seg, DotMatrix etc
+
+#define LCD_ALTERNATE_MODE    4   // Write message to Alternate Backplanes
+#define LCD_NORMAL_MODE       0   // Write message to Original BackPlanes 
+
+
+/* variables */
+extern uint32_t __VECTOR_RAM[]; //Get vector table that was copied to RAM
+
+extern const uint32_t MASK_BIT[];  
+extern const uint32_t *LCD_TO_PORT[];
+
+
+#if _LCDINTENABLE == 1
+  extern void LcdInterruptCallBack(void);
+#endif
+  
+class vfnLCD {
+    
+public: 
+/*||||||||||||||||||||||       vfnLCD_Init            ||||||||||||||||||||||
+brief:  Initialize all the registers on the mcu module 
+param:  void                            return:  void    
+*/  
+vfnLCD(void);
+  
+void vfnLCD_Home (void);
+ /*||||||||||||||||||||||       vfnLCD_Write_Char   ||||||||||||||||||||||
+ brief:  Writes on char after the last character was write
+ param:  uint8 --- Ascii to write                            return:  void    
+*/
+void vfnLCD_Write_Char (uint8_t lbValue);
+
+/*
+   Send a message until a end of char or max number of characters
+   if the message size is greater than LCD character the message is cut ad the size of LCD Characters
+   If the message lenght is minor than Display character is filled with Blanks
+ */
+void vfnLCD_Write_Msg (uint8_t *lbpMessage);
+
+
+
+ /*||||||||||||||||||||||       vfnLCD_Write_Msg    ||||||||||||||||||||||
+brief:  Writes on message on the LCD   if the message is longer than the number of character  is send to the Scroll function
+param:  uint8 pointer --- the first character  on the array to write
+param: uint8 --- the numbers of characterts to write      
+return:  void    
+*/
+void vfnLCD_Write_MsgPlace (uint8_t *lbpMessage, uint8_t lbSize );
+
+/*||||||||||||||||||||||       vfnLCD_Scroll    ||||||||||||||||||||||
+brief:  Moves the message on the LCD 
+param:  uint8 pointer --- the first character  on the array to write
+param: uint8 --- the size of the character  
+return:  void    
+*/
+
+void vfnLCD_Scroll (uint8_t *lbpMessage,uint8_t lbSize);
+
+ /*||||||||||||||||||||||       vfnLCD_All_Segments_ON   ||||||||||||||||||||||
+brief: Turns on all the segments on the LCD
+param:  uint8 pointer --- the first character  on the array to write
+param: uint8 --- the size of the character  
+return:  void    
+*/
+
+void vfnLCD_All_Segments_ON (void);
+                                                                                                      
+/*Same as clear dispay */
+void vfnLCD_All_Segments_OFF (void);
+  
+void vfnLCD_Contrast (uint8_t lbContrast);
+void vfnLCD_isrv(void) ;
+
+
+/* functions for DOT matrix LCD panel only*/
+void vfnLCD_All_Segments_Char (uint8_t val);
+void PutPoint(uint8_t x, uint8_t y);
+void ClrPoint(uint8_t x, uint8_t y);
+void SetX(uint8_t x, uint8_t value);
+
+private:
+char  lcdBuffer[];
+
+
+uint8_t lcd_alternate_mode;
+
+
+void LCD_vector_interrupt_init(void);
+void lcd_pinmux(uint8_t  mux_val);  //only 0 or 7 is allowed
+
+void vfnBP_VScroll(int8_t scroll_count);
+
+ // LCD call samples
+ //  vfnLCD_Home();
+ //  vfnLCD_Write_Char ('0');
+ //  vfnLCD_All_Segments_ON();
+ //  vfnLCD_All_Segments_OFF();
+ //  vfnLCD_Write_Msg("@@@@@@@@@");  // TURN ON all characters
+ //  vfnLCD_All_Segments_OFF();
+
+
+
+/*{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{        Macros            }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}*/
+/*{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{   ----------------------------  }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}*/
+
+#define LCD_ENABLE()        (LCD_GCR |=  LCD_GCR_LCDEN_MASK)
+#define LCD_DISABLE()       (LCD_GCR &= ~LCD_GCR_LCDEN_MASK) 
+#define LCD_VTRIM(x)        (LCD_GCR &= ~LCD_GCR_RVTRIM_MASK; LCD_GCR |= LCD_GCR_RVTRIM(x));
+
+
+
+
+
+
+
+/*{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{        Functions        }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}*/
+/*{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{   ----------------------------  }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}*/
+
+
+
+/*||||||||||||||||||||||       vfnLCD_EnablePins   ||||||||||||||||||||
+brief: Enable all the pins of the mcu directly connected to the  LCD on use
+param:  void                            return:  void    
+*/  
+void vfnEnablePins (void);
+
+ /*||||||||||||||||||||||       vfnLCD_SetBackplanes ||||||||||||||
+brief:  Set as a backplane and give the number of COM that corresponds  
+param:  void                            return:  void    
+*/
+void vfnSetBackplanes (void);
+
+/*||||||||||||||||||||||       vfnLCD_Home            ||||||||||||||||||||||
+brief:  Reset the counter to the first position
+param:  void
+return:  void    
+*/  
+
+
+
+void vfnLCD_interrupt_init(void);
+};
+