Code to interface mbed to a Nokia 3310 LCD using the Nokia 3310 LCD shield from nuelectronics. Includes joystick interface and demo.

Dependencies:   mbed

Committer:
snatch59
Date:
Mon Dec 07 17:24:52 2009 +0000
Revision:
0:36fb749b83c7

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
snatch59 0:36fb749b83c7 1 /*
snatch59 0:36fb749b83c7 2 * N3310LCD. A program to interface mbed with the nuelectronics
snatch59 0:36fb749b83c7 3 * Nokia 3310 LCD shield from www.nuelectronics.com. Ported from
snatch59 0:36fb749b83c7 4 * the nuelectronics Arduino code.
snatch59 0:36fb749b83c7 5 *
snatch59 0:36fb749b83c7 6 * Copyright (C) <2009> Petras Saduikis <petras@petras.co.uk>
snatch59 0:36fb749b83c7 7 *
snatch59 0:36fb749b83c7 8 * This file is part of N3310LCD.
snatch59 0:36fb749b83c7 9 *
snatch59 0:36fb749b83c7 10 * N3310LCD is free software: you can redistribute it and/or modify
snatch59 0:36fb749b83c7 11 * it under the terms of the GNU General Public License as published by
snatch59 0:36fb749b83c7 12 * the Free Software Foundation, either version 3 of the License, or
snatch59 0:36fb749b83c7 13 * (at your option) any later version.
snatch59 0:36fb749b83c7 14 *
snatch59 0:36fb749b83c7 15 * N3310LCD is distributed in the hope that it will be useful,
snatch59 0:36fb749b83c7 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
snatch59 0:36fb749b83c7 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
snatch59 0:36fb749b83c7 18 * GNU General Public License for more details.
snatch59 0:36fb749b83c7 19 *
snatch59 0:36fb749b83c7 20 * You should have received a copy of the GNU General Public License
snatch59 0:36fb749b83c7 21 * along with N3310LCD. If not, see <http://www.gnu.org/licenses/>.
snatch59 0:36fb749b83c7 22 */
snatch59 0:36fb749b83c7 23
snatch59 0:36fb749b83c7 24 #ifndef SNATCH59_N3310SPICONFIG_H
snatch59 0:36fb749b83c7 25 #define SNATCH59_N3310SPICONFIG_H
snatch59 0:36fb749b83c7 26
snatch59 0:36fb749b83c7 27 #include <mbed.h>
snatch59 0:36fb749b83c7 28
snatch59 0:36fb749b83c7 29 class N3310SPIPort
snatch59 0:36fb749b83c7 30 {
snatch59 0:36fb749b83c7 31 public:
snatch59 0:36fb749b83c7 32 static const PinName MOSI; // Master Out Slave In
snatch59 0:36fb749b83c7 33 static const PinName MISO; // Master In Slave Out
snatch59 0:36fb749b83c7 34 static const PinName SCK; // SPI clock
snatch59 0:36fb749b83c7 35 static const PinName CE; // Chip Enable (aka Chip Select)
snatch59 0:36fb749b83c7 36 static const PinName LCD_RST; // LCD reset
snatch59 0:36fb749b83c7 37 static const PinName DAT_CMD; // indicates if the SPI write is command or date
snatch59 0:36fb749b83c7 38 static const PinName BL_ON; // Back Light On
snatch59 0:36fb749b83c7 39
snatch59 0:36fb749b83c7 40 static const PinName AD0; // analog in for joystick
snatch59 0:36fb749b83c7 41 };
snatch59 0:36fb749b83c7 42
snatch59 0:36fb749b83c7 43 // NOTE pins have been chosen not to conflict with any I2C usage.
snatch59 0:36fb749b83c7 44 // MOSI = p5, MISO = p6, SCK = p7 is also an option
snatch59 0:36fb749b83c7 45 const PinName N3310SPIPort::MOSI = p11;
snatch59 0:36fb749b83c7 46 const PinName N3310SPIPort::MISO = p12; // not used for 3310
snatch59 0:36fb749b83c7 47 const PinName N3310SPIPort::SCK = p13;
snatch59 0:36fb749b83c7 48
snatch59 0:36fb749b83c7 49 const PinName N3310SPIPort::CE = p21;
snatch59 0:36fb749b83c7 50 const PinName N3310SPIPort::LCD_RST = p22;
snatch59 0:36fb749b83c7 51 const PinName N3310SPIPort::DAT_CMD = p23;
snatch59 0:36fb749b83c7 52 const PinName N3310SPIPort::BL_ON = p24;
snatch59 0:36fb749b83c7 53
snatch59 0:36fb749b83c7 54 const PinName N3310SPIPort::AD0 = p20; // joystick analog
snatch59 0:36fb749b83c7 55
snatch59 0:36fb749b83c7 56 /************************************************
snatch59 0:36fb749b83c7 57 *
snatch59 0:36fb749b83c7 58 * Nokia 3310 LCD Shield Pins
snatch59 0:36fb749b83c7 59 * NOTE: the LCD shield must be powered from a 3.3V supply in order
snatch59 0:36fb749b83c7 60 * for the joystick to be read correctly by the mbed analog in
snatch59 0:36fb749b83c7 61 * (which operates on a range of 0 - 3.3V).
snatch59 0:36fb749b83c7 62 *
snatch59 0:36fb749b83c7 63 * Connector J3:
snatch59 0:36fb749b83c7 64 * p13: SCK
snatch59 0:36fb749b83c7 65 * p12: MISO (not used)
snatch59 0:36fb749b83c7 66 * p11: MOSI
snatch59 0:36fb749b83c7 67 * p10: CE
snatch59 0:36fb749b83c7 68 * p9: LCD_RST
snatch59 0:36fb749b83c7 69 * p8: DAT_CMD
snatch59 0:36fb749b83c7 70 *
snatch59 0:36fb749b83c7 71 * Connector J1:
snatch59 0:36fb749b83c7 72 * p7: BL_ON
snatch59 0:36fb749b83c7 73 *
snatch59 0:36fb749b83c7 74 * Connector J2:
snatch59 0:36fb749b83c7 75 * p1 : AD0
snatch59 0:36fb749b83c7 76 *
snatch59 0:36fb749b83c7 77 **************************************************/
snatch59 0:36fb749b83c7 78
snatch59 0:36fb749b83c7 79 #endif