fastest sampling rate

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
TimeString
Date:
Mon Feb 03 02:45:03 2014 +0000
Commit message:
fastest sampling rate for all sensors

Changed in this revision

MAG3110/MAG3110.cpp Show annotated file Show diff for this revision Revisions of this file
MAG3110/MAG3110.h Show annotated file Show diff for this revision Revisions of this file
MMA8451Q/MMA8451Q.cpp Show annotated file Show diff for this revision Revisions of this file
MMA8451Q/MMA8451Q.h Show annotated file Show diff for this revision Revisions of this file
SLCD/FRDM-s401.h Show annotated file Show diff for this revision Revisions of this file
SLCD/LCDconfig.h Show annotated file Show diff for this revision Revisions of this file
SLCD/SLCD.cpp Show annotated file Show diff for this revision Revisions of this file
SLCD/SLCD.h Show annotated file Show diff for this revision Revisions of this file
TSI/TSISensor.cpp Show annotated file Show diff for this revision Revisions of this file
TSI/TSISensor.h Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
mbed_fastest_rate.cpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MAG3110/MAG3110.cpp	Mon Feb 03 02:45:03 2014 +0000
@@ -0,0 +1,91 @@
+
+#include "MAG3110.h"
+#include "mbed.h"
+
+/******************************************************************************
+ * Constructors
+ ******************************************************************************/
+MAG3110::MAG3110(PinName sda, PinName scl, int addr): _i2c(sda, scl), 
+    _i2c_address(addr), _pc(NULL), _debug(false)
+{
+    begin();
+}
+
+MAG3110::MAG3110(PinName sda, PinName scl, Serial *pc): _i2c(sda, scl), 
+   _i2c_address(0x1D), _pc(pc), _debug(true)
+{
+    begin();
+}
+
+void MAG3110::begin()
+{
+    char cmd[2];
+
+    cmd[0] = MAG_CTRL_REG2;
+    cmd[1] = 0x80;
+    _i2c.write(_i2c_address, cmd, 2);
+
+    cmd[0] = MAG_CTRL_REG1;
+    cmd[1] = MAG_3110_SAMPLE80+MAG_3110_OVERSAMPLE2+MAG_3110_ACTIVE;
+    _i2c.write(_i2c_address, cmd, 2);
+    
+    // No adjustment initially
+    _avgX = 0;
+    _avgY = 0;
+}
+
+// Read a single byte form 8 bit register, return as int
+int MAG3110::readReg(char regAddr)
+{
+    char cmd[1];
+
+    cmd[0] = regAddr;
+    _i2c.write(_i2c_address, cmd, 1);
+
+    cmd[0] = 0x00;
+    _i2c.read(_i2c_address, cmd, 1);
+    return (int)( cmd[0]);
+}
+
+
+// read a register per, pass first reg value, reading 2 bytes increments register
+// Reads MSB first then LSB
+int MAG3110::readVal(char regAddr)
+{
+    char cmd[2];
+
+    cmd[0] = regAddr;
+    _i2c.write(_i2c_address, cmd, 1);
+
+    cmd[0] = 0x00;
+    cmd[1] = 0x00;
+    _i2c.read(_i2c_address, cmd, 2);
+    return (int)( (cmd[1]|(cmd[0] << 8))); //concatenate the MSB and LSB
+}
+
+
+float MAG3110::getHeading()
+{
+    int xVal = readVal(MAG_OUT_X_MSB);
+    int yVal = readVal(MAG_OUT_Y_MSB);
+    return (atan2((double)(yVal - _avgY),(double)(xVal - _avgX)))*180/PI;
+}
+
+void MAG3110::getValues(int *xVal, int *yVal, int *zVal)
+{
+    *xVal = readVal(MAG_OUT_X_MSB);
+    *yVal = readVal(MAG_OUT_Y_MSB);
+    *zVal = readVal(MAG_OUT_Z_MSB);
+}
+
+
+void MAG3110::setCalibration(int minX, int maxX, int minY, int maxY )
+{
+    _avgX=(maxX+minX)/2;
+    _avgY=(maxY+minY)/2;
+}
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MAG3110/MAG3110.h	Mon Feb 03 02:45:03 2014 +0000
@@ -0,0 +1,144 @@
+/*
+ * MAG3110 Sensor Library for mbed
+ * TODO: Add proper header
+ */
+
+#ifndef MAG3110_H
+#define MAG3110_H
+
+#include "mbed.h"
+
+#define PI 3.14159265359
+
+#define MAG_ADDR 0x1D
+
+// define registers
+#define MAG_DR_STATUS 0x00
+#define MAG_OUT_X_MSB 0x01
+#define MAG_OUT_X_LSB 0x02
+#define MAG_OUT_Y_MSB 0x03
+#define MAG_OUT_Y_LSB 0x04
+#define MAG_OUT_Z_MSB 0x05
+#define MAG_OUT_Z_LSB 0x06
+#define MAG_WHO_AM_I  0x07
+#define MAG_SYSMOD    0x08
+#define MAG_OFF_X_MSB 0x09
+#define MAG_OFF_X_LSB 0x0A
+#define MAG_OFF_Y_MSB 0x0B
+#define MAG_OFF_Y_LSB 0x0C
+#define MAG_OFF_Z_MSB 0x0D
+#define MAG_OFF_Z_LSB 0x0E
+#define MAG_DIE_TEMP  0x0F
+#define MAG_CTRL_REG1 0x10
+#define MAG_CTRL_REG2 0x11
+
+// what should WHO_AM_I return?
+#define MAG_3110_WHO_AM_I_VALUE 0xC4
+
+
+// Fields in registers
+// CTRL_REG1: dr2,dr1,dr0  os1,os0  fr tm ac
+
+// Sampling rate from 80Hz down to 0.625Hz
+#define MAG_3110_SAMPLE80 0
+#define MAG_3110_SAMPLE40 0x20
+#define MAG_3110_SAMPLE20 0x40
+#define MAG_3110_SAMPLE10 0x60
+#define MAG_3110_SAMPLE5 0x80
+#define MAG_3110_SAMPLE2_5 0xA0
+#define MAG_3110_SAMPLE1_25 0xC0
+#define MAG_3110_SAMPLE0_625 0xE0
+
+// How many samples to average (lowers data rate)
+#define MAG_3110_OVERSAMPLE1 0
+#define MAG_3110_OVERSAMPLE2 0x08
+#define MAG_3110_OVERSAMPLE3 0x10
+#define MAG_3110_OVERSAMPLE4 0x18
+
+// read only 1 byte per axis
+#define MAG_3110_FASTREAD 0x04
+// do one measurement (even if in standby mode)
+#define MAG_3110_TRIGGER 0x02
+// put in active mode
+#define MAG_3110_ACTIVE 0x01
+
+// CTRL_REG2: AUTO_MRST_EN  _ RAW MAG_RST _ _ _ _ _
+// reset sensor after each reading
+#define MAG_3110_AUTO_MRST_EN 0x80
+// don't subtract user offsets
+#define MAG_3110_RAW 0x20
+// reset magnetic sensor after too-large field
+#define MAG_3110_MAG_RST 0x10
+
+// DR_STATUS Register ZYXOW ZOW YOW XOW ZYXDR ZDR YDR XDR
+#define MAG_3110_ZYXDR  0x08
+
+/**
+ * MAG3110 Class to read X/Y/Z data from the magentometer
+ *
+ */
+class MAG3110
+{
+public:
+    /**
+     * Main constructor
+     * @param sda SDA pin
+     * @param sdl SCL pin
+     * @param addr addr of the I2C peripheral
+     */
+    MAG3110(PinName sda, PinName scl, int addr);
+    /**
+     * Debug version of constructor
+     * @param sda SDA pin
+     * @param sdl SCL pin
+     * @param addr Address of the I2C peripheral
+     * @param pc Serial object to output debug messages
+     */
+    MAG3110(PinName sda, PinName scl, Serial *pc); //pass serial for debug
+    /**
+     * Setup the Magnetometer
+     *
+     */
+    void begin();
+    /**
+     * Read a register, return its value as int
+     * @param regAddr The address to read
+     * @return value in register
+     */
+    int readReg(char regAddr);
+    /**
+     * Read a value from a pair of registers, return as int
+     * @param regAddr The address to read
+     * @return Value from 2 consecutive registers
+     */
+    int readVal(char regAddr);
+    /**
+     * Calculate the heading
+     * @return heading in degrees
+     */
+    float getHeading();
+    /**
+     * Perform a read on the X, Y and Z values.
+     * @param xVal Pointer to X value
+     * @param yVal Pointer to Y value
+     * @param zVal Pointer to Z value
+     */
+    void getValues(int *xVal, int *yVal, int *zVal);
+    /**
+     * Set the calibration parameters if required.
+     * @param minX Minimum value for X range
+     * @param maxX Maximum value for X range
+     * @param minY Minimum value for Y range
+     * @param maxY maximum value for Y range
+     */
+    void setCalibration(int minX, int maxX, int minY, int maxY);
+
+private:
+    I2C _i2c;
+    int _i2c_address;
+    Serial *_pc;
+    bool _debug;
+    int _avgX, _avgY;
+
+};
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MMA8451Q/MMA8451Q.cpp	Mon Feb 03 02:45:03 2014 +0000
@@ -0,0 +1,155 @@
+/* Copyright (c) 2010-2011 mbed.org, MIT License
+*
+* 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.
+*/
+
+#include "MMA8451Q.h"
+
+#define INT_SOURCE        0x0C 
+#define REG_WHO_AM_I      0x0D
+#define HP_FILTER_CUTOFF  0x0F 
+#define PULSE_CFG         0x21 
+#define PULSE_SRC         0x22 
+#define PULSE_THSX        0x23 
+#define PULSE_THSY        0x24 
+#define PULSE_THSZ        0x25 
+#define PULSE_TMLT        0x26 
+#define PULSE_LTCY        0x27 
+#define PULSE_WIND        0x28 
+#define REG_CTRL_REG_1    0x2A 
+#define CTRL_REG2         0x2B
+#define CTRL_REG4         0x2D 
+#define CTRL_REG5         0x2E 
+#define REG_OUT_X_MSB     0x01
+#define REG_OUT_Y_MSB     0x03
+#define REG_OUT_Z_MSB     0x05
+
+#define UINT14_MAX        16383
+
+MMA8451Q::MMA8451Q(PinName sda, PinName scl, int addr) : m_i2c(sda, scl), m_addr(addr) {
+    // activate the peripheral
+    uint8_t data[2] = {REG_CTRL_REG_1, 0x01};
+    writeRegs(data, 2);
+}
+
+MMA8451Q::~MMA8451Q() { }
+
+uint8_t MMA8451Q::getWhoAmI() {
+    uint8_t who_am_i = 0;
+    readRegs(REG_WHO_AM_I, &who_am_i, 1);
+    return who_am_i;
+}
+
+float MMA8451Q::getAccX() {
+//divide by 4096 b/c MMA output is 4096 counts per g so this f outputs accelorometer value formatted to g (gravity)
+    return (float(getAccAxis(REG_OUT_X_MSB))/4096.0);
+}
+
+float MMA8451Q::getAccY() {
+    return (float(getAccAxis(REG_OUT_Y_MSB))/4096.0);
+}
+
+float MMA8451Q::getAccZ() {
+    return (float(getAccAxis(REG_OUT_Z_MSB))/4096.0);
+}
+
+void MMA8451Q::getAccAllAxis(float * res) {
+    res[0] = getAccX();
+    res[1] = getAccY();
+    res[2] = getAccZ();
+}
+
+int16_t MMA8451Q::getAccAxis(uint8_t addr) {
+    int16_t acc;
+    uint8_t res[2];
+    readRegs(addr, res, 2);
+
+    acc = (res[0] << 6) | (res[1] >> 2);
+    if (acc > UINT14_MAX/2)
+        acc -= UINT14_MAX;
+
+    return acc;
+}
+
+void MMA8451Q::setDoubleTap(void){
+//Implemented directly from Freescale's AN4072 
+//Added to MMA8451Q lib
+
+    uint8_t CTRL_REG1_Data;
+//    int adds;
+   uint8_t data[2] = {REG_CTRL_REG_1, 0x08};
+    
+    //400 Hz, Standby Mode
+    writeRegs(data,2);
+    
+    //Enable X, Y and Z Double Pulse with DPA = 0 no double pulse abort    
+    data[0]=PULSE_CFG;data[1]=0x2A;
+    writeRegs(data,2);
+    
+    //SetThreshold 3g on X and Y and 5g on Z
+    //Note: Every step is 0.063g
+    //3 g/0.063g = 48 counts
+    //5g/0.063g = 79 counts
+    data[0]=PULSE_THSX;data[1]=0x30;
+    writeRegs(data,2);//Set X Threshold to 3g 
+    data[0]=PULSE_THSY;data[1]=0x30;
+    writeRegs(data,2);//Set Y Threshold to 3g 
+    data[0]=PULSE_THSZ;data[1]=0x4F;
+    writeRegs(data,2);//Set Z Threshold to 5g
+
+    //Set Time Limit for Tap Detection to 60 ms LP Mode
+    //Note: 400 Hz ODR, Time step is 1.25 ms per step
+    //60 ms/1.25 ms = 48 counts 
+    data[0]=PULSE_TMLT;data[1]=0x30;
+    writeRegs(data,2);//60 ms
+    
+    //Set Latency Time to 200 ms
+    //Note: 400 Hz ODR LPMode, Time step is 2.5 ms per step 00 ms/2.5 ms = 80 counts
+    data[0]=PULSE_LTCY;data[1]=0x50;
+    writeRegs(data,2);//200 ms
+    
+    //Set Time Window for second tap to 300 ms
+    //Note: 400 Hz ODR LP Mode, Time step is 2.5 ms per step
+    //300 ms/2.5 ms = 120 counts
+    data[0]=PULSE_WIND;data[1]=0x78;
+    writeRegs(data,2);//300 ms
+    
+    //Route INT1 to System Interrupt
+    data[0]=CTRL_REG4;data[1]=0x08;
+    writeRegs(data,2);//Enable Pulse Interrupt in System CTRL_REG4
+    data[0]=CTRL_REG5;data[1]=0x08; 
+    writeRegs(data,2);//Route Pulse Interrupt to INT1 hardware Pin CTRL_REG5
+
+    //Set the device to Active Mode
+    readRegs(0x2A,&CTRL_REG1_Data,1);//Read out the contents of the register 
+    CTRL_REG1_Data |= 0x01; //Change the value in the register to Active Mode.
+    data[0]=REG_CTRL_REG_1; 
+    data[1]=CTRL_REG1_Data;
+    writeRegs(data,2);//Write in the updated value to put the device in Active Mode
+}
+
+
+void MMA8451Q::readRegs(int addr, uint8_t * data, int len) {
+    char t[1] = {addr};
+    m_i2c.write(m_addr, t, 1, true);
+    m_i2c.read(m_addr, (char *)data, len);
+}
+
+
+
+void MMA8451Q::writeRegs(uint8_t * data, int len) {
+    m_i2c.write(m_addr, (char *)data, len);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MMA8451Q/MMA8451Q.h	Mon Feb 03 02:45:03 2014 +0000
@@ -0,0 +1,159 @@
+/* Copyright (c) 2010-2011 mbed.org, MIT License
+*
+* 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 MMA8451Q_H
+#define MMA8451Q_H
+
+#include "mbed.h"
+
+/**
+* MMA8451Q accelerometer example
+*
+* @code
+* #include "mbed.h"
+* #include "MMA8451Q.h"
+* 
+* #define MMA8451_I2C_ADDRESS (0x1d<<1)
+* 
+* int main(void) {
+* 
+* MMA8451Q acc(P_E25, P_E24, MMA8451_I2C_ADDRESS);
+* PwmOut rled(LED_RED);
+* PwmOut gled(LED_GREEN);
+* PwmOut bled(LED_BLUE);
+* 
+*     while (true) {       
+*         rled = 1.0 - abs(acc.getAccX());
+*         gled = 1.0 - abs(acc.getAccY());
+*         bled = 1.0 - abs(acc.getAccZ());
+*         wait(0.1);
+*     }
+* }
+* @endcode
+*/
+class MMA8451Q
+{
+public:
+  /**
+  * MMA8451Q constructor
+  *
+  * @param sda SDA pin
+  * @param sdl SCL pin
+  * @param addr addr of the I2C peripheral
+  */
+  MMA8451Q(PinName sda, PinName scl, int addr);
+
+  /**
+  * MMA8451Q destructor
+  */
+  ~MMA8451Q();
+
+  /**
+   * Get the value of the WHO_AM_I register
+   *
+   * @returns WHO_AM_I value
+   */
+  uint8_t getWhoAmI();
+
+  /**
+   * Get X axis acceleration
+   *
+   * @returns X axis acceleration
+   */
+  float getAccX();
+
+  /**
+   * Get Y axis acceleration
+   *
+   * @returns Y axis acceleration
+   */
+  float getAccY();
+
+  /**
+   * Get Z axis acceleration
+   *
+   * @returns Z axis acceleration
+   */
+  float getAccZ();
+
+  /**
+   * Get XYZ axis acceleration
+   *
+   * @param res array where acceleration data will be stored
+   */
+  void getAccAllAxis(float * res);
+  
+  /** JK
+  * Setup Double Tap detection
+ 
+ 
+Example:
+
+#include "mbed.h"
+#include "MMA8451Q.h"
+
+#define MMA8451_I2C_ADDRESS (0x1d<<1)
+#define ON  0
+#define OFF !ON
+
+//Setup the interrupts for the MMA8451Q
+InterruptIn accInt1(PTA14);
+InterruptIn accInt2(PTA15);//not used in this prog but this is the other int from the accelorometer
+
+uint8_t togstat=0;//Led status
+DigitalOut bled(LED_BLUE);
+
+
+void tapTrue(void){//ISR
+    if(togstat == 0){
+        togstat = 1;
+        bled=ON;
+    } else {
+        togstat = 0;
+        bled=OFF;
+    }
+        
+}
+
+
+int main(void) {
+
+    MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS);//accelorometer instance
+  
+    acc.setDoubleTap();//Setup the MMA8451Q to look for a double Tap
+    accInt1.rise(&tapTrue);//call tapTrue when an interrupt is generated on PTA14
+    
+    while (true) {
+    //Interrupt driven so nothing in main loop
+    }
+}
+
+
+  */
+  void setDoubleTap(void);
+
+private:
+  I2C m_i2c;
+  int m_addr;
+  void readRegs(int addr, uint8_t * data, int len);
+  void writeRegs(uint8_t * data, int len);
+  int16_t getAccAxis(uint8_t addr);
+
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SLCD/FRDM-s401.h	Mon Feb 03 02:45:03 2014 +0000
@@ -0,0 +1,96 @@
+/*^^^^^^^^^^^^^^^^      LCD HARDWARE CONECTION ^^^^^^^^^^^^^^^^^^^^^^^^*/
+#define  _LCDFRONTPLANES   (8)            // # of frontPlanes
+#define  _LCDBACKPLANES    (4)            // # of backplanes
+
+/*
+   LCD logical organization definition
+   This section indicates 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
+#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
+
+/*
+  Following definitions indicate how characters are associated to waveform
+*/
+/* Hardware configuration  */
+#if HARDWARE_CONFIG == 0
+
+// 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
+
+// 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
+
+#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
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SLCD/LCDconfig.h	Mon Feb 03 02:45:03 2014 +0000
@@ -0,0 +1,183 @@
+#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 gets darker
+
+/*~|~|~|~|~|~|~|~|~|~|~|~|~|~  LCD  Blink Control Register ~|~|~|~|~|~|~|~|~|~|~|~*/
+/*~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|*/
+#define _LCDBLINKCONTROL        (1)     //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->WF8B[0]
+
+// General definitions used by the LCD library         
+#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
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SLCD/SLCD.cpp	Mon Feb 03 02:45:03 2014 +0000
@@ -0,0 +1,243 @@
+#include "SLCD.h"
+#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
+};
+
+const char ASCII_TO_WF_CODIFICATION_TABLE [ ] =
+{
+ 
+ /*
+                segA
+              ________  
+             |        | 
+        segF |        | segB
+             |        |
+              -segG--
+             |        |
+        segE |        | segC
+             |________|
+                segD
+ */   
+    
+( 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
+};
+
+SLCD::SLCD() {
+    init();
+    CharPosition = 0;    
+}
+
+void SLCD::init(){
+    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     
+     LCD->GCR = 0x0;
+     LCD->AR  = 0x0;     
+    // LCD configurartion     
+      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
+                 );    
+   uint8_t i;
+   uint32_t *p_pen;
+   uint8_t pen_offset;   // 0 or 1   
+   uint8_t pen_bit;      // 0 to 31
+   LCD->PEN[0] = 0x0;
+   LCD->PEN[1] = 0x0;
+   LCD->BPEN[0] = 0x0;
+   LCD->BPEN[1] = 0x0;   
+   p_pen = (uint32_t *)&LCD->PEN[0];
+    for (i=0;i<_LCDUSEDPINS;i++) 
+    {
+      pen_offset = WF_ORDERING_TABLE[i]/32;
+      pen_bit    = WF_ORDERING_TABLE[i]%32;
+      p_pen[pen_offset] |= 1 << pen_bit;
+      if (i>= _LCDFRONTPLANES)    // Pin is a backplane
+      {
+        p_pen[pen_offset+2] |= 1 << pen_bit;  // Enable  BPEN 
+        LCD->WF8B[(uint8_t)WF_ORDERING_TABLE[i]] = 1 << (i - _LCDFRONTPLANES);   // fill with 0x01, 0x02, etc 
+      } 
+    }    
+      LCD->GCR |= LCD_GCR_LCDEN_MASK;
+}
+
+int SLCD::_putc(int c) {
+    Write_Char(c);
+    return 0;
+}
+
+void SLCD::Write_Char (char lbValue) {
+  uint8_t char_val;
+  uint8_t temp;
+  uint8_t *lbpLCDWF;
+  uint8_t lbCounter;
+  uint16_t arrayOffset;
+  uint8_t position;
+  
+  if (CharPosition >= _CHARNUM)
+    CharPosition = 0;  
+  lbpLCDWF = (uint8_t *)&LCD->WF8B[0];
+  /* 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) {
+    position = (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++;
+  }  
+  CharPosition++;
+}
+
+void SLCD::Home (void)
+ {
+      CharPosition =  0;
+ }
+
+void SLCD::Contrast (uint8_t lbContrast)
+{ 
+       lbContrast &= 0x0F;              //Forced to the only values accepted 
+       LCD->GCR |= LCD_GCR_RVTRIM(lbContrast);
+}
+ 
+void SLCD::All_Segments (int mode)
+{
+ uint8_t lbTotalBytes = _CHARNUM * _LCDTYPE;              
+ uint8_t lbCounter=0;
+ uint8_t *lbpLCDWF;
+ 
+    lbpLCDWF = (uint8_t *)&LCD->WF8B[0];      
+        while (lbCounter < lbTotalBytes)
+          {
+              if (mode==1){lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[lbCounter++]]=_ALLON;}
+                else {lbpLCDWF[WF_ORDERING_TABLE[lbCounter++]]=0;}
+          }         
+}
+
+void SLCD::DP1 (int mode)
+{
+  uint8_t *lbpLCDWF; 
+    lbpLCDWF = (uint8_t *)&LCD->WF8B[0];       
+        if (mode==1){lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[1]]|=1;}
+            else {lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[1]]&=~1;}                
+}
+ 
+void SLCD::DP2 (int mode)
+{
+  uint8_t *lbpLCDWF; 
+    lbpLCDWF = (uint8_t *)&LCD->WF8B[0];       
+        if (mode==1){lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[3]]|=1;}
+            else {lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[3]]&=~1;}               
+} 
+
+void SLCD::DP3 (int mode)
+{
+  uint8_t *lbpLCDWF; 
+    lbpLCDWF = (uint8_t *)&LCD->WF8B[0];
+        if (mode==1){lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[5]]|=1;}
+            else {lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[5]]&=~1;}
+}
+ 
+void SLCD::Colon (int mode)
+{
+  uint8_t *lbpLCDWF; 
+    lbpLCDWF = (uint8_t *)&LCD->WF8B[0];     
+        if (mode==1){lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[7]]|=1;}
+            else {lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[7]]&=~1;}                 
+}
+ 
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SLCD/SLCD.h	Mon Feb 03 02:45:03 2014 +0000
@@ -0,0 +1,44 @@
+#include "mbed.h"
+
+
+/*  ------ sample usage------
+
+    #include "mbed.h"
+    #include "SLCD.h"
+    
+    SLCD slcd;
+    
+    main()
+    {
+        slcd.printf("1234");    // standard printf function, only charaters in ASCII_TO_WF_CODIFICATION_TABLE will display
+        slcd.putc("A");         // prints a single character 
+        slcd.Write_Char('A');   // prints a single character
+        slcd.All_Segments(y);   // y=1 for ALL segments on, 0 for ALL segments off  
+        slcd.DPx(y);            // x=DP1 to DP3, y=1 for on 0 for off
+        slcd.Colon(y);          // y=1 for on, 0 for off
+        slcd.CharPosition=x;    // x=0 to 3, 0 is start position
+        slcd.Home();            // sets next charater to posistion 0 (start)
+        slcd.Contrast (x);      // set contrast x=0 - 15, 0 lightest, 15 darkest    
+    }   
+*/
+
+class SLCD : public Stream {
+    public:
+    SLCD();
+    
+    void init();
+    void Write_Char(char lbValue);
+    void Home (void);
+    void Contrast (uint8_t lbContrast);
+    void All_Segments (int);     
+    void DP1 (int);
+    void DP2 (int);
+    void DP3 (int);
+    void Colon (int);     
+    uint8_t CharPosition;
+         
+    virtual int _putc(int c);
+    virtual int _getc() {
+        return 0;
+    }  
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TSI/TSISensor.cpp	Mon Feb 03 02:45:03 2014 +0000
@@ -0,0 +1,254 @@
+/* Freescale Semiconductor Inc.
+ * (c) Copyright 2004-2005 Freescale Semiconductor, Inc.
+ * (c) Copyright 2001-2004 Motorola, Inc. 
+ *
+ * mbed Microcontroller Library
+ * (c) Copyright 2009-2012 ARM Limited.
+ *
+ * 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.
+ */
+
+#include "mbed.h"
+#include "TSISensor.h"
+
+#define NO_TOUCH                 0
+#define SLIDER_LENGTH           40 //LENGTH in mm
+#define TOTAL_ELECTRODE          3
+
+#define TSI0a        0
+#define TSI1         1
+#define TSI2         2
+#define TSI3         3
+#define TSI4         4
+#define TSI5         5
+#define TSI6         6
+#define TSI7         7
+#define TSI8         8
+#define TSI9         9
+#define TSI10        10
+#define TSI11        11
+#define TSI12        12
+#define TSI13        13
+#define TSI14        14
+#define TSI15        15
+
+/*Chose the correct TSI channel for the electrode number*/
+#define ELECTRODE0   TSI9
+#define ELECTRODE1   TSI10
+#define ELECTRODE2   TSI0a
+#define ELECTRODE3   TSI1
+#define ELECTRODE4   TSI2
+#define ELECTRODE5   TSI3
+#define ELECTRODE6   TSI4
+#define ELECTRODE7   TSI5
+#define ELECTRODE8   TSI6
+#define ELECTRODE9   TSI7
+#define ELECTRODE10  TSI8
+#define ELECTRODE11  TSI11
+#define ELECTRODE12  TSI12
+#define ELECTRODE13  TSI13
+#define ELECTRODE14  TSI14
+#define ELECTRODE15  TSI15
+
+#define THRESHOLD0   100
+#define THRESHOLD1   100
+#define THRESHOLD2   100
+#define THRESHOLD3   100
+#define THRESHOLD4   100
+#define THRESHOLD5   100
+#define THRESHOLD6   100
+#define THRESHOLD7   100
+#define THRESHOLD8   100
+#define THRESHOLD9   100
+#define THRESHOLD10   100
+#define THRESHOLD11   100
+#define THRESHOLD12   100
+#define THRESHOLD13   100
+#define THRESHOLD14   100
+#define THRESHOLD15   100
+
+static uint8_t total_electrode = TOTAL_ELECTRODE;
+static uint8_t elec_array[16]={ELECTRODE0,ELECTRODE1,ELECTRODE2,ELECTRODE3,ELECTRODE4,ELECTRODE5,
+                               ELECTRODE6,ELECTRODE7,ELECTRODE8,ELECTRODE9,ELECTRODE10,ELECTRODE11,
+                               ELECTRODE12,ELECTRODE13,ELECTRODE14,ELECTRODE15};
+static uint16_t gu16TSICount[16];
+static uint16_t gu16Baseline[16];
+static uint16_t gu16Threshold[16]={THRESHOLD0,THRESHOLD1,THRESHOLD2,THRESHOLD3,THRESHOLD4,THRESHOLD5,
+                                   THRESHOLD6,THRESHOLD7,THRESHOLD8,THRESHOLD9,THRESHOLD10,THRESHOLD11,
+                                   THRESHOLD12,THRESHOLD13,THRESHOLD14,THRESHOLD15};
+static uint16_t gu16Delta[16];
+static uint8_t ongoing_elec;
+static uint8_t end_flag = 1;
+
+static uint8_t SliderPercentegePosition[2] = {NO_TOUCH,NO_TOUCH};
+static uint8_t SliderDistancePosition[2] = {NO_TOUCH,NO_TOUCH};
+static uint32_t AbsolutePercentegePosition = NO_TOUCH;
+static uint32_t AbsoluteDistancePosition = NO_TOUCH;
+
+static void tsi_irq();
+
+TSISensor::TSISensor() {
+    SIM->SCGC5 |= SIM_SCGC5_PORTB_MASK;
+    SIM->SCGC5 |= SIM_SCGC5_TSI_MASK;
+
+    TSI0->GENCS |= (TSI_GENCS_ESOR_MASK
+                   | TSI_GENCS_MODE(0)
+                   | TSI_GENCS_REFCHRG(4)
+                   | TSI_GENCS_DVOLT(0)
+                   | TSI_GENCS_EXTCHRG(7)
+                   | TSI_GENCS_PS(4)
+                   | TSI_GENCS_NSCN(11)
+                   | TSI_GENCS_TSIIEN_MASK
+                   | TSI_GENCS_STPE_MASK
+                   );
+
+    TSI0->GENCS |= TSI_GENCS_TSIEN_MASK;
+
+    NVIC_SetVector(TSI0_IRQn, (uint32_t)&tsi_irq);
+    NVIC_EnableIRQ(TSI0_IRQn);
+
+    selfCalibration();
+}
+
+void TSISensor::TSISensor_reset(void) {
+    SIM->SCGC5 |= SIM_SCGC5_PORTB_MASK;
+    SIM->SCGC5 |= SIM_SCGC5_TSI_MASK;
+
+    TSI0->GENCS |= (TSI_GENCS_ESOR_MASK
+                   | TSI_GENCS_MODE(0)
+                   | TSI_GENCS_REFCHRG(4)
+                   | TSI_GENCS_DVOLT(0)
+                   | TSI_GENCS_EXTCHRG(7)
+                   | TSI_GENCS_PS(4)
+                   | TSI_GENCS_NSCN(11)
+                   | TSI_GENCS_TSIIEN_MASK
+                   | TSI_GENCS_STPE_MASK
+                   );
+
+    TSI0->GENCS |= TSI_GENCS_TSIEN_MASK;
+
+    //NVIC_SetVector(TSI0_IRQn, (uint32_t)&tsi_irq);
+    //NVIC_EnableIRQ(TSI0_IRQn);
+
+    selfCalibration();
+}
+
+void TSISensor::selfCalibration(void)
+{
+    unsigned char cnt;
+    unsigned char trigger_backup;
+
+    TSI0->GENCS |= TSI_GENCS_EOSF_MASK;      // Clear End of Scan Flag
+    TSI0->GENCS &= ~TSI_GENCS_TSIEN_MASK;    // Disable TSI module
+
+    if(TSI0->GENCS & TSI_GENCS_STM_MASK)     // Back-up TSI Trigger mode from Application
+        trigger_backup = 1;
+    else
+        trigger_backup = 0;
+
+    TSI0->GENCS &= ~TSI_GENCS_STM_MASK;      // Use SW trigger
+    TSI0->GENCS &= ~TSI_GENCS_TSIIEN_MASK;    // Enable TSI interrupts
+
+    TSI0->GENCS |= TSI_GENCS_TSIEN_MASK;     // Enable TSI module
+
+    for(cnt=0; cnt < total_electrode; cnt++)  // Get Counts when Electrode not pressed
+    {
+        TSI0->DATA = ((elec_array[cnt] << TSI_DATA_TSICH_SHIFT) );
+        TSI0->DATA |= TSI_DATA_SWTS_MASK;
+        while(!(TSI0->GENCS & TSI_GENCS_EOSF_MASK));
+        TSI0->GENCS |= TSI_GENCS_EOSF_MASK;
+        gu16Baseline[cnt] = (TSI0->DATA & TSI_DATA_TSICNT_MASK);
+    }
+
+    TSI0->GENCS &= ~TSI_GENCS_TSIEN_MASK;    // Disable TSI module
+    TSI0->GENCS |= TSI_GENCS_TSIIEN_MASK;     // Enale TSI interrupt
+    if(trigger_backup)                      // Restore trigger mode
+        TSI0->GENCS |= TSI_GENCS_STM_MASK;
+    else
+        TSI0->GENCS &= ~TSI_GENCS_STM_MASK;
+
+    TSI0->GENCS |= TSI_GENCS_TSIEN_MASK;     // Enable TSI module
+
+    TSI0->DATA = ((elec_array[0]<<TSI_DATA_TSICH_SHIFT) );
+    TSI0->DATA |= TSI_DATA_SWTS_MASK;
+}
+
+void TSISensor::sliderRead(void ) {
+    if(end_flag) {
+        end_flag = 0;
+        if((gu16Delta[0] > gu16Threshold[0])||(gu16Delta[1] > gu16Threshold[1])) {
+            SliderPercentegePosition[0] = (gu16Delta[0]*100)/(gu16Delta[0]+gu16Delta[1]);
+            SliderPercentegePosition[1] = (gu16Delta[1]*100)/(gu16Delta[0]+gu16Delta[1]);
+            SliderDistancePosition[0] = (SliderPercentegePosition[0]* SLIDER_LENGTH)/100;
+            SliderDistancePosition[1] = (SliderPercentegePosition[1]* SLIDER_LENGTH)/100;
+            AbsolutePercentegePosition = ((100 - SliderPercentegePosition[0]) + SliderPercentegePosition[1])/2;
+            AbsoluteDistancePosition = ((SLIDER_LENGTH - SliderDistancePosition[0]) + SliderDistancePosition[1])/2;
+         } else {
+            SliderPercentegePosition[0] = NO_TOUCH;
+            SliderPercentegePosition[1] = NO_TOUCH;
+            SliderDistancePosition[0] = NO_TOUCH;
+            SliderDistancePosition[1] = NO_TOUCH;
+            AbsolutePercentegePosition = NO_TOUCH;
+            AbsoluteDistancePosition = NO_TOUCH;
+         }
+    }
+}
+
+float TSISensor::readPercentage() {
+    sliderRead();
+    return (float)AbsolutePercentegePosition/100.0;
+}
+
+uint8_t TSISensor::readDistance() {
+    sliderRead();
+    return AbsoluteDistancePosition;
+}
+
+uint16_t TSISensor::readValue(uint8_t index)
+{
+    return gu16TSICount[index];
+}
+
+static void changeElectrode(void)
+{
+    int16_t u16temp_delta;
+
+    gu16TSICount[ongoing_elec] = (TSI0->DATA & TSI_DATA_TSICNT_MASK);          // Save Counts for current electrode
+    u16temp_delta = gu16TSICount[ongoing_elec] - gu16Baseline[ongoing_elec];  // Obtains Counts Delta from callibration reference
+    if(u16temp_delta < 0)
+        gu16Delta[ongoing_elec] = 0;
+    else
+        gu16Delta[ongoing_elec] = u16temp_delta;
+
+    //Change Electrode to Scan
+    if(total_electrode > 1)  
+    {
+        if((total_electrode-1) > ongoing_elec)
+            ongoing_elec++;
+        else
+            ongoing_elec = 0;
+
+        TSI0->DATA = ((elec_array[ongoing_elec]<<TSI_DATA_TSICH_SHIFT) );
+        TSI0->DATA |= TSI_DATA_SWTS_MASK;
+    }
+}
+
+void tsi_irq(void)
+{
+    end_flag = 1;
+    TSI0->GENCS |= TSI_GENCS_EOSF_MASK; // Clear End of Scan Flag
+    changeElectrode();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TSI/TSISensor.h	Mon Feb 03 02:45:03 2014 +0000
@@ -0,0 +1,73 @@
+/* Freescale Semiconductor Inc.
+ * (c) Copyright 2004-2005 Freescale Semiconductor, Inc.
+ * (c) Copyright 2001-2004 Motorola, Inc. 
+ *
+ * mbed Microcontroller Library
+ * (c) Copyright 2009-2012 ARM Limited.
+ *
+ * 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 TSISENSOR_H
+#define TSISENSOR_H
+
+/**
+* TSISensor example
+*
+* @code
+* #include "mbed.h"
+* #include "TSISensor.h"
+* 
+* int main(void) {
+*     PwmOut led(LED_GREEN);
+*     TSISensor tsi;
+*     
+*     while (true) {
+*         led = 1.0 - tsi.readPercentage();
+*         wait(0.1);
+*     }
+* }
+* @endcode
+*/
+class TSISensor {
+public:
+    /**
+     *   Initialize the TSI Touch Sensor
+     */
+    TSISensor();
+
+    /**
+     * Read Touch Sensor percentage value
+     *
+     * @returns percentage value between [0 ... 1]
+     */
+    float readPercentage();
+
+    /**
+     * Read Touch Sensor distance
+     *
+     * @returns distance in mm. The value is between [0 ... 40]
+     */
+    uint8_t readDistance();
+    uint16_t readValue(uint8_t);
+    void TSISensor_reset(void);
+
+private:
+    void sliderRead(void);
+    void selfCalibration(void);
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Feb 03 02:45:03 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/824293ae5e43
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed_fastest_rate.cpp	Mon Feb 03 02:45:03 2014 +0000
@@ -0,0 +1,133 @@
+#include "mbed.h"
+#include "MMA8451Q.h"
+#include "MAG3110.h"
+#include "SLCD.h"
+#include "TSISensor.h"
+
+#define MMA8451_I2C_ADDRESS (0x1d << 1)
+#define MAG3110_I2C_ADDRESS (0x0e << 1)
+
+Serial pc(USBTX, USBRX);
+MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS);
+MAG3110 mag(PTE25, PTE24, MAG3110_I2C_ADDRESS);
+AnalogIn lightSensor(PTE22);
+DigitalOut myled(LED1);
+DigitalOut myled2(LED2);
+Timer t;
+SLCD slcd;
+TSISensor tsi;
+
+int main() {
+    while (true) {
+        slcd.printf("   1");
+        t.reset();
+        t.start();
+        for (int i = 0; i < 1000; i++) {
+            acc.getAccX();
+        }
+        t.stop();
+        pc.printf("AccX 1000 samples takes %f secs\n", t.read());
+        
+        slcd.printf("   2");
+        t.reset();
+        t.start();
+        for (int i = 0; i < 1000; i++) {
+            acc.getAccY();
+        }
+        t.stop();
+        pc.printf("AccY 1000 samples takes %f secs\n", t.read());
+        
+        slcd.printf("   3");
+        t.reset();
+        t.start();
+        for (int i = 0; i < 1000; i++) {
+            acc.getAccZ();
+        }
+        t.stop();
+        pc.printf("AccZ 1000 samples takes %f secs\n", t.read());
+        
+        slcd.printf("   4");
+        t.reset();
+        t.start();
+        for (int i = 0; i < 1000; i++) {
+            acc.getAccX();
+            acc.getAccY();
+            acc.getAccZ();
+        }
+        t.stop();
+        pc.printf("AccXYZ together 1000 samples takes %f secs\n", t.read());
+        
+        slcd.printf("   5");
+        t.reset();
+        t.start();
+        for (int i = 0; i < 1000; i++) {
+            mag.readVal(MAG_OUT_X_MSB);
+        }
+        t.stop();
+        pc.printf("magX 1000 samples takes %f secs\n", t.read());
+        
+        slcd.printf("   6");
+        t.reset();
+        t.start();
+        for (int i = 0; i < 1000; i++) {
+            mag.readVal(MAG_OUT_Y_MSB);
+        }
+        t.stop();
+        pc.printf("magY 1000 samples takes %f secs\n", t.read());
+        
+        slcd.printf("   7");
+        t.reset();
+        t.start();
+        for (int i = 0; i < 1000; i++) {
+            mag.readVal(MAG_OUT_Z_MSB);
+        }
+        t.stop();
+        pc.printf("magZ 1000 samples takes %f secs\n", t.read());
+        
+        slcd.printf("   8");
+        t.reset();
+        t.start();
+        for (int i = 0; i < 1000; i++) {
+            mag.readVal(MAG_OUT_X_MSB);
+            mag.readVal(MAG_OUT_Y_MSB);
+            mag.readVal(MAG_OUT_Z_MSB);
+        }
+        t.stop();
+        pc.printf("magXYZ together 1000 samples takes %f secs\n", t.read());
+        
+        slcd.printf("   9");
+        t.reset();
+        t.start();
+        for (int i = 0; i < 1000; i++) {
+            double tsl = (double)(lightSensor.read());
+        }
+        t.stop();
+        pc.printf("light sensor 1000 samples takes %f secs\n", t.read());
+        
+        slcd.printf("  10");
+        t.reset();
+        t.start();
+        for (int i = 0; i < 1000; i++) {
+           tsi.readPercentage();
+        }
+        t.stop();
+        pc.printf("touch sensor 1000 samples takes %f secs\n", t.read());
+        
+        slcd.printf("  99");
+        t.reset();
+        t.start();
+        for (int i = 0; i < 1000; i++) {
+            acc.getAccX();
+            acc.getAccY();
+            acc.getAccZ();
+            mag.readVal(MAG_OUT_X_MSB);
+            mag.readVal(MAG_OUT_Y_MSB);
+            mag.readVal(MAG_OUT_Z_MSB);
+            lightSensor.read();
+            tsi.readPercentage();
+        }
+        t.stop();
+        pc.printf("all sensors 1000 samples takes %f secs\n", t.read());
+        
+    }
+}
\ No newline at end of file