2c
Fork of TS_DISCO_F429ZI by
TS_DISCO_F429ZI.h@1:b346257d266d, 2017-05-05 (annotated)
- Committer:
- Robsonik16
- Date:
- Fri May 05 19:35:45 2017 +0000
- Revision:
- 1:b346257d266d
- Parent:
- 0:4f8b6df8e235
a
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bcostm | 0:4f8b6df8e235 | 1 | /* Copyright (c) 2010-2011 mbed.org, MIT License |
bcostm | 0:4f8b6df8e235 | 2 | * |
bcostm | 0:4f8b6df8e235 | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
bcostm | 0:4f8b6df8e235 | 4 | * and associated documentation files (the "Software"), to deal in the Software without |
bcostm | 0:4f8b6df8e235 | 5 | * restriction, including without limitation the rights to use, copy, modify, merge, publish, |
bcostm | 0:4f8b6df8e235 | 6 | * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the |
bcostm | 0:4f8b6df8e235 | 7 | * Software is furnished to do so, subject to the following conditions: |
bcostm | 0:4f8b6df8e235 | 8 | * |
bcostm | 0:4f8b6df8e235 | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
bcostm | 0:4f8b6df8e235 | 10 | * substantial portions of the Software. |
bcostm | 0:4f8b6df8e235 | 11 | * |
bcostm | 0:4f8b6df8e235 | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
bcostm | 0:4f8b6df8e235 | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
bcostm | 0:4f8b6df8e235 | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
bcostm | 0:4f8b6df8e235 | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
bcostm | 0:4f8b6df8e235 | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
bcostm | 0:4f8b6df8e235 | 17 | */ |
bcostm | 0:4f8b6df8e235 | 18 | |
bcostm | 0:4f8b6df8e235 | 19 | #ifndef __TS_DISCO_F429ZI_H |
bcostm | 0:4f8b6df8e235 | 20 | #define __TS_DISCO_F429ZI_H |
bcostm | 0:4f8b6df8e235 | 21 | |
bcostm | 0:4f8b6df8e235 | 22 | #ifdef TARGET_DISCO_F429ZI |
bcostm | 0:4f8b6df8e235 | 23 | |
bcostm | 0:4f8b6df8e235 | 24 | #include "mbed.h" |
bcostm | 0:4f8b6df8e235 | 25 | #include "stm32f429i_discovery_ts.h" |
bcostm | 0:4f8b6df8e235 | 26 | |
bcostm | 0:4f8b6df8e235 | 27 | /* |
bcostm | 0:4f8b6df8e235 | 28 | This class drives the touch screen module of the LCD display |
bcostm | 0:4f8b6df8e235 | 29 | present on DISCO_F429ZI board. |
bcostm | 0:4f8b6df8e235 | 30 | |
bcostm | 0:4f8b6df8e235 | 31 | Usage: |
bcostm | 0:4f8b6df8e235 | 32 | |
bcostm | 0:4f8b6df8e235 | 33 | #include "mbed.h" |
bcostm | 0:4f8b6df8e235 | 34 | #include "TS_DISCO_F429ZI.h" |
bcostm | 0:4f8b6df8e235 | 35 | |
bcostm | 0:4f8b6df8e235 | 36 | TS_DISCO_F429ZI ts; |
bcostm | 0:4f8b6df8e235 | 37 | |
bcostm | 0:4f8b6df8e235 | 38 | DigitalOut led1(LED1); |
bcostm | 0:4f8b6df8e235 | 39 | |
bcostm | 0:4f8b6df8e235 | 40 | int main() |
bcostm | 0:4f8b6df8e235 | 41 | { |
bcostm | 0:4f8b6df8e235 | 42 | TS_StateTypeDef TS_State; |
bcostm | 0:4f8b6df8e235 | 43 | |
bcostm | 0:4f8b6df8e235 | 44 | ts.Init(420, 272); |
bcostm | 0:4f8b6df8e235 | 45 | |
bcostm | 0:4f8b6df8e235 | 46 | while(1) |
bcostm | 0:4f8b6df8e235 | 47 | { |
bcostm | 0:4f8b6df8e235 | 48 | ts.GetState(&TS_State); |
bcostm | 0:4f8b6df8e235 | 49 | if ((TS_State.touchDetected) && (TS_State.touchX[0] > 240)) |
bcostm | 0:4f8b6df8e235 | 50 | { |
bcostm | 0:4f8b6df8e235 | 51 | led1 = 1; |
bcostm | 0:4f8b6df8e235 | 52 | } |
bcostm | 0:4f8b6df8e235 | 53 | else |
bcostm | 0:4f8b6df8e235 | 54 | { |
bcostm | 0:4f8b6df8e235 | 55 | led1 = 0; |
bcostm | 0:4f8b6df8e235 | 56 | } |
bcostm | 0:4f8b6df8e235 | 57 | } |
bcostm | 0:4f8b6df8e235 | 58 | } |
bcostm | 0:4f8b6df8e235 | 59 | */ |
bcostm | 0:4f8b6df8e235 | 60 | class TS_DISCO_F429ZI |
bcostm | 0:4f8b6df8e235 | 61 | { |
bcostm | 0:4f8b6df8e235 | 62 | |
bcostm | 0:4f8b6df8e235 | 63 | public: |
bcostm | 0:4f8b6df8e235 | 64 | //! Constructor |
bcostm | 0:4f8b6df8e235 | 65 | TS_DISCO_F429ZI(); |
bcostm | 0:4f8b6df8e235 | 66 | |
bcostm | 0:4f8b6df8e235 | 67 | //! Destructor |
bcostm | 0:4f8b6df8e235 | 68 | ~TS_DISCO_F429ZI(); |
bcostm | 0:4f8b6df8e235 | 69 | |
bcostm | 0:4f8b6df8e235 | 70 | /** |
bcostm | 0:4f8b6df8e235 | 71 | * @brief Initializes and configures the touch screen functionalities and |
bcostm | 0:4f8b6df8e235 | 72 | * configures all necessary hardware resources (GPIOs, clocks..);. |
bcostm | 0:4f8b6df8e235 | 73 | * @param XSize: The maximum X size of the TS area on LCD |
bcostm | 0:4f8b6df8e235 | 74 | * @param YSize: The maximum Y size of the TS area on LCD |
bcostm | 0:4f8b6df8e235 | 75 | * @retval TS_OK: if all initializations are OK. Other value if error. |
bcostm | 0:4f8b6df8e235 | 76 | */ |
bcostm | 0:4f8b6df8e235 | 77 | uint8_t Init(uint16_t XSize, uint16_t YSize); |
bcostm | 0:4f8b6df8e235 | 78 | |
bcostm | 0:4f8b6df8e235 | 79 | /** |
bcostm | 0:4f8b6df8e235 | 80 | * @brief Configures and enables the touch screen interrupts. |
bcostm | 0:4f8b6df8e235 | 81 | * @param None |
bcostm | 0:4f8b6df8e235 | 82 | * @retval TS_OK: if ITconfig is OK. Other value if error. |
bcostm | 0:4f8b6df8e235 | 83 | */ |
bcostm | 0:4f8b6df8e235 | 84 | uint8_t ITConfig(void); |
bcostm | 0:4f8b6df8e235 | 85 | |
bcostm | 0:4f8b6df8e235 | 86 | /** |
bcostm | 0:4f8b6df8e235 | 87 | * @brief Gets the TS IT status. |
bcostm | 0:4f8b6df8e235 | 88 | * @param None |
bcostm | 0:4f8b6df8e235 | 89 | * @retval Interrupt status. |
bcostm | 0:4f8b6df8e235 | 90 | */ |
bcostm | 0:4f8b6df8e235 | 91 | uint8_t ITGetStatus(void); |
bcostm | 0:4f8b6df8e235 | 92 | |
bcostm | 0:4f8b6df8e235 | 93 | /** |
bcostm | 0:4f8b6df8e235 | 94 | * @brief Returns status and positions of the touch screen. |
bcostm | 0:4f8b6df8e235 | 95 | * @param TsState: Pointer to touch screen current state structure |
bcostm | 0:4f8b6df8e235 | 96 | * @retval None. |
bcostm | 0:4f8b6df8e235 | 97 | */ |
bcostm | 0:4f8b6df8e235 | 98 | void GetState(TS_StateTypeDef* TsState); |
bcostm | 0:4f8b6df8e235 | 99 | |
bcostm | 0:4f8b6df8e235 | 100 | /** |
bcostm | 0:4f8b6df8e235 | 101 | * @brief Clears all touch screen interrupts. |
bcostm | 0:4f8b6df8e235 | 102 | * @param None |
bcostm | 0:4f8b6df8e235 | 103 | * @retval None |
bcostm | 0:4f8b6df8e235 | 104 | */ |
bcostm | 0:4f8b6df8e235 | 105 | void ITClear(void); |
bcostm | 0:4f8b6df8e235 | 106 | |
bcostm | 0:4f8b6df8e235 | 107 | private: |
bcostm | 0:4f8b6df8e235 | 108 | |
bcostm | 0:4f8b6df8e235 | 109 | }; |
bcostm | 0:4f8b6df8e235 | 110 | |
bcostm | 0:4f8b6df8e235 | 111 | #else |
bcostm | 0:4f8b6df8e235 | 112 | #error "This class must be used with DISCO_F429ZI board only." |
bcostm | 0:4f8b6df8e235 | 113 | #endif // TARGET_DISCO_F429ZI |
bcostm | 0:4f8b6df8e235 | 114 | |
bcostm | 0:4f8b6df8e235 | 115 | #endif |