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 __FRDM_S401_H_
highroads 0:c5fea5b6b339 2 #define __FRDM_S401_H_
highroads 0:c5fea5b6b339 3 /*^^^^^^^^^^^^^^^^ LCD HARDWARE CONECTION ^^^^^^^^^^^^^^^^^^^^^^^^*/
highroads 0:c5fea5b6b339 4 #define _LCDFRONTPLANES (8) // # of frontPlanes
highroads 0:c5fea5b6b339 5 #define _LCDBACKPLANES (4) // # of backplanes
highroads 0:c5fea5b6b339 6
highroads 0:c5fea5b6b339 7 /*
highroads 0:c5fea5b6b339 8 LCD logical organization definition
highroads 0:c5fea5b6b339 9 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
highroads 0:c5fea5b6b339 10 First character is forced only one can be written
highroads 0:c5fea5b6b339 11
highroads 0:c5fea5b6b339 12 */
highroads 0:c5fea5b6b339 13 // HARDWARE_CONFIG Changing LCD pins Allows to verify all LCD pins easily
highroads 0:c5fea5b6b339 14 // if HARDWARE_CONFIG == 0 FRDM-KL46 RevB
highroads 0:c5fea5b6b339 15 // if HARDWARE_CONFIG == 1 FRDM-KL46 RevA
highroads 0:c5fea5b6b339 16 #include "mbed.h"
highroads 0:c5fea5b6b339 17
highroads 0:c5fea5b6b339 18 #ifdef FRDM_REVA
highroads 0:c5fea5b6b339 19 #define HARDWARE_CONFIG 1
highroads 0:c5fea5b6b339 20 #else
highroads 0:c5fea5b6b339 21 #define HARDWARE_CONFIG 0
highroads 0:c5fea5b6b339 22 #endif
highroads 0:c5fea5b6b339 23
highroads 0:c5fea5b6b339 24 #define _CHARNUM (4) //number of chars that can be written
highroads 0:c5fea5b6b339 25 #define _CHAR_SIZE (2) // Used only when Dot Matrix is used
highroads 0:c5fea5b6b339 26 #define _LCDTYPE (2) //indicate how many LCD_WF are required to write a single Character / or Column in case of DOT matrix LCD
highroads 0:c5fea5b6b339 27
highroads 0:c5fea5b6b339 28 /*
highroads 0:c5fea5b6b339 29 Following definitions indicate how characters are associated to waveform
highroads 0:c5fea5b6b339 30 */
highroads 0:c5fea5b6b339 31 /* Hardware configuration */
highroads 0:c5fea5b6b339 32 #if HARDWARE_CONFIG == 0
highroads 0:c5fea5b6b339 33 #undef DOT_MATRIX
highroads 0:c5fea5b6b339 34
highroads 0:c5fea5b6b339 35 // LCD PIN1 to LCDWF0 Rev B
highroads 0:c5fea5b6b339 36 #define CHAR1a 37 // LCD Pin 5
highroads 0:c5fea5b6b339 37 #define CHAR1b 17 // LCD Pin 6
highroads 0:c5fea5b6b339 38 #define CHAR2a 7 // LCD Pin 7
highroads 0:c5fea5b6b339 39 #define CHAR2b 8 // LCD Pin 8
highroads 0:c5fea5b6b339 40 #define CHAR3a 53 // LCD Pin 9
highroads 0:c5fea5b6b339 41 #define CHAR3b 38 // LCD Pin 10
highroads 0:c5fea5b6b339 42 #define CHAR4a 10 // LCD Pin 11
highroads 0:c5fea5b6b339 43 #define CHAR4b 11 // LCD Pin 12
highroads 0:c5fea5b6b339 44 #define CHARCOM0 40 // LCD Pin 1
highroads 0:c5fea5b6b339 45 #define CHARCOM1 52 // LCD Pin 2
highroads 0:c5fea5b6b339 46 #define CHARCOM2 19 // LCD Pin 3
highroads 0:c5fea5b6b339 47 #define CHARCOM3 18 // LCD Pin 4
highroads 0:c5fea5b6b339 48
highroads 0:c5fea5b6b339 49 /*Special Symbols */
highroads 0:c5fea5b6b339 50 #define SPECIAL_SYMBOL_COUNT 4
highroads 0:c5fea5b6b339 51
highroads 0:c5fea5b6b339 52 #define _LCD_DP1_ON() SymbolON(17,0)
highroads 0:c5fea5b6b339 53 #define _LCD_DP2_ON() SymbolON(8,0)
highroads 0:c5fea5b6b339 54 #define _LCD_DP3_ON() SymbolON(38,0)
highroads 0:c5fea5b6b339 55 #define _LCD_COL_ON() SymbolON(11,0)
highroads 0:c5fea5b6b339 56
highroads 0:c5fea5b6b339 57 #define _LCD_DP1_OFF() SymbolOFF(17,0)
highroads 0:c5fea5b6b339 58 #define _LCD_DP2_OFF() SymbolOFF(8,0)
highroads 0:c5fea5b6b339 59 #define _LCD_DP3_OFF() SymbolOFF(38,0)
highroads 0:c5fea5b6b339 60 #define _LCD_COL_OFF() SymbolOFF(11,0)
highroads 0:c5fea5b6b339 61
highroads 0:c5fea5b6b339 62 // LCD PIN1 to LCDWF2 for FRDM-KL46Z
highroads 0:c5fea5b6b339 63 #elif HARDWARE_CONFIG == 1
highroads 0:c5fea5b6b339 64 #define CHAR1a 37 // LCD Pin 5
highroads 0:c5fea5b6b339 65 #define CHAR1b 17 // LCD Pin 6
highroads 0:c5fea5b6b339 66 #define CHAR2a 7 // LCD Pin 7
highroads 0:c5fea5b6b339 67 #define CHAR2b 8 // LCD Pin 8
highroads 0:c5fea5b6b339 68 #define CHAR3a 12 // LCD Pin 9
highroads 0:c5fea5b6b339 69 #define CHAR3b 26 // LCD Pin 10
highroads 0:c5fea5b6b339 70 #define CHAR4a 10 // LCD Pin 11
highroads 0:c5fea5b6b339 71 #define CHAR4b 11 // LCD Pin 12
highroads 0:c5fea5b6b339 72 #define CHARCOM0 51 // LCD Pin 1
highroads 0:c5fea5b6b339 73 #define CHARCOM1 52 // LCD Pin 2
highroads 0:c5fea5b6b339 74 #define CHARCOM2 19 // LCD Pin 3
highroads 0:c5fea5b6b339 75 #define CHARCOM3 16 // LCD Pin 4
highroads 0:c5fea5b6b339 76
highroads 0:c5fea5b6b339 77 #define SPECIAL_SYMBOL_COUNT 4
highroads 0:c5fea5b6b339 78
highroads 0:c5fea5b6b339 79
highroads 0:c5fea5b6b339 80 #define _LCD_DP1_ON() SymbolON(17,0)
highroads 0:c5fea5b6b339 81 #define _LCD_DP2_ON() SymbolON(8,0)
highroads 0:c5fea5b6b339 82 #define _LCD_DP3_ON() SymbolON(26,0)
highroads 0:c5fea5b6b339 83 #define _LCD_COL_ON() SymbolON(11,0)
highroads 0:c5fea5b6b339 84
highroads 0:c5fea5b6b339 85 #define _LCD_DP1_OFF() SymbolOFF(17,0)
highroads 0:c5fea5b6b339 86 #define _LCD_DP2_OFF() SymbolOFF(8,0)
highroads 0:c5fea5b6b339 87 #define _LCD_DP3_OFF() SymbolOFF(26,0)
highroads 0:c5fea5b6b339 88 #define _LCD_COL_OFF() SymbolOFF(11,0)
highroads 0:c5fea5b6b339 89
highroads 0:c5fea5b6b339 90
highroads 0:c5fea5b6b339 91
highroads 0:c5fea5b6b339 92 #endif
highroads 0:c5fea5b6b339 93
highroads 0:c5fea5b6b339 94
highroads 0:c5fea5b6b339 95 /*Ascii Codification table information */
highroads 0:c5fea5b6b339 96 #define ASCCI_TABLE_START '0' // indicates which is the first Ascii character in the table
highroads 0:c5fea5b6b339 97 #define ASCCI_TABLE_END 'Z' // indicates which is the first Ascii character in the table
highroads 0:c5fea5b6b339 98 #define BLANK_CHARACTER '>' // Indicate which ASCII character is a blank character (depends on ASCII table)
highroads 0:c5fea5b6b339 99
highroads 0:c5fea5b6b339 100 #define _ALLON 0xFF // Used for ALL_on function
highroads 0:c5fea5b6b339 101
highroads 0:c5fea5b6b339 102 #define SEGDP 0x01
highroads 0:c5fea5b6b339 103 #define SEGC 0x02
highroads 0:c5fea5b6b339 104 #define SEGB 0x04
highroads 0:c5fea5b6b339 105 #define SEGA 0x08
highroads 0:c5fea5b6b339 106
highroads 0:c5fea5b6b339 107 #define SEGD 0x01
highroads 0:c5fea5b6b339 108 #define SEGE 0x02
highroads 0:c5fea5b6b339 109 #define SEGG 0x04
highroads 0:c5fea5b6b339 110 #define SEGF 0x08
highroads 0:c5fea5b6b339 111
highroads 0:c5fea5b6b339 112
highroads 0:c5fea5b6b339 113 /* Fault detect initial limits */
highroads 0:c5fea5b6b339 114
highroads 0:c5fea5b6b339 115 /* Fault detect initial parameters and limits */
highroads 0:c5fea5b6b339 116 #define FAULTD_FP_FDPRS FDPRS_32
highroads 0:c5fea5b6b339 117 #define FAULTD_FP_FDSWW FDSWW_128
highroads 0:c5fea5b6b339 118 #define FAULTD_BP_FDPRS FDPRS_64
highroads 0:c5fea5b6b339 119 #define FAULTD_BP_FDSWW FDSWW_128
highroads 0:c5fea5b6b339 120
highroads 0:c5fea5b6b339 121 #define FAULTD_FP_HI 127
highroads 0:c5fea5b6b339 122 #define FAULTD_FP_LO 110
highroads 0:c5fea5b6b339 123 #define FAULTD_BP_HI 127
highroads 0:c5fea5b6b339 124 #define FAULTD_BP_LO 110
highroads 0:c5fea5b6b339 125 #define FAULTD_TIME 6
highroads 0:c5fea5b6b339 126
highroads 0:c5fea5b6b339 127 extern const uint8_t WF_ORDERING_TABLE[]; // Logical Front plane N to LCD_WFx
highroads 0:c5fea5b6b339 128 extern const char ASCII_TO_WF_CODIFICATION_TABLE[]; // ASCII to 7x5 Dot Matrix
highroads 0:c5fea5b6b339 129
highroads 0:c5fea5b6b339 130 #endif /* __FRDM_S401_H_ */