Preliminary main mbed library for nexpaq development
libraries/tests/mbed/spi_C12832/main.cpp@1:d96dbedaebdb, 2016-11-04 (annotated)
- Committer:
- nexpaq
- Date:
- Fri Nov 04 20:54:50 2016 +0000
- Revision:
- 1:d96dbedaebdb
- Parent:
- 0:6c56fb4bc5f0
Removed extra directories for other platforms
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nexpaq | 0:6c56fb4bc5f0 | 1 | /* Copyright (c) 2010-2011 mbed.org, MIT License |
nexpaq | 0:6c56fb4bc5f0 | 2 | * |
nexpaq | 0:6c56fb4bc5f0 | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
nexpaq | 0:6c56fb4bc5f0 | 4 | * and associated documentation files (the "Software"), to deal in the Software without |
nexpaq | 0:6c56fb4bc5f0 | 5 | * restriction, including without limitation the rights to use, copy, modify, merge, publish, |
nexpaq | 0:6c56fb4bc5f0 | 6 | * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the |
nexpaq | 0:6c56fb4bc5f0 | 7 | * Software is furnished to do so, subject to the following conditions: |
nexpaq | 0:6c56fb4bc5f0 | 8 | * |
nexpaq | 0:6c56fb4bc5f0 | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
nexpaq | 0:6c56fb4bc5f0 | 10 | * substantial portions of the Software. |
nexpaq | 0:6c56fb4bc5f0 | 11 | * |
nexpaq | 0:6c56fb4bc5f0 | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
nexpaq | 0:6c56fb4bc5f0 | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
nexpaq | 0:6c56fb4bc5f0 | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
nexpaq | 0:6c56fb4bc5f0 | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
nexpaq | 0:6c56fb4bc5f0 | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
nexpaq | 0:6c56fb4bc5f0 | 17 | */ |
nexpaq | 0:6c56fb4bc5f0 | 18 | |
nexpaq | 0:6c56fb4bc5f0 | 19 | #include "test_env.h" |
nexpaq | 0:6c56fb4bc5f0 | 20 | #include "mbed.h" |
nexpaq | 0:6c56fb4bc5f0 | 21 | #include "C12832.h" |
nexpaq | 0:6c56fb4bc5f0 | 22 | |
nexpaq | 0:6c56fb4bc5f0 | 23 | int main() |
nexpaq | 0:6c56fb4bc5f0 | 24 | { |
nexpaq | 0:6c56fb4bc5f0 | 25 | MBED_HOSTTEST_TIMEOUT(15); |
nexpaq | 0:6c56fb4bc5f0 | 26 | MBED_HOSTTEST_SELECT(default_auto); |
nexpaq | 0:6c56fb4bc5f0 | 27 | MBED_HOSTTEST_DESCRIPTION(SPI C12832 display); |
nexpaq | 0:6c56fb4bc5f0 | 28 | MBED_HOSTTEST_START("MBED_35"); |
nexpaq | 0:6c56fb4bc5f0 | 29 | |
nexpaq | 0:6c56fb4bc5f0 | 30 | C12832 lcd(D11, D13, D12, D7, D10); |
nexpaq | 0:6c56fb4bc5f0 | 31 | |
nexpaq | 0:6c56fb4bc5f0 | 32 | // clear the screen |
nexpaq | 0:6c56fb4bc5f0 | 33 | lcd.cls(); |
nexpaq | 0:6c56fb4bc5f0 | 34 | |
nexpaq | 0:6c56fb4bc5f0 | 35 | // print the first line and wait 3 sec |
nexpaq | 0:6c56fb4bc5f0 | 36 | lcd.locate(0,3); |
nexpaq | 0:6c56fb4bc5f0 | 37 | lcd.printf("mbed application board!"); |
nexpaq | 0:6c56fb4bc5f0 | 38 | |
nexpaq | 0:6c56fb4bc5f0 | 39 | // print the counter prefix; the number will be printed in the while loop |
nexpaq | 0:6c56fb4bc5f0 | 40 | lcd.locate(0,15); |
nexpaq | 0:6c56fb4bc5f0 | 41 | lcd.printf("Counting:"); |
nexpaq | 0:6c56fb4bc5f0 | 42 | |
nexpaq | 0:6c56fb4bc5f0 | 43 | int i=1, j=0; |
nexpaq | 0:6c56fb4bc5f0 | 44 | while(i++,i<=200) { |
nexpaq | 0:6c56fb4bc5f0 | 45 | lcd.locate(42,15); |
nexpaq | 0:6c56fb4bc5f0 | 46 | lcd.printf("%d", i); |
nexpaq | 0:6c56fb4bc5f0 | 47 | if (i % 50 == 0) { |
nexpaq | 0:6c56fb4bc5f0 | 48 | lcd.invert(j = j ? 0 : 1); |
nexpaq | 0:6c56fb4bc5f0 | 49 | }; |
nexpaq | 0:6c56fb4bc5f0 | 50 | wait(0.001); |
nexpaq | 0:6c56fb4bc5f0 | 51 | } |
nexpaq | 0:6c56fb4bc5f0 | 52 | |
nexpaq | 0:6c56fb4bc5f0 | 53 | MBED_HOSTTEST_RESULT(1); |
nexpaq | 0:6c56fb4bc5f0 | 54 | } |