Simple test for reading chip id of resistive touch controller on Adafruit TFT Wing.
Dependencies: SPI_STMPE610 max32630fthr mbed
main.cpp@0:87d0353776f3, 2017-03-19 (annotated)
- Committer:
- j3
- Date:
- Sun Mar 19 02:36:24 2017 +0000
- Revision:
- 0:87d0353776f3
init commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
j3 | 0:87d0353776f3 | 1 | /********************************************************************** |
j3 | 0:87d0353776f3 | 2 | * Copyright (C) 2017 Maxim Integrated Products, Inc., All Rights Reserved. |
j3 | 0:87d0353776f3 | 3 | * |
j3 | 0:87d0353776f3 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
j3 | 0:87d0353776f3 | 5 | * copy of this software and associated documentation files (the "Software"), |
j3 | 0:87d0353776f3 | 6 | * to deal in the Software without restriction, including without limitation |
j3 | 0:87d0353776f3 | 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
j3 | 0:87d0353776f3 | 8 | * and/or sell copies of the Software, and to permit persons to whom the |
j3 | 0:87d0353776f3 | 9 | * Software is furnished to do so, subject to the following conditions: |
j3 | 0:87d0353776f3 | 10 | * |
j3 | 0:87d0353776f3 | 11 | * The above copyright notice and this permission notice shall be included |
j3 | 0:87d0353776f3 | 12 | * in all copies or substantial portions of the Software. |
j3 | 0:87d0353776f3 | 13 | * |
j3 | 0:87d0353776f3 | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
j3 | 0:87d0353776f3 | 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
j3 | 0:87d0353776f3 | 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
j3 | 0:87d0353776f3 | 17 | * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES |
j3 | 0:87d0353776f3 | 18 | * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
j3 | 0:87d0353776f3 | 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
j3 | 0:87d0353776f3 | 20 | * OTHER DEALINGS IN THE SOFTWARE. |
j3 | 0:87d0353776f3 | 21 | * |
j3 | 0:87d0353776f3 | 22 | * Except as contained in this notice, the name of Maxim Integrated |
j3 | 0:87d0353776f3 | 23 | * Products, Inc. shall not be used except as stated in the Maxim Integrated |
j3 | 0:87d0353776f3 | 24 | * Products, Inc. Branding Policy. |
j3 | 0:87d0353776f3 | 25 | * |
j3 | 0:87d0353776f3 | 26 | * The mere transfer of this software does not imply any licenses |
j3 | 0:87d0353776f3 | 27 | * of trade secrets, proprietary technology, copyrights, patents, |
j3 | 0:87d0353776f3 | 28 | * trademarks, maskwork rights, or any other form of intellectual |
j3 | 0:87d0353776f3 | 29 | * property whatsoever. Maxim Integrated Products, Inc. retains all |
j3 | 0:87d0353776f3 | 30 | * ownership rights. |
j3 | 0:87d0353776f3 | 31 | **********************************************************************/ |
j3 | 0:87d0353776f3 | 32 | |
j3 | 0:87d0353776f3 | 33 | |
j3 | 0:87d0353776f3 | 34 | #include "mbed.h" |
j3 | 0:87d0353776f3 | 35 | #include "max32630fthr.h" |
j3 | 0:87d0353776f3 | 36 | #include "SPI_STMPE610.h" |
j3 | 0:87d0353776f3 | 37 | |
j3 | 0:87d0353776f3 | 38 | |
j3 | 0:87d0353776f3 | 39 | int main() |
j3 | 0:87d0353776f3 | 40 | { |
j3 | 0:87d0353776f3 | 41 | MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3); |
j3 | 0:87d0353776f3 | 42 | |
j3 | 0:87d0353776f3 | 43 | DigitalOut led1(LED1, 1); |
j3 | 0:87d0353776f3 | 44 | |
j3 | 0:87d0353776f3 | 45 | SPI_STMPE610 rt2(SPI2_MOSI, SPI2_MISO, SPI2_SCK, P3_3); |
j3 | 0:87d0353776f3 | 46 | |
j3 | 0:87d0353776f3 | 47 | uint16_t chip_id; |
j3 | 0:87d0353776f3 | 48 | |
j3 | 0:87d0353776f3 | 49 | while(1) |
j3 | 0:87d0353776f3 | 50 | { |
j3 | 0:87d0353776f3 | 51 | //get chip id |
j3 | 0:87d0353776f3 | 52 | chip_id = rt2.read16(0); |
j3 | 0:87d0353776f3 | 53 | //print it |
j3 | 0:87d0353776f3 | 54 | printf("\r\nChip ID = 0x%04x\r\n", chip_id); |
j3 | 0:87d0353776f3 | 55 | //clear to test multiple reads |
j3 | 0:87d0353776f3 | 56 | chip_id = 0; |
j3 | 0:87d0353776f3 | 57 | //blink |
j3 | 0:87d0353776f3 | 58 | led1 = !led1; |
j3 | 0:87d0353776f3 | 59 | wait(0.5); |
j3 | 0:87d0353776f3 | 60 | } |
j3 | 0:87d0353776f3 | 61 | } |