Production Test Program (PTP) for the LPC4088 Experiment Base Board
Dependencies: EALib I2S LM75B SDFileSystem mbed
TestShiftreg.cpp@7:48375cb50f3a, 2014-09-25 (annotated)
- Committer:
- embeddedartists
- Date:
- Thu Sep 25 07:17:44 2014 +0000
- Revision:
- 7:48375cb50f3a
- Parent:
- 2:2f4b7535ceb3
Fixed audio test volume issues and issues with the touch controller.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
embeddedartists | 2:2f4b7535ceb3 | 1 | /* |
embeddedartists | 2:2f4b7535ceb3 | 2 | * Copyright 2013 Embedded Artists AB |
embeddedartists | 2:2f4b7535ceb3 | 3 | * |
embeddedartists | 2:2f4b7535ceb3 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
embeddedartists | 2:2f4b7535ceb3 | 5 | * you may not use this file except in compliance with the License. |
embeddedartists | 2:2f4b7535ceb3 | 6 | * You may obtain a copy of the License at |
embeddedartists | 2:2f4b7535ceb3 | 7 | * |
embeddedartists | 2:2f4b7535ceb3 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
embeddedartists | 2:2f4b7535ceb3 | 9 | * |
embeddedartists | 2:2f4b7535ceb3 | 10 | * Unless required by applicable law or agreed to in writing, software |
embeddedartists | 2:2f4b7535ceb3 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
embeddedartists | 2:2f4b7535ceb3 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
embeddedartists | 2:2f4b7535ceb3 | 13 | * See the License for the specific language governing permissions and |
embeddedartists | 2:2f4b7535ceb3 | 14 | * limitations under the License. |
embeddedartists | 2:2f4b7535ceb3 | 15 | */ |
embeddedartists | 2:2f4b7535ceb3 | 16 | |
embeddedartists | 2:2f4b7535ceb3 | 17 | /****************************************************************************** |
embeddedartists | 2:2f4b7535ceb3 | 18 | * Includes |
embeddedartists | 2:2f4b7535ceb3 | 19 | *****************************************************************************/ |
embeddedartists | 2:2f4b7535ceb3 | 20 | |
embeddedartists | 2:2f4b7535ceb3 | 21 | #include "mbed.h" |
embeddedartists | 2:2f4b7535ceb3 | 22 | #include "TestShiftreg.h" |
embeddedartists | 2:2f4b7535ceb3 | 23 | |
embeddedartists | 2:2f4b7535ceb3 | 24 | /****************************************************************************** |
embeddedartists | 2:2f4b7535ceb3 | 25 | * Defines and typedefs |
embeddedartists | 2:2f4b7535ceb3 | 26 | *****************************************************************************/ |
embeddedartists | 2:2f4b7535ceb3 | 27 | |
embeddedartists | 2:2f4b7535ceb3 | 28 | |
embeddedartists | 2:2f4b7535ceb3 | 29 | /****************************************************************************** |
embeddedartists | 2:2f4b7535ceb3 | 30 | * Public Functions |
embeddedartists | 2:2f4b7535ceb3 | 31 | *****************************************************************************/ |
embeddedartists | 2:2f4b7535ceb3 | 32 | |
embeddedartists | 2:2f4b7535ceb3 | 33 | TestShiftreg::TestShiftreg(PinName mosi, PinName miso, PinName sclk, PinName cs) : |
embeddedartists | 2:2f4b7535ceb3 | 34 | _spi(mosi, miso, sclk), _cs(cs) { |
embeddedartists | 2:2f4b7535ceb3 | 35 | |
embeddedartists | 2:2f4b7535ceb3 | 36 | _cs = 1; // to get it in a known state |
embeddedartists | 2:2f4b7535ceb3 | 37 | output(0x00); |
embeddedartists | 2:2f4b7535ceb3 | 38 | } |
embeddedartists | 2:2f4b7535ceb3 | 39 | |
embeddedartists | 2:2f4b7535ceb3 | 40 | bool TestShiftreg::runTest() { |
embeddedartists | 2:2f4b7535ceb3 | 41 | output(0x1); |
embeddedartists | 2:2f4b7535ceb3 | 42 | wait(0.1); |
embeddedartists | 2:2f4b7535ceb3 | 43 | output(0x2); |
embeddedartists | 2:2f4b7535ceb3 | 44 | wait(0.1); |
embeddedartists | 2:2f4b7535ceb3 | 45 | output(0x4); |
embeddedartists | 2:2f4b7535ceb3 | 46 | wait(0.1); |
embeddedartists | 2:2f4b7535ceb3 | 47 | output(0x8); |
embeddedartists | 2:2f4b7535ceb3 | 48 | wait(0.1); |
embeddedartists | 2:2f4b7535ceb3 | 49 | output(0x10); |
embeddedartists | 2:2f4b7535ceb3 | 50 | wait(0.1); |
embeddedartists | 2:2f4b7535ceb3 | 51 | output(0x20); |
embeddedartists | 2:2f4b7535ceb3 | 52 | wait(0.1); |
embeddedartists | 2:2f4b7535ceb3 | 53 | output(0x40); |
embeddedartists | 2:2f4b7535ceb3 | 54 | wait(0.1); |
embeddedartists | 2:2f4b7535ceb3 | 55 | output(0x80); |
embeddedartists | 2:2f4b7535ceb3 | 56 | wait(0.1); |
embeddedartists | 2:2f4b7535ceb3 | 57 | output(0x40); |
embeddedartists | 2:2f4b7535ceb3 | 58 | wait(0.1); |
embeddedartists | 2:2f4b7535ceb3 | 59 | output(0x20); |
embeddedartists | 2:2f4b7535ceb3 | 60 | wait(0.1); |
embeddedartists | 2:2f4b7535ceb3 | 61 | output(0x10); |
embeddedartists | 2:2f4b7535ceb3 | 62 | wait(0.1); |
embeddedartists | 2:2f4b7535ceb3 | 63 | output(0x8); |
embeddedartists | 2:2f4b7535ceb3 | 64 | wait(0.1); |
embeddedartists | 2:2f4b7535ceb3 | 65 | output(0x4); |
embeddedartists | 2:2f4b7535ceb3 | 66 | wait(0.1); |
embeddedartists | 2:2f4b7535ceb3 | 67 | output(0x2); |
embeddedartists | 2:2f4b7535ceb3 | 68 | wait(0.1); |
embeddedartists | 2:2f4b7535ceb3 | 69 | output(0x1); |
embeddedartists | 2:2f4b7535ceb3 | 70 | wait(0.1); |
embeddedartists | 2:2f4b7535ceb3 | 71 | output(0x0); |
embeddedartists | 2:2f4b7535ceb3 | 72 | return true; |
embeddedartists | 2:2f4b7535ceb3 | 73 | } |
embeddedartists | 2:2f4b7535ceb3 | 74 | |
embeddedartists | 2:2f4b7535ceb3 | 75 | void TestShiftreg::output(uint8_t value) { |
embeddedartists | 2:2f4b7535ceb3 | 76 | _cs = 0; |
embeddedartists | 2:2f4b7535ceb3 | 77 | _spi.write(value); |
embeddedartists | 2:2f4b7535ceb3 | 78 | _cs = 1; |
embeddedartists | 2:2f4b7535ceb3 | 79 | } |
embeddedartists | 2:2f4b7535ceb3 | 80 |