![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Graphical demo for the LPC4088 Experiment Base Board with one of the Display Expansion Kits. This demo shows a rotating 3D cube with and without textures.
EaLcdBoardGPIO.cpp@0:c828045bbe69, 2014-10-03 (annotated)
- Committer:
- embeddedartists
- Date:
- Fri Oct 03 12:48:37 2014 +0000
- Revision:
- 0:c828045bbe69
First version.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
embeddedartists | 0:c828045bbe69 | 1 | /* |
embeddedartists | 0:c828045bbe69 | 2 | * Copyright 2013 Embedded Artists AB |
embeddedartists | 0:c828045bbe69 | 3 | * |
embeddedartists | 0:c828045bbe69 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
embeddedartists | 0:c828045bbe69 | 5 | * you may not use this file except in compliance with the License. |
embeddedartists | 0:c828045bbe69 | 6 | * You may obtain a copy of the License at |
embeddedartists | 0:c828045bbe69 | 7 | * |
embeddedartists | 0:c828045bbe69 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
embeddedartists | 0:c828045bbe69 | 9 | * |
embeddedartists | 0:c828045bbe69 | 10 | * Unless required by applicable law or agreed to in writing, software |
embeddedartists | 0:c828045bbe69 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
embeddedartists | 0:c828045bbe69 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
embeddedartists | 0:c828045bbe69 | 13 | * See the License for the specific language governing permissions and |
embeddedartists | 0:c828045bbe69 | 14 | * limitations under the License. |
embeddedartists | 0:c828045bbe69 | 15 | */ |
embeddedartists | 0:c828045bbe69 | 16 | |
embeddedartists | 0:c828045bbe69 | 17 | /****************************************************************************** |
embeddedartists | 0:c828045bbe69 | 18 | * Includes |
embeddedartists | 0:c828045bbe69 | 19 | *****************************************************************************/ |
embeddedartists | 0:c828045bbe69 | 20 | |
embeddedartists | 0:c828045bbe69 | 21 | #include "mbed.h" |
embeddedartists | 0:c828045bbe69 | 22 | #include "EaLcdBoardGPIO.h" |
embeddedartists | 0:c828045bbe69 | 23 | |
embeddedartists | 0:c828045bbe69 | 24 | /****************************************************************************** |
embeddedartists | 0:c828045bbe69 | 25 | * Defines and typedefs |
embeddedartists | 0:c828045bbe69 | 26 | *****************************************************************************/ |
embeddedartists | 0:c828045bbe69 | 27 | |
embeddedartists | 0:c828045bbe69 | 28 | |
embeddedartists | 0:c828045bbe69 | 29 | EaLcdBoardGPIO::EaLcdBoardGPIO(PinName sda, PinName scl) |
embeddedartists | 0:c828045bbe69 | 30 | : EaLcdBoard(sda, scl), /*pinWP(P4_15),*/ pin3v3(P2_0), pin5v(P2_21), pinDE(P2_11), pinContrast(P2_1) |
embeddedartists | 0:c828045bbe69 | 31 | { |
embeddedartists | 0:c828045bbe69 | 32 | pinContrast.period_ms(10); |
embeddedartists | 0:c828045bbe69 | 33 | setWriteProtect(true); |
embeddedartists | 0:c828045bbe69 | 34 | set3V3Signal(false); |
embeddedartists | 0:c828045bbe69 | 35 | set5VSignal(false); |
embeddedartists | 0:c828045bbe69 | 36 | setDisplayEnableSignal(false); |
embeddedartists | 0:c828045bbe69 | 37 | setBacklightContrast(0); |
embeddedartists | 0:c828045bbe69 | 38 | } |
embeddedartists | 0:c828045bbe69 | 39 | |
embeddedartists | 0:c828045bbe69 | 40 | |
embeddedartists | 0:c828045bbe69 | 41 | void EaLcdBoardGPIO::setWriteProtect(bool enable) |
embeddedartists | 0:c828045bbe69 | 42 | { |
embeddedartists | 0:c828045bbe69 | 43 | // Not Applicable |
embeddedartists | 0:c828045bbe69 | 44 | } |
embeddedartists | 0:c828045bbe69 | 45 | |
embeddedartists | 0:c828045bbe69 | 46 | void EaLcdBoardGPIO::set3V3Signal(bool enabled) { //P2.0 L=3.3V on |
embeddedartists | 0:c828045bbe69 | 47 | if (enabled) { |
embeddedartists | 0:c828045bbe69 | 48 | pin3v3 = 0; |
embeddedartists | 0:c828045bbe69 | 49 | } else { |
embeddedartists | 0:c828045bbe69 | 50 | pin3v3 = 1; |
embeddedartists | 0:c828045bbe69 | 51 | } |
embeddedartists | 0:c828045bbe69 | 52 | } |
embeddedartists | 0:c828045bbe69 | 53 | |
embeddedartists | 0:c828045bbe69 | 54 | void EaLcdBoardGPIO::set5VSignal(bool enabled) { //P2.21 H=5V on |
embeddedartists | 0:c828045bbe69 | 55 | if (enabled) { |
embeddedartists | 0:c828045bbe69 | 56 | pin5v = 1; |
embeddedartists | 0:c828045bbe69 | 57 | } else { |
embeddedartists | 0:c828045bbe69 | 58 | pin5v = 0; |
embeddedartists | 0:c828045bbe69 | 59 | } |
embeddedartists | 0:c828045bbe69 | 60 | } |
embeddedartists | 0:c828045bbe69 | 61 | |
embeddedartists | 0:c828045bbe69 | 62 | void EaLcdBoardGPIO::setDisplayEnableSignal(bool enabled) { //P2.11 H=enabled |
embeddedartists | 0:c828045bbe69 | 63 | LPC_IOCON->P2_11 &= ~7; /* GPIO2[11] @ P2.11 */ |
embeddedartists | 0:c828045bbe69 | 64 | if (enabled) { |
embeddedartists | 0:c828045bbe69 | 65 | pinDE = 1; |
embeddedartists | 0:c828045bbe69 | 66 | } else { |
embeddedartists | 0:c828045bbe69 | 67 | pinDE = 0; |
embeddedartists | 0:c828045bbe69 | 68 | } |
embeddedartists | 0:c828045bbe69 | 69 | } |
embeddedartists | 0:c828045bbe69 | 70 | |
embeddedartists | 0:c828045bbe69 | 71 | void EaLcdBoardGPIO::setBacklightContrast(uint32_t value) { //P2.1, set to 4.30 for now |
embeddedartists | 0:c828045bbe69 | 72 | #if 0 |
embeddedartists | 0:c828045bbe69 | 73 | LPC_IOCON->P2_1 &= ~7; /* GPIO2[1] @ P2.1 */ |
embeddedartists | 0:c828045bbe69 | 74 | if (value > 50) { |
embeddedartists | 0:c828045bbe69 | 75 | pinContrast = 1; |
embeddedartists | 0:c828045bbe69 | 76 | } else { |
embeddedartists | 0:c828045bbe69 | 77 | pinContrast = 0; |
embeddedartists | 0:c828045bbe69 | 78 | } |
embeddedartists | 0:c828045bbe69 | 79 | #else |
embeddedartists | 0:c828045bbe69 | 80 | uint32_t tmp = LPC_IOCON->P2_1; |
embeddedartists | 0:c828045bbe69 | 81 | tmp &= ~7; |
embeddedartists | 0:c828045bbe69 | 82 | tmp |= 1; |
embeddedartists | 0:c828045bbe69 | 83 | LPC_IOCON->P2_1 = tmp; /* PWM2[1] @ P2.1 */ |
embeddedartists | 0:c828045bbe69 | 84 | float f = value; |
embeddedartists | 0:c828045bbe69 | 85 | pinContrast = f/100.0f; |
embeddedartists | 0:c828045bbe69 | 86 | #endif |
embeddedartists | 0:c828045bbe69 | 87 | |
embeddedartists | 0:c828045bbe69 | 88 | // if (value > 100) return; |
embeddedartists | 0:c828045bbe69 | 89 | |
embeddedartists | 0:c828045bbe69 | 90 | // pca9532_setBlink0Duty(100-value); |
embeddedartists | 0:c828045bbe69 | 91 | // pca9532_setBlink0Period(0); |
embeddedartists | 0:c828045bbe69 | 92 | // pca9532_setBlink0Leds(LCDB_CTRL_BL_C); |
embeddedartists | 0:c828045bbe69 | 93 | } |
embeddedartists | 0:c828045bbe69 | 94 | |
embeddedartists | 0:c828045bbe69 | 95 | |
embeddedartists | 0:c828045bbe69 | 96 |