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;
}

Committer:
highroads
Date:
Mon Jan 13 22:32:43 2014 +0000
Revision:
0:c5fea5b6b339
Partially working version.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
highroads 0:c5fea5b6b339 1 #ifndef __LCDConfig_H_
highroads 0:c5fea5b6b339 2 #define __LCDConfig_H_
highroads 0:c5fea5b6b339 3
highroads 0:c5fea5b6b339 4 #include "FRDM-s401.h" // 4x7 segdisplay
highroads 0:c5fea5b6b339 5
highroads 0:c5fea5b6b339 6
highroads 0:c5fea5b6b339 7 #if 1 // VREF to VLL1
highroads 0:c5fea5b6b339 8 /* Following configuration is used for LCD default initialization */
highroads 0:c5fea5b6b339 9 #define _LCDRVEN (1) //
highroads 0:c5fea5b6b339 10 #define _LCDRVTRIM (8) // CPSEL = 1 0 -- 8000 pf 1 -- 6000 pf 2 -- 4000 pf 3 -- 2000 pf
highroads 0:c5fea5b6b339 11 #define _LCDCPSEL (1) // charge pump select 0 or 1
highroads 0:c5fea5b6b339 12 #define _LCDLOADADJUST (3) // CPSEL = 1 0 -- 8000 pf 1 -- 6000 pf 2 -- 4000 pf 3 -- 2000 pf
highroads 0:c5fea5b6b339 13 #define _LCDALTDIV (0) // CPSEL = 1 0 -- 8000 pf 1 -- 6000 pf 2 -- 4000 pf 3 -- 2000 pf
highroads 0:c5fea5b6b339 14 #define _LCDALRCLKSOURCE (0) // 0 -- External clock 1 -- Alternate clock
highroads 0:c5fea5b6b339 15
highroads 0:c5fea5b6b339 16 #define _LCDCLKPSL (0) // Clock divider to generate the LCD Waveforms
highroads 0:c5fea5b6b339 17 #define _LCDSUPPLY (1)
highroads 0:c5fea5b6b339 18 #define _LCDHREF (0) // 0 or 1
highroads 0:c5fea5b6b339 19 #define _LCDCLKSOURCE (1) // 0 -- External clock 1 -- Alternate clock
highroads 0:c5fea5b6b339 20 #define _LCDLCK (1) //Any number between 0 and 7
highroads 0:c5fea5b6b339 21 #define _LCDBLINKRATE (3) //Any number between 0 and 7
highroads 0:c5fea5b6b339 22
highroads 0:c5fea5b6b339 23
highroads 0:c5fea5b6b339 24 #else //VLL3 to VDD internally
highroads 0:c5fea5b6b339 25 /* Following configuration is used for LCD default initialization */
highroads 0:c5fea5b6b339 26 #define _LCDCLKSOURCE (1) // 0 -- External clock 1 -- Alternate clock
highroads 0:c5fea5b6b339 27 #define _LCDALRCLKSOURCE (0) // 0 -- External clock 1 -- Alternate clock
highroads 0:c5fea5b6b339 28 #define _LCDCLKPSL (0) // Clock divider to generate the LCD Waveforms
highroads 0:c5fea5b6b339 29 #define _LCDSUPPLY (0)
highroads 0:c5fea5b6b339 30 #define _LCDLOADADJUST (3) // CPSEL = 1 0 -- 8000 pf 1 -- 6000 pf 2 -- 4000 pf 3 -- 2000 pf
highroads 0:c5fea5b6b339 31 #define _LCDALTDIV (0) // CPSEL = 1 0 -- 8000 pf 1 -- 6000 pf 2 -- 4000 pf 3 -- 2000 pf
highroads 0:c5fea5b6b339 32 #define _LCDRVTRIM (0) // CPSEL = 1 0 -- 8000 pf 1 -- 6000 pf 2 -- 4000 pf 3 -- 2000 pf
highroads 0:c5fea5b6b339 33 #define _LCDHREF (0) // 0 or 1
highroads 0:c5fea5b6b339 34 #define _LCDCPSEL (1) // 0 or 1
highroads 0:c5fea5b6b339 35 #define _LCDRVEN (0) //
highroads 0:c5fea5b6b339 36 #define _LCDBLINKRATE (3) //Any number between 0 and 7
highroads 0:c5fea5b6b339 37 #define _LCDLCK (0) //Any number between 0 and 7
highroads 0:c5fea5b6b339 38
highroads 0:c5fea5b6b339 39 #endif
highroads 0:c5fea5b6b339 40
highroads 0:c5fea5b6b339 41
highroads 0:c5fea5b6b339 42
highroads 0:c5fea5b6b339 43
highroads 0:c5fea5b6b339 44 /*~|~|~|~|~|~|~|~|~|~|~|~|~|~ LCD Control Register 0 ~|~|~|~|~|~|~|~|~|~|~|~|~*/
highroads 0:c5fea5b6b339 45 /*~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|*/
highroads 0:c5fea5b6b339 46 #define _LCDINTENABLE (1)
highroads 0:c5fea5b6b339 47
highroads 0:c5fea5b6b339 48 /*~|~|~|~|~|~|~|~|~|~|~|~|~|~ LCD Control Register 1 ~|~|~|~|~|~|~|~|~|~|~|~|~|*/
highroads 0:c5fea5b6b339 49 /*~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|*/
highroads 0:c5fea5b6b339 50 #define _LCDFRAMEINTERRUPT (0) //0 Disable Frame Frequency Interrupt
highroads 0:c5fea5b6b339 51 //1 Enable an LCD interrupt that coincides with the LCD frame frequency
highroads 0:c5fea5b6b339 52 #define _LCDFULLCPLDIRIVE (0) // 0 GPIO shared with the LCD. Inputs levels and internal pullup reference to VDD
highroads 0:c5fea5b6b339 53 // 1 If VSUPPLY=11and RVEN=0. Inputs levels and internal pullup reference to VLL3
highroads 0:c5fea5b6b339 54 #define _LCDWAITMODE (0) // 0 Allows the LCD driver and charge pump to continue running during wait mode
highroads 0:c5fea5b6b339 55 // 1 Disable the LCD when the MCU goes into wait mode
highroads 0:c5fea5b6b339 56 #define _LCDSTOPMODE (0) // 0 Allows the LCD driver and charge pump to continue running during stop2 or stop3
highroads 0:c5fea5b6b339 57
highroads 0:c5fea5b6b339 58 // 1 Disable the LCD when and charge pump when the MCU goes into stop2 or stop3
highroads 0:c5fea5b6b339 59
highroads 0:c5fea5b6b339 60 /*~|~|~|~|~|~|~|~|~|~|~|~|~|~ LCD Voltage Supply Register ~|~|~|~|~|~|~|~|~|~|~|~*/
highroads 0:c5fea5b6b339 61 /*~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|*/
highroads 0:c5fea5b6b339 62 #define _LCDHIGHREF (0) //0 Divide input VIREG=1.0v
highroads 0:c5fea5b6b339 63 //1 Do not divide the input VIREG=1.67v
highroads 0:c5fea5b6b339 64 #define _LCDBBYPASS (0) //Determines whether the internal LCD op amp buffer is bypassed
highroads 0:c5fea5b6b339 65 //0 Buffered mode
highroads 0:c5fea5b6b339 66 //1 Unbuffered mode
highroads 0:c5fea5b6b339 67
highroads 0:c5fea5b6b339 68 /*~|~|~|~|~|~|~|~|~|~|~|~|~|~ LCD Regulated Voltage Control |~|~|~|~|~|~|~|~|~|~*/
highroads 0:c5fea5b6b339 69 /*~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|*/
highroads 0:c5fea5b6b339 70 #define _LCDCONTRAST (1) //Contrast by software 0 -- Disable 1-- Enable
highroads 0:c5fea5b6b339 71 #define _LVLCONTRAST (0) //Any number between 0 and 15, if the number is bigger the glass get darker
highroads 0:c5fea5b6b339 72
highroads 0:c5fea5b6b339 73 /*~|~|~|~|~|~|~|~|~|~|~|~|~|~ LCD Blink Control Register ~|~|~|~|~|~|~|~|~|~|~|~*/
highroads 0:c5fea5b6b339 74 /*~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|~|*/
highroads 0:c5fea5b6b339 75 #define _LCDBLINKCONTROL (0) //0 Disable blink mode
highroads 0:c5fea5b6b339 76 //1 Enable blink mode
highroads 0:c5fea5b6b339 77 #define _LCDALTMODE (0) //0 Normal display
highroads 0:c5fea5b6b339 78 //1 Alternate display for 4 backplanes or less the LCD backplane sequencer changes to otuput an alternate display
highroads 0:c5fea5b6b339 79 #define _LCDBLANKDISP (0) //0 Do not blank display
highroads 0:c5fea5b6b339 80 //1 Blank display if you put it in 0 the text before blank is manteined
highroads 0:c5fea5b6b339 81 #define _LCDBLINKMODE (0) //0 Display blank during the blink period
highroads 0:c5fea5b6b339 82 //1 Display alternate displat during blink period (Ignored if duty is 5 or greater)
highroads 0:c5fea5b6b339 83
highroads 0:c5fea5b6b339 84
highroads 0:c5fea5b6b339 85 //Calculated values
highroads 0:c5fea5b6b339 86 #define _LCDUSEDPINS (_LCDFRONTPLANES + _LCDBACKPLANES)
highroads 0:c5fea5b6b339 87 #define _LCDDUTY (_LCDBACKPLANES-1) //Any number between 0 and 7
highroads 0:c5fea5b6b339 88 #define LCD_WF_BASE LCD_WF3TO0
highroads 0:c5fea5b6b339 89
highroads 0:c5fea5b6b339 90 // General definitions used by the LCD library
highroads 0:c5fea5b6b339 91 #define SymbolON(LCDn,bit) *((uint8 *)&LCD_WF_BASE + LCDn) |= (1<<(bit))
highroads 0:c5fea5b6b339 92 #define SymbolOFF(LCDn,bit) *((uint8 *)&LCD_WF_BASE + LCDn) &= ~(1<<(bit))
highroads 0:c5fea5b6b339 93 //#define LCD_WF(x) *((uint8 *)&LCD_WF_BASE + x)
highroads 0:c5fea5b6b339 94
highroads 0:c5fea5b6b339 95 /*LCD Fault Detections Consts*/
highroads 0:c5fea5b6b339 96 #define FP_TYPE 0x00 // pin is a Front Plane
highroads 0:c5fea5b6b339 97 #define BP_TYPE 0x80 // pin is Back Plane
highroads 0:c5fea5b6b339 98
highroads 0:c5fea5b6b339 99 // Fault Detect Preescaler Options
highroads 0:c5fea5b6b339 100 #define FDPRS_1 0
highroads 0:c5fea5b6b339 101 #define FDPRS_2 1
highroads 0:c5fea5b6b339 102 #define FDPRS_4 2
highroads 0:c5fea5b6b339 103 #define FDPRS_8 3
highroads 0:c5fea5b6b339 104 #define FDPRS_16 4
highroads 0:c5fea5b6b339 105 #define FDPRS_32 5
highroads 0:c5fea5b6b339 106 #define FDPRS_64 6
highroads 0:c5fea5b6b339 107 #define FDPRS_128 7
highroads 0:c5fea5b6b339 108
highroads 0:c5fea5b6b339 109 // Fault Detect Sample Window Width Values
highroads 0:c5fea5b6b339 110 #define FDSWW_4 0
highroads 0:c5fea5b6b339 111 #define FDSWW_8 1
highroads 0:c5fea5b6b339 112 #define FDSWW_16 2
highroads 0:c5fea5b6b339 113 #define FDSWW_32 3
highroads 0:c5fea5b6b339 114 #define FDSWW_64 4
highroads 0:c5fea5b6b339 115 #define FDSWW_128 5
highroads 0:c5fea5b6b339 116 #define FDSWW_256 6
highroads 0:c5fea5b6b339 117 #define FDSWW_512 7
highroads 0:c5fea5b6b339 118
highroads 0:c5fea5b6b339 119 /*
highroads 0:c5fea5b6b339 120 Mask Bit definitions used f
highroads 0:c5fea5b6b339 121 */
highroads 0:c5fea5b6b339 122 #define mBIT0 1
highroads 0:c5fea5b6b339 123 #define mBIT1 2
highroads 0:c5fea5b6b339 124 #define mBIT2 4
highroads 0:c5fea5b6b339 125 #define mBIT3 8
highroads 0:c5fea5b6b339 126 #define mBIT4 16
highroads 0:c5fea5b6b339 127 #define mBIT5 32
highroads 0:c5fea5b6b339 128 #define mBIT6 64
highroads 0:c5fea5b6b339 129 #define mBIT7 128
highroads 0:c5fea5b6b339 130 #define mBIT8 256
highroads 0:c5fea5b6b339 131 #define mBIT9 512
highroads 0:c5fea5b6b339 132 #define mBIT10 1024
highroads 0:c5fea5b6b339 133 #define mBIT11 2048
highroads 0:c5fea5b6b339 134 #define mBIT12 4096
highroads 0:c5fea5b6b339 135 #define mBIT13 8192
highroads 0:c5fea5b6b339 136 #define mBIT14 16384
highroads 0:c5fea5b6b339 137 #define mBIT15 32768
highroads 0:c5fea5b6b339 138 #define mBIT16 65536
highroads 0:c5fea5b6b339 139 #define mBIT17 131072
highroads 0:c5fea5b6b339 140 #define mBIT18 262144
highroads 0:c5fea5b6b339 141 #define mBIT19 524288
highroads 0:c5fea5b6b339 142 #define mBIT20 1048576
highroads 0:c5fea5b6b339 143 #define mBIT21 2097152
highroads 0:c5fea5b6b339 144 #define mBIT22 4194304
highroads 0:c5fea5b6b339 145 #define mBIT23 8388608
highroads 0:c5fea5b6b339 146 #define mBIT24 16777216
highroads 0:c5fea5b6b339 147 #define mBIT25 33554432
highroads 0:c5fea5b6b339 148 #define mBIT26 67108864
highroads 0:c5fea5b6b339 149 #define mBIT27 134217728
highroads 0:c5fea5b6b339 150 #define mBIT28 268435456
highroads 0:c5fea5b6b339 151 #define mBIT29 536870912
highroads 0:c5fea5b6b339 152 #define mBIT30 1073741824
highroads 0:c5fea5b6b339 153 #define mBIT31 2147483648
highroads 0:c5fea5b6b339 154
highroads 0:c5fea5b6b339 155 #define mBIT32 1
highroads 0:c5fea5b6b339 156 #define mBIT33 2
highroads 0:c5fea5b6b339 157 #define mBIT34 4
highroads 0:c5fea5b6b339 158 #define mBIT35 8
highroads 0:c5fea5b6b339 159 #define mBIT36 16
highroads 0:c5fea5b6b339 160 #define mBIT37 32
highroads 0:c5fea5b6b339 161 #define mBIT38 64
highroads 0:c5fea5b6b339 162 #define mBIT39 128
highroads 0:c5fea5b6b339 163 #define mBIT40 256
highroads 0:c5fea5b6b339 164 #define mBIT41 512
highroads 0:c5fea5b6b339 165 #define mBIT42 1024
highroads 0:c5fea5b6b339 166 #define mBIT43 2048
highroads 0:c5fea5b6b339 167 #define mBIT44 4096
highroads 0:c5fea5b6b339 168 #define mBIT45 8192
highroads 0:c5fea5b6b339 169 #define mBIT46 16384
highroads 0:c5fea5b6b339 170 #define mBIT47 32768
highroads 0:c5fea5b6b339 171 #define mBIT48 65536
highroads 0:c5fea5b6b339 172 #define mBIT49 131072
highroads 0:c5fea5b6b339 173 #define mBIT50 262144
highroads 0:c5fea5b6b339 174 #define mBIT51 524288
highroads 0:c5fea5b6b339 175 #define mBIT52 1048576
highroads 0:c5fea5b6b339 176 #define mBIT53 2097152
highroads 0:c5fea5b6b339 177 #define mBIT54 4194304
highroads 0:c5fea5b6b339 178 #define mBIT55 8388608
highroads 0:c5fea5b6b339 179 #define mBIT56 16777216
highroads 0:c5fea5b6b339 180 #define mBIT57 33554432
highroads 0:c5fea5b6b339 181 #define mBIT58 67108864
highroads 0:c5fea5b6b339 182 #define mBIT59 134217728
highroads 0:c5fea5b6b339 183 #define mBIT60 268435456
highroads 0:c5fea5b6b339 184 #define mBIT61 536870912
highroads 0:c5fea5b6b339 185 #define mBIT62 1073741824
highroads 0:c5fea5b6b339 186 #define mBIT63 2147483648
highroads 0:c5fea5b6b339 187
highroads 0:c5fea5b6b339 188 #endif /* __LCDConfig_H_ */